1) { $sfile = preg_split("/_/", $fns[0]); if (count($sfile)>2) { $files []= array($sfile, $fns[0]); } } } } } sort($files); return $files; } function getIndexContents($files) { $il = array(); foreach ($files as $file) { $fn = $file[1]; $sfile = $file[0]; $title = ucfirst(str_replace('-',' ',$sfile[2])); $chap = $sfile[0]; if (mb_substr($chap, 0, 1)=='0') { $chap = mb_substr($chap, 1, 1); } $subchap = $sfile[1]; if (mb_substr($subchap, 0, 1)=='0') { $subchap = mb_substr($subchap, 1, 1); } if ($subchap=='0') { $il []= array($chap, $title, $fn, array()); } else { $il[intval($chap)-1][3] []= array($subchap, $title, $fn); } } return $il; } function getHelpFromContents($files, $help) { $il = array(); foreach ($files as $file) { $word = strtolower($help); $fn = $file[1]; $sfile = $file[0]; $mach = strtolower(str_replace("-", "", $sfile[2])); if ($word==$mach) { $chap = $sfile[0]; if (mb_substr($chap, 0, 1)=='0') { $chap = mb_substr($chap, 1, 1); } header('Location: help.php?page='.$fn.'&chapter='.$chap); } } return false; } $fc = getFolderContents(); if ( isset($_GET['help']) ) { $res = getHelpFromContents($fc, $_GET['help']); } require_once("includes/phptal/PHPTAL.php"); require_once("includes/phptal/PHPTAL/GetTextTranslator.php"); $tr = new PHPTAL_GetTextTranslator(); $tr->setLanguage("et_EE.UTF-8", "et_EE.UTF-8"); $tr->addDomain('krihvel', 'i18n'); $tr->useDomain('krihvel'); $template = new PHPTAL(); $template->setTemplateRepository('help/'); $page = "index.html"; if ( isset($_GET['page']) ) { $page = $_GET['page'].".html"; } $template->setTemplate($page); $template->setTranslator($tr); $template->indexContents = getIndexContents($fc); $template->request = $_GET; echo $template->execute(); ?>