now the templates know about $globals. this is COMPILED so any config change need...
authorx2000habouzit <x2000habouzit>
Tue, 23 Nov 2004 12:01:31 +0000 (12:01 +0000)
committerx2000habouzit <x2000habouzit>
Tue, 23 Nov 2004 12:01:31 +0000 (12:01 +0000)
include/xorg.page.inc.php
include/xorg/smarty.plugins.inc.php

index 76bb1b7..e834afe 100644 (file)
@@ -18,7 +18,7 @@
  *  Foundation, Inc.,                                                      *
  *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
  ***************************************************************************
-    $Id: xorg.page.inc.php,v 1.52 2004-11-22 10:42:52 x2000habouzit Exp $
+    $Id: xorg.page.inc.php,v 1.53 2004-11-23 12:01:31 x2000habouzit Exp $
  ***************************************************************************/
 
 require_once("diogenes.core.page.inc.php");
@@ -31,7 +31,7 @@ require_once("diogenes.core.page.inc.php");
  * @category XOrgCore
  * @package  XOrgCore
  * @author   Jeremy LainĂ© <jeremy.laine@polytechnique.org>
- * @version  $Id: xorg.page.inc.php,v 1.52 2004-11-22 10:42:52 x2000habouzit Exp $
+ * @version  $Id: xorg.page.inc.php,v 1.53 2004-11-23 12:01:31 x2000habouzit Exp $
  * @access   public
  * @see      DiogenesCorePage
  */
@@ -76,6 +76,7 @@ class XorgPage extends DiogenesCorePage
         $this->register_function('dyn', 'function_dyn', false);
         $this->register_function('implode', 'function_implode');
         $this->register_prefilter('triple_quote_to_gettext');
+        $this->register_prefilter('at_to_globals');
 
         // if necessary, construct new session
         if (empty($_SESSION['session']))
index 6ed207e..613c65f 100644 (file)
@@ -18,7 +18,7 @@
  *  Foundation, Inc.,                                                      *
  *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
  ***************************************************************************
-    $Id: smarty.plugins.inc.php,v 1.1 2004-11-21 17:05:40 x2000habouzit Exp $
+    $Id: smarty.plugins.inc.php,v 1.2 2004-11-23 12:01:32 x2000habouzit Exp $
  ***************************************************************************/
 
 // {{{ function block_dynamic()
@@ -103,6 +103,32 @@ function triple_quote_to_gettext($tpl_source, &$smarty)
 }
 
 // }}}
+// {{{ function at_to_globals()
+
+/**
+ * helper
+ */
+
+function _to_globals($s) {
+    global $globals;
+    $t = explode('.',$s);
+    if (count($t) == 1) {
+        return $globals->$t[0];
+    } else {
+        return $globals->$t[0]->$t[1];
+    }
+}
+
+/**
+ * compilation plugin used to import $globals confing through #globals.foo.bar# directives
+ */
+
+function at_to_globals($tpl_source, &$smarty)
+{
+    return preg_replace('/#globals\.([a-zA-Z0-9_.]+?)#/e', '_to_globals(\'\\1\')', $tpl_source);
+}
+
+// }}}
 
 // vim:set et sw=4 sts=4 sws=4 foldmethod=marker:
 ?>