From 63954a5cda90fd426e81494b12ec63454ba8e9d7 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Rapha=C3=ABl=20Barrois?= Date: Fri, 19 Aug 2011 19:02:52 +0200 Subject: [PATCH] Add a mechanism for forcing the skin from within a view. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Use it for the 'register' page. Signed-off-by: Raphaël Barrois --- classes/xorgpage.php | 32 +++++++++++++++++++++++++++++--- configs/platal.ini | 4 ---- modules/register.php | 2 ++ 3 files changed, 31 insertions(+), 7 deletions(-) diff --git a/classes/xorgpage.php b/classes/xorgpage.php index 852b842..2bf2062 100644 --- a/classes/xorgpage.php +++ b/classes/xorgpage.php @@ -21,6 +21,9 @@ class XorgPage extends PlPage { + protected $forced_skin = null; + protected $default_skin = null; + public function __construct() { parent::__construct(); @@ -52,13 +55,36 @@ class XorgPage extends PlPage } } + /** Force the skin to use, bypassing user choice. + * Typically used for the 'register' page. + * @param $skin The skin to use. + */ + public function forceSkin($skin) + { + $this->forced_skin = $skin; + } + + /** Choose another 'default' skin. + * Typically used for the 'Auth Groupe X' login page. + * @param $skin The default skin to use. + */ + public function setDefaultSkin($skin) + { + $this->default_skin = $skin; + } + public function run() { global $globals, $platal; - if (isset($platal) && $platal->path == 'register') { - $skin = $globals->register_skin . ".tpl"; + if ($this->forced_skin !== null) { + $skin = $this->forced_skin . '.tpl'; } else { - $skin = S::v('skin', $globals->skin . ".tpl"); + if ($this->default_skin === null) { + $default_skin = $globals->skin; + } else { + $default_skin = $this->default_skin; + } + $skin = S::v('skin', $default_skin . '.tpl'); } $this->_run('skin/' . $skin); } diff --git a/configs/platal.ini b/configs/platal.ini index a7abb91..9ce8614 100644 --- a/configs/platal.ini +++ b/configs/platal.ini @@ -149,10 +149,6 @@ memcache = "" ; select a skin. skin = "default" -; $globals->register_skin -; Skin to use during registration process -register_skin = "register" - ; $globals->core->econfiance ; Key used to perform transactions with the 'econfiance' webservice in order ; to synchronize the X-Informatique directory with polytechnique.net diff --git a/modules/register.php b/modules/register.php index 6c55a23..83169e8 100644 --- a/modules/register.php +++ b/modules/register.php @@ -31,6 +31,8 @@ class RegisterModule extends PLModule function handler_register($page, $hash = null) { + $page->forceSkin('register'); + $alert = array(); $alert_details = ''; $subState = new PlDict(S::v('subState', array())); -- 2.1.4