Code

[COSMETIC] Removed default styles for <input> and <img>. Use class='' instead.
[gosa.git] / html / main.php
index 66b48334b4e0b361f6ca1fc1925a3f9339d06e53..4a96f4657e356b912a27f80cfdd2c1e9c86fd450 100644 (file)
@@ -24,10 +24,6 @@ require_once ("../include/php_setup.inc");
 require_once ("functions.inc");
 header("Content-type: text/html; charset=UTF-8");
 
-/* Reset error handler */
-$error_collector= "";
-set_error_handler('gosaRaiseError');
-
 /* Find all class files and include them */
 get_dir_list("$BASE_DIR/plugins");
 
@@ -37,6 +33,7 @@ bindtextdomain($domain, "$BASE_DIR/locale");
 textdomain($domain);
 
 /* Remember everything we did after the last click */
+session_set_cookie_params(2*60*60);
 session_start ();
 if ($_SERVER["REQUEST_METHOD"] == "POST"){
   @DEBUG (DEBUG_POST, __LINE__, __FUNCTION__, __FILE__, $_POST, "_POST");
@@ -61,6 +58,7 @@ if ($_SERVER['REMOTE_ADDR'] != $ui->ip){
   exit;
 }
 $config= $_SESSION['config'];
+
 @DEBUG (DEBUG_CONFIG, __LINE__, __FUNCTION__, __FILE__, $config->data, "config");
 
 /* Set template compile directory */
@@ -70,12 +68,28 @@ if (isset ($config->data['MAIN']['COMPILE'])){
   $smarty->compile_dir= '/var/spool/gosa/';
 }
 
+/* Set default */
+$reload_navigation = false;
+
+/* Set last initialised language to current, browser settings */
+if((!isset($_SESSION['Last_init_lang']))){
+  $reload_navigation = true;
+  $_SESSION['Last_init_lang'] = get_browser_language();
+}
+
 /* Language setup */
 if ($config->data['MAIN']['LANG'] == ""){
+  
+  /* If last language != current force navi reload */
+  if($_SESSION['Last_init_lang'] != get_browser_language()){
+    $reload_navigation = true;
+  }
   $lang= get_browser_language();
+  $_SESSION['Last_init_lang'] = $lang;
 } else {
   $lang= $config->data['MAIN']['LANG'];
 }
+
 $lang.=".UTF-8";
 putenv("LANGUAGE=");
 putenv("LANG=$lang");
@@ -202,11 +216,19 @@ if(isset($_SESSION['POST'])){
 /* show web frontend */
 $smarty->assign ("date", date("l, dS F Y H:i:s O"));
 $smarty->assign ("must", "<font class=\"must\">*</font>");
+if (isset($plug)){
+  $plug= "?plug=$plug";
+} else {
+  $plug= "";
+}
 if ($_SESSION['js']==FALSE){
   $smarty->assign("javascript", "false");
+  $smarty->assign("help_method", "href='helpviewer.php$plug' target='_new'");
 } else {
   $smarty->assign("javascript", "true");
+  $smarty->assign("help_method"," onclick=\"return popup('helpviewer.php$plug','GOsa help');\"");
 }
+
 $smarty->assign ("username", $ui->username);
 $smarty->assign ("go_logo", get_template_path('images/go_logo.png'));
 $smarty->assign ("go_base", get_template_path('images/dtree.png'));
@@ -216,14 +238,17 @@ $smarty->assign ("go_top", get_template_path('images/go_top.png'));
 $smarty->assign ("go_corner", get_template_path('images/go_corner.png'));
 $smarty->assign ("go_left", get_template_path('images/go_left.png'));
 $smarty->assign ("go_help", get_template_path('images/help.png'));
+
+/* reload navigation if language changed*/  
+if($reload_navigation){
+  $plist->menu="";;
+}
+$plist->gen_headlines();
 $plist->gen_menu();
 $smarty->assign ("menu", $plist->menu);
-if (isset($plug)){
-  $smarty->assign ("plug", "?plug=$plug");
-} else {
-  $smarty->assign ("plug", "");
-}
-$mtmp="<!-- headers.tpl-->".$smarty->fetch(get_template_path('headers.tpl'));
+$smarty->assign ("plug", "$plug");
+
+$header= "<!-- headers.tpl-->".$smarty->fetch(get_template_path('headers.tpl'));
 
 
 /* React on clicks */
@@ -258,7 +283,6 @@ if (isset ($_SESSION['post_cnt'])){
 /* Load plugin */
 if (is_file("$plugin_dir/main.inc")){
   require_once ("$plugin_dir/main.inc");
-  print $plugin_dir."/main.inc";
 } else {
   print_red(sprintf(_("Can't find any plugin definitions for plugin '%s'!"), $plug));
   echo $_SESSION['errors'];
@@ -275,17 +299,31 @@ if ($error_collector != ""){
 } else {
   $smarty->assign("php_errors", "");
 }
-$display = $mtmp.$smarty->fetch(get_template_path('framework.tpl'));
-print $display;
-
-if(file_exists("dow3ccheck.chk"))
-  {
-  $fp = fopen("/tmp/current.html","w+");
-  fwrite($fp,$display,strlen($display));
-  $str = shell_exec( "curl -F uploaded_file=@/tmp/current.html http://127.0.0.1/w3c-markup-validator/check ");
-  print $str;
+$display= $header.$smarty->fetch(get_template_path('framework.tpl'));
+
+/* For development, perform a W3C conformance check if specified in gosa.conf */
+if (isset($config->data['MAIN']['W3CTEST']) && preg_match('/true/i', $config->data['MAIN']['W3CTEST'])) {
+
+  /* Use PHP tidy for debugging */
+  $tidy = new tidy();
+  $config = array('indent' => TRUE,
+               'output-xhtml' => TRUE,
+               'wrap' => 200);
+  $display = tidy_parse_string($display, $config, 'UTF8');
+  tidy_clean_repair($display);
+  $cnt =  (tidy_error_count($display))+(tidy_warning_count($display));
+  if($cnt != 0){
+    echo "<table summary=\"\" width=\"100%\" style='background-color:#E0E0E0;border-bottom:1px solid black'><tr><td><img alt=\"W3C\" align=\"middle\" src='images/warning.png'>&nbsp;<font style='font-size:14px;font-weight:bold'>"._("Generating this page caused the W3C conformance checker to raise some errors!")."</font></td><td align=right><button onClick='toggle(\"w3cbox\")'>"._("Toggle information")."</button></td></tr></table><div id='w3cbox' style='width:100%; position:absolute; z-index:0; visibility: hidden; background-color:white; border-bottom:1px solid black;'>";
+
+    echo nl2br(htmlentities($display->errorBuffer))."</div>";
   }
+  tidy_clean_repair($display);
+}
+
+/* Show page... */
+echo $display;
 
+/* Save plist */
 $_SESSION['plist']= $plist;
 
 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: