From 3dab26c6797b32926287f22a041380080551060b Mon Sep 17 00:00:00 2001 From: M.Gergo Date: Fri, 8 Mar 2019 20:50:48 +0100 Subject: pici rendrakás --- mayor-mod/www/include/modules/naplo/share/file.php | 662 --------------------- 1 file changed, 662 deletions(-) delete mode 100644 mayor-mod/www/include/modules/naplo/share/file.php (limited to 'mayor-mod/www/include/modules/naplo/share/file.php') diff --git a/mayor-mod/www/include/modules/naplo/share/file.php b/mayor-mod/www/include/modules/naplo/share/file.php deleted file mode 100644 index 1e6c7595..00000000 --- a/mayor-mod/www/include/modules/naplo/share/file.php +++ /dev/null @@ -1,662 +0,0 @@ - _ATTR_DIAKID, - 'oid' => _ATTR_OID, - 'diakigazolvanyszam' => _ATTR_IGAZOLVANYSZAM, - 'viseltnevelotag' => _ATTR_VNE, - 'viseltcsaladinev' => _ATTR_VCSN, - 'viseltutonev' => _ATTR_VUN, - 'szuleteskorinevelotag' => _ATTR_SZNE, - 'szuleteskoricsaladinev' => _ATTR_SZCSN, - 'szuleteskoriutonev' => _ATTR_SZUN, - 'szuletesihely' => _ATTR_SZH, - 'szuletesiido' => _ATTR_SZI, - 'anyanevelotag' => _ATTR_ANE, - 'anyacsaladinev' => _ATTR_ACSN, - 'anyautoneve' => _ATTR_AUN, - 'kezdotanev' => _ATTR_KEZDO_TANEV, - 'kezdoszemeszter' => _ATTR_KEZDO_SZEMESZTER, - 'vegzotanev' => _ATTR_VEGZO_TANEV, - 'vegzoszemeszter' => _ATTR_VEGZO_SZEMESZTER, - 'adoazonosito' => _ATTR_ADOAZONOSITO, - 'allampolgarsag' => _ATTR_ALLAMPOLGARSAG, - 'anyaid' => _ATTR_ANYAID, - 'apaid' => _ATTR_APAID, - 'gondviseloid' => _ATTR_GONDVISELOID, - 'neveloid' => _ATTR_NEVELOID, - 'diaknaplosorszam' => _ATTR_DIAKNAPLOSORSZAM, - 'elozoiskolaomkod' => _ATTR_ELOZOISKOLAOMKOD, - 'email' => _ATTR_EMAIL, - 'fogyatekossag' => _ATTR_FOGYATEKOSSAG, - 'gondozasiszam' => _ATTR_GONDOZASISZAM, - 'jogviszonykezdete' => _ATTR_JOGVISZONYKEZDETE, - 'jogviszonyvege' => _ATTR_JOGVISZONYVEGE, - - 'lakhelyorszag' => _ATTR_LAKHELY_ORSZAG, - 'lakhelyirsz' => _ATTR_LAKHELY_IRSZ, - 'lakhelyhelyseg' => _ATTR_LAKHELY_HELYSEG, - 'lakhelykozteruletnev' => _ATTR_LAKHELY_KOZTERULETNEV, - 'lakhelykozteruletjelleg' => _ATTR_LAKHELY_KOZTERULETJELLEG, - 'lakhelyhazszam' => _ATTR_LAKHELY_HAZSZAM, - 'lakhelyemelet' => _ATTR_LAKHELY_EMELET, - 'lakhelyajto' => _ATTR_LAKHELY_AJTO, - - 'tartorszag' => _ATTR_TART_ORSZAG, - 'tartirsz' => _ATTR_TART_IRSZ, - 'tarthelyseg' => _ATTR_TART_HELYSEG, - 'tartkozteruletnev' => _ATTR_TART_KOZTERULETNEV, - 'tartkozteruletjelleg' => _ATTR_TART_KOZTERULETJELLEG, - 'tarthazszam' => _ATTR_TART_HAZSZAM, - 'tartemelet' => _ATTR_TART_EMELET, - 'tartajto' => _ATTR_TART_AJTO, - - 'tajszam' => _ATTR_TAJSZAM, - 'osztalyjel' => _ATTR_OSZTALYJEL, - 'penzugyistatusz' => _ATTR_PENZUGYISTATUSZ, - 'szemelyiigazolvanyszam' => _ATTR_SZEMELYIIGAZOLVANYSZAM, - 'szocialishelyzet' => _ATTR_SZOCIALISHELYZET, - 'statusz' => _ATTR_STATUSZ, - 'tartozkodasiokiratszam' => _ATTR_TARTOZKODASIOKIRATSZAM, - 'torvenyeskepviselo' => _ATTR_TORVENYESKEPVISELO, - 'telefon' => _ATTR_TELEFON, - 'mobil' => _ATTR_MOBIL, - 'nem' => _ATTR_NEM, - 'lakohelyijellemzo' => _ATTR_LAKOHELYIJELLEMZO, - 'megjegyzes' => _ATTR_MEGJEGYZES, - ); - - function readUpdateFile($fileName, $mezo_elvalaszto = ' ') { - - - $ADATOK = array(); - if ($fp = @fopen($fileName,'r')) { - // Az első 50 sor beolvasása - minta a mező-hozzárendeléshez - $i=0; - while (($sor = fgets($fp,1024)) and ($i<50)) { - $ADATOK[$i] = explode($mezo_elvalaszto,chop($sor)); - $i++; - } - fclose($fp); - } else { - $_SESSION['alert'][] = 'message:file_open_error:'.$fileName; - } - - return $ADATOK; - } -/* - * Lekérdezi egy adatbázis (naplo_intezmeny, naplo (tanév)) egy adott táblájának mezőit. - * Ha szükséges ezek listáját kiegészíti az extraAttrs tömbben felsorolt mezőkkel. - * A mezőnevekhez nyelvi konstansokat rendelhetünk ($Attrs tömb és lang/.../share/file.php) - */ - function getTableFields($table, $db = 'naplo_intezmeny', $extraAttrs = array(), $SET = array('withType' => false)) { - - global $Attrs; - - $return = $type = $name = array(); - $q = "SHOW FIELDS FROM `%s`"; - $r = db_query($q, array('fv' => 'getTableFields','modul' => $db, 'result' => 'indexed', 'values' => array($table))); - for ($i = 0; $i < count($r); $i++) { - if ($SET['withType']) { - if (substr($r[$i]['Type'],0,7) == 'varchar') $type[ $r[$i]['Field'] ] = 'string'; - elseif (substr($r[$i]['Type'],0,4) == 'enum') $type[ $r[$i]['Field'] ] = 'enum'; - elseif (substr($r[$i]['Type'],0,4) == 'date') $type[ $r[$i]['Field'] ] = 'date'; - elseif (strpos($r[$i]['Type'],'int(') !== false) $type[ $r[$i]['Field'] ] = 'int'; - else $type[ $r[$i]['Field'] ] = 'string'; - } - if ($Attrs[kisbetus($r[$i]['Field'])] != '') $name[$r[$i]['Field']] = $Attrs[kisbetus($r[$i]['Field'])]; - else $name[$r[$i]['Field']] = $r[$i]['Field']; - } - for ($i = 0; $i < count($extraAttrs); $i++) { - if (!isset($name[$extraAttrs[$i]])) { - if ($Attrs[kisbetus($extraAttrs[$i])] != '') $name[$extraAttrs[$i]] = $Attrs[kisbetus($extraAttrs[$i])]; - else $name[$extraAttrs[$i]] = $extraAttrs[$i]; - } - } - ksort($name); - - if ($SET['withType']) return array('names' => $name, 'types' => $type); - return $name; - - } - - - function getEnumField($modul, $table, $field) { - - $table = '`'.str_replace('.','`.`',$table).'`'; - $q = "SHOW FIELDS FROM %s LIKE '%s'"; - $v = array($table, $field); - $field = db_query($q, array('fv' => 'getEnumField', 'modul' => $modul, 'result' => 'record', 'values' => $v)); - $enum = substr($field['Type'], 6, -2); - $values = explode("','", $enum); - - return $values; - } - - function getSetField($modul, $table, $field) { - - $table = '`'.str_replace('.','`.`',$table).'`'; - $q = "SHOW FIELDS FROM %s LIKE '%s'"; - $v = array($table, $field); - $field = db_query($q, array('fv' => 'getSetField', 'modul' => $modul, 'result' => 'record', 'values' => $v)); - $set = substr($field['Type'], 5, -2); - $values = explode("','", $set); - - return $values; - } - - - function updateTable($table, $file, $MEZO_LISTA, $KULCS_MEZOK, $mezo_elvalaszto = ' ', $rovatfej = false, $db = 'naplo_intezmeny') { - - - if (!file_exists($file)) { - $_SESSION['alert'][] = 'message:file_not_found:updateTable:'.$file; - return false; - } - - if (!is_array($MEZO_LISTA)) { - $_SESSION['alert'][] = 'message:wrong_data:updateTable:MEZO_LISTA'; - return false; - } - - if (!is_array($KULCS_MEZOK)) { - $_SESSION['alert'][] = 'message:wrong_data:updateTable:KULCS_MEZOK'; - return false; - } - - // A frissítendő attribútumok listája - $attrList = array_values(array_filter($MEZO_LISTA)); - - $fp = fopen($file,'r'); - if (!$fp) { - $_SESSION['alert'][] = 'message:file_open_error:updateTable:'.$file; - return false; - } - - $lr = db_connect($db, array('fv' => 'updateTable')); - if (!$lr) { - $_SESSION['alert'][] = 'message:db_connect_failure:updateTable'; - fclose($fp); - return false; - } - db_start_trans($lr); - - // Az első sor kihagyása - if ($rovatfej) $sor = fgets($fp,1024); - while ($sor = fgets($fp,1024)) { - - $insertValues = $insertPatterns = array(); - $adatSor = explode($mezo_elvalaszto,chop($sor)); - $update = false; - - // keresési feltétel összerakása - $where = $v = $vw = array(); - for ($i = 0; $i < count($KULCS_MEZOK); $i++) { - if ($adatSor[$KULCS_MEZOK[$i]] != '') { - $where[] = "`%s`='%s'"; - array_push($vw, $MEZO_LISTA[$KULCS_MEZOK[$i]], $adatSor[$KULCS_MEZOK[$i]]); - } - } - $num = 0; - if (count($where) != 0) { - $q = 'SELECT COUNT(*) FROM `%s` WHERE '.implode(' AND ', $where); - array_unshift($vw, $table); - $num = db_query($q, array('fv' => 'updateTable', 'values' => $vw, 'result' => 'value', 'modul' => $db), $lr); - } - if ($num == 1 && _SKIP_ON_DUP === true) { $_SESSION['alert'][] = 'info:_SKIP_ON_DUP:'.serialize($sor); continue; } - if ($num == 1) { // update - $v = $vw; - array_shift($v); //$table kivétele - $UPDATE = array(); - for ($i = 0; $i < count($MEZO_LISTA); $i++) { - if ( - $MEZO_LISTA[$i] != '' - and $adatSor[$i] != '' - and !in_array($i,$KULCS_MEZOK) - ) { - if ($adatSor[$i] == '\N') { - array_unshift($UPDATE, "`%s`=NULL"); - array_unshift($v, $MEZO_LISTA[$i]); - } else { - array_unshift($UPDATE, "`%s`='%s'"); - array_unshift($v, $MEZO_LISTA[$i], $adatSor[$i]); - } - } - } - if (count($UPDATE) > 0) { - array_unshift($v, $table); - $q = 'UPDATE `%s` SET '.implode(',',$UPDATE).' WHERE '.implode(' AND ', $where); - $r = db_query($q, array('fv' => 'updateTable/update', 'values' => $v, 'modul' => $db, 'rollback' => true), $lr); - if (!$r) { - db_close($lr); - return false; - } - } - } elseif ($num == 0) { // insert - for ($i = 0; $i < count($MEZO_LISTA); $i++) { - if ($MEZO_LISTA[$i] != '') { - if ($adatSor[$i] == '\N') { - $insertValues[] = 'NULL'; - $insertPatterns[] = '%s'; - } else { - $insertValues[] = $adatSor[$i]; - $insertPatterns[] = "'%s'"; - } - } - } - $q = 'INSERT INTO `%s` ('.implode(',', array_fill(0, count($attrList), '%s')).') - VALUES ('.implode(',', $insertPatterns).')'; - $v = mayor_array_join(array($table), $attrList, $insertValues); - $r = db_query($q, array('fv' => 'updateTable/insert', 'modul' => $db, 'values' => $v, 'rollback' => true), $lr); - if (!$r) { - db_close($lr); - return false; - } - } else { - $_SESSION['alert'][] = 'message:wrong_data:updateTable:több illeszkedő rekord is van, túl laza a kulcs feltétel (' - .call_user_func_array('sprintf', array_merge(array('%s tábla, '.implode(' AND ',$where)), $vw)).')'; - db_rollback($lr); - db_close($lr); - return false; - } - } // while - db_commit($lr); - db_close($lr); - - fclose($fp); - - } - - function generatePDF($outputFile, $outputDir, $str, $booklet=false) { - - - // A szöveg file-ba írása - if (!$fp = fopen($outputDir.'/'.$outputFile.'-u8.tex', 'w')) { - $_SESSION['alert'][] = 'message:file_open_failure:generatePDF:'.$outputDir.'/'.$outputFile.'-u8.tex'; - return false; - } - if (!fwrite($fp, $str)) { - $_SESSION['alert'][] = 'message:file_write_failure:generatePDF:'.$outputDir.'/'.$outputFile.'-u8.tex'; - return false; - } - fclose($fp); - if (__NYOMTATAS_XETEX===true) { - $ret = exec('cd '.$outputDir.'; cat < '.$outputFile.'.tex -%\font\kicsi=ecrm0500 -%\font\nagy=ecbx1200 -%\font\vastag=ecsx0800 -%\font\nagyss=ecsx1200 -%\font\normal=ecss0800 -%\font\dolt=ecsi0800 - -\font\kicsi="Linux Libertine O" at 5pt -\font\nagy="Linux Libertine O/B" at 12pt -\font\nagyss="Arial/B" at 12pt -\font\normal="Linux Biolinum O" at 8pt -\font\dolt="Linux Biolinum O/I" at 8pt -\normal - -EOF -'); - $ret = exec('cd '.$outputDir.'; cat '.$outputFile.'-u8.tex >> '.$outputFile.'.tex'); - $ret = exec('cd '.$outputDir.'; xetex -fmt '._MAYOR_DIR.'/print/module-naplo/xetex/mayor-xetex '.$outputFile.'.tex'); -#ex -fmt '._MAYOR_DIR.'/print/module-naplo/tex/mayor '.$outputFile.'.tex'); - } else { - // utf8 --> cork (t1) - $ret = exec('cd '.$outputDir.'; cat '.$outputFile.'-u8.tex | sed -e "s/\xc2\xa0/\x20/g" | recode u8..T1 > '.$outputFile.'.tex'); - // DVI, PS, PFD generálás (a rotate miatt nem megy a pdftex közvetlenül :o( - $ret = exec('cd '.$outputDir.'; tex -fmt '._MAYOR_DIR.'/print/module-naplo/tex/mayor '.$outputFile.'.tex'); - if ($ret === false) { $_SESSION['alert'][] = 'message:futási_hiba:generatePDF:tex'; return false; } -# LOG $ret = exec('cd '.$outputDir.'; dvips '.$outputFile.'.dvi 2>&1 | tee -a /tmp/x.log '); - $ret = exec('HOME=/tmp && export HOME && cd '.$outputDir.'; dvips '.$outputFile.'.dvi '); - if ($ret === false) { $_SESSION['alert'][] = 'message:futási_hiba:generatePDF:ps'; return false; } - $ret = exec('cd '.$outputDir.'; ps2pdf -sPAPERSIZE=a4 -dAutoRotatePages=/None '.$outputFile.'.ps'); - if (strpos($ret, 'error') !== false) { $_SESSION['alert'][] = 'message:futási_hiba:generatePDF:pdf'; return false; } - - } - if ($booklet) { - $ret = exec('cd '.$outputDir.'; mv '.$outputFile.'.pdf '.$outputFile.'-A4.pdf; pdfbook --short-edge --outfile '.$outputFile.'.pdf '.$outputFile.'-A4.pdf'); - } - return true; - } - - function generateXLS($fileName, $Table, $title) { - - global $policy, $page, $sub, $f; - - if (dirname($fileName) == '.') $fileName = _DOWNLOADDIR."/$policy/$page/$sub/$f/$fileName"; - $fp = fopen($fileName, 'w'); - if (!$fp) { - $_SESSION['alert'][] = 'message:file_open_failure:'.$fileName; - return false; - } - - fputs($fp, ''."\r\n"); - fputs($fp, ''."\r\n"); - fputs($fp, ' '."\r\n" - .' '."\r\n" - .' '."\r\n" - ."\r\n".' '."\r\n"); - - fputs($fp, ''."\r\n"); - fputs($fp, ''."\r\n"); - - for ($i = 0; $i < count($Table); $i++) { - fputs($fp, ' '."\r\n"); - foreach ($Table[$i] as $index => $value) { - if (is_numeric($value)) - fputs($fp, " ".$value."\r\n"); - elseif (strtotime($value)) - if (strlen($value) > 10) { - fputs($fp, " ".str_replace(' ','T',$value).'.000'."\r\n"); - } else { - fputs($fp, " ".$value.'T08:40:00.000'."\r\n"); - } - else - fputs($fp, " ".$value."\r\n"); - } - fputs($fp, ' '."\r\n"); - } - - fputs($fp, '
'."\r\n"); - fputs($fp, '
'."\r\n"); - fputs($fp, '
'."\r\n"); - - fclose($fp); - return true; - - } - - function generateCSV($fileName, $Table, $title, $mezoElvalaszto=' ') { - - global $policy, $page, $sub, $f; - - if (dirname($fileName) == '.') $fileName = _DOWNLOADDIR."/$policy/$page/$sub/$f/$fileName"; - $fp = fopen($fileName, 'w'); - if (!$fp) { - $_SESSION['alert'][] = 'message:file_open_failure:'.$fileName; - return false; - } - - if ($title !='') fputs($fp, $title."\n"); - for ($i = 0; $i < count($Table); $i++) fputs($fp, implode($mezoElvalaszto, $Table[$i])."\n"); - - fclose($fp); - return true; - - } - - function generateODS($fileName, $Table, $title) { - - global $policy, $page, $sub, $f; - - if (dirname($fileName) == '.') $fileName = _DOWNLOADDIR."/$policy/$page/$sub/$f/$fileName"; - define('TMPZIP','/tmp/'.substr(basename($fileName), 0, strpos(basename($fileName), '.'))); - define('ODS_MIMETIPE','application/vnd.oasis.opendocument.spreadsheet'); - define('ODS_MANIFEST',' - - - -'); - define('ODS_START_XMLDOCUMENT',' -'); - define('ODS_ASTYLES',' - - - - - - - - - - - '); - define('ODS_START_SPREADSHEET',''); - define('ODS_START_TABLE',''); - define('ODS_START_ROW',''); - define('ODS_END_ROW',''); - define('ODS_END_TABLE',''); - define('ODS_END_SPREADSHEET',''); - define('ODS_END_XMLDOCUMENT',''); - - $content = ODS_START_XMLDOCUMENT . ODS_ASTYLES . ODS_START_SPREADSHEET . ODS_START_TABLE; - for ($i = 0; $i < count($Table); $i++) { - $content .= ODS_START_ROW; - foreach ($Table[$i] as $index => $value) { - if (is_numeric($value)) - $content .= ''."\n"; - elseif (strtotime($value)) - if (strlen($value) > 10) { - $content .= ''."\n"; - } else { - $content .= ''."\n"; - } - elseif ($value[0] == '=') $content .= ''."\n"; - // formula példa: $value = 'of:=SUM([.A1:.B1])*2+[.A1]' - else $content .= ''.$value.''."\n"; - } - $content .= ODS_END_ROW; - } - $content .= ODS_END_TABLE . ODS_END_SPREADSHEET . ODS_END_XMLDOCUMENT; - - mkdir(TMPZIP); - mkdir(TMPZIP."/META-INF"); - file_put_contents(TMPZIP."/META-INF/manifest.xml", ODS_MANIFEST); - file_put_contents(TMPZIP."/content.xml", $content); - file_put_contents(TMPZIP."/mimetype", ODS_MIMETIPE); - system("cd ".TMPZIP."; zip -mr ".$fileName." mimetype META-INF/* content.xml >/dev/null"); - rmdir(TMPZIP."/META-INF"); - rmdir(TMPZIP); - - return true; - } - -/* --------------------------------------- */ - - function _template2array($fp, $type, &$aTeX) { - $vege = false; - $aTeX[$type] = array(); - while (!$vege && ($sor = fgets($fp, 1024))) { - $sor = chop($sor); - if ($sor == "%}$type") { - $vege = true; - } elseif (substr($sor, 0, 2) != '%!') { // A feldolgozást végző függvény megadása - if (substr($sor, 0, 2) == '%}') { - echo "HIBA #1 Megnyitás előtti blokk lezárás a {$type} blokkban: $sor
"; - } else { - if (substr($sor, 0, 2) == '%{') { - $_type = substr($sor, 2); - _template2array($fp, $_type, $aTeX); - $aTeX[$type][] = '%{'.$_type.'}'; - } else { - // feltételes szövegrészek - $condArray = explode('%?', $sor); - for ($i = 1; $i < count($condArray); $i = $i + 2) { - $str = $condArray[$i]; - $tmpArray = explode('|', $str); - $j = 0; while (is_array($aTeX['conditional']["$j".$tmpArray[0]])) $j++; - $newCondition = "$j".$tmpArray[0]; - $aTeX['conditional'][$newCondition] = array(true => $tmpArray[1], false => $tmpArray[2], 'orig' => $tmpArray[0]); - $sor = str_replace($str.'%?', $newCondition, $sor); - } -// $aTeX[$type][] = $sor; - // lezáró eset - $finalArray = explode('%>', $sor); - for ($i = 1; $i < count($finalArray); $i = $i + 2) { - $str = $finalArray[$i]; - $tmpArray = explode('', $str); - $j = 0; while (is_array($aTeX['finalCase']["$j".$type])) $j++; - $newCondition = "$j".$type; - $aTeX['finalCase'][$newCondition] = array(true => $tmpArray[0], false => $tmpArray[1]); - $sor = str_replace($str.'%>', $newCondition, $sor); - } - $aTeX[$type][] = $sor; - } - } - } - } - } - - function _array2text($type, $id, $mit, $mire, $aTeX, $ADAT, $flag = null) { - $ret = ''; - if (is_null($id)) $A = $ADAT[$type]; - else $A = $ADAT[$type][$id]; - - // A cserélendő attribútumok - if (is_array($A)) foreach ($A as $attr => $value) { - if (!is_array($value)) { - if (true || !is_bool($value)) { // feltételes szövegrészek külön kezelendők ??? Miért is? Az általánosabb feltételes kiíráshoz kell! - if (in_array('%$'.$attr, $mit)) { // A már szereplő mintát felülírjuk! - $key = array_search('%$'.$attr, $mit); - $mit[$key] = '%$'.$attr; - $mire[$key] = $value; - } else { - $mit[] = '%$'.$attr; - $mire[] = $value; - } - } - } - } - - // aTeX feldolgozása - $TeX = $aTeX[$type]; - for ($i = 0; $i < count($TeX); $i++) { - $sor = $TeX[$i]; - if (substr($sor, 0, 2) == '%{') { - // Almodul feldolgozása - $_type = substr($sor, 2, -1); - if (is_array($A[$_type])) { - if (is_null($id)) { - foreach ($A[$_type] as $key => $_id) $ret .= _array2text($_type, $_id, $mit, $mire, $aTeX, $ADAT); - } else { - $count = count($A[$_type]); $db = 0; - foreach ($A[$_type] as $_id => $_data) { - $db++; if ($count == $db) $_flag = 'final'; else $_flag = null; - if (!is_array($ADAT[$_type][$_id]) && !is_array($_data)) { - echo '
HIBA#2!!! '.$_type.':'.$_id.':'.$_data.'
'; -// return false; - } else { - if (!is_array($ADAT[$_type][$_id])) $ADAT[$_type][$_id] = array(); - elseif (!is_array($_data)) $_data = array(); - $ADAT[$_type][$_id] = $ADAT[$_type][$_id] + $_data; - $ret .= _array2text($_type, $_id, $mit, $mire, $aTeX, $ADAT, $_flag); - } - } - } - } elseif (__DEBUG === true) { echo '
HIBA#3: '.$sor.'
'.$_type.':'; var_dump($A[$_type]); echo '
';} - } else { - // Csere - lezáró eset - if (strpos($sor, '%>') !== false) foreach ($aTeX['finalCase'] as $attr => $values) { - $sor = str_replace('%>'.$attr, $values[ $flag === 'final' ], $sor); - } - // Csete - feltételes kiírás - if (strpos($sor, '%?') !== false) foreach ($aTeX['conditional'] as $attr => $values) { - // Nem csak az adott szintről veszi az értéket, hanem feljebbről is (a feljebbi a meghatározó - ez nem biztos, hogy jó...) - if ($key = array_search('%$'.$values['orig'], $mit)) $_val = $mire[$key]; - else $_val = $A[$values['orig']]; - $sor = str_replace('%?'.$attr, $values[ $_val==true ], $sor); - //$sor = str_replace('%?'.$attr, $values[ $A[$values['orig']]==true ], $sor); - } - // Kiírás - $ret .= str_replace($mit, $mire, $sor)."\n"; - } - } - - return $ret; - } - - function template2text($templateFile, $ADAT) { - - $mit = $mire = array(); - $aTeX = array('conditional' => array()); - - $fp = fopen($templateFile, 'r'); - _template2array($fp, 'base', $aTeX); - fclose($fp); - return _array2text('base', null, $mit, $mire, $aTeX, $ADAT); - - } - - function template2file($templateFile, $ADAT) { - - global $policy, $page, $sub, $f; - - $mit = $mire = array(); - $aTeX = array('conditional' => array()); - - $fp = fopen($templateFile, 'r'); - // A feldolgozást végző függvény neve - $sor = fgets($fp, 1024); - rewind($fp); - if (substr($sor, 0, 2) == '%!') { - list($func,$ext,$opt) = explode(' ', substr(chop($sor), 2)); - if (!function_exists($func)) unset($func); - } - if ($ext=='') $ext = 'txt'; - _template2array($fp, 'base', $aTeX); - fclose($fp); - $text = _array2text('base', null, $mit, $mire, $aTeX, $ADAT); -//die(); - if ($text === false) return false; - $success = true; - if (isset($func)) { - $success = $func($text, $ADAT['file'], $opt); - } else { - $fp = fopen(_DOWNLOADDIR."/$policy/$page/$sub/$f/".$ADAT['file'].'.'.$ext, 'w'); - fputs($fp, $text); - fclose($fp); - } - if ($success) return $ADAT['file'].".$ext"; - else return false; - - } - - - -?> -- cgit v1.2.3