From 7299bfcef8ccaffa52ecd0ca3adf92c84f79c248 Mon Sep 17 00:00:00 2001 From: Florent Bruneau Date: Thu, 9 Dec 2010 22:22:37 +0100 Subject: [PATCH] Add an embedded mode for platal. You can query /embedded/{mode}/path/to/url to get a mode in which the skinning mode information is propagated through pages. e.g.: https://www.p.org/embedded/light/search can be used to get the search page with light skinning. Note: This only requires a hack in .htaccess to work with static files. Signed-off-by: Florent Bruneau --- classes/plpage.php | 7 ++++--- include/platal.inc.php | 3 +++ modules/core.php | 15 +++++++++++++++ 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/classes/plpage.php b/classes/plpage.php index 1fbbe23..8cbbf13 100644 --- a/classes/plpage.php +++ b/classes/plpage.php @@ -126,11 +126,12 @@ abstract class PlPage extends Smarty return $this->jsonDisplay(); } - if (Env::v('display') == 'light') { + $display = Env::s('display'); + if ($display == 'light' && $this->_page_type == SKINNED) { $this->_page_type = SIMPLE; - } elseif (Env::v('display') == 'raw') { + } elseif ($display == 'raw') { $this->_page_type = NO_SKIN; - } elseif (Env::v('display') == 'full') { + } elseif ($display == 'full') { $this->_page_typ = SKINNED; } diff --git a/include/platal.inc.php b/include/platal.inc.php index 069a661..b9e42fd 100644 --- a/include/platal.inc.php +++ b/include/platal.inc.php @@ -155,6 +155,9 @@ function pl_url($path, $query = null, $fragment = null) { global $platal; + if (Env::has('__embedded')) { + $path = 'embedded/' . Env::s('__embedded') . '/' . $path; + } $base = $platal->ns . $path . ($query ? '?'.$query : ''); return $fragment ? $base.'#'.$fragment : $base; } diff --git a/modules/core.php b/modules/core.php index f9b429d..4c00f88 100644 --- a/modules/core.php +++ b/modules/core.php @@ -34,6 +34,8 @@ class CoreModule extends PLModule 'assert_errors' => $this->make_hook('siteerror', AUTH_COOKIE, 'admin'), 'site_errors' => $this->make_hook('siteerror', AUTH_COOKIE, 'admin'), + 'embedded' => $this->make_hook('embedded', AUTH_PUBLIC), + 'wiki_help' => $this->make_hook('wiki_help', AUTH_PUBLIC), 'wiki_preview' => $this->make_hook('wiki_preview', AUTH_COOKIE, 'user', NO_AUTH), @@ -187,6 +189,19 @@ class CoreModule extends PLModule $page->trigSuccess("Erreurs effacées."); } } + + function handler_embedded($page) + { + global $platal, $globals; + $allkeys = func_get_args(); + $mode = $allkeys[1]; + unset($allkeys[0]); + unset($allkeys[1]); + $_REQUEST['display'] = $mode; + $globals->baseurl .= '/embedded/' . $mode; + $platal->path = join('/', $allkeys); + $platal->run(); + } } // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: -- 2.1.4