data['MAIN']['LANG'] == ""){ $lang= get_browser_language(); } else { $lang= $config->data['MAIN']['LANG']; } $lang.=".UTF-8"; putenv("LANGUAGE="); putenv("LANG=$lang"); setlocale(LC_ALL, $lang); $GLOBALS['t_language']= $lang; $GLOBALS['t_gettext_message_dir'] = $BASE_DIR.'/locale/'; /* Set the text domain as 'messages' */ $domain = 'messages'; bindtextdomain($domain, "$BASE_DIR/locale"); textdomain($domain); @DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, $lang, "Setting language to"); /* Logged in? Simple security check */ if (!isset($_SESSION['ui'])){ gosa_log ("Error: helpviewer.php called without session"); echo ""._("Help is not available if you are not logged in.").""; exit; } /* Set template compile directory */ $config= $_SESSION['config']; if (isset ($config->data['MAIN']['COMPILE'])){ $smarty->compile_dir= $config->data['MAIN']['COMPILE']; } else { $smarty->compile_dir= '/var/spool/gosa/'; } /* Get plugin list */ $plist= $_SESSION['plist']; /* ################## My PART ^^ ################## */ $helpdir = "/home/hickert/gosa/doc/guide/user/fr/html/"; // Folder to use for help files $defaultpage = "index.html"; // alternative file, shown on error, or on first call $prefix = "node"; // Prefix of the generated help files $suffix = ".html"; // Suffix of the generated helpfiles $maxresults = 10; // max number of results shown in result list $minwordlength = 3; // Word less than 3 chars will be dropped in search $allowed_chars_in_searchword = "'[^a-z0-9 %_-]'i"; // Remove all chars that would disturb our search like < or > ... $pre_mark = "" ; // Sign words with this $suf_mark = ""; // and this $backwardlink = " \""._("previous")."\" "; $forwardlink = " \""._("next")."\" "; /* Default pages */ $backward =$defaultpage; $index =$defaultpage; $forward ="node1.html"; /* Here it begins, the real function, above only definitions */ /* Path exists ? */ if((is_dir($helpdir))&&($fp = opendir($helpdir))){ /* read all available directories */ while($dir = readdir($fp)){ /* Skip . / .. */ if(!in_array($dir,array(".","..","images"))){ $arr[$dir] = readfiles($helpdir."/".$dir."/",$prefix,$suffix,false,$singlepage=false); } } /* Handle posts */ if((isset($_GET['folder']))&&(is_dir($helpdir."/".$_GET['folder']."/"))){ $_SESSION['helpbrowser']['folder'] = $_GET['folder']; } if((isset($_GET['folder']))&&(empty($_GET['folder']))){ $_SESSION['helpbrowser']['folder'] = ""; $_SESSION['helpbrowser']['file'] = ""; } if((isset($_GET['pg']))&&(empty($_GET['pg']))){ $_SESSION['helpbrowser']['folder'] = ""; $_SESSION['helpbrowser']['file'] = ""; } if((isset($_GET['pg']))&&(is_file($helpdir."/".$_SESSION['helpbrowser']['folder']."/".$_GET['pg']))){ $_SESSION['helpbrowser']['file'] = $_GET['pg']; } /* Open helppage */ if(!empty($_SESSION['helpbrowser']['folder'])){ $folder = $_SESSION['helpbrowser']['folder']; if(!empty($_SESSION['helpbrowser']['file'])){ $file = $_SESSION['helpbrowser']['file']; $index = readfiles($helpdir."/".$folder."/",$prefix,"",false,$file); $smarty->assign("help_contents",$index[$file]['content']); }else{ $index = readfiles($helpdir."/".$folder."/",$prefix,"",false,$singlepage="index.html"); $smarty->assign("help_contents",$index['index.html']['content']); } }else{ $smarty->assign("help_contents",genIndex($arr)); } $header= "".$smarty->fetch(get_template_path('headers.tpl')); $display= utf8_encode( $header.$smarty->fetch(get_template_path('help.tpl'))); echo $display; }else{ $smarty->assign("help_contents","

".sprintf(_("Helpdir '%s' is not accessible, can't read any helpfiles."),$helpdir))."


"; $header= "".$smarty->fetch(get_template_path('headers.tpl')); $display= utf8_encode( $header.$smarty->fetch(get_template_path('help.tpl'))); echo $display; } function genIndex($arr) { $str = "

"._("Index")."

"; foreach($arr as $index => $obj){ $nr = preg_replace("/_.*$/i","",$index); $name = preg_replace("/^.*_/i","",$index); if(empty($name)){ $name = preg_replace("/_/","",$index); $nr = ""; } $str .= "

".$nr." - ".$name."

"; } return $str; } // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: ?>