From: x2003bruneau Date: Thu, 11 Jan 2007 17:32:00 +0000 (+0000) Subject: Can hide unuseful pages X-Git-Url: http://git.polytechnique.org/?a=commitdiff_plain;h=f345066a2db42f11065c9f92a63e4d3930faae34;p=banana.git Can hide unuseful pages git-svn-id: svn+ssh://murphy/home/svn/banana/trunk@154 9869982d-c50d-0410-be91-f2a2ec7c7c7b --- diff --git a/banana/page.inc.php b/banana/page.inc.php index 8882b42..f148566 100644 --- a/banana/page.inc.php +++ b/banana/page.inc.php @@ -15,6 +15,7 @@ class BananaPage extends Smarty private $page = null; private $pages = array(); + private $killed = array(); private $actions = array(); public function __construct() @@ -53,6 +54,7 @@ class BananaPage extends Smarty public function setPage($page) { $this->page = $page; + return true; } /** Register an action to show on banana page @@ -78,6 +80,14 @@ class BananaPage extends Smarty return true; } + /** Remove a page + * @param page STRING page name to kill + */ + public function killPage($page) + { + $this->killed[] = $page; + } + /** Preparte the page generation * @return template to use */ @@ -98,6 +108,9 @@ class BananaPage extends Smarty $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 +125,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); @@ -126,7 +144,7 @@ class BananaPage extends Smarty $this->register_function('link', array($this, 'makeLink')); $this->register_function('imglink', array($this, 'makeImgLink')); $this->register_function('img', array($this, 'makeImg')); - + $this->assign('errors', $this->error); $this->assign('page', $this->page); $this->assign('pages', $this->pages);