Add an embedded mode for platal.
authorFlorent Bruneau <florent.bruneau@polytechnique.org>
Thu, 9 Dec 2010 21:22:37 +0000 (22:22 +0100)
committerFlorent Bruneau <florent.bruneau@polytechnique.org>
Thu, 9 Dec 2010 21:26:45 +0000 (22:26 +0100)
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 <florent.bruneau@polytechnique.org>
classes/plpage.php
include/platal.inc.php
modules/core.php

index 1fbbe23..8cbbf13 100644 (file)
@@ -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;
         }
 
index 069a661..b9e42fd 100644 (file)
@@ -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;
 }
index f9b429d..4c00f88 100644 (file)
@@ -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: