diff --git a/admin/survey/export/latexclasses/class.LatexDocument.php b/admin/survey/export/latexclasses/class.LatexDocument.php index 091536e16..7dd3f0006 100644 --- a/admin/survey/export/latexclasses/class.LatexDocument.php +++ b/admin/survey/export/latexclasses/class.LatexDocument.php @@ -224,13 +224,16 @@ class LatexDocument{ $datumGeneriranjaIzvoza = date("d. m. Y"); $anketaUstvarjena = SurveyInfo::getInstance()->getSurveyInsertDate(); - $dolgoImeAnkete = SurveyInfo::getSurveyColumn('akronim'); + $dolgoImeAnkete = $this->encodeText(SurveyInfo::getSurveyColumn('akronim')); + if($this->language!=-1){ //ce ni default jezik, ampak je prevod $_lang = '_'.$this->language; $kratkoImeAnkete = SurveySetting::getInstance()->getSurveyMiscSetting('srvlang_srv_novaanketa_kratkoime'.$_lang); }else{ $kratkoImeAnkete = SurveyInfo::getSurveyColumn('naslov'); - } + } + $kratkoImeAnkete = $this->encodeText($kratkoImeAnkete); + $steviloVprasanj = SurveyInfo::getSurveyQuestionCount(); $anketaSpremenjena = SurveyInfo::getSurveyEditDate(); $avtorAnkete = SurveyInfo::getSurveyInsertName(); @@ -785,6 +788,8 @@ class LatexDocument{ //echo "stevilo spremenljivk: ".(SurveyInfo::getSurveyVariableCount()); $steviloSpremenljivk = SurveyInfo::getSurveyVariableCount(); + + if($export_format == 'pdf'){ #################################### //klicanje latex funkcije za generiranje naslovnice @@ -1336,4 +1341,74 @@ class LatexDocument{ $recnum = $rowu['recnum']; return $recnum; } + + #funkcija ki skrbi za encode dolocenih spornih delov besedila v latex-u prijazno + function encodeText($text=''){ + global $site_path, $lang; + //$text = str_replace(' ','X',$text); //nadomesti presledke + //echo "Encoding ".$text."
"; + + $this->path2UploadedImages = $site_path.'uploadi/editor/'; + if($text == ''){ //ce ni teksta, vrni se + return; + } + + //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); + //$text = str_replace('}','\}',$text); + $text = str_replace('$','\$ ',$text); + $text = str_replace('#','\# ',$text); + $text = str_replace('%','\% ',$text); + $text = str_replace('€','\euro',$text); + $text = str_replace('^','\textasciicircum{} ',$text); + $text = str_replace('_','\_ ',$text); + $text = str_replace('~','\textasciitilde{} ',$text); + $text = str_replace('&','\&',$text); + $text = str_replace('&','\&',$text); + $text = str_replace(' ','~',$text); + //$text = str_replace('<','\textless ',$text); + $text = str_replace('<',' \textless ',$text); + //$text = str_replace('>','\textgreater ',$text); + $text = str_replace('>',' \textgreater ',$text); + //ureditev posebnih karakterjev za Latex - konec + + //ureditev grskih crk + $text = str_replace('α','\textalpha ',$text); + $text = str_replace('β','\textbeta ',$text); + $text = str_replace('γ','\textgamma ',$text); + $text = str_replace('δ','\textdelta ',$text); + $text = str_replace('ε','\textepsilon ',$text); + $text = str_replace('ζ','\textzeta ',$text); + $text = str_replace('η','\texteta ',$text); + $text = str_replace('θ','\texttheta ',$text); + $text = str_replace('ι','\textiota ',$text); + $text = str_replace('κ','\textkappa ',$text); + $text = str_replace('λ','\textlambda ',$text); + $text = str_replace('μ','\textmugreek ',$text); + $text = str_replace('ν','\textnu ',$text); + $text = str_replace('ξ','\textxi ',$text); + //$text = str_replace('ο','\textomikron ',$text); + $text = str_replace('π','\textpi ',$text); + $text = str_replace('ρ','\textrho ',$text); + $text = str_replace('σ','\textsigma ',$text); + $text = str_replace('τ','\texttau ',$text); + $text = str_replace('υ','\textupsilon ',$text); + $text = str_replace('φ','\textphi ',$text); + $text = str_replace('χ','\textchi ',$text); + $text = str_replace('ψ','\textpsi ',$text); + $text = str_replace('ω','\textomega ',$text); + //ureditev grskih crk - konec + + + //RESEVANJE BESEDILA V CIRILICI + $contains_cyrillic = (bool) preg_match('/[\p{Cyrillic}]/u', $text); //ali je v besedilu cirilica? + if($contains_cyrillic){ // ce je cirilica v besedilu + $text = '\foreignlanguage{russian}{'.$text.'}'; + } + //RESEVANJE BESEDILA V CIRILICI - konec + + return $text; + } + #funkcija ki skrbi za encode dolocenih spornih delov besedila v latex-u prijazno - konec } \ No newline at end of file