diff options
author | Anton Luka Šijanec <anton@sijanec.eu> | 2024-05-27 13:08:29 +0200 |
---|---|---|
committer | Anton Luka Šijanec <anton@sijanec.eu> | 2024-05-27 13:08:29 +0200 |
commit | 75160b12821f7f4299cce7f0b69c83c1502ae071 (patch) | |
tree | 27e25e4ccaef45f0c58b22831164050d1af1d4db /admin/survey/export/latexclasses/class.LatexSurvey.php | |
parent | prvi-commit (diff) | |
download | 1ka-75160b12821f7f4299cce7f0b69c83c1502ae071.tar 1ka-75160b12821f7f4299cce7f0b69c83c1502ae071.tar.gz 1ka-75160b12821f7f4299cce7f0b69c83c1502ae071.tar.bz2 1ka-75160b12821f7f4299cce7f0b69c83c1502ae071.tar.lz 1ka-75160b12821f7f4299cce7f0b69c83c1502ae071.tar.xz 1ka-75160b12821f7f4299cce7f0b69c83c1502ae071.tar.zst 1ka-75160b12821f7f4299cce7f0b69c83c1502ae071.zip |
Diffstat (limited to 'admin/survey/export/latexclasses/class.LatexSurvey.php')
-rw-r--r-- | admin/survey/export/latexclasses/class.LatexSurvey.php | 682 |
1 files changed, 559 insertions, 123 deletions
diff --git a/admin/survey/export/latexclasses/class.LatexSurvey.php b/admin/survey/export/latexclasses/class.LatexSurvey.php index 7f93749..575043e 100644 --- a/admin/survey/export/latexclasses/class.LatexSurvey.php +++ b/admin/survey/export/latexclasses/class.LatexSurvey.php @@ -10,14 +10,14 @@ include('../../vendor/autoload.php');
-define("RADIO_BTN_SIZE", 0.13);
+if (!defined('RADIO_BTN_SIZE')) define("RADIO_BTN_SIZE", 0.13);
+if (!defined('PIC_SIZE_ANS')) define("PIC_SIZE_ANS", "\includegraphics[width=3cm]"); //slika dolocene sirine
class LatexSurvey{
var $anketa; // ID ankete
var $tex; //shrani tex kodo
var $texNewLine = '\\\\ ';
- //var $texPageBreak = "\\pagebreak";
var $texPageBreak = "\\newpage";
var $export_format;
var $export_data_show_recnum;
@@ -28,6 +28,7 @@ class LatexSurvey{ var $loop_id = null; // id trenutnega loopa ce jih imamo
var $db_table = '';
+ var $path2Images = '';
protected $showIntro = 0;
protected $showGDPRIntro = 0;
@@ -43,13 +44,18 @@ class LatexSurvey{ protected $usr_id = 0;
protected $texBigSkip = '\bigskip';
+ protected $grupa = 0;
+ protected $currentHeight = 0;
+ protected $variableName = '';
+
protected $admin_type;
protected $path2UploadedImages;
protected $language = -1; // Katero verzijo prevoda izvazamo
+
+ public static $spremenljivka;
- //function __construct($anketa, $export_format){
function __construct($anketa=null, $export_format='', $export_show_intro=null, $export_show_if=null, $export_data_skip_empty=null, $export_data_skip_empty_sub=null){
global $site_path, $global_user_id, $admin_type, $lang;
@@ -58,7 +64,7 @@ class LatexSurvey{ $this->admin_type = $admin_type;
- $this->usr_id = $_GET['usr_id'];
+ $this->usr_id = isset($_GET['usr_id']) ? $_GET['usr_id'] : '';
$this->showIntro = $export_show_intro;
$this->showIf = $export_show_if;
@@ -73,12 +79,9 @@ class LatexSurvey{ //Prikazi GDPR v uvodu
$gdpr = new GDPR();
$this->showGDPRIntro = $gdpr->isGDPRSurveyTemplate($this->anketa);
- //echo "gdpr nastavitve: ".$this->showGDPRIntro."</br>";
if($this->showGDPRIntro){
$this->GDPRIntro = $gdpr->getSurveyIntro($this->anketa);
- //echo "gdpr te: ".$this->GDPRIntro."</br>";
}
-
if ($this->usr_id != '') {
$sqlR = sisplet_query("SELECT recnum FROM srv_user WHERE id = '$this->usr_id '");
$rowR = mysqli_fetch_array($sqlR);
@@ -95,9 +98,7 @@ class LatexSurvey{ //if ( SurveyInfo::getInstance()->SurveyInit($this->anketa['id']) && $this->init())
if ( SurveyInfo::getInstance()->SurveyInit($this->anketa) )
{
- if (SurveyInfo::getInstance()->getSurveyColumn('db_table') == 1){
- $this->db_table = '_active';
- }
+ $this->db_table = SurveyInfo::getInstance()->getSurveyArchiveDBString();
}
else{
return false;
@@ -107,7 +108,7 @@ class LatexSurvey{ #funkcija, ki skrbi za izpis praznega vprasalnika in vprasalnika z odgovori enega respondenta
public function displaySurvey($export_subtype='', $export_data_type='', $language=null){
global $lang, $site_url;
- //echo "Funkcija displaySurvey user: $this->usr_id</br>";
+
$this->language = $language;
if($this->language!=-1){
// Naložimo jezikovno datoteko
@@ -130,12 +131,13 @@ class LatexSurvey{ $tmp_svp_pv[$vid] = substr($vid, 0, strpos($vid, '_'));
}
-
+ $tex = '';
+
if($export_subtype=='q_data'){ //ce je vprasalnik za enega respondenta
//pridobitev podatkov trenutnega respondenta za izpis Recnum
$izbranStatusProfile = SurveyStatusProfiles :: getStatusAsQueryString();
$sqluString = "SELECT id, last_status, lurker, recnum FROM srv_user WHERE ank_id = '".$this->anketa."' ".$izbranStatusProfile." AND deleted='0' AND preview='0' AND id='".$this->usr_id."' ORDER BY recnum";
- //echo $sqluString;
+
$sqlu = sisplet_query($sqluString);
$rowu = mysqli_fetch_array($sqlu);
$recnum = $rowu['recnum'];
@@ -145,20 +147,18 @@ class LatexSurvey{ $recnumBesedilo = "";
}
//pridobitev podatkov trenutnega respondenta za izpis Recnum - konec
-
-
-
- //$tex .= $lang['srv_respondent_answer'].": ".$this->recnum;
- $tex .= '\MakeUppercase{\huge \textbf{'.$lang['srv_respondent_answer'].' '.$recnumBesedilo.'}}'; //izpisi "Odgovori respondenta"
+
+ $tex .= '\MakeUppercase{\huge \textbf{'./* $lang['srv_respondent_answer']. */' '.$recnumBesedilo.'}}'; //izpisi "Odgovori respondenta"
$tex .= $this->texNewLine;
$tex .= $this->texNewLine;
}
-
//ce je potrebno izpisati GDPR besedilo v intro
- if($this->showGDPRIntro == 1){
- //$GDPRintro = "gdpr INTRO";
+ if($this->showGDPRIntro == 1){
$GDPRintro = strip_tags($this->GDPRIntro, '<a><img><ul><li><ol><br><p>');
- $GDPRintro = $this->encodeTextHere($GDPRintro);
+
+ //$GDPRintro = $this->encodeTextHere($GDPRintro);
+ $GDPRintro = LatexDocument::encodeText($GDPRintro, 0, 0, 0, 'gdpr');
+
$tex .= ' \textbf{'.$GDPRintro.'} ';
//radio buttona
@@ -176,11 +176,11 @@ class LatexSurvey{ //pridobitev informacije obiska strani oz. ankete
$sqlStringStran = "SELECT time_edit FROM srv_user_grupa".$this->db_table." WHERE usr_id='".$this->usr_id."' AND gru_id='".$grupa."'";
- //echo $sqlStringStran;
+
$sqlStran = sisplet_query($sqlStringStran);
$rowStran = mysqli_fetch_array( $sqlStran );
$stran = $rowStran['time_edit'];
- //echo $stran;
+
//pridobitev informacije obiska strani oz. ankete - konec
if($stran){
@@ -209,28 +209,31 @@ class LatexSurvey{ {
//preverjanje, ali je prevod
if(isset($_GET['language'])){
- $this->language = $_GET['language'];
+ //$this->language = $_GET['language'];
+ $this->language = isset($_GET['language'])?$_GET['language']:null;
$prevod = 1;
}else{
$prevod = 0;
}
//preverjanje, ali je prevod - konec
- //if($this->language!=-1){ //ce je prevod ankete
if($prevod){ //ce je prevod ankete
$spr_id_uvod = -1;
$sqll = sisplet_query("SELECT naslov, info FROM srv_language_spremenljivka WHERE ank_id='".$this->anketa."' AND spr_id='".$spr_id_uvod."' AND lang_id='".$this->language."'");
$rowl = mysqli_fetch_array($sqll); //pridobi prevod uvoda v ustreznem jeziku
$intro = $rowl['naslov']; //prevod uvoda v ustreznem jeziku
}else{
- $intro = (SurveyInfo::getInstance()->getSurveyIntro() == '') ? $lang['srv_intro'] : SurveyInfo::getInstance()->getSurveyIntro();
- }
- $tex .= $this->encodeTextHere($intro);
+ $sqlIntroString = "SELECT introduction FROM srv_anketa WHERE id=".$this->anketa." ";
+ $sqlIntro = sisplet_query($sqlIntroString);
+ $rowl = mysqli_fetch_array($sqlIntro); //pridobi besedilu uvoda
+ $intro = $rowl['introduction']; //prevod uvoda v ustreznem jeziku
+ }
+ $tex .= LatexDocument::encodeText($intro, 0, 0, 0, 'intro');
if($intro){
+ $tex .= "\r\n";
$tex .= $this->texNewLine;
$tex .= $this->texNewLine;
}
-
}
}
@@ -244,22 +247,19 @@ class LatexSurvey{ }
$question = new LatexSurveyElement($this->anketa, $this->export_format, 0, $this->usr_id, $export_subtype, $language);
-
########
while ( $rowGrupe = mysqli_fetch_assoc( $sqlGrupe ) )
{ // sprehodmo se skozi grupe ankete
$this->grupa = $rowGrupe['id'];
-
// Pogledamo prvo spremenljivko v grupi ce je v loopu
$sql = sisplet_query("SELECT id FROM srv_spremenljivka WHERE gru_id='".$this->grupa."' AND visible='1' ORDER BY vrstni_red ASC");
$row = mysqli_fetch_array($sql);
-
+
// ce je ima loop za parenta
- $if_id = $this->find_parent_loop($row['id']);
+ $if_id = isset(($row['id']))?$this->find_parent_loop($row['id']):null;
if ($if_id > 0 && ($export_subtype=='q_data'||$export_subtype=='q_data_all')){ //ce je loop in (je izpis odgovorov respondentov)
$texLoop = '';
- //echo "Je v loopu $if_id </br>";
$sql1 = sisplet_query("SELECT if_id FROM srv_loop WHERE if_id = '$if_id'");
$row1 = mysqli_fetch_array($sql1);
@@ -277,14 +277,13 @@ class LatexSurvey{ // Izrisemo naslov loopa
$tex .= $this->dataPiping($loop_title);
-
+ $zaporedna = 0;
//TODO: TUdi tu se celotna spremenljivka prenaša naprej
- $sqlSpremenljivke = sisplet_query("SELECT id, tip, visible, sistem, variable, naslov, info, orientation, dostop FROM srv_spremenljivka WHERE gru_id='".$this->grupa."' AND visible='1' ORDER BY vrstni_red ASC");
- //echo "SELECT id, tip, visible, sistem, variable, naslov, info, orientation FROM srv_spremenljivka WHERE gru_id='".$this->grupa."' AND visible='1' ORDER BY vrstni_red ASC "."</br>";
+ $sqlSpremenljivke = sisplet_query("SELECT id, tip, visible, sistem, variable, naslov, info, orientation, dostop, grids, ranking_k, enota, grid_subtitle1, grid_subtitle2, text_kosov, text_orientation, signature, upload, size, design, vsota FROM srv_spremenljivka WHERE gru_id='".$this->grupa."' AND visible='1' ORDER BY vrstni_red ASC");
while ($rowSpremenljivke = mysqli_fetch_assoc($sqlSpremenljivke))
{ // sprehodimo se skozi spremenljivke grupe
-
+
$spremenljivka = $rowSpremenljivke['id'];
if ($rowSpremenljivke['visible'] == 0 || !( ($this->admin_type <= $rowSpremenljivke['dostop'] && $this->admin_type>=0) || ($this->admin_type==-1 && $rowSpremenljivke['dostop']==4) ) ) {
@@ -308,16 +307,23 @@ class LatexSurvey{ {
if ($rowSpremenljivke['sistem'] == 1)
{ // če je oboje = vijolčno
- $this->pdf->SetTextColor(128,0,128);
+ //$this->pdf->SetTextColor(128,0,128);
}
else
{ // Če je skrito = rdeče
- $this->pdf->SetTextColor(255,0,0);
+ //$this->pdf->SetTextColor(255,0,0);
}
}
else if ($rowSpremenljivke['sistem'] == 1)
- $this->pdf->SetTextColor(0,0,255);
-
+ {
+ //$this->pdf->SetTextColor(0,0,255);
+ }
+
+ // če imamo številčenje Type = 1 potem številčimo V1
+ if (SurveyInfo::getInstance()->getSurveyCountType())
+ $zaporedna++;
+ $stevilcenje = ( SurveyInfo::getInstance()->getSurveyCountType() ) ?
+ ( ( SurveyInfo::getInstance()->getSurveyCountType() == 2 ) ? $rowSpremenljivke['variable'].") " : $zaporedna.") " ) : null;
// Izpis vprasalnika z rezultati
@@ -363,11 +369,8 @@ class LatexSurvey{ $loop_id = 'IS NULL';
$zaporedna = 0;
//TODO: Omenjen query je potrebno optimizirati in da se naprej samo prenaša ID, ki se potem v podfunkcijah kliče ustrezen query
- // trenutno se potrebuje: id, tip, visible, sistem, variable, params
- $sqlSpremenljivke = sisplet_query("SELECT * FROM srv_spremenljivka WHERE gru_id='".$this->grupa."' AND visible='1' ORDER BY vrstni_red ASC");
-
- //$testniStavek = "SELECT * FROM srv_spremenljivka WHERE gru_id='".$this->grupa."' AND visible='1' ORDER BY vrstni_red ASC";
- //echo "sql stavek za testiranje: ".$testniStavek."</br>";
+ // trenutno se potrebuje: id, tip, visible, sistem, variable, params
+ $sqlSpremenljivke = sisplet_query("SELECT id, tip, visible, sistem, variable, params, dostop, naslov, orientation, info, grids, ranking_k, enota, grid_subtitle1, grid_subtitle2, text_kosov, text_orientation, signature, upload, size, design, vsota FROM srv_spremenljivka WHERE gru_id='".$this->grupa."' AND visible='1' ORDER BY vrstni_red ASC");
while ($rowSpremenljivke = mysqli_fetch_assoc($sqlSpremenljivke)){ // sprehodimo se skozi spremenljivke grupe
$spremenljivka = $rowSpremenljivke['id'];
@@ -383,7 +386,6 @@ class LatexSurvey{ $preveriSpremenljivko = $this->checkSpremenljivka($spremenljivka);
}
- //if ( $this->checkSpremenljivka ($spremenljivka) /*|| $this->showIf == 1*/ )
if ($preveriSpremenljivko)
{ // lahko izrišemo spremenljivke
@@ -587,7 +589,7 @@ class LatexSurvey{ if ( mysqli_num_rows($sql) > 0 && ( (int)$question_resp_comment_viewadminonly + (int)$question_comment_viewadminonly ) > 0 ) {
-
+ $zaporedna = 0;
while ($row = mysqli_fetch_array($sql)) {
$sql1 = sisplet_query("SELECT thread, note FROM srv_spremenljivka WHERE id = '$row[id]'");
@@ -613,6 +615,12 @@ class LatexSurvey{ if ($this->commentType == 5) $only_unresolved = " AND ocena = 3 ";
if ($this->commentType == 5) $only_unresolved2 = " AND text2 = 3 ";
+
+ // če imamo številčenje Type = 1 potem številčimo V1
+ if (SurveyInfo::getInstance()->getSurveyCountType())
+ $zaporedna++;
+ $stevilcenje = ( SurveyInfo::getInstance()->getSurveyCountType() ) ?
+ ( ( SurveyInfo::getInstance()->getSurveyCountType() == 2 ) ? $row['variable'].") " : $zaporedna.") " ) : null;
$tema_vsebuje = substr($lang['srv_forum_intro'],0,10); // da ne prikazujemo 1. default sporocila
@@ -642,11 +650,11 @@ class LatexSurvey{ //$tex .= $texNewLine;
$tex .= $this->texNewLine;
- $tex .= $question->encodeText($lang['hour_comment']);
+ $tex .= LatexDocument::encodeText($lang['hour_comment']);
//$tex .= $texNewLine;
$tex .= $this->texNewLine;
- $tex .= $question->encodeText($row1['note']);
+ $tex .= LatexDocument::encodeText($row1['note']);
}
}
@@ -656,17 +664,15 @@ class LatexSurvey{ if (mysqli_num_rows($sqlt) > 0) {
//$tex .= $texNewLine;
$tex .= $this->texNewLine;
- //$tex .= '\textbf{'.$question->encodeText($lang['srv_admin_comment']).'}'; //izpis naslova komentarjev
- $tex .= '\textcolor{komentar}{\textbf{'.$question->encodeText($lang['srv_admin_comment']).'}}'; //izpis naslova komentarjev
- //$tex .= '\textcolor{komentar}{\textbf{'.$question->encodeText($lang['srv_admin_comment']).'}}'; //izpis naslova komentarjev
+ $tex .= '\textcolor{komentar}{\textbf{'.LatexDocument::encodeText($lang['srv_admin_comment']).'}}'; //izpis naslova komentarjev
$tex .= '\\\\';
$i = 0;
while ($rowt = mysqli_fetch_array($sqlt)) {
- $tex .= '\textbf{'.$question->encodeText($f->user($rowt['uid'])).'}'; //izpis imena trenutnega urednika
+ $tex .= '\textbf{'.LatexDocument::encodeText($f->user($rowt['uid'])).'}'; //izpis imena trenutnega urednika
- $tex .= $question->encodeText(' ('.$f->datetime1($rowt['time']).'):'); //izpis datuma komentarja
+ $tex .= LatexDocument::encodeText(' ('.$f->datetime1($rowt['time']).'):'); //izpis datuma komentarja
$tex .= '\\\\';
@@ -674,7 +680,7 @@ class LatexSurvey{ $vsebina = $rowt['vsebina'];
$odgovori = explode("<blockquote style=\"margin-left:20px\">", $vsebina);
- $tex .= $question->encodeText($odgovori[0]); //izpis komentarja
+ $tex .= LatexDocument::encodeText($odgovori[0]); //izpis komentarja
unset($odgovori[0]);
foreach($odgovori as $odgovor){ //izpis replik
@@ -683,12 +689,12 @@ class LatexSurvey{ $tex .= '\\\\';
$tex .= '\forceindent'; //da je indented
- $tex .= '\textbf{'.$question->encodeText($avtor[0]).'} '; //avtor replike
- $tex .= $question->encodeText($avtor[1]); //izpis datuma replike
+ $tex .= '\textbf{'.LatexDocument::encodeText($avtor[0]).'} '; //avtor replike
+ $tex .= LatexDocument::encodeText($avtor[1]); //izpis datuma replike
$tex .= '\\\\';
$tex .= '\forceindent '; //da je indented
- $tex .= $question->encodeText($odgovor[1]); //izpis replike
+ $tex .= LatexDocument::encodeText($odgovor[1]); //izpis replike
}
// Crta
@@ -703,14 +709,8 @@ class LatexSurvey{ if ($row2['count'] > 0) {
if ($admin_type <= $question_resp_comment_viewadminonly) {
-
-/* $this->pdf->Ln(3);
- $this->pdf->setFont('','B', 10);
- $this->pdf->Write (0, $this->encodeText($lang['srv_repondent_comment']), '', 0, 'l', 1, 1); */
- //$tex .= $texNewLine;
$tex .= $this->texNewLine;
- //$tex .= '\textbf{'.$question->encodeText($lang['srv_repondent_comment']).'}'; //izpisa naslova komentarjev
- $tex .= '\textcolor{komentar}{\textbf{'.$question->encodeText($lang['srv_repondent_comment']).'}}'; //izpisa naslova komentarjev
+ $tex .= '\textcolor{komentar}{\textbf{'.LatexDocument::encodeText($lang['srv_repondent_comment']).'}}'; //izpisa naslova komentarjev
$tex .= '\\\\';
//$this->pdf->Ln(3);
@@ -720,16 +720,12 @@ class LatexSurvey{ $sqlt = sisplet_query("SELECT d.text AS text, u.time_edit AS time_edit FROM srv_data_text".$this->db_table." d, srv_user u WHERE d.spr_id='0' AND d.vre_id='$row[id]' AND u.id=d.usr_id $only_unresolved2 ORDER BY d.id ASC");
if (!$sqlt) echo mysqli_error($GLOBALS['connect_db']);
while ($rowt = mysqli_fetch_array($sqlt)) {
-
-/* $this->pdf->setFont('','', 10);
- $this->pdf->Write(0, $this->encodeText($f->datetime1($rowt['time_edit']).':'), '', 0, 'l', 1, 1);*/
-
- $tex .= $question->encodeText($f->datetime1($rowt['time_edit']).':'); //izpis datuma komentarja
+
+ $tex .= LatexDocument::encodeText($f->datetime1($rowt['time_edit']).':'); //izpis datuma komentarja
$tex .= '\\\\';
- //$this->pdf->MultiCell(100, 0, $this->encodeText($rowt['text']),0,'L',0,1,0,0,true,0);
- $tex .= $question->encodeText($rowt['text']); //izpis komentarja respondenta
+ $tex .= LatexDocument::encodeText($rowt['text']); //izpis komentarja respondenta
$tex .= '\\\\';
@@ -1070,14 +1066,16 @@ class LatexSurvey{ $sql = sisplet_query("SELECT parent FROM srv_branching WHERE element_spr = '$element_spr' AND element_if = '$element_if' AND ank_id='".$this->anketa."'");
if (!$sql) echo mysqli_error($GLOBALS['connect_db']);
$row = mysqli_fetch_array($sql);
+
+ $row_parent = isset($row['parent'])?$row['parent']:null;
- if ($row['parent'] == 0) return 0;
-
+ if ($row_parent == 0) return 0;
+
$count = sisplet_query("SELECT COUNT(*) AS st FROM srv_if WHERE id = '$row[parent]' AND tip = '2'", "obj");
if ($count->st > 0) {
- return $row['parent'];
+ return $row_parent;
}else {
- return $this->find_parent_loop(0, $row['parent']);
+ return $this->find_parent_loop(0, $row_parent);
}
}
@@ -1217,11 +1215,34 @@ class LatexSurvey{ }
#funkcija ki skrbi za encode dolocenih spornih delov besedila v latex-u prijazno
- function encodeTextHere($text='', $vre_id=0){
+ function encodeTextHere($text='', $vre_id=0, $naslovStolpca = 0, $img_id=0){
global $site_path, $lang;
-
+ //$text = str_replace(' ','X',$text); //nadomesti presledke
//echo "Encoding ".$text."</br>";
//echo "vre_id: ".$vre_id."</br>";
+ //echo "ime spremenljivke ".$this->variableName."</br>";
+
+ $text = ($text!=null && $text='' ? htmlspecialchars_decode($text) : ''); //vse html special chars kot je & spremeni v ustrezne simbole (npr. &=>&)
+
+ //resevanje razbirajanja predolgih neprekinjenih besed in URL - spremenljivke za kasnejsi prilagojen izpis
+ //$numOfWords = str_word_count($text, 0);
+ $numOfSpacesPrej = substr_count($text, ' '); //stevilo presledkov v besedilu
+ $stringLength = strlen($text);
+
+ $findSpace = ' ';
+ $posSpace1 = strpos($text, $findSpace); //najdi pozicijo prvega presledka v besedilu
+ $posSpace2 = strripos($text, $findSpace); //najdi pozicijo zadnjega presledka v besedilu
+
+
+ $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
$this->path2UploadedImages = $site_path.'uploadi/editor/';
if($text == ''){ //ce ni teksta, vrni se
@@ -1234,6 +1255,7 @@ class LatexSurvey{ $findImgLength = strlen($findImg);
$findUl = '<ul';
$findUlLength = strlen($findUl);
+ $findOl = '<ol';
$findLi = '<li';
$findPar = '<p>';
@@ -1241,28 +1263,140 @@ class LatexSurvey{ $pos = strpos($text, $findme);
$posImg = strpos($text, $findImg);
$posUl = strpos($text, $findUl);
+ $posOl = strpos($text, $findOl);
$posLi = strpos($text, $findLi);
$posPar = strpos($text, $findPar);
-
+ //echo "pozicija paragrafa: $posPar </br>";
+
+ //ureditev izrisa slike
+ if($posImg !== false){
+ $numOfImgs = substr_count($text, $findImg); //stevilo '<img ' v tekstu
+ $posImg = strpos($text, $findImg);
+ $textPrej = '';
+ $textPotem = '';
+ for($i=0; $i<$numOfImgs; $i++){
+ $posImg = strpos($text, $findImg);
+ $textPrej = substr($text, 0, $posImg); //tekst do img
+ $textPotem = substr($text, $posImg); //tekst po img, z vkljuceno hmlt kodo z img
+ $posImgEnd = strpos($textPotem, '/>'); //pozicija, kjer se konca html koda za img
+ $textPotem = substr($textPotem, $posImgEnd+strlen('/>')); //tekst od konca html kode za img dalje
+
+ $imageName = $this->path2UploadedImages."".$this->getImageName($text, 0, '<img', $vre_id, $img_id);
+ $imageNameTest = $imageName.'.png'; //za preveriti, ali obstaja slikovna datoteka na strezniku
+ //echo $imageName."</br>";
+ //error_log("iz survey element: ".$imageNameTest);
+ //echo("iz survey element imageNameTest: ".$imageNameTest."</br>");
+ //echo "Obstaja ? ".file_exists($imageNameTest)."</br>";
+ //echo("iz survey element imageName: ".$imageName."</br>");
+ //echo "velikost: ".filesize($imageNameTest)."</br>";
+/* if(filesize($imageNameTest) > 0){
+ $text = $textPrej.' '.PIC_SIZE_ANS."{".$imageName."}".' '.$textPotem;
+ }else{
+ $image = $lang['srv_pc_unavailable'];
+ $text = $textPrej.' '.$image.' '.$textPotem;
+ } */
+ $text = '';
+ //$text = $textPrej.' ';
+
+ //if(filesize($imageNameTest) > 0){
+ if(file_exists($imageNameTest)){
+ $text .= $textPrej.' '.PIC_SIZE_ANS."{".$imageName."}";
+ }else{
+ $image = $lang['srv_pc_unavailable'];
+ $text .= $image;
+ }
+ $text .= ' '.$textPotem;
+ }
+
+ //pred ureditvijo posebnih karakterjev, odstrani del teksta s kodo za sliko, da se ne pojavijo tezave zaradi imena datoteke od slike
+ $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;
+
+ //pred ureditvijo posebnih karakterjev, odstrani del teksta s kodo za sliko, da se ne pojavijo tezave zaradi imena datoteke od slike - konec
+ }
+ //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);
//$text = str_replace('}','\}',$text);
$text = str_replace('$','\$ ',$text);
- $text = str_replace('#','\# ',$text);
+
+ if(substr_count($text, '#')){ //ce je stevilo # vecje od 1
+ $text = str_replace('#','\#',$text);
+ }else{
+ $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);
+ if(strpos($text, '&')){ //ce je prisotno v besedilu &'
+ $text = str_replace('&','\& ',$text);
+ }else{
+ $text = str_replace('&','\& ',$text);
+ }
+ $text = str_replace(' ','~',$text);
//$text = str_replace('<','\textless ',$text);
- $text = str_replace('<','\textless',$text);
+ $text = str_replace('<',' \textless ',$text);
//$text = str_replace('>','\textgreater ',$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('ά','\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('ο','o',$text); // \textomicron ne dela
+ //$text = str_replace('ο','\textgreek{ο}',$text);
+ //$text = str_replace('ς','\textvarsigma ',$text);
+ /* $text = str_replace('ς','\textgreek{ς}',$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);
+ $text = str_replace('ύ','\textgreek{ύ}',$text); */
+ //ureditev grskih crk - konec
+
+ //ureditev ostalih posebnih crk
+ $text = str_replace('ə','\textschwa ',$text);
+ //ureditev ostalih posebnih crk - konec
+
+
//ureditev preureditve html kode ul in li v latex itemize
if($posUl !== false){
//echo "text prej: ".$text."</br>";
@@ -1272,27 +1406,148 @@ class LatexSurvey{ //if($numOfUl!=0){
if($numOfUl!=0 && $posLi !== false){ //ce imamo ul in li
$text = str_replace('<ul>','\begin{itemize} ', $text);
- $text = str_replace('<li>','\item ', $text);
- $text = str_replace('</ul>','\end{itemize} ', $text);
+ $text = str_replace('<ul','\begin{itemize} ', $text);
+/* $text = str_replace('<li>','\item ', $text);
+ $text = str_replace('<li','\item ', $text); */
+ $text = str_replace('<li>','\item \ ', $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
-
+
+ //ureditev preureditve html kode ol in li v latex enumerate, ki je ostevilcen
+ if($posOl !== false){
+ //echo "text prej: ".$text."</br>";
+ $numOfOl = substr_count($text, $findOl); //stevilo '<ol' v tekstu
+ //echo "numOfUl ".$numOfUl."</br>";
+ ######################
+ //if($numOfUl!=0){
+ if($numOfOl!=0 && $posLi !== false){ //ce imamo ol in li
+ $text = str_replace('<ol>','\begin{enumerate} ', $text);
+/* $text = str_replace('<li>','\item ', $text);
+ $text = str_replace('<li','\item ', $text); */
+ $text = str_replace('<li>','\item \ ', $text);
+ $text = str_replace('<li','\item \ ', $text);
+ $text = str_replace('</ol>','\end{enumerate} \ ', $text);
+ }
+ //echo "prazno v html: ".strpos($text, '\r')."</br>";
+ //echo "text potem: ".$text."</br>";
+ ######################
+ }
+ //ureditev preureditve html kode ol in li v latex enumerate, ki je ostevilcen - 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($posPar !== false){ //ce je kaksen html tag <p>, dodaj prazno vrstico oz. break
- if($numOfUl!=0 && $posLi !== false){ //ce imamo ul in li
- $divider = ' ';
+ if($this->variableName=='gdpr'){
+ if($numOfUl!=0 && $posLi !== false){ //ce imamo ul in li
+ $divider = ' ';
+ }else{
+ $divider = ' \\ \\\\ ';
+ }
+ $text = str_replace('<p>',$divider, $text);
+ }else{
+ $text = str_replace('<p>',' ', $text);
+ }
+ }
+
+
+ //priprava izpisa zelo dolgega besedila brez presledkov (URL, email, ...)
+ //if($numOfSpacesPrej == 0 && ($stringLength >= MAX_STRING_LENGTH)){ //ce v besedilu ni presledkov in je besedilo daljse od max dovoljene dolzine
+ if( ($numOfSpacesPrej == 0 && ($stringLength >= MAX_STRING_LENGTH)) || ($numOfSpacesPrej == 1 && $posSpace1 == $posSpace2 && $stringLength >= MAX_STRING_LENGTH)){ //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
+ $text = substr_replace($text, $this->texNewLine, MAX_STRING_LENGTH, 0); //dodaj na ustrezni dolzini besedila prehod v novo vrstico
+ }
+ //priprava izpisa zelo dolgega besedila brez presledkov - konec
+
+ //echo "text potem: ".$text."</br>";
+
+ //detekcija prisotnosti e-naslova v besedilu in primerna preureditev, da pride do pravilnega izpisa
+ $findAt = '@1'; //IZKLOPIL DETEKCIJO, KER DELA TUDI BREZ TEGA
+ $numOfAt = substr_count($text, $findAt); //stevilo '@' v besedilu
+ $findNewline = 'br';
+
+ $text = preg_replace("/<\/?a( [^>]*)?>/i", "", $text); //remove anchor tag from string <a href= ... </a>, to se je uredilo za rešiti <a href= mailto: ...
+
+ $posAt = strpos($text, $findAt);
+ if($posAt && $posSpace1){ //ce je prisotna afna in je prisoten presledek v besedilu
+
+ $posSpace1Mail = strpos(substr($text, $posAt), $findSpace); //najdi pozicijo prvega presledka v besedilu po e-naslovu
+ $posSpace1Mail = $posSpace1Mail+$posAt; //koncna pozicija, ce se gleda celotno besedilo
+ //echo "pozicija prvega presledka v besedilu po e-naslovu: ".$posSpace1Mail."</br>";
+
+ //najdi prvi presledek pred afno
+ $posSpace2Mail = strripos(substr($text, 0, $posAt), $findSpace); //najdi pozicijo zadnjega presledka v besedilu pred e-naslovom
+ //echo "pozicijo zadnjega presledka v besedilu pred e-naslovom: ".$posSpace2Mail."</br>";
+
+
+
+ //najdi prvi simbol za v novo vrstico "br" po afni
+ //echo substr($text, $posAt) ."</br>";
+ $posNewLineMail = strpos(substr($text, $posAt), $findNewline); //najdi pozicijo prvega simbola za v novo vrstico v besedilu po e-naslovu
+ $posNewLineMail = $posNewLineMail+$posAt-1; //koncna pozicija, ce se gleda celotno besedilo
+
+ if($posSpace1Mail<$posNewLineMail){ //ce se po e-naslovu pojavi prej presledek
+ $posKonec = $posSpace1Mail; //se zakljuci pri presledku, ker je ta lokacija za zakljucek url
}else{
- $divider = ' \\ \\\\ ';
+ $posKonec = $posNewLineMail; //se zakljuci pred simbolom za novo vrstico, ker je ta lokacija za zakljucek url
}
- //$text = str_replace('<p>',' ', $text);
- //$text = str_replace('<p>',' \break ', $text);
- //$text = str_replace('<p>',' \\\\ ', $text);
+ //echo "posKonec: ".$posKonec."</br>";
+
+ //dodaj po e-naslovu potrebno latex kodo za zakljucek url
+ //$text = substr_replace($text, '}', $posSpace1Mail, 0);
+ $text = substr_replace($text, '}', $posKonec, 0);
+
+ //dodaj pred e-naslovom potrebno latex kodo za url
+ //substr_replace(string_name, replacement_string, start_pos, length)
+ $text = substr_replace($text, ' \url{', $posSpace2Mail, 0);
+ //echo $text."</br>";
- $text = str_replace('<p>', $divider, $text);
}
+ //detekcija prisotnosti e-naslova v besedilu in primerna preureditev, da pride do pravilnega izpisa - 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
+
+
+
+ //RESEVANJE odstranitve dodatnih style tag-ov po ul, ipd. #######################################################
+ $findStyleTagFull = '<style="';
+ $findStyleTagIn = 'style="';
+ $findStyleTagEnd = '">';
+ $numOfStyleTagsFull = substr_count($text, $findStyleTagFull); //stevilo '<style=" ' v tekstu
+ $numOfStyleTagsIn = substr_count($text, $findStyleTagIn); //stevilo 'style=" ' v tekstu
+ if($numOfStyleTagsFull){
+ $numOfStyleTags = $numOfStyleTagsFull;
+ $findStyleTag = $findStyleTagFull;
+ $offset = 2;
+ }else{
+ $numOfStyleTags = $numOfStyleTagsIn;
+ $findStyleTag = $findStyleTagIn;
+ $offset = 1;
+ }
+ for($s=0; $s<$numOfStyleTags; $s++){ //za vsako najdeno 'style=" ' besedilo, uredi njeno odstranitev
+ $posStyleTag = strpos($text, $findStyleTag);
+ $posStyleTagEnd = strpos($text, $findStyleTagEnd, $posStyleTag); //strpos(string,find,start) najdi $findStyleTagEnd v $text, isci od $posStyleTag dalje
+ $dolzinaOff = $posStyleTagEnd - $posStyleTag + $offset;
+ $text = substr_replace($text, "", $posStyleTag, $dolzinaOff); //substr_replace(string,replacement,start,length)
+ }
+ //RESEVANJE odstranitve dodatnih style tag-ov po ul, ipd. - konec #################################################
+
+ //echo "po style: ".$text."</br>";
if($pos === false && $posImg === false) { //v tekstu ni br in img
@@ -1300,37 +1555,39 @@ class LatexSurvey{ return strip_tags($text);
}else { //v tekstu sta prisotna br ali img
$text2Return = ''; //tekst ki bo vrnjen
-
+
//ureditev preureditev html kode za novo vrstico v latex, ureditev prenosa v novo vrstico
- if($pos !== false){
- $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);
- if($i == $numOfBr-1){
- //$text2Return .= $textPrej.' \break '.$textPotem;
- $text2Return .= $textPrej.' \\\\ '.$textPotem;
- }else{
- //$text2Return .= $textPrej.' \break ';
- $text2Return .= $textPrej.' \\\\ ';
- }
- }else{ //drugace
- $pos = strpos($textPotem, $findme);
- $textPrej = substr($textPotem, 0, $pos);
- $textPotem = substr($textPotem, $pos+$findmeLength);
- if($i == $numOfBr-1){
- //$text2Return .= $textPrej.' \break '.$textPotem;
- $text2Return .= $textPrej.' \\\\ '.$textPotem;
- }else{
- //$text2Return .= $textPrej.' \break ';
- $text2Return .= $textPrej.' \\\\ ';
+ if($naslovStolpca==0){ // ce besedilo ni naslov stolpca tabele
+ if($pos !== false){
+ $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);
+ if($i == $numOfBr-1){
+ //$text2Return .= $textPrej.' \break '.$textPotem;
+ $text2Return .= $textPrej.' \\\\ '.$textPotem;
+ }else{
+ //$text2Return .= $textPrej.' \break ';
+ $text2Return .= $textPrej.' \\\\ ';
+ }
+ }else{ //drugace
+ $pos = strpos($textPotem, $findme);
+ $textPrej = substr($textPotem, 0, $pos);
+ $textPotem = substr($textPotem, $pos+$findmeLength);
+ if($i == $numOfBr-1){
+ //$text2Return .= $textPrej.' \break '.$textPotem;
+ $text2Return .= $textPrej.' \\\\ '.$textPotem;
+ }else{
+ //$text2Return .= $textPrej.' \break ';
+ $text2Return .= $textPrej.' \\\\ ';
+ }
}
}
+ $text = $text2Return;
}
- $text = $text2Return;
- }
+ }
//ureditev preureditev html kode za novo vrstico v latex, ureditev prenosa v novo vrstico - konec
//echo "text potem: ".$text."</br>";
$text = preg_replace("/(\R){2,}/", "$1", $text);
@@ -1338,5 +1595,184 @@ class LatexSurvey{ }
}
#funkcija ki skrbi za encode dolocenih spornih delov besedila v latex-u prijazno - konec
+
+ #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 |