summaryrefslogtreecommitdiffstats
path: root/admin/survey/export/latexclasses/class.LatexAnalysisElement.php
diff options
context:
space:
mode:
Diffstat (limited to 'admin/survey/export/latexclasses/class.LatexAnalysisElement.php')
-rw-r--r--admin/survey/export/latexclasses/class.LatexAnalysisElement.php598
1 files changed, 372 insertions, 226 deletions
diff --git a/admin/survey/export/latexclasses/class.LatexAnalysisElement.php b/admin/survey/export/latexclasses/class.LatexAnalysisElement.php
index 9b3cec2..4e0696b 100644
--- a/admin/survey/export/latexclasses/class.LatexAnalysisElement.php
+++ b/admin/survey/export/latexclasses/class.LatexAnalysisElement.php
@@ -9,7 +9,7 @@
include('../../vendor/autoload.php');
-define("MAX_STRING_LENGTH", 20);
+if (!defined("MAX_STRING_LENGTH")) define("MAX_STRING_LENGTH", 20);
class LatexAnalysisElement{
@@ -35,6 +35,20 @@ class LatexAnalysisElement{
protected $export_subtype;
protected $export_format;
+
+ protected $path2HeatmapImages = '';
+
+ protected $counter = 0;
+
+ protected $ttestClass = null;
+
+ protected $tableSettingsNumerus = null;
+
+ protected $tableSettingsPercent = null;
+
+ protected $tableSettingsAvgVar = null;
+
+ protected $tableSettingsDelezVar = null;
public $crosstabClass = null; //crosstab class
protected $crossData1;
@@ -59,7 +73,7 @@ class LatexAnalysisElement{
protected $path2Images;
protected $path2Charts;
-
+
//function __construct($anketa, $spremenljivka){ //$anketa, $export_format, $fillablePdf, $usr_id
//function __construct($anketa, $export_format, $fillablePdf, $usr_id, $export_subtype){
@@ -171,11 +185,10 @@ class LatexAnalysisElement{
switch ( $this->export_subtype ){
case 'crosstab':
- $this->crosstabClass->_LOOPS = SurveyZankaProfiles::getFiltersForLoops();
- //echo "stevilo crosstab loopov: ".count($this->crosstabClass->_LOOPS)."</br>";
- if (count($this->crosstabClass->_LOOPS) > 0) {
+ $_LOOPS = SurveyZankaProfiles::getFiltersForLoops();
+ if (count($_LOOPS) > 0) {
# če mamo zanke
- foreach ( $this->crosstabClass->_LOOPS AS $loop) {
+ foreach ( $_LOOPS AS $loop) {
$this->crosstabClass->_CURRENT_LOOP = $loop;
$tabela .= $this->displayCrosstabsTable();
}
@@ -187,10 +200,12 @@ class LatexAnalysisElement{
for($j=0; $j<sizeof($this->crossData2); $j++){
for($i=0; $i<sizeof($this->crossData1); $i++){
- if($addPage)
- $this->pdf->AddPage();
- else
+ if($addPage){
+ //$this->pdf->AddPage();
+ }else{
$addPage = true;
+ }
+
/*$this->pdf->ln(5);*/
$this->crosstabClass->setVariables($this->crossData2[$j][0],$this->crossData2[$j][1],$this->crossData2[$j][2],$this->crossData1[$i][0],$this->crossData1[$i][1],$this->crossData1[$i][2]);
@@ -310,7 +325,7 @@ class LatexAnalysisElement{
$means = array();
- if (meanData1 !== null && $meanData2 !== null) {
+ if ($meanData1 !== null && $meanData2 !== null) {
$variables1 = $meanData2;
$variables2 = $meanData1;
$c1=0;
@@ -322,7 +337,7 @@ class LatexAnalysisElement{
if(is_array($variables2) && count($variables2) > 0){
#prikazujemo ločeno
- if ($this->sessionData['means']['meansSeperateTables'] == true || $this->sessionData['mean_charts']['showChart'] == '1') {
+ if ((isset($this->sessionData['means']['meansSeperateTables'])?$this->sessionData['means']['meansSeperateTables']:null) == true || (isset($this->sessionData['mean_charts']['showChart'])?$this->sessionData['mean_charts']['showChart']:0) == '1') {
foreach ($variables2 AS $v_second) {
if (is_array($variables1) && count($variables1) > 0) {
foreach ($variables1 AS $v_first) {
@@ -358,7 +373,7 @@ class LatexAnalysisElement{
$count = 0;
foreach ($means AS $mean_sub_grup) {
- if($this->sessionData['mean_charts']['showChart'] == '1'){
+ if((isset($this->sessionData['mean_charts']['showChart'])?$this->sessionData['mean_charts']['showChart']:0) == '1'){
//$this->displayMeansTable($mean_sub_grup);
$tabela .= $mean->displayMeansTable($mean_sub_grup, $this->meansClass, $this->export_format);
@@ -441,7 +456,7 @@ class LatexAnalysisElement{
# če nimamo zank
if(count(SurveyAnalysis::$_LOOPS) == 0){
- $graf .= $chart->displayCharts();
+ $graf .= $chart->displayCharts($this->exportClass);
}
else{
// izrisemo samo eno tabelo iz enega loopa
@@ -452,14 +467,7 @@ class LatexAnalysisElement{
SurveyAnalysis::$_CURRENT_LOOP = $loop;
// Izpisemo naslov zanke za skupino
-/* $this->pdf->setFont('','B','10');
- $this->pdf->ln(5);
- $this->pdf->MultiCell(200, 5, $this->encodeText($lang['srv_zanka_note'].$loop['text']), 0, 'L', 0, 1, 0 ,0, true);
- $this->pdf->ln(5);
- $this->pdf->setFont('','','6'); */
-
- //$graf .= $this->displayCharts();
- $graf .= $chart->displayCharts();
+ $graf .= $chart->displayCharts($this->exportClass);
}
// Izrisemo vse tabele spremenljivka (iz vseh loopov)
@@ -472,14 +480,7 @@ class LatexAnalysisElement{
SurveyAnalysis::$_CURRENT_LOOP = $loop;
// Izpisemo naslov zanke za skupino
-/* $this->pdf->setFont('','B','10');
- $this->pdf->ln(5);
- $this->pdf->MultiCell(200, 5, $this->encodeText($lang['srv_zanka_note'].$loop['text']), 0, 'L', 0, 1, 0 ,0, true);
- $this->pdf->ln(5);
- $this->pdf->setFont('','','6'); */
-
- //$graf .= $this->displayCharts();
- $graf .= $chart->displayCharts();
+ $graf .= $chart->displayCharts($this->exportClass);
}
}
}
@@ -506,7 +507,7 @@ class LatexAnalysisElement{
$creportProfile= $creport->getCreportProfile();
$what = 'creport_title_profile_'.$creportProfile;
- $sqlT = sisplet_query("SELECT value FROM srv_user_setting_for_survey WHERE sid='$this->ank_id' AND uid='$this->usr_id' AND what='$what'");
+ $sqlT = sisplet_query("SELECT value FROM srv_user_setting_for_survey WHERE sid='$anketaId' AND uid='$global_user_id' AND what='$what'");
if(mysqli_num_rows($sqlT) == 0){
$titleString = $lang['export_analisys_creport'].': '.SurveyInfo::getInstance()->getSurveyTitle();
@@ -516,9 +517,9 @@ class LatexAnalysisElement{
$titleString = $rowT['value'];
}
- $naslovIzvoza = $this->encodeText($titleString);
+ $naslovIzvoza = LatexDocument::encodeText($titleString);
//$creportLatex .= '\textbf{'.$naslovIzvoza.'}'.$this->texBigSkip.$this->texNewLine;
- $creportLatex .= '\MakeUppercase{\huge \textbf{'.$naslovIzvoza.'}}'.$this->texBigSkip.$this->texNewLine;
+ $creportLatex .= '\MakeUppercase{\huge \textbf{'.$naslovIzvoza.'}}'./* $this->texBigSkip. */$this->texNewLine;
if($this->export_format == 'pdf'){
$creportLatex .= '\begin{tableAnalysis}'; /*zacetek environmenta z manjsim fontom*/
@@ -755,6 +756,8 @@ class LatexAnalysisElement{
$imgName = $Cache->GetHash($ID,$DataSet->GetData());
}
+ $boldedSubTitle='';
+ $boldedTitle='';
// Izrisemo naslov (v creportu ne, ker imamo drugacne naslove)
if($fromCharts){
@@ -780,7 +783,7 @@ class LatexAnalysisElement{
//self::$exportClass->pdf->setFont('','b','6');
//self::$exportClass->pdf->MultiCell(165, 5, $title, 0, 'C', 0, 1, 0 ,0, true);
- $boldedTitle = $this->returnBold($this->encodeText($title)).$this->texNewLine; //vrni boldan naslov in skoci v novo vrstico
+ $boldedTitle = $this->returnBold(LatexDocument::encodeText($title)).$this->texNewLine; //vrni boldan naslov in skoci v novo vrstico
if($spremenljivka['tip'] == 2){
//self::$exportClass->pdf->setFont('','','5');
@@ -804,7 +807,8 @@ class LatexAnalysisElement{
shell_exec($pretvoriPng_v_Pdf);
##### ZA TESTIRANJE ureditev pretvorbe slike v pdf - konec
- $texImageOnly = " \\includegraphics[scale=0.66]{".$this->path2Charts."".$imgName."} "; //latex za sliko
+ $texImageOnly = " \\includegraphics[width=\linewidth, frame, scale=0.66]{".$this->path2Charts."".$imgName."} "; //latex za sliko
+ //$texImageOnly = " \\includegraphics[scale=0.66]{".$this->path2Charts."".$imgName."} "; //latex za sliko
//$texImageOnly = " \\includegraphics[scale=0.66, draft=false]{".$this->path2Charts."".$imgName."} "; //latex za sliko
//$texImageOnly = " \\includegraphics[scale=0.85]{".$this->path2Charts."".$imgName."} "; //latex za sliko
//echo "ime slike: $texImageOnly </br>";
@@ -838,30 +842,26 @@ class LatexAnalysisElement{
#moja funkcija encodeText
function encodeText($text=''){
- // popravimo sumnike ce je potrebno
- //$text = html_entity_decode($text, ENT_NOQUOTES, 'UTF-8');
- //$text = str_replace("&scaron;","š",$text);
- //echo "Encoding ".$text."</br>";
-
+ $text = isset($text)?$text:'';
//resevanje razbirajanja predolgih neprekinjenih besed in URL - spremenljivke za kasnejsi prilagojen izpis
$numOfWords = str_word_count($text, 0); //stevilo besed v besedilu
$numOfSpacesPrej = substr_count($text, ' '); //stevilo presledkov v besedilu
$stringLength = strlen($text); //dolzina besedila
-
+
$findSpace = ' ';
$findHttp = 'http://';
$findHttps = 'https://';
$posHttp = strpos($text, $findHttp);
$posHttps = strpos($text, $findHttps);
$isURL = 0;
- /* if($posHttp !== false || $posHttps !== false) { //imamo URL naslov
- $isURL = 1;
- } */
//resevanje razbirajanja predolgih neprekinjenih besed in URL - konec
+
if($text == ''){ //ce ni teksta, vrni se
return;
}
+
+
$textOrig = $text;
$findme = '<br />';
$findmeLength = strlen($findme);
@@ -884,27 +884,19 @@ class LatexAnalysisElement{
$posImgEnd = strpos($textPotem, '/>'); //pozicija, kjer se konca html koda za img
$textPotem = substr($textPotem, $posImgEnd+strlen('/>')); //tekst od konca html kode za img dalje
- //$text = $textPrej.' '.PIC_SIZE_ANS."{".$this->getImageName($text, 0, '<img')."}".' '.$textPotem;
$text = $textPrej.' '.PIC_SIZE_ANS."{".$this->path2Images."".$this->getImageName($text, 0, '<img')."}".' '.$textPotem;
}
//pred ureditvijo posebnih karakterjev, odstrani del teksta s kodo za sliko, da se ne pojavijo tezave zaradi imena datoteke od slike
- $findImgCode = '\includegraphics';
+ $findImgCode = '\includegraphics';
$posOfImgCode = strpos($text, $findImgCode);
- //echo $posOfImgCode."</br>";
$textToImgCode = substr($text, 0, $posOfImgCode); //tekst do $findImgCode
- //echo $textToImgCode."</br>";
$textFromImgCode = substr($text, $posOfImgCode); //tekst po $findImgCode
- //echo $textFromImgCode."</br>";
$findImgCodeEnd = '}';
- //$posOfImgCodeEnd = strpos($text, $findImgCodeEnd);
$posOfImgCodeEnd = strpos($textFromImgCode, $findImgCodeEnd);
- //echo $posOfImgCodeEnd."</br>";
$textAfterImgCode = substr($textFromImgCode, $posOfImgCodeEnd+1); //tekst po $findImgCodeEnd
- //echo $textAfterImgCode."</br>";
$textOfImgCode = substr($text, $posOfImgCode, $posOfImgCodeEnd+1);
- //echo $textOfImgCode."</br>";
$text = $textToImgCode.$textAfterImgCode;
@@ -912,6 +904,7 @@ class LatexAnalysisElement{
}
//ureditev izrisa slike - konec
+
//ureditev posebnih karakterjev za Latex http://www.cespedes.org/blog/85/how-to-escape-latex-special-characters, https://en.wikibooks.org/wiki/LaTeX/Special_Characters#Other_symbols
$text = str_replace('\\','\textbackslash{} ',$text);
//$text = str_replace('{','\{',$text);
@@ -925,29 +918,22 @@ class LatexAnalysisElement{
//$text = str_replace('_','\_ ',$text);
$text = str_replace('_','\_',$text);
$text = str_replace('~','\textasciitilde{} ',$text);
- if(strpos($text, '&amp;')){ //ce je prisotno v besedilu &amp;'
- $text = str_replace('&amp;','\& ',$text);
- }else{
- $text = str_replace('&','\& ',$text);
- }
-
- $andSymbolPresent = 0;
- $posAndSymbolPresent = strpos($text,'&amp;');
- if($posAndSymbolPresent !== false){ //ce je v besedilu prisoten '&' zapisan kot '&amp;'
- $text = str_replace('&amp;','\&',$text);
- $andSymbolPresent = 1;
- }
- if($andSymbolPresent == 0){
- $text = str_replace('&','\&',$text);
- }
//$text = str_replace('&lt;','\textless ',$text);
$text = str_replace('&lt;','\textless',$text);
//$text = str_replace('&gt;','\textgreater ',$text);
$text = str_replace('&gt;','\textgreater',$text);
$text = str_replace('&nbsp;',' ',$text);
+
+ if(strpos($text, '&amp;')){ //ce je prisotno v besedilu &amp;'
+ $text = str_replace('&amp;','\&',$text);
+ }
+ else{
+ $text = str_replace('&','\&',$text);
+ }
//ureditev posebnih karakterjev za Latex - konec
+
//ureditev grskih crk
$text = str_replace('α','\textalpha ',$text);
$text = str_replace('β','\textbeta ',$text);
@@ -975,39 +961,38 @@ class LatexAnalysisElement{
$text = str_replace('ω','\textomega ',$text);
//ureditev grskih crk - konec
+
//ureditev preureditve html kode ul in li v latex itemize
$findUl = '<ul';
$findUlLength = strlen($findUl);
$posUl = strpos($text, $findUl);
+
if($posUl !== false){
- //echo "text prej: ".$text."</br>";
+
$numOfUl = substr_count($text, $findUl); //stevilo '<ul' v tekstu
- //echo "numOfUl ".$numOfUl."</br>";
- ######################
+
if($numOfUl!=0){
$text = str_replace('<ul>','\begin{itemize} ', $text);
$text = str_replace('<li>','\item ', $text);
$text = str_replace('</ul>','\end{itemize} ', $text);
}
- //echo "prazno v html: ".strpos($text, '\r')."</br>";
- //echo "text potem: ".$text."</br>";
- ######################
}
-
//ureditev preureditve html kode ul in li v latex itemize - konec
+
//po ureditvi posebnih karakterjev, dodati del teksta s kodo za sliko, ce je slika prisotna
if($posImg !== false){
$text = substr_replace($text, $textOfImgCode, $posOfImgCode, 0);
}
//po ureditvi posebnih karakterjev, dodati del teksta s kodo za sliko, ce je slika prisotna
- if($pos === false && $posImg === false) { //v tekstu ni br in img
- //return $text;
-/* echo "encode pred strip: ".$text."</br>";
- echo "encode po strip: ".strip_tags($text)."</br>";
- return strip_tags($text); */
- }else { //v tekstu sta prisotna br ali img
+
+ //v tekstu ni br in img
+ if($pos === false && $posImg === false) {
+
+ }
+ //v tekstu sta prisotna br ali img
+ else {
$text2Return = ''; //tekst ki bo vrnjen
//ureditev preureditev html kode za novo vrstico v latex, ureditev prenosa v novo vrstico
@@ -1015,6 +1000,7 @@ class LatexAnalysisElement{
$pos = strpos($text, $findme);
$numOfBr = substr_count($text, $findme); //stevilo '<br />' v tekstu
for($i=0; $i<$numOfBr; $i++){
+
if($i == 0){ //ce je prvi najdeni '<br />'
$textPrej = substr($text, 0, $pos);
$textPotem = substr($text, $pos+$findmeLength);
@@ -1023,7 +1009,8 @@ class LatexAnalysisElement{
}else{
$text2Return .= $textPrej.' \break ';
}
- }else{ //drugace
+ }
+ else{ //drugace
$pos = strpos($textPotem, $findme);
$textPrej = substr($textPotem, 0, $pos);
$textPotem = substr($textPotem, $pos+$findmeLength);
@@ -1034,40 +1021,43 @@ class LatexAnalysisElement{
}
}
}
+
$text = $text2Return;
}
- //ureditev preureditev html kode za novo vrstico v latex, ureditev prenosa v novo vrstico - konec
-/* echo "encode pred strip: ".$text."</br>";
- echo "encode po strip: ".strip_tags($text)."</br>";
- return strip_tags($text); //vrni tekst brez html tag-ov */
}
+
//ureditev odstranjevanja presledkov, ce so na zacetku ali koncu besedila
if(($numOfSpacesPrej)){ //ce so prisotni presledki
$odstranjeno = 0; //belezi, ali so bili presledki odstranjeni iz zacetka ali konca
+
for($numPresledkovTmp = 1; $numPresledkovTmp <= $numOfSpacesPrej; $numPresledkovTmp++){ //za vsak presledek
$posSpace = strpos($text, $findSpace); //najdi pozicijo presledka v besedilu//preveri, kje se nahaja
+
if($posSpace==0){ //ce je presledek na zacetku besedila
$text = substr_replace($text, '', $posSpace, 1); //odstrani presledek iz besedila
$stringLength = strlen($text);
$odstranjeno = 1;
- }elseif($posSpace==$stringLength){ //ce je presledek na koncu besedila
+ }
+ elseif($posSpace==$stringLength){ //ce je presledek na koncu besedila
$text = substr_replace($text, '', $posSpace, 1); //odstrani presledek iz besedila
$stringLength = strlen($text);
$odstranjeno = 1;
}
}
+
$numOfSpacesPrej = substr_count($text, ' '); //stevilo presledkov v besedilu
}
//ureditev odstranjevanja presledkov, ce so na zacetku ali koncu besedila - konec
+
- //echo "v besedilu $text je stevilo presledkov $numOfSpacesPrej in besed $numOfWords </br>";
//priprava izpisa zelo dolgega besedila brez presledkov s seqsplit (URL, email, ...)
- if( ($numOfSpacesPrej == 0 && $stringLength >= MAX_STRING_LENGTH && $odstranjeno) ){ //ce v besedilu ni presledkov in je besedilo daljse od max dovoljene dolzine
+ if( ($numOfSpacesPrej == 0 && $stringLength >= MAX_STRING_LENGTH && isset($odstranjeno)?$odstranjeno:0) ){ //ce v besedilu ni presledkov in je besedilo daljse od max dovoljene dolzine
$text = "\seqsplit{".$text."}"; //ni v redu seqsplit, ker ne dela, če so posebni znaki
}
//priprava izpisa zelo dolgega besedila brez presledkov - konec
+
return strip_tags($text); //vrni tekst brez html tag-ov
}
@@ -1078,9 +1068,10 @@ class LatexAnalysisElement{
$tex .= '\keepXColumns';
if($export_format == 'pdf'){
$tex .= '\begin{'.$pdfTable.'}';
- if($pdfTable=='tabularx'){
+ if($pdfTable=='xltabular'){
//$tex .= '{'.$pdfTableWidth.'\textwidth}';
- $tex .= '{\hsize}';
+ //$tex .= '{\hsize}';
+ $tex .= '{\textwidth}';
}
$tex .= '{ '.$parameterTabular.' }';
}elseif($export_format == 'rtf'||$export_format == 'xls'){
@@ -1098,7 +1089,7 @@ class LatexAnalysisElement{
global $lang;
$text = array();
- $texoutputSumaValidAnswerVertical = '';
+ $outputSumaValidAnswerVertical = '';
# opcije
$options = array( 'isTextAnswer' => false, # ali je tekstovni odgovor
@@ -1110,26 +1101,26 @@ class LatexAnalysisElement{
$options[$_oKey] = $_option;
}
- $_percent = (SurveyAnalysis::$_FREQUENCYS[$_sequence]['allCnt'] > 0 ) ? 100*SurveyAnalysis::$_FREQUENCYS[$_sequence]['validCnt'] / SurveyAnalysis::$_FREQUENCYS[$_sequence]['allCnt'] : 0;
+ $_percent = (SurveyAnalysis::$_FREQUENCYS[$_sequence]['allCnt'] > 0 ) ? 100*(isset(SurveyAnalysis::$_FREQUENCYS[$_sequence]['validCnt'])?SurveyAnalysis::$_FREQUENCYS[$_sequence]['validCnt']:0) / SurveyAnalysis::$_FREQUENCYS[$_sequence]['allCnt'] : 0;
$_brez_MV = ((int)SurveyAnalysis::$currentMissingProfile == 2) ? TRUE : FALSE;
$_sufix = '';
- $text[] = $this->encodeText($lang['srv_anl_valid']);
- $text[] = $this->encodeText($lang['srv_anl_suma1']);
+ $text[] = LatexDocument::encodeText($lang['srv_anl_valid']);
+ $text[] = LatexDocument::encodeText($lang['srv_anl_suma1']);
- $text[] = $this->encodeText(SurveyAnalysis::$_FREQUENCYS[$_sequence]['validCnt'] > 0 ? SurveyAnalysis::$_FREQUENCYS[$_sequence]['validCnt'] : 0);
+ $text[] = LatexDocument::encodeText((isset(SurveyAnalysis::$_FREQUENCYS[$_sequence]['validCnt'])?SurveyAnalysis::$_FREQUENCYS[$_sequence]['validCnt']:0) > 0 ? (isset(SurveyAnalysis::$_FREQUENCYS[$_sequence]['validCnt'])?SurveyAnalysis::$_FREQUENCYS[$_sequence]['validCnt']:0) : 0);
- //$text[] = $this->encodeText(SurveyAnalysis::formatNumber($_percent, SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_PERCENT'), '%'));
- $text[] = $this->encodeText(self::formatNumber($_percent, SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_PERCENT'), '%'));
- //$text[] = $this->encodeText(SurveyAnalysis::formatNumber(100, SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_PERCENT'), '%'));
- $text[] = $this->encodeText(self::formatNumber(100, SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_PERCENT'), '%'));
+ //$text[] = LatexDocument::encodeText(SurveyAnalysis::formatNumber($_percent, SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_PERCENT'), '%'));
+ $text[] = LatexDocument::encodeText(self::formatNumber($_percent, SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_PERCENT'), '%'));
+ //$text[] = LatexDocument::encodeText(SurveyAnalysis::formatNumber(100, SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_PERCENT'), '%'));
+ $text[] = LatexDocument::encodeText(self::formatNumber(100, SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_PERCENT'), '%'));
$text[] = '';
- $exportformat = $options['exportFormat'];
+ $exportformat = isset($options['exportFormat'])?$options['exportFormat']:null;
$brezHline = $this->getBrezHline($exportformat);
$outputSumaValidAnswerVertical .= self::tableRow($text, $brezHline);
@@ -1138,9 +1129,8 @@ class LatexAnalysisElement{
//return $counter;
}
- function outputValidAnswerVertical($counter=null,$vkey='', $vAnswer=null, $_sequence=null,$spid=null, &$_kumulativa=null,$_options=array()) {
+ function outputValidAnswerVertical($counter=null,$vkey='', $vAnswer=null, $_sequence=null,$spid=null, &$_kumulativa=null,$_options=array(), $sprTip=null) {
global $lang;
- //echo "funkcija outputValidAnswerVertical </br>";
$text = array();
$texoutputValidAnswerVertical = '';
@@ -1156,50 +1146,33 @@ class LatexAnalysisElement{
}
$cssBck = ' '.SurveyAnalysis::$cssColors['0_' . ($counter & 1)];
- $_valid = (SurveyAnalysis::$_FREQUENCYS[$_sequence]['validCnt'] > 0 ) ? 100*$vAnswer['cnt'] / SurveyAnalysis::$_FREQUENCYS[$_sequence]['validCnt'] : 0;
+ $_valid = ((isset(SurveyAnalysis::$_FREQUENCYS[$_sequence]['validCnt'])?SurveyAnalysis::$_FREQUENCYS[$_sequence]['validCnt']:0) > 0 ) ? 100*$vAnswer['cnt'] / SurveyAnalysis::$_FREQUENCYS[$_sequence]['validCnt'] : 0;
$_percent = (SurveyAnalysis::$_FREQUENCYS[$_sequence]['allCnt'] > 0 ) ? 100*$vAnswer['cnt'] / SurveyAnalysis::$_FREQUENCYS[$_sequence]['allCnt'] : 0;
$_kumulativa += $_valid;
# ali presegamo število prikazanih vrstic, takrat v zadnji prikazani dodamo link več.. ostale vrstice pa skrijemo
-/* if ($options['textAnswerExceed'] == true) {
- if ($counter == TEXT_ANSWER_LIMIT ) {
- # link za več
- $show_more = '<div id="valid_row_togle_'.$_sequence.'" class="floatRight blue pointer" onclick="showHidenTextRow(\''.$_sequence.'\');return false;">(več...)</div>'.NEW_LINE;
- } elseif ($counter > TEXT_ANSWER_LIMIT ) {
- $hide_row = ' hidden';
- $_exceed = true;
- }
- } */
- //if ($counter < TEXT_MAX_ANSWER_LIMIT) {
- $text[] = '';
+ $text[] = '';
- $addText = (($options['isTextAnswer'] == false && (string)$vkey != $vAnswer['text']) ? ' ('.$vAnswer['text'] .')' : '');
- //$text[] = $this->encodeText(' '.$vkey.$addText);
- $text[] = $this->snippet($this->encodeText(' '.$vkey.$addText), 400);
-
+ $addText = (($options['isTextAnswer'] == false && (string)$vkey != $vAnswer['text']) ? ' ('.$vAnswer['text'] .')' : '');
+ $tmptext = $this->snippet($vkey.$addText, 400);
+ $text[] = LatexDocument::encodeText($tmptext);
+ //$text[] = $this->snippet(LatexDocument::encodeText(' '.$vkey.$addText), 400);
+
+ if($sprTip!=21){
$text[] = (int)$vAnswer['cnt'];
- //$text[] = $this->encodeText(SurveyAnalysis::formatNumber($_percent, SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_PERCENT'), '%'));
- $text[] = $this->encodeText(self::formatNumber($_percent, SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_PERCENT'), '%'));
+ $text[] = LatexDocument::encodeText(self::formatNumber($_percent, SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_PERCENT'), '%'));
- //$text[] = $this->encodeText(SurveyAnalysis::formatNumber($_valid, SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_PERCENT'), '%'));
- $text[] = $this->encodeText(self::formatNumber($_valid, SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_PERCENT'), '%'));
+ $text[] = LatexDocument::encodeText(self::formatNumber($_valid, SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_PERCENT'), '%'));
- //$text[] = $this->encodeText(SurveyAnalysis::formatNumber($_kumulativa, SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_PERCENT'), '%'));
- $text[] = $this->encodeText(self::formatNumber($_kumulativa, SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_PERCENT'), '%'));
-
- /*} elseif ($counter == TEXT_MAX_ANSWER_LIMIT ) {
- echo '<tr id="'.$spid.'_'.$_sequence.'_'.$counter.'" name="valid_row_'.$_sequence.'">';
- echo '<td class="anl_bl anl_ac anl_br gray anl_dash_bt anl_dash_bb" colspan="'.(6+(int)SurveyAnalysis::$_HEADERS[$spid]['show_valid_percent']+((int)SurveyAnalysis::$_SHOW_LEGENDA*2)).'"> . . . Prikazujemo samo prvih '.TEXT_MAX_ANSWER_LIMIT.' veljavnih odgovorov!</td>';
- echo '</tr>';
- }*/
+ $text[] = LatexDocument::encodeText(self::formatNumber($_kumulativa, SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_PERCENT'), '%'));
+ }
- $exportformat = $options['exportFormat'];
+ $exportformat = isset($options['exportFormat'])?$options['exportFormat']:null;
$brezHline = $this->getBrezHline($exportformat);
$texoutputValidAnswerVertical .= self::tableRow($text, $brezHline);
- //echo "Besedilo na koncu funkcije outputValidAnswerVertical:".$texoutputValidAnswerVertical."</br>";
return $texoutputValidAnswerVertical;
/* $counter++;
return $counter; */
@@ -1221,7 +1194,7 @@ class LatexAnalysisElement{
$options[$_oKey] = $_option;
}
- $exportformat = $options['exportFormat'];
+ $exportformat = isset($options['exportFormat'])?$options['exportFormat']:null;
$brezHline = $this->getBrezHline($exportformat);
$_percent = (SurveyAnalysis::$_FREQUENCYS[$_sequence]['allCnt'] > 0 ) ? 100*$vAnswer['cnt'] / SurveyAnalysis::$_FREQUENCYS[$_sequence]['allCnt'] : 0;
@@ -1236,17 +1209,17 @@ class LatexAnalysisElement{
//$_Z_MV = 1;
if($_Z_MV){
//echo "this->hideEmpty: ".$this->hideEmpty."</br>";
- //$text[] = $this->encodeText($lang['srv_anl_missing1']);
- //$text[] = '\multirow{ '.$vAnswer['cnt'].'}{*}{ '.$this->encodeText($lang['srv_anl_missing1']).' }';
+ //$text[] = LatexDocument::encodeText($lang['srv_anl_missing1']);
+ //$text[] = '\multirow{ '.$vAnswer['cnt'].'}{*}{ '.LatexDocument::encodeText($lang['srv_anl_missing1']).' }';
$text[] = '';
- $text[] = $this->encodeText($vkey.' (' . $vAnswer['text'].')');
+ $text[] = LatexDocument::encodeText($vkey.' (' . $vAnswer['text'].')');
- $text[] = $this->encodeText((int)$vAnswer['cnt']);
+ $text[] = LatexDocument::encodeText((int)$vAnswer['cnt']);
- //$text[] = $this->encodeText(SurveyAnalysis::formatNumber($_percent, SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_PERCENT'), '%'));
- $text[] = $this->encodeText(self::formatNumber($_percent, SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_PERCENT'), '%'));
+ //$text[] = LatexDocument::encodeText(SurveyAnalysis::formatNumber($_percent, SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_PERCENT'), '%'));
+ $text[] = LatexDocument::encodeText(self::formatNumber($_percent, SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_PERCENT'), '%'));
$text[] = '';
$text[] = '';
@@ -1274,34 +1247,32 @@ class LatexAnalysisElement{
$options[$_oKey] = $_option;
}
- $exportformat = $options['exportFormat'];
+ $exportformat = isset($options['exportFormat'])?$options['exportFormat']:null;
$brezHline = $this->getBrezHline($exportformat);
$cssBck = ' '.SurveyAnalysis::$cssColors['text_' . ($counter & 1)];
- $_percent = (SurveyAnalysis::$_FREQUENCYS[$_sequence]['allCnt'] > 0 ) ? 100*SurveyAnalysis::$_FREQUENCYS[$_sequence]['invalidCnt'] / SurveyAnalysis::$_FREQUENCYS[$_sequence]['allCnt'] : 0;
+ $_percent = (SurveyAnalysis::$_FREQUENCYS[$_sequence]['allCnt'] > 0 ) ? 100*(isset(SurveyAnalysis::$_FREQUENCYS[$_sequence]['invalidCnt'])?SurveyAnalysis::$_FREQUENCYS[$_sequence]['invalidCnt']:0) / (isset(SurveyAnalysis::$_FREQUENCYS[$_sequence]['allCnt'])?SurveyAnalysis::$_FREQUENCYS[$_sequence]['allCnt']:null) : 0;
//$_brez_MV = ((int)SurveyAnalysis::$missingProfileData['display_mv_type'] === 0) ? TRUE : FALSE;
$_brez_MV = $this->hideEmpty;
if(!$_brez_MV){
$text = array();
- //$text[] = $this->encodeText($lang['srv_anl_missing1']);
$text[] = '';
- $text[] = $this->encodeText($lang['srv_anl_suma1']);
- //$text[] = $this->encodeText(SurveyAnalysis::$_FREQUENCYS[$_sequence]['invalidCnt']);
+ $text[] = LatexDocument::encodeText($lang['srv_anl_suma1']);
+ //$text[] = LatexDocument::encodeText(SurveyAnalysis::$_FREQUENCYS[$_sequence]['invalidCnt']);
$answer['cnt'] = SurveyAnalysis::$_FREQUENCYS[$_sequence]['invalidCnt'] > 0 ? SurveyAnalysis::$_FREQUENCYS[$_sequence]['invalidCnt'] : 0;
- $text[] = $this->encodeText((int)$answer['cnt']);
+ $text[] = LatexDocument::encodeText((int)$answer['cnt']);
- //$text[] = $this->encodeText(SurveyAnalysis::formatNumber($_percent, SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_PERCENT'), '%'));
- $text[] = $this->encodeText(self::formatNumber($_percent, SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_PERCENT'), '%'));
+ //$text[] = LatexDocument::encodeText(SurveyAnalysis::formatNumber($_percent, SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_PERCENT'), '%'));
+ $text[] = LatexDocument::encodeText(self::formatNumber($_percent, SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_PERCENT'), '%'));
$text[] = '';
$text[] = '';
$texoutputSumaInvalidAnswerVertical .= $this->tableRow($text, $brezHline);
}
- //echo $texoutputSumaInvalidAnswerVertical."</br>";
return $texoutputSumaInvalidAnswerVertical;
/* $counter++;
return $counter; */
@@ -1331,7 +1302,7 @@ class LatexAnalysisElement{
$brezHline = 0;
} */
- $exportformat = $options['exportFormat'];
+ $exportformat = isset($options['exportFormat'])?$options['exportFormat']:null;
$brezHline = $this->getBrezHline($exportformat);
$_brez_MV = $this->hideEmpty;
@@ -1340,10 +1311,10 @@ class LatexAnalysisElement{
$text = array();
$text[] = '';
- $text[] = $this->encodeText($lang['srv_anl_suma2']);
- $text[] = $this->encodeText((SurveyAnalysis::$_FREQUENCYS[$_sequence]['allCnt'] ? SurveyAnalysis::$_FREQUENCYS[$_sequence]['allCnt'] : 0));
- //$text[] = $this->encodeText(SurveyAnalysis::formatNumber('100', SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_PERCENT'), '%'));
- $text[] = $this->encodeText(self::formatNumber('100', SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_PERCENT'), '%'));
+ $text[] = LatexDocument::encodeText($lang['srv_anl_suma2']);
+ $text[] = LatexDocument::encodeText((SurveyAnalysis::$_FREQUENCYS[$_sequence]['allCnt'] ? SurveyAnalysis::$_FREQUENCYS[$_sequence]['allCnt'] : 0));
+ //$text[] = LatexDocument::encodeText(SurveyAnalysis::formatNumber('100', SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_PERCENT'), '%'));
+ $text[] = LatexDocument::encodeText(self::formatNumber('100', SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_PERCENT'), '%'));
$text[] = '';
$text[] = '';
@@ -1383,7 +1354,7 @@ class LatexAnalysisElement{
//Priprava parametrov za tabelo - konec
//zacetek latex tabele z obrobo za Drugo
- $pdfTable = 'tabularx';
+ $pdfTable = 'xltabular';
$rtfTable = 'tabular';
$pdfTableWidth = 1;
$rtfTableWidth = 1;
@@ -1396,8 +1367,8 @@ class LatexAnalysisElement{
/*Naslovni vrstici tabele*/
//prva vrstica tabele
- $texOutputOtherAnswers .= $this->encodeText($_variable['variable'])." & \multicolumn{5}{l|}{".$this->encodeText(SurveyAnalysis::$_HEADERS[$oAnswers['spid']]['variable'].' ('.$_variable['naslov'].' )')."} ".$this->texNewLine;
- //$texOutputOtherAnswers .= $this->encodeText($_variable['variable'])." & \multicolumn{5}{X|}{".$this->encodeText(SurveyAnalysis::$_HEADERS[$oAnswers['spid']]['variable'].' ('.$_variable['naslov'].' )')."} ".$this->texNewLine;
+ $texOutputOtherAnswers .= LatexDocument::encodeText($_variable['variable'])." & \multicolumn{5}{l|}{".LatexDocument::encodeText(SurveyAnalysis::$_HEADERS[$oAnswers['spid']]['variable'].' ('.$_variable['naslov'].' )')."} ".$this->texNewLine;
+ //$texOutputOtherAnswers .= LatexDocument::encodeText($_variable['variable'])." & \multicolumn{5}{X|}{".LatexDocument::encodeText(SurveyAnalysis::$_HEADERS[$oAnswers['spid']]['variable'].' ('.$_variable['naslov'].' )')."} ".$this->texNewLine;
if($export_format != 'xls'){
$texOutputOtherAnswers .= $this->horizontalLineTex; /*obroba*/
$brezHline = 1;
@@ -1415,8 +1386,8 @@ class LatexAnalysisElement{
//prva vrstica
/* $this->pdf->setFont('','b','6');
$this->pdf->ln(5);
- $this->pdf->MultiCell(18, $height, $this->encodeText($_variable['variable']), 1, 'C', 0, 0, 0 ,0, true);
- $this->pdf->MultiCell(162, $height, $this->encodeText(SurveyAnalysis::$_HEADERS[$oAnswers['spid']]['variable'].' ('.$_variable['naslov'].' )'), 1, 'L', 0, 1, 0 ,0, true); */
+ $this->pdf->MultiCell(18, $height, LatexDocument::encodeText($_variable['variable']), 1, 'C', 0, 0, 0 ,0, true);
+ $this->pdf->MultiCell(162, $height, LatexDocument::encodeText(SurveyAnalysis::$_HEADERS[$oAnswers['spid']]['variable'].' ('.$_variable['naslov'].' )'), 1, 'L', 0, 1, 0 ,0, true); */
//druga vrstica
/* $this->tableHeader();
@@ -1425,7 +1396,8 @@ class LatexAnalysisElement{
$counter = 1;
$_kumulativa = 0;
- if (count(SurveyAnalysis::$_FREQUENCYS[$_sequence]['valid'])> 0 ) {
+ $freg_seq = array_key_exists('valid', SurveyAnalysis::$_FREQUENCYS[$_sequence])?SurveyAnalysis::$_FREQUENCYS[$_sequence]['valid']:null;
+ if (is_countable($freg_seq)&&count($freg_seq)> 0 ) {
foreach (SurveyAnalysis::$_FREQUENCYS[$_sequence]['valid'] AS $vkey => $vAnswer) {
if ($vAnswer['cnt'] > 0 ) { # izpisujemo samo tiste ki nisno 0
//$counter = self::outputValidAnswerVertical($counter,$vkey,$vAnswer,$_sequence,$spid,$_kumulativa,array('isOtherAnswer'=>true));
@@ -1439,7 +1411,7 @@ class LatexAnalysisElement{
if (count(SurveyAnalysis::$_FREQUENCYS[$_sequence]['invalid'])> 0 ) {
$_Z_MV = !$this->hideEmpty;
if($_Z_MV){ //ce je potrebno izpisati tudi manjkajoce
- $texOutputOtherAnswers .= $this->encodeText($lang['srv_anl_missing1']);
+ $texOutputOtherAnswers .= LatexDocument::encodeText($lang['srv_anl_missing1']);
}
foreach (SurveyAnalysis::$_FREQUENCYS[$_sequence]['invalid'] AS $ikey => $iAnswer) {
if ($iAnswer['cnt'] > 0 ) { # izpisujemo samo tiste ki nisno 0
@@ -1457,7 +1429,7 @@ class LatexAnalysisElement{
$texOutputOtherAnswers .= self::outputSumaVertical($counter,$_sequence,$spid,array('isOtherAnswer'=>true, 'exportFormat'=>$export_format));
//zaljucek latex tabele za Drugo
- $texOutputOtherAnswers .= ($export_format == 'pdf' ? "\\end{tabularx}" : "\\end{tabular}");
+ $texOutputOtherAnswers .= ($export_format == 'pdf' ? "\\end{xltabular}" : "\\end{tabular}");
//zaljucek latex tabele za Drugo - konec
return $texOutputOtherAnswers;
@@ -1470,11 +1442,11 @@ class LatexAnalysisElement{
$naslov = array();
$naslov[] = '';
- $naslov[] = $this->encodeText($lang['srv_analiza_frekvence_titleAnswers']);
- $naslov[] = $this->encodeText($lang['srv_analiza_frekvence_titleFrekvenca']);
- $naslov[] = $this->encodeText($lang['srv_analiza_frekvence_titleOdstotek']);
- $naslov[] = $this->encodeText($lang['srv_analiza_frekvence_titleVeljavni']);
- $naslov[] = $this->encodeText($lang['srv_analiza_frekvence_titleKumulativa']);
+ $naslov[] = LatexDocument::encodeText($lang['srv_analiza_frekvence_titleAnswers']);
+ $naslov[] = LatexDocument::encodeText($lang['srv_analiza_frekvence_titleFrekvenca']);
+ $naslov[] = LatexDocument::encodeText($lang['srv_analiza_frekvence_titleOdstotek']);
+ $naslov[] = LatexDocument::encodeText($lang['srv_analiza_frekvence_titleVeljavni']);
+ $naslov[] = LatexDocument::encodeText($lang['srv_analiza_frekvence_titleKumulativa']);
$params = array('border' => 'TB', 'bold' => 'B', 'align2' => 'C');
@@ -1486,9 +1458,9 @@ class LatexAnalysisElement{
}
$tableHeader .= $this->tableRow($naslov, $brezHline);
- /*$linecount = $this->pdf->getNumLines($this->encodeText($arrayText[1]), 90);
+ /*$linecount = $this->pdf->getNumLines(LatexDocument::encodeText($arrayText[1]), 90);
$linecount == 1 ? $height = 4.7 : $height = 4.7 + ($linecount-1)*3.3;*/
- $height = 1; //$height = $this->getCellHeight($this->encodeText($arrayText[1]), 90);
+ $height = 1; //$height = $this->getCellHeight(LatexDocument::encodeText($arrayText[1]), 90);
//ce smo na prelomu strani
/* if( ($this->pdf->getY() + $height) > 270){
@@ -1509,9 +1481,10 @@ class LatexAnalysisElement{
}
//funkcija skrbi za izpis multicol celice
- function MultiColCellLatex($steviloVmesnihStolpcevPodvrstic=null, $text='', $odZacetka=0){
+ function MultiColCellLatex($steviloVmesnihStolpcevPodvrstic=null, $text='', $odZacetka=0, $export_format=null){
$tabela = '';
//echo "steviloVmesnihStolpcevPodvrstic: $steviloVmesnihStolpcevPodvrstic</br>";
+ //echo "format: $export_format</br>";
if($steviloVmesnihStolpcevPodvrstic==1){ //ce je 1, ne sme biti multicolumn{1}, saj so drugace tezave z izpisom
$tabela .= " & ".$text." ";
}else{
@@ -1519,10 +1492,19 @@ class LatexAnalysisElement{
$steviloArrayrulewidth = ($steviloVmesnihStolpcevPodvrstic-1);
if($odZacetka==0){
//$tabela .= " & \multicolumn{".$steviloVmesnihStolpcevPodvrstic."}{X|}{";//zacetek multicol
- $tabela .= " & \multicolumn{".$steviloVmesnihStolpcevPodvrstic."}{>{\hsize=\dimexpr".$steviloVmesnihStolpcevPodvrstic."\hsize+".$steviloTabColSep."\\tabcolsep+".$steviloArrayrulewidth."\arrayrulewidth\\relax}C|}{";//zacetek multicol
+ if($export_format=='pdf'){
+ $tabela .= " & \multicolumn{".$steviloVmesnihStolpcevPodvrstic."}{>{\hsize=\dimexpr".$steviloVmesnihStolpcevPodvrstic."\hsize+".$steviloTabColSep."\\tabcolsep+".$steviloArrayrulewidth."\arrayrulewidth\\relax}C|}{";//zacetek multicol
+ }elseif($export_format=='rtf'){
+ $tabela .= " & \multicolumn{".$steviloVmesnihStolpcevPodvrstic."}{C|}{";//zacetek multicol
+ }
+
}else{
//$tabela .= " \multicolumn{".$steviloVmesnihStolpcevPodvrstic."}{X|}{";//zacetek multicol
- $tabela .= " \multicolumn{".$steviloVmesnihStolpcevPodvrstic."}{>{\hsize=\dimexpr".$steviloVmesnihStolpcevPodvrstic."\hsize+".$steviloTabColSep."\\tabcolsep+".$steviloArrayrulewidth."\arrayrulewidth\\relax}C|}{";//zacetek multicol
+ if($export_format=='pdf'){
+ $tabela .= " \multicolumn{".$steviloVmesnihStolpcevPodvrstic."}{>{\hsize=\dimexpr".$steviloVmesnihStolpcevPodvrstic."\hsize+".$steviloTabColSep."\\tabcolsep+".$steviloArrayrulewidth."\arrayrulewidth\\relax}C|}{";//zacetek multicol
+ }elseif($export_format=='rtf'){
+ $tabela .= " \multicolumn{".$steviloVmesnihStolpcevPodvrstic."}{C|}{";//zacetek multicol
+ }
}
$tabela .= $text;
if($odZacetka==0){
@@ -1546,7 +1528,7 @@ class LatexAnalysisElement{
$tabela .= '\multirow{'.$steviloVmesnihVrstic.'}{*}{'; //zacetek multirow
}
$tabela .= $text;
- /* if($cols==0 && $text==$this->encodeText($lang['srv_analiza_crosstab_skupaj'])){ //premaknil nize, ker je delalo težave pri izpisu daljsih tabel
+ /* if($cols==0 && $text==LatexDocument::encodeText($lang['srv_analiza_crosstab_skupaj'])){ //premaknil nize, ker je delalo težave pri izpisu daljsih tabel
$tabela .= ' & ';
} */
//if($steviloVmesnihVrstic > 1){ //ce je potrebno multirow prikazovanje
@@ -1554,7 +1536,7 @@ class LatexAnalysisElement{
$tabela .= '}'; //konec multirow
}
- if($cols==0 && $text==$this->encodeText($lang['srv_analiza_crosstab_skupaj'])){
+ if($cols==0 && $text==LatexDocument::encodeText($lang['srv_analiza_crosstab_skupaj'])){
$tabela .= ' & ';
}
//echo $tabela."</br>";
@@ -1575,21 +1557,14 @@ class LatexAnalysisElement{
return $tabela;
}
- //function tableRow($arrayText, $brezHline=0, $brezNoveVrstice=0, $nadaljevanjeVrstice=0, $steviloPodstolpcev){
- //function tableRow($arrayText, $brezHline=0, $brezNoveVrstice=0, $nadaljevanjeVrstice=0, $color='', $export_format, $steviloPodstolpcev){
+
function tableRow($arrayText=[], $brezHline=0, $brezNoveVrstice=0, $nadaljevanjeVrstice=0, $color='', $export_format='', $steviloPodstolpcev=[]){
$tableRow = '';
- /*$linecount = $this->pdf->getNumLines($this->encodeText($arrayText[1]), 90);
+ /*$linecount = $this->pdf->getNumLines(LatexDocument::encodeText($arrayText[1]), 90);
$linecount == 1 ? $height = 4.7 : $height = 4.7 + ($linecount-1)*3.3;*/
- $height = 1; //$height = $this->getCellHeight($this->encodeText($arrayText[1]), 90);
-/* echo $arrayText[0]."</br>";
- echo $arrayText[1]."</br>";
- echo "brez hline: ".$brezHline."</br>"; */
-
- if($arrayParams['align2'] != 'C')
- $arrayParams['align2'] = 'L';
- //echo "velikost polja s tekstom: ".count($arrayText)."</br>";
-
+ $height = 1; //$height = $this->getCellHeight(LatexDocument::encodeText($arrayText[1]), 90);
+
+ $cellBgColor = '';
if($export_format == 'pdf'){
if($color=='blue'){
//$cellBgColor = 'cyan';
@@ -1787,35 +1762,33 @@ class LatexAnalysisElement{
//echo "funkcija displayDescriptivesSpremenljivkaRow: ".$spremenljivka['variable']." </br>";
$texDisplayDescriptivesSpremenljivkaRow = '';
if ($_sequence != null) {
- $_desc = SurveyAnalysis::$_DESCRIPTIVES[$_sequence];
+ $_desc = isset(SurveyAnalysis::$_DESCRIPTIVES[$_sequence])?SurveyAnalysis::$_DESCRIPTIVES[$_sequence]:null;
}
$text = array();
- $text[] = '\textbf{'.$this->encodeText($spremenljivka['variable']).'}';
- $text[] = '\textbf{'.$this->encodeText($spremenljivka['naslov']).'}';
+ $text[] = '\textbf{'.LatexDocument::encodeText($spremenljivka['variable']).'}';
+ $text[] = '\textbf{'.LatexDocument::encodeText($spremenljivka['naslov']).'}';
#veljavno
- $text[] = $this->encodeText((!$show_enota ? (int)$_desc['validCnt'] : ''));
+ $text[] = LatexDocument::encodeText((!$show_enota ? (int)(isset($_desc['validCnt'])?$_desc['validCnt']:0) : ''));
#ustrezno
- $text[] = $this->encodeText((!$show_enota ? (int)$_desc['allCnt'] : ''));
+ $text[] = LatexDocument::encodeText((!$show_enota ? (int)(isset($_desc['allCnt'])?$_desc['allCnt']:0) : ''));
if (isset($_desc['avg']) && (int)$spremenljivka['skala'] !== 1)
- //$text[] = $this->encodeText(SurveyAnalysis::formatNumber($_desc['avg'],SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_AVERAGE'),''));
- $text[] = $this->encodeText(self::formatNumber($_desc['avg'],SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_AVERAGE'),''));
+ //$text[] = LatexDocument::encodeText(SurveyAnalysis::formatNumber($_desc['avg'],SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_AVERAGE'),''));
+ $text[] = LatexDocument::encodeText(self::formatNumber($_desc['avg'],SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_AVERAGE'),''));
else
- $text[] = $this->encodeText('');
+ $text[] = LatexDocument::encodeText('');
if (isset($_desc['div']) && (int)$spremenljivka['skala'] !== 1)
- //$text[] = $this->encodeText(SurveyAnalysis::formatNumber($_desc['div'],SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_DEVIATION'),''));
- $text[] = $this->encodeText(self::formatNumber($_desc['div'],SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_DEVIATION'),''));
+ //$text[] = LatexDocument::encodeText(SurveyAnalysis::formatNumber($_desc['div'],SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_DEVIATION'),''));
+ $text[] = LatexDocument::encodeText(self::formatNumber($_desc['div'],SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_DEVIATION'),''));
else
- $text[] = $this->encodeText('');
+ $text[] = LatexDocument::encodeText('');
- //$text[] = $this->encodeText((int)$spremenljivka['skala'] !== 1 ? $_desc['min'] : '');
- //$text[] = $this->encodeText((int)$spremenljivka['skala'] !== 1 ? $_desc['max'] : '');
- $text[] = (int)$spremenljivka['skala'] !== 1 ? $_desc['min'] : '';
- $text[] = (int)$spremenljivka['skala'] !== 1 ? $_desc['max'] : '';
+ $text[] = (int)(isset($spremenljivka['skala'])?$spremenljivka['skala']:0) !== 1 ? (isset($_desc['min'])?$_desc['min']:0) : '';
+ $text[] = (int)(isset($spremenljivka['skala'])?$spremenljivka['skala']:0) !== 1 ? (isset($_desc['max'])?$_desc['max']:0) : '';
//$texDisplayDescriptivesSpremenljivkaRow .= $this->descTableRow($text);
@@ -1836,55 +1809,50 @@ class LatexAnalysisElement{
$texDescriptivesVariablaRow = '';
$_sequence = $variable['sequence']; # id kolone z podatki
if ($_sequence != null) {
- $_desc = SurveyAnalysis::$_DESCRIPTIVES[$_sequence];
+ $_desc = isset(SurveyAnalysis::$_DESCRIPTIVES[$_sequence])?SurveyAnalysis::$_DESCRIPTIVES[$_sequence]:null;
}
$text = array();
- $text[] = $this->encodeText($variable['variable']);
- $text[] = $this->encodeText($variable['naslov']);
+ $text[] = LatexDocument::encodeText($variable['variable']);
+ $text[] = LatexDocument::encodeText($variable['naslov']);
#veljavno
- $text[] = $this->encodeText((int)$_desc['validCnt']);
+ $text[] = LatexDocument::encodeText((int)(isset($_desc['validCnt'])?$_desc['validCnt']:0));
#ustrezno
- $text[] = $this->encodeText((int)$_desc['allCnt']);
+ $text[] = LatexDocument::encodeText((int)(isset($_desc['allCnt'])?$_desc['allCnt']:0));
- //if (isset($_desc['avg']) && (int)$spremenljivka['skala'] !== 1)
- //if (isset($_desc['avg']) && (int)$spremenljivka['skala'] !== 1 && $spremenljivka['tip'] != 16)
if (isset($_desc['avg']) && (int)$spremenljivka['skala'] !== 1 && ($spremenljivka['tip'] != 16 && $spremenljivka['tip'] != 2))
- //$text[] = $this->encodeText(SurveyAnalysis::formatNumber($_desc['avg'],SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_AVERAGE'),''));
- $text[] = $this->encodeText(self::formatNumber($_desc['avg'],SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_AVERAGE'),''));
+ //$text[] = LatexDocument::encodeText(SurveyAnalysis::formatNumber($_desc['avg'],SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_AVERAGE'),''));
+ $text[] = LatexDocument::encodeText(self::formatNumber($_desc['avg'],SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_AVERAGE'),''));
//else if (isset($_desc['avg']) && $spremenljivka['tip'] == 2 && (int)$spremenljivka['skala'] == 1 )
else if (isset($_desc['avg']) && $spremenljivka['tip'] == 2 && (int)$spremenljivka['skala'] !== 1 && ($spremenljivka['tip'] != 16))
- //$text[] = $this->encodeText(SurveyAnalysis::formatNumber($_desc['avg']*100,SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_AVERAGE'),'&nbsp;%'));
- $text[] = $this->encodeText(self::formatNumber($_desc['avg']*100,SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_AVERAGE'),'&nbsp;%'));
+ //$text[] = LatexDocument::encodeText(SurveyAnalysis::formatNumber($_desc['avg']*100,SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_AVERAGE'),'&nbsp;%'));
+ $text[] = LatexDocument::encodeText(self::formatNumber($_desc['avg']*100,SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_AVERAGE'),'&nbsp;%'));
else
- $text[] = $this->encodeText('');
+ $text[] = LatexDocument::encodeText('');
- //if (isset($_desc['div']) && (int)$spremenljivka['skala'] !== 1)
- //if (isset($_desc['div']) && (int)$spremenljivka['skala'] !== 1 && $spremenljivka['tip'] != 16)
if (isset($_desc['div']) && (int)$spremenljivka['skala'] !== 1 && ($spremenljivka['tip'] != 16 && $spremenljivka['tip'] != 2))
- //$text[] = $this->encodeText(SurveyAnalysis::formatNumber($_desc['div'],SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_DEVIATION'),''));
- $text[] = $this->encodeText(self::formatNumber($_desc['div'],SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_DEVIATION'),''));
+ //$text[] = LatexDocument::encodeText(SurveyAnalysis::formatNumber($_desc['div'],SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_DEVIATION'),''));
+ $text[] = LatexDocument::encodeText(self::formatNumber($_desc['div'],SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_DEVIATION'),''));
else
- $text[] = $this->encodeText('');
+ $text[] = LatexDocument::encodeText('');
- //if ((int)$spremenljivka['skala'] !== 1 && $spremenljivka['tip'] != 16){
- if ((int)$spremenljivka['skala'] !== 1 && ($spremenljivka['tip'] != 16 && $spremenljivka['tip'] != 2)){
- $text[] = $this->encodeText($_desc['min']);
- $text[] = $this->encodeText($_desc['max']);
+ if ((int)(isset($spremenljivka['skala'])?$spremenljivka['skala']:0) !== 1 && ($spremenljivka['tip'] != 16 && $spremenljivka['tip'] != 2)){
+ $text[] = LatexDocument::encodeText(isset($_desc['min'])?$_desc['min']:0);
+ $text[] = LatexDocument::encodeText(isset($_desc['max'])?$_desc['max']:0);
}else{
- $text[] = $this->encodeText('');
- $text[] = $this->encodeText('');
+ $text[] = LatexDocument::encodeText('');
+ $text[] = LatexDocument::encodeText('');
}
- //$text[] = $this->encodeText((int)$spremenljivka['skala'] !== 1 ? $_desc['min'] : '');
- //$text[] = $this->encodeText((int)$spremenljivka['skala'] !== 1 ? $_desc['max'] : '');
+ //$text[] = LatexDocument::encodeText((int)$spremenljivka['skala'] !== 1 ? $_desc['min'] : '');
+ //$text[] = LatexDocument::encodeText((int)$spremenljivka['skala'] !== 1 ? $_desc['max'] : '');
$texDescriptivesVariablaRow .= $this->tableRow($text);
- //echo "nekaj: ".$this->encodeText(self::formatNumber($_desc['avg']*100,SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_AVERAGE'),'&nbsp;%'))." ".$spremenljivka['tip']."</br>";
+ //echo "nekaj: ".LatexDocument::encodeText(self::formatNumber($_desc['avg']*100,SurveyDataSettingProfiles :: getSetting('NUM_DIGIT_AVERAGE'),'&nbsp;%'))." ".$spremenljivka['tip']."</br>";
//echo "tex iz funkcije displayDescriptivesVariablaRow: ".$texDescriptivesVariablaRow."</br>";
return $texDescriptivesVariablaRow;
}
@@ -2019,4 +1987,182 @@ class LatexAnalysisElement{
return $brezHline;
}
+ #funkcija, ki skrbi za pridobitev imena slike, ki jo je potrebno izrisati ######################################
+ function getImageName($text='', $sprId=null, $findme='', $vre_id=0, $img_id=0){
+ global $site_path, $site_url;
+ $imageName = '';
+ //echo "id slike $img_id </br>";
+ if($text == 'hotspot' && $findme == 'hotspot_image='){
+ $sqlParametrov = sisplet_query("SELECT params FROM srv_spremenljivka WHERE id='".$sprId."'");
+ $rowParametrov = mysqli_fetch_row($sqlParametrov);
+ $text = $rowParametrov[0];
+ }
+
+ $pos = strpos($text, $findme); //najdi pozicijo teksta v $findme
+ //echo "text za echo: ".$text."</br>";
+ //if($pos!=''){ //ce je slika v bazi
+ if($pos!=''||$pos==0){ //ce je slika v bazi
+ $imageName = substr($text,$pos); //pokazi le del text od besedila $findme dalje (vkljucno z besedilom)
+ //echo "imageName prej: ".$imageName."</br>";
+
+ //$findme = $site_path.'uploadi/editor/';
+ $findme = $site_url.'uploadi/editor/';
+ //$findme = 'uploadi/editor/';
+ //$findme = 'editor/';
+ //echo "findme: ".$findme."</br>";
+ $pos = strpos($imageName, $findme); //najdi pozicijo teksta v $findme
+ //echo "najdi tole: ".$findme."</br>";
+ //echo "najdi tukaj: ".$imageName."</br>";
+ //echo "pozicija tega: ".$pos."</br>";
+ if($pos){ //ce je slika na strezniku
+ $slikaNaStrezniku = 1;
+ }else{//ce slike ni na strezniku
+ $slikaNaStrezniku = 0;
+ }
+ //echo "ali je slika na strežniku: ".$slikaNaStrezniku."</br>";
+ if($slikaNaStrezniku==1){ //ce je slika na strezniku
+ $findEditor = 'editor/';
+ $posEditor = strpos($imageName, $findEditor); //najdi pozicijo teksta v $findEditor
+ $imageName = substr($imageName,$posEditor+7); //pokazi le del params od besedila 'editor/' dalje, brez besedila 'editor/'
+ //echo "imagename : ".$imageName."</br>";
+ $pos = $this->getEndPosition($imageName); //najdi pozicijo konca URL slike
+ $imageExtension = substr($imageName, $pos-3, 3); //pridobi koncnico slike (za gif je potrebno sliko pretvoriti v png, saj latex ne podpira gif)
+ $imageName = substr($imageName, 0, $pos); //pokazi le del params od zacetka besedila do '"' oz. konca URL slike
+
+ $path = $site_path.'uploadi/editor/'.$imageName;
+ //$path = $site_url.'uploadi/editor/'.$imageName;
+
+ if($imageExtension == 'gif'){ //ce je slika gif, jo je potrebno pretvoriti v png
+ $this->convertGifToPng($path, $slikaNaStrezniku);
+ }
+
+ if($imageExtension == 'jpg' || $imageExtension == 'peg'){ //ce je slika jpg ali jpeg, jo je potrebno pretvoriti v png
+ $this->convertJpgToPng($path, $slikaNaStrezniku, $imageExtension);
+ }
+ }elseif($slikaNaStrezniku==0){ //ce slike ni na strezniku
+ //echo "vre_id: $vre_id </br>";
+ $imageName = $this->getOnlineImageName($imageName, $slikaNaStrezniku, $vre_id, $img_id); //pridobi njen URL
+ }
+
+ $imageName = substr($imageName, 0, strrpos($imageName, '.'));
+
+ }
+
+ //echo "imagename pred return: ".$imageName."</br>";
+ return $imageName;
+ }
+ #funkcija, ki skrbi za pridobitev imena slike, ki jo je potrebno izrisati - konec ###############################
+ function getEndPosition($imageName=''){
+ $findme = '"';
+ $pos = strpos($imageName, $findme); //najdi pozicijo teksta '"'
+ return $pos;
+ }
+
+ function convertGifToPng($path='', $slikaNaStrezniku=null){
+ //echo "path: ".$path."</br>";
+ $image = imagecreatefromgif($path); //pripravi sliko iz gif za pretvorbo
+ $imageName = substr($path, 0, -3); //ime slike brez extension-a
+ //echo $imageName."</br>";
+ $imageNamePNG = $imageName.'png'; //ime slike z ustreznim extension
+ imagepng($image, $imageNamePNG); //pretvori pripravljeno gif sliko v png
+
+ if($slikaNaStrezniku==0){ //ce slika je iz URL in ni na strezniku, GIF izbrisi
+ unlink($imageName.'gif'); //izbrisi gif sliko
+ }
+ }
+
+ function convertJpgToPng($path='', $slikaNaStrezniku=null, $imageExtension=''){
+ $image = imagecreatefromjpeg($path); //pripravi sliko iz jpg za pretvorbo
+ $imageName = substr($path, 0, strrpos($path, '.')); //ime slike brez extension-a
+ //echo $imageName."</br>";
+ $imageNamePNG = $imageName.'.png'; //ime slike z ustreznim extension
+ imagepng($image, $imageNamePNG); //pretvori pripravljeno jpg sliko v png
+ //echo "pretvorba v png: ".$imageNamePNG."</br>";
+ //echo "xtens: ".$imageExtension."</br>";
+ //$origExtension = strrchr($path, '.');
+ //echo "ali je slika na strežniku: ".$slikaNaStrezniku."</br>";
+ if($slikaNaStrezniku==0){ //ce slika je iz URL in ni na strezniku, izbrisi jo
+ //echo "tukaj </br>";
+ if($imageExtension == 'jpg'){
+ unlink($imageName.'.'.$imageExtension); //izbrisi sliko
+ }elseif($imageExtension == 'peg'){
+ unlink($imageName.'.j'.$imageExtension); //izbrisi sliko
+ }
+ }
+ }
+ #funkcija, ki skrbi za pridobitev slike, ki se nahaja nekje online in jo je potrebno izrisati, in vrne lokalno ime slike ######################################
+ function getOnlineImageName($imageName='', $slikaNaStrezniku=null, $vre_id=null, $img_id=0){
+ global $site_path;
+ //echo "imageName v getOnlineImageName nekje vmes 1: ".$imageName."</br>";
+ $row = Cache::srv_spremenljivka(self::$spremenljivka);
+ //echo "sprem: ".self::$spremenljivka."</br>";
+ $spremenljivkaParams = new enkaParameters($row['params']);
+ //echo "params: ".$spremenljivkaParams->get('hotspot_image')."</br>";
+ $imageNameTmp = $spremenljivkaParams->get('hotspot_image');
+ //if($imageNameTmp!=''){ //ce je hotspot
+ if($imageNameTmp!=''&&$vre_id==0){ //ce je hotspot
+ $imageName = $imageNameTmp;
+ }
+
+ $findHttp = 'http';
+ $posHttp = strpos($imageName, $findHttp);
+ $imageName = substr($imageName,$posHttp); //besedilo do zacetka http
+
+ $pos = $this->getEndPosition($imageName); //najdi pozicijo konca URL slike
+ $imageName = substr($imageName, 0, $pos); //pokazi le del params od zacetka besedila do '"' oz. konca URL slike
+ //echo "imageName v getOnlineImageName nekje vmes 2: ".$imageName."</br>";
+ $imageExtension = substr($imageName, $pos-3, 3); //pridobi koncnico slike
+ //echo "imageExtension: ".$imageExtension."</br>";
+
+ //if($imageExtension!='jpg'&&$imageExtension!='png'&&$imageExtension!='gif'&&$imageExtension!='jpeg'){ //ce ni veljavnen extension, spremeni ga v png
+ if($imageExtension=='jpg'||$imageExtension=='gif'||$imageExtension=='jpeg'){ //ce ni veljavnen extension, spremeni ga v png
+ //echo "spremeni extension </br>";
+ $imageExtension='png';
+ }
+
+ if($vre_id){ //ce se pridobiva imena tmp slik iz vrednosti vprasanja
+ //$imgFilename = self::$spremenljivka.'_'.$vre_id.'_tmpImage.'.$imageExtension; //tmp ime slike, ki je sestavljeno iz id spremenljivke+tmpImage+extension
+ $imgFilename = self::$spremenljivka.'_'.$vre_id.'_tmpImage_'.$img_id.'.'.$imageExtension; //tmp ime slike, ki je sestavljeno iz id spremenljivke+tmpImage+extension
+ }else{
+ //$imgFilename = self::$spremenljivka.'_tmpImage.'.$imageExtension; //tmp ime slike, ki je sestavljeno iz id spremenljivke+tmpImage+extension
+ $imgFilename = self::$spremenljivka.'_tmpImage_'.$img_id.'.'.$imageExtension; //tmp ime slike, ki je sestavljeno iz id spremenljivke+tmpImage+extension
+ }
+
+ $pathDir = $site_path.'uploadi/editor/'; //pot za novo mapo, kjer se bodo shranjevale slike za trenutno anketo
+ $path = $pathDir.$imgFilename; //pot do datoteke z imenom datoteke
+
+ # ukaz za pretakanje slike
+ if(IS_WINDOWS){
+ //za windows sisteme //powershell -command "& { iwr URL -OutFile 'PATH' }"
+ $command = 'powershell -command "& { iwr \''.$imageName.'\' -OutFile \''.$path.'\' }"';
+ //$command = 'wget -O \''.$imageName.'\' -O '.$path.' ';
+ }elseif(IS_LINUX){
+ //za linux sisteme //exec('wget URL -P PATH ');
+ //$command = 'wget \''.$imageName.'\' -P '.$path.' ';
+ $command = 'wget -O '.$path.' \''.$imageName.'\' ';
+ //echo "ukaz za pobiranje: $command </br>";
+ }
+
+ //echo "command: ".$command."</br>";
+ exec($command); //pretoci sliko
+
+ //$path = $pathDir.$imgFilename; //pot do datoteke z imenom datoteke
+
+/* if($imageExtension == 'gif'){ //ce je slika gif, jo je potrebno pretvoriti v png, saj latex ne podpira gif
+ $this->convertGifToPng($path, $slikaNaStrezniku);
+ } */
+ //echo "imgfilename na koncu: ".$imgFilename."</br>";
+ if($imageExtension != 'png'){ //ce slika ni png, jo pretvori
+ if($imageExtension == 'gif'){ //ce je slika gif, jo je potrebno pretvoriti v png, saj latex ne podpira gif
+ $this->convertGifToPng($path, $slikaNaStrezniku);
+ }else{
+ $this->convertJpgToPng($path, $slikaNaStrezniku, $imageExtension);
+ }
+ }
+
+ //echo "imgfilename na koncu: ".$imgFilename."</br>";
+ return $imgFilename;
+ }
+ #funkcija, ki skrbi za pridobitev slike, ki se nahaja nekje online in jo je potrebno izrisati, in vrne lokalno ime slike - konec ###############################
+
} \ No newline at end of file