]> git.mjollnir.org Git - s9y.git/commitdiff
* New plugin API method "parseTemplate($filename)" to allow a
authorgarvinhicking <garvinhicking>
Fri, 31 Aug 2007 10:39:55 +0000 (10:39 +0000)
committergarvinhicking <garvinhicking>
Fri, 31 Aug 2007 10:39:55 +0000 (10:39 +0000)
      sidebar- or event-plugin to fetch+display a smarty template.
      (garvinhicking)

docs/NEWS
include/plugin_api.inc.php

index d7de3de5eaa15b2f4fbb0c5841c2f471c414e615..1578b4477f2aef124023e26efcc277c2d84eb7cd 100644 (file)
--- a/docs/NEWS
+++ b/docs/NEWS
@@ -3,6 +3,10 @@
 Version 1.3 ()
 ------------------------------------------------------------------------
 
+    * New plugin API method "parseTemplate($filename)" to allow a
+      sidebar- or event-plugin to fetch+display a smarty template.
+      (garvinhicking)
+
     * Made short-urls index.php?serendipity[id]=X or index.php?p=X
       properly show a single entry view (garvinhicking)
 
index 69bbc679203f3c3337bb8eda380e35020dbbedfb..535025664febfc598292cb0c577cf2df05410a5b 100644 (file)
@@ -567,6 +567,9 @@ class serendipity_plugin_api
                 $p->serendipity_owner = $owner[0];
             }
         }
+        
+        $p->pluginPath = $pluginPath;
+        $p->pluginFile = $pluginFile;
 
         return $p;
     }
@@ -1141,6 +1144,9 @@ class serendipity_plugin
     var $title_class   = 'serendipitySideBarTitle';
     var $content_class = 'serendipitySideBarContent';
     var $title         = null;
+    var $pluginPath    = null;
+    var $pluginFile    = null;
+    var $serendipity_owner = null;
 
     /**
      * The constructor of a plugin
@@ -1474,6 +1480,31 @@ class serendipity_plugin
 
         return true;
     }
+
+    /**
+     * Parses a smarty template file (which can be stored in either the plugin directory, the user template directory
+     * or the default template directory, and return the parsed output.
+     *
+     * @access public
+     * @param  string    template filename (no directory!)
+     * @return string   Parsed Smarty return
+     */
+    function &parseTemplate($filename) {
+        global $serendipity;
+
+        $filename = basename($filename);
+        $tfile    = serendipity_getTemplateFile($filename, 'serendipityPath');
+        if (!$tfile || $tfile == $filename) {
+            $tfile = dirname($this->pluginFile) . '/' . $filename;
+        }
+        $inclusion = $serendipity['smarty']->security_settings[INCLUDE_ANY];
+        $serendipity['smarty']->security_settings[INCLUDE_ANY] = true;
+        $content = $serendipity['smarty']->fetch('file:'. $tfile, null, null, false);
+        $serendipity['smarty']->security_settings[INCLUDE_ANY] = $inclusion;
+        
+        return $content;    
+    }
+
 }
 
 /**