X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=html%2Fhelpviewer.php;h=308500d0aa1da9fe7d56d1980ffc71a401a197a9;hb=af68c0eb4e77ea7e8f783b08fa1396a8fd8463b7;hp=c37153fa5f93cb30dfda4f01628e78dcfded53db;hpb=b40f4dfadbf2603c4c1fb5d5bab3a7f44c0dfd17;p=gosa.git diff --git a/html/helpviewer.php b/html/helpviewer.php index c37153fa5..308500d0a 100644 --- a/html/helpviewer.php +++ b/html/helpviewer.php @@ -19,29 +19,14 @@ */ - - /* Basic setup, remove eventually registered sessions */ require_once ("../include/php_setup.inc"); -require_once ("../include/functions.inc"); -require_once ("../include/functions_helpviewer.inc"); +require_once ("functions.inc"); +require_once ("functions_helpviewer.inc"); +header("Content-type: text/html; charset=UTF-8"); + session_start (); error_reporting(E_ALL); -/* 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/'; -} /* Language setup */ if ($config->data['MAIN']['LANG'] == ""){ @@ -62,6 +47,22 @@ 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']; @@ -71,39 +72,55 @@ My PART ^^ ################## */ -set_error_handler("myone"); -$helpdir = "../doc/guide/admin/en/manual_gosa_en/"; // 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 - -// Only for testing delete this if everything works fine -function myone($par1,$par2,$par3,$par3) -{ - print "
Seite : ".$par1."
Name : ".$par2."
Seite : ".$par3."
Zeile : ".$par3; -} +$helpdir = HELP_BASEDIR."/en/manual_gosa_en/"; // 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")."\" + "; /* Define which tags musst be delete, header, navigation, banner */ $replacements=array(); $replacements['from']=array("@@si", - "@]*?>.*?DIV>@si", - "''", - "/
/", - "@]*?>.*?ADDRESS>@si", - "@<\/BODY[^>]*?>.*?HTML>@si", - "''"); + "/border=\".*\"/i", + "''", +// "/alt=\".*\"/i", + "/
/", + "@]*?>.*?ADDRESS>@si", + "@<\/BODY[^>]*?>.*?HTML>@si", + "''", + "/src.*icons/i", + "/src=\"/i", + "/

/", + /* picture replacements */ + // "", + ); + + $replacements['to']=array("", - "", - "", - "", - "", - "", - ""); + " border=\"0\" ", + "", + // "", + "", + "", + "", + "
", + "src=\"", + "src=\"images/", + "

", + /* picture replacements */ +// "", + ); /* Default pages */ @@ -114,116 +131,158 @@ $forward ="node1.html"; /* Here it begins, the real function, above only definitions */ -/* We prepare to search, all Document for the given keyword */ -if(isset($_POST['search'])){ - /* Get Keyword */ - $keyword = $_POST['search_string']; +if(!file_exists(HELP_BASEDIR."/en/manual_gosa_en/")){ + /* prevent php warning missing value ... or so*/ + $smarty->assign("backward",""); + $smarty->assign("index" ,""); + $smarty->assign("forward" ,""); + $smarty->assign("search_string",""); + $smarty->assign("help_contents","
".sprintf(_("Can't read any helpfiles from ' %s ', possibly there is no help available."),HELP_BASEDIR."/en/manual_gosa_en/")); - /* Save Keyword to be able to show last searched word in template */ - $_SESSION['search_string']= $keyword; + /* Output html ...*/ + $header= "".$smarty->fetch(get_template_path('headers.tpl')); + $display= $header.$smarty->fetch(get_template_path('help.tpl')); + echo $display; - /* Read all files with contents*/ - /* |Folder="/var/ww...", - | |Fileprefix="node" - | | |Filesuffix=".html" - | | | |WithoutContent=false(This means : read content) - | | | | |Singlepage=false(Means read all, if w want to read single, specify its filename)"*/ - $arr = readfiles($helpdir,$prefix,$suffix,false,$singlepage=false); +}else{ - /* Create Searchresult for our Keyword(s) */ - $res = search($arr,$keyword); + /* We prepare to search, all Document for the given keyword */ + if(isset($_POST['search'])){ - /* Tell smarty which pages to use for backward forwa.. */ - $smarty->assign("backward",$backward); - $smarty->assign("index" ,$index); - $smarty->assign("forward" ,$forward); + /* Get Keyword */ + $keyword = $_POST['search_string']; - /* Tell smarty the Keyword, to show it in the input field again */ - $smarty->assign("search_string",$keyword); + /* Save Keyword to be able to show last searched word in template */ + $_SESSION['search_string']= $keyword; - /* Create result list */ - $smarty->assign("help_contents",searchlist($arr,$res,$maxresults)); + /* Read all files with contents*/ + /* |Folder="/var/ww...", + | |Fileprefix="node" + | | |Filesuffix=".html" + | | | |WithoutContent=false(This means : read content) + | | | | |Singlepage=false(Means read all, if w want to read single, specify its filename)"*/ + $arr = readfiles($helpdir,$prefix,$suffix,false,$singlepage=false); - /* Output html ...*/ - $header= "".$smarty->fetch(get_template_path('headers.tpl')); - $display= $header.$smarty->fetch(get_template_path('help.tpl')); - echo $display; + /* Create Searchresult for our Keyword(s) */ + $res = search($arr,$keyword); - /* - Don't search, only show selected page - */ -}else{ + /* Tell smarty which pages to use for backward forwa.. */ + $smarty->assign("backward",""); + $smarty->assign("index" ,$index); + $smarty->assign("forward" ,""); - /* present last searched word(s)*/ - if(!isset($_SESSION['search_string'])){ - $_SESSION['search_string']=""; - } - + /* Tell smarty the Keyword, to show it in the input field again */ + $smarty->assign("search_string",$keyword); - $smarty->assign("search_string",$_SESSION['search_string']); + /* Create result list */ + $smarty->assign("help_contents",searchlist($arr,$res,$maxresults)); - /* Read all files, prepare to serach */ - $helppages = readfiles("../doc/guide/admin/en/manual_gosa_en/",$prefix,$suffix,true); + /* show some errors */ + if (isset($_SESSION['errors'])){ + $smarty->assign("errors", $_SESSION['errors']); + } + if ($error_collector != ""){ + $smarty->assign("php_errors", $error_collector.""); + } else { + $smarty->assign("php_errors", ""); + } - /* Get transmitted page */ - if(isset($_GET['pg'])){ - $page = $_GET['pg']; + /* Output html ...*/ + $header= "".$smarty->fetch(get_template_path('headers.tpl')); + $display= $header.$smarty->fetch(get_template_path('help.tpl')); + echo $display; + + /* + Don't search, only show selected page + */ }else{ - $page = $defaultpage; - } - /* test if this page exists, in our array of files */ - if((!isset($helppages[$page]))&&($page!=$defaultpage)) - { - //print "Requested helppage is unknown, redirekted to index"; // For debugging only - $page = $defaultpage; - } + /* present last searched word(s)*/ + if(!isset($_SESSION['search_string'])){ + $_SESSION['search_string']=""; + } - /* Check forward backward, funtionality*/ - if($page != $defaultpage) - { - /* Extract Number of node page */ - $number = str_replace($prefix,"",str_replace($suffix,"",$page)); - /* Check if we can switch forward and/or backward*/ - $bck = $prefix.($number-1).$suffix; - $fck = $prefix.($number+1).$suffix; + $smarty->assign("search_string",$_SESSION['search_string']); - /* backward page exists ?, so allow it*/ - if((isset($helppages[$bck]))) { - $backward = $bck; + /* Read all files, prepare to serach */ + $helppages = readfiles($helpdir,$prefix,$suffix,true); + + /* Get transmitted page */ + if(isset($_GET['pg'])){ + $page = $_GET['pg']; + }else{ + $page = $defaultpage; + } + + /* test if this page exists, in our array of files */ + if((!isset($helppages[$page]))&&($page!=$defaultpage)) + { + //print "Requested helppage is unknown, redirekted to index"; // For debugging only + $page = $defaultpage; } - /* forward exists ?*/ - if((isset($helppages[$fck]))) { + /* Check forward backward, funtionality*/ + if($page != $defaultpage) + { + /* Extract Number of node page */ + $number = str_replace($prefix,"",str_replace($suffix,"",$page)); + + /* Check if we can switch forward and/or backward*/ + $bck = $prefix.($number-1).$suffix; + $fck = $prefix.($number+1).$suffix; + + /* backward page exists ?, so allow it*/ + if((isset($helppages[$bck]))) { + $backward = $bck; + } + $forward = $fck; } - } - $help_contents=readfiles($helpdir,$prefix,$suffix,false,$page); + $help_contents=readfiles($helpdir,$prefix,$suffix,false,$page); - /* Mark last searched words */ - if(isset($_GET['mark'])){ - $marks = ($_SESSION['lastresults']) ; - $help_contents = markup_page($help_contents[$page]['content'],$marks[$page]); - $help_contents=remove_unwanted_tags($help_contents,$replacements); - }else{ - $help_contents=remove_unwanted_tags($help_contents[$page]['content'],$replacements); - } + /* Mark last searched words */ + if(isset($_GET['mark'])){ + $marks = ($_SESSION['lastresults']) ; + $help_contents = markup_page($help_contents[$page]['content'],$marks[$page]); + $help_contents=$help_contents; + }else{ + $help_contents=$help_contents[$page]['content']; + } + + $smarty->assign("help_contents",$help_contents); - $smarty->assign("help_contents",$help_contents); + /* Define our own navigation pages */ + if($page == $defaultpage){ + $smarty->assign("backward",""); + }else{ + $smarty->assign("backward",sprintf($backwardlink,$backward)); + } + $smarty->assign("index" ,$index); + + if(!(isset($helppages[$forward]))){ + $smarty->assign("forward",""); + }else{ + $smarty->assign("forward",sprintf($forwardlink,$forward)); + } - /* Define our own navigation pages */ - $smarty->assign("backward",$backward); - $smarty->assign("index" ,$index); - $smarty->assign("forward" ,$forward); + /* show some errors */ + if (isset($_SESSION['errors'])){ + $smarty->assign("errors", $_SESSION['errors']); + } + if ($error_collector != ""){ + $smarty->assign("php_errors", $error_collector.""); + } else { + $smarty->assign("php_errors", ""); + } - /* Fill page */ - $header= "".$smarty->fetch(get_template_path('headers.tpl')); - $display= $header.$smarty->fetch(get_template_path('help.tpl')); - echo $display; + /* Fill page */ + $header= "".$smarty->fetch(get_template_path('headers.tpl')); + $display= $header.$smarty->fetch(get_template_path('help.tpl')); + echo $display; + } } - // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: ?>