remove fail() that is not used
[platal.git] / include / platal / page.inc.php
index daadc3d..f81f994 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2004 Polytechnique.org                              *
+ *  Copyright (C) 2003-2006 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
  ***************************************************************************/
 
 require_once 'smarty/libs/Smarty.class.php';
-require_once 'platal/errors.inc.php';
 require_once 'platal/smarty.plugins.inc.php';
 
-// {{{ class PlatalPage
-
 class PlatalPage extends Smarty
 {
     // {{{ properties
-    
+
     var $_page_type;
     var $_tpl;
     var $_errors;
+    var $_failure;
 
     // defaults
     var $caching          = false;
@@ -41,7 +39,7 @@ class PlatalPage extends Smarty
     // }}}
     // {{{ function PlatalPage()
 
-    function PlatalPage($tpl, $type=SKINNED)
+    function PlatalPage($tpl, $type = SKINNED)
     {
         global $globals;
 
@@ -54,25 +52,19 @@ class PlatalPage extends Smarty
 
         $this->compile_check = !empty($globals->debug);
 
-        if ($type == SKINNED) {
-            $this->register_modifier('escape_html', 'escape_html');
-            $this->default_modifiers[] = '@escape_html';
-        }
-
         $this->_page_type = $type;
         $this->_tpl       = $tpl;
-        $this->_errors    = new XOrgErrors;
+        $this->_errors    = array();
+        $this->_failure   = false;
 
         $this->register_prefilter('at_to_globals');
         $this->register_prefilter('trimwhitespace');
         $this->addJsLink('javascript/xorg.js');
-
-        $this->doAuth();
     }
 
     // }}}
-    // {{{
-    
+    // {{{ function fakeDiogenes()
+
     function fakeDiogenes()
     {
         require_once 'diogenes/diogenes.core.page.inc.php';
@@ -85,19 +77,14 @@ class PlatalPage extends Smarty
         $this->register_function("tag","diogenes_func_tag");
         $this->register_function("toolbar","diogenes_func_toolbar");
     }
-    
+
     // }}}
     // {{{ function changeTpl()
 
-    function changeTpl($tpl, $type=SKINNED)
+    function changeTpl($tpl, $type = SKINNED)
     {
        $this->_tpl       = $tpl;
        $this->_page_type = $type;
-       if ($type == SKINNED) {
-           $this->register_modifier('escape_html', 'escape_html');
-           $this->default_modifiers = Array('@escape_html');
-       }
-
         $this->_page_type = $type;
        $this->assign('xorg_tpl', $tpl);
     }
@@ -108,48 +95,58 @@ class PlatalPage extends Smarty
     function _run($skin)
     {
         global $globals, $TIME_BEGIN;
-        $this->assign("xorg_error", $this->_errors);
-        
-        if ($this->_page_type == NO_SKIN) {
+
+        session_write_close();
+
+        $this->assign("xorg_errors", $this->_errors);
+        $this->assign("xorg_failure", $this->_failure);
+
+        switch ($this->_page_type) {
+          case NO_SKIN:
             $this->display($this->_tpl);
             exit;
+
+          case SIMPLE:
+            $this->assign('simple', true);
+          case SKINNED:
+           $this->register_modifier('escape_html', 'escape_html');
+           $this->default_modifiers = Array('@escape_html');
         }
-        
-        if ($globals->debug) {
 
-            if ($globals->debug & 1) {
-                $this->assign('db_trace', $globals->db->trace_format($this, 'database-debug.tpl'));
-            }
+        if (!$globals->debug) {
+            $this->display($skin);
+            exit;
+        }
+
+        if ($globals->debug & 1) {
+            $this->assign('db_trace', $globals->db->trace_format($this, 'database-debug.tpl'));
+        }
+
+        $this->assign('validate', true);
+        $result = $this->fetch($skin);
+        $ttime .= sprintf('Temps total: %.02fs<br />', microtime_float() - $TIME_BEGIN);
+        $replc  = "<span class='erreur'>VALIDATION HTML INACTIVE</span><br />";
+
+        if ($globals->debug & 2) {
 
-            $this->assign('validate', urlencode($globals->baseurl.'/valid.html'));
-            $result = $this->fetch($skin);
-            $ttime  = sprintf('Temps total: %.02fs<br />', microtime_float() - $TIME_BEGIN);
-            $replc  = "<span class='erreur'>VALIDATION HTML INACTIVE</span><br />";
-
-            if ($globals->debug & 2) {
-
-                $fd = fopen($this->compile_dir."/valid.html","w");
-                fwrite($fd, $result);
-                fclose($fd);
-       
-                exec($globals->spoolroot."/bin/devel/xhtml.validate.pl ".$this->compile_dir."/valid.html", $val);
-                foreach ($val as $h) {
-                    if (preg_match("/^X-W3C-Validator-Errors: (\d+)$/", $h, $m)) {
-                        $replc = '<span style="color: #080;">HTML OK</span><br />';
-                        if ($m[1]) {
-                            $replc = "<span class='erreur'><a href='http://validator.w3.org/check?uri={$globals->baseurl}"
-                                ."/valid.html&amp;ss=1#result'>{$m[1]} ERREUR(S) !!!</a></span><br />";
-                        }
-                        break;
+            $fd = fopen($this->compile_dir."/valid.html","w");
+            fwrite($fd, $result);
+            fclose($fd);
+
+            exec($globals->spoolroot."/bin/devel/xhtml.validate.pl ".$this->compile_dir."/valid.html", $val);
+            foreach ($val as $h) {
+                if (preg_match("/^X-W3C-Validator-Errors: (\d+)$/", $h, $m)) {
+                    $replc = '<span style="color: #080;">HTML OK</span><br />';
+                    if ($m[1]) {
+                        $replc = "<span class='erreur'><a href='http://validator.w3.org/check?uri={$globals->baseurl}"
+                            ."/valid.html&amp;ss=1#result'>{$m[1]} ERREUR(S) !!!</a></span><br />";
                     }
+                    break;
                 }
             }
-
-            echo str_replace("@HOOK@", $ttime.$replc, $result);
-            exit;
         }
 
-        $this->display($skin);
+        echo str_replace("@HOOK@", $ttime.$replc, $result);
         exit;
     }
 
@@ -166,7 +163,7 @@ class PlatalPage extends Smarty
 
     function nb_errs()
     {
-        return count($this->_errors->errs);
+        return count($this->_errors);
     }
 
     // }}}
@@ -174,24 +171,7 @@ class PlatalPage extends Smarty
 
     function trig($msg)
     {
-        $this->_errors->trig($msg);
-    }
-
-    // }}}
-    // {{{ function trig()
-
-    function trig_run($msg)
-    {
-        $this->_errors->trig($msg);
-        $this->run();
-    }
-
-    // }}}
-    // {{{ function fail()
-
-    function fail($msg)
-    {
-        $this->_errors->fail($msg);
+        $this->_errors[] = $msg;
     }
 
     // }}}
@@ -199,18 +179,14 @@ class PlatalPage extends Smarty
 
     function kill($msg)
     {
-        $this->fail($msg);
+        $this->trig($msg);
+        $this->_failure = true;
         $this->run();
     }
 
     // }}}
-    // {{{ function doAuth()
-
-    function doAuth() { }
-    
-    // }}}
     // {{{ function loadModule()
-    
+
     function loadModule($modname)
     {
         require_once("$modname.inc.php");
@@ -233,18 +209,7 @@ class PlatalPage extends Smarty
     }
 
     // }}}
-    // {{{ function gassign
-    
-    function gassign($varname)
-    {
-        global $$varname;
-        $this->assign($varname, $$varname);
-    }
-
-    // }}}
 }
 
-// }}}
-
 // vim:set et sw=4 sts=4 sws=4 foldmethod=marker:
 ?>