Can configure spool root
[banana.git] / banana / page.inc.php
index 8882b42..41576f6 100644 (file)
@@ -15,8 +15,11 @@ class BananaPage extends Smarty
     private $page  = null;
 
     private $pages   = array();
+    private $killed  = array();
     private $actions = array();
 
+    public $css = '';
+
     public function __construct()
     {
         $this->Smarty();
@@ -53,6 +56,7 @@ class BananaPage extends Smarty
     public function setPage($page)
     {
         $this->page = $page;
+        return true;
     }
 
     /** Register an action to show on banana page
@@ -78,6 +82,22 @@ class BananaPage extends Smarty
         return true;
     }
 
+    /** Remove a page
+     * @param page STRING page name to kill
+     */
+    public function killPage($page)
+    {
+        $this->killed[] = $page;
+    }
+
+    /** Add Inline CSS to put in the page headers
+     * @param css CSS code
+     */
+    public function addCssInline($css)
+    {
+        $this->css .= $css;
+    }
+
     /** Preparte the page generation
      * @return template to use
      */
@@ -92,12 +112,15 @@ class BananaPage extends Smarty
                 if ($this->page == 'cancel') {
                     $this->registerPage('cancel', _b_('Annulation'), null);
                 } elseif ($this->page == 'new') {
-                    $this->registerPage('new', _b_('Répondre'), null);
+                    $this->registerPage('new', _b_('Répondre'), null);
                 }
             } elseif ($this->page == 'new') {
                 $this->registerPage('new', _b_('Nouveau'), null);
             }
         }
+        foreach ($this->killed as $page) {
+            unset($this->pages[$page]);
+        }
         foreach ($this->actions as $key=>&$action) {
             if (!is_null($action['pages']) && !in_array($this->page, $action['pages'])) {
                 unset($this->actions[$key]);
@@ -112,6 +135,11 @@ class BananaPage extends Smarty
     public function run()
     {
         $tpl = $this->prepare();
+        if (!isset($this->pages[$this->page])) {
+            $this->trig(_b_('La page demandée n\'existe pas'));
+            $this->actions = array();
+            $this->page = null;
+        }
 
         $this->assign('group',     Banana::$group);
         $this->assign('artid',     Banana::$artid);
@@ -121,12 +149,16 @@ class BananaPage extends Smarty
         $this->assign('profile',   Banana::$profile);
         $this->assign('spool',     Banana::$spool);
         $this->assign('protocole', Banana::$protocole);
+        $this->assign('showboxlist', Banana::$spool_boxlist);
+        $this->assign('showthread',  Banana::$msgshow_withthread);
+        $this->assign('withtabs'   , Banana::$withtabs);
 
         $this->register_function('url',     array($this, 'makeUrl'));
         $this->register_function('link',    array($this, 'makeLink'));
         $this->register_function('imglink', array($this, 'makeImgLink'));
         $this->register_function('img',     array($this, 'makeImg'));
-        
+        $this->register_modifier('b',       '_b_');
+
         $this->assign('errors',    $this->error);
         $this->assign('page',      $this->page);
         $this->assign('pages',     $this->pages);
@@ -322,5 +354,5 @@ function banana_trimwhitespace($source, &$smarty)
 // }}}
 
 
-// vim:set et sw=4 sts=4 ts=4:
+// vim:set et sw=4 sts=4 ts=4 enc=utf-8:
 ?>