From: x2000habouzit Date: Tue, 23 Nov 2004 12:01:31 +0000 (+0000) Subject: now the templates know about $globals. this is COMPILED so any config change need... X-Git-Tag: xorg/old~822 X-Git-Url: http://git.polytechnique.org/?a=commitdiff_plain;h=e8357d86f65f237e4488b60144bd63b2438420ec;p=platal.git now the templates know about $globals. this is COMPILED so any config change need a cleaning of the compile cache --- diff --git a/include/xorg.page.inc.php b/include/xorg.page.inc.php index 76bb1b7..e834afe 100644 --- a/include/xorg.page.inc.php +++ b/include/xorg.page.inc.php @@ -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é - * @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'])) diff --git a/include/xorg/smarty.plugins.inc.php b/include/xorg/smarty.plugins.inc.php index 6ed207e..613c65f 100644 --- a/include/xorg/smarty.plugins.inc.php +++ b/include/xorg/smarty.plugins.inc.php @@ -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: ?>