Merge remote branch 'origin/core/1.1.1/maint' into core/master
authorFlorent Bruneau <florent.bruneau@polytechnique.org>
Thu, 16 Dec 2010 20:13:55 +0000 (21:13 +0100)
committerFlorent Bruneau <florent.bruneau@polytechnique.org>
Thu, 16 Dec 2010 20:13:55 +0000 (21:13 +0100)
classes/plimage.php
classes/plpage.php
classes/plwikipage.php
classes/xmlrpcclient.php
modules/core.php

index 0578665..99519c2 100644 (file)
@@ -23,6 +23,7 @@ class PlImage {
     protected $mime = null;
     protected $x = null;
     protected $y = null;
+    protected $ts = null;
 
     protected $data = null;
     protected $file = null;
@@ -33,6 +34,9 @@ class PlImage {
 
     public function send()
     {
+        if (!is_null($this->ts)) {
+            header('Last-Modified: ' . gmdate('D, d M Y H:i:s', $this->ts) . ' GMT');
+        }
         pl_cached_dynamic_content_headers($this->mime);
         if (empty($this->data)) {
             readfile($this->file);
@@ -68,23 +72,25 @@ class PlImage {
         return $this->mime;
     }
 
-    public static function fromData($data, $mime, $x = null, $y = null)
+    public static function fromData($data, $mime, $x = null, $y = null, $ts = null)
     {
         $image = new PlImage();
         $image->data = $data;
         $image->mime = $mime;
         $image->x    = $x;
         $image->y    = $y;
+        $image->ts   = $ts;
         return $image;
     }
 
-    public static function fromFile($path, $mime, $x = null, $y = null)
+    public static function fromFile($path, $mime, $x = null, $y = null, $ts = null)
     {
         $image = new PlImage();
         $image->file = $path;
         $image->mime = $mime;
         $image->x    = $x;
         $image->y    = $y;
+        $image->ts   = $ts;
         return $image;
     }
 }
index c13410e..55442d0 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 4e3ce78..3a8157a 100644 (file)
@@ -432,6 +432,9 @@ class PlWikiPage
             global $platal;
             $page =& Platal::page();
             $platal->force_login($page);
+        } else if ($perm == 'admin' && !S::admin()) {
+            global $platal;
+            $platal->error403();
         }
     }
 
index c359730..55eb51a 100644 (file)
@@ -107,6 +107,13 @@ class XmlrpcClient
         if ($this->bt) {
             $this->bt->stop();
         }
+        if (is_null($answer)) {
+            Platal::page()->trigError("L'accès aux listes de diffusion n'est pas disponible actuellement.");
+            $this->bt->update(0, "Connection failed");
+            return null;
+        }
+        Platal::assert(starts_with($answer, 'HTTP/1.0 200 OK'), "HTTP Error:\n" . $answer,
+                       "Une erreur est survenue lors de l'accès aux listes de diffusion.");
         $result = $this->find_and_decode_xml($answer);
         if ($this->bt) {
             if (is_array($result) && isset($result['faultCode'])) {
@@ -114,6 +121,10 @@ class XmlrpcClient
             } else {
                 $this->bt->update(count($result));
             }
+        } else {
+            Platal::assert(!is_array($result) || !isset($result['faultCode']),
+                           "RPC Error:\n" . $answer,
+                           "Une erreur est survenue lors de l'accès aux listes de diffusion.");
         }
 
         if (is_array($result) && isset($result['faultCode'])) {
index 4a378ff..6557ca4 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),
 
@@ -188,6 +190,19 @@ class CoreModule extends PLModule
         }
         $page->assign('errors', PlErrorReport::iterate());
     }
+
+    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: