Code

Readded smarty
[gosa.git] / gosa-core / include / smarty / SmartyBC.class.php
diff --git a/gosa-core/include/smarty/SmartyBC.class.php b/gosa-core/include/smarty/SmartyBC.class.php
new file mode 100644 (file)
index 0000000..f8f0a13
--- /dev/null
@@ -0,0 +1,460 @@
+<?php\r
+/**\r
+ * Project:     Smarty: the PHP compiling template engine\r
+ * File:        SmartyBC.class.php\r
+ * SVN:         $Id: $\r
+ *\r
+ * This library is free software; you can redistribute it and/or\r
+ * modify it under the terms of the GNU Lesser General Public\r
+ * License as published by the Free Software Foundation; either\r
+ * version 2.1 of the License, or (at your option) any later version.\r
+ *\r
+ * This library is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\r
+ * Lesser General Public License for more details.\r
+ *\r
+ * You should have received a copy of the GNU Lesser General Public\r
+ * License along with this library; if not, write to the Free Software\r
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\r
+ *\r
+ * For questions, help, comments, discussion, etc., please join the\r
+ * Smarty mailing list. Send a blank e-mail to\r
+ * smarty-discussion-subscribe@googlegroups.com\r
+ *\r
+ * @link http://www.smarty.net/\r
+ * @copyright 2008 New Digital Group, Inc.\r
+ * @author Monte Ohrt <monte at ohrt dot com>\r
+ * @author Uwe Tews\r
+ * @author Rodney Rehm\r
+ * @package Smarty\r
+ */\r
+/**\r
+ * @ignore\r
+ */\r
+require(dirname(__FILE__) . '/Smarty.class.php');\r
+\r
+/**\r
+ * Smarty Backward Compatability Wrapper Class\r
+ *\r
+ * @package Smarty\r
+ */\r
+class SmartyBC extends Smarty {\r
+\r
+    /**\r
+     * Smarty 2 BC\r
+     * @var string\r
+     */\r
+    public $_version = self::SMARTY_VERSION;\r
+\r
+    /**\r
+     * Initialize new SmartyBC object\r
+     *\r
+     * @param array $options options to set during initialization, e.g. array( 'forceCompile' => false )\r
+     */\r
+    public function __construct(array $options=array())\r
+    {\r
+        parent::__construct($options);\r
+        // register {php} tag\r
+        $this->registerPlugin('block', 'php', 'smarty_php_tag');\r
+    }\r
+\r
+    /**\r
+     * wrapper for assign_by_ref\r
+     *\r
+     * @param string $tpl_var the template variable name\r
+     * @param mixed  &$value  the referenced value to assign\r
+     */\r
+    public function assign_by_ref($tpl_var, &$value)\r
+    {\r
+        $this->assignByRef($tpl_var, $value);\r
+    }\r
+\r
+    /**\r
+     * wrapper for append_by_ref\r
+     *\r
+     * @param string  $tpl_var the template variable name\r
+     * @param mixed   &$value  the referenced value to append\r
+     * @param boolean $merge   flag if array elements shall be merged\r
+     */\r
+    public function append_by_ref($tpl_var, &$value, $merge = false)\r
+    {\r
+        $this->appendByRef($tpl_var, $value, $merge);\r
+    }\r
+\r
+    /**\r
+     * clear the given assigned template variable.\r
+     *\r
+     * @param string $tpl_var the template variable to clear\r
+     */\r
+    public function clear_assign($tpl_var)\r
+    {\r
+        $this->clearAssign($tpl_var);\r
+    }\r
+\r
+    /**\r
+     * Registers custom function to be used in templates\r
+     *\r
+     * @param string $function      the name of the template function\r
+     * @param string $function_impl the name of the PHP function to register\r
+     * @param bool   $cacheable\r
+     * @param mixed  $cache_attrs\r
+     */\r
+    public function register_function($function, $function_impl, $cacheable=true, $cache_attrs=null)\r
+    {\r
+        $this->registerPlugin('function', $function, $function_impl, $cacheable, $cache_attrs);\r
+    }\r
+\r
+    /**\r
+     * Unregisters custom function\r
+     *\r
+     * @param string $function name of template function\r
+     */\r
+    public function unregister_function($function)\r
+    {\r
+        $this->unregisterPlugin('function', $function);\r
+    }\r
+\r
+    /**\r
+     * Registers object to be used in templates\r
+     *\r
+     * @param string  $object      name of template object\r
+     * @param object  $object_impl the referenced PHP object to register\r
+     * @param array   $allowed     list of allowed methods (empty = all)\r
+     * @param boolean $smarty_args smarty argument format, else traditional\r
+     * @param array   $block_functs list of methods that are block format\r
+     */\r
+    public function register_object($object, $object_impl, $allowed = array(), $smarty_args = true, $block_methods = array())\r
+    {\r
+        settype($allowed, 'array');\r
+        settype($smarty_args, 'boolean');\r
+        $this->registerObject($object, $object_impl, $allowed, $smarty_args, $block_methods);\r
+    }\r
+\r
+    /**\r
+     * Unregisters object\r
+     *\r
+     * @param string $object name of template object\r
+     */\r
+    public function unregister_object($object)\r
+    {\r
+        $this->unregisterObject($object);\r
+    }\r
+\r
+    /**\r
+     * Registers block function to be used in templates\r
+     *\r
+     * @param string $block      name of template block\r
+     * @param string $block_impl PHP function to register\r
+     * @param bool   $cacheable\r
+     * @param mixed  $cache_attrs\r
+     */\r
+    public function register_block($block, $block_impl, $cacheable=true, $cache_attrs=null)\r
+    {\r
+        $this->registerPlugin('block', $block, $block_impl, $cacheable, $cache_attrs);\r
+    }\r
+\r
+    /**\r
+     * Unregisters block function\r
+     *\r
+     * @param string $block name of template function\r
+     */\r
+    public function unregister_block($block)\r
+    {\r
+        $this->unregisterPlugin('block', $block);\r
+    }\r
+\r
+    /**\r
+     * Registers compiler function\r
+     *\r
+     * @param string $function      name of template function\r
+     * @param string $function_impl name of PHP function to register\r
+     * @param bool   $cacheable\r
+     */\r
+    public function register_compiler_function($function, $function_impl, $cacheable=true)\r
+    {\r
+        $this->registerPlugin('compiler', $function, $function_impl, $cacheable);\r
+    }\r
+\r
+    /**\r
+     * Unregisters compiler function\r
+     *\r
+     * @param string $function name of template function\r
+     */\r
+    public function unregister_compiler_function($function)\r
+    {\r
+        $this->unregisterPlugin('compiler', $function);\r
+    }\r
+\r
+    /**\r
+     * Registers modifier to be used in templates\r
+     *\r
+     * @param string $modifier name of template modifier\r
+     * @param string $modifier_impl name of PHP function to register\r
+     */\r
+    public function register_modifier($modifier, $modifier_impl)\r
+    {\r
+        $this->registerPlugin('modifier', $modifier, $modifier_impl);\r
+    }\r
+\r
+    /**\r
+     * Unregisters modifier\r
+     *\r
+     * @param string $modifier name of template modifier\r
+     */\r
+    public function unregister_modifier($modifier)\r
+    {\r
+        $this->unregisterPlugin('modifier', $modifier);\r
+    }\r
+\r
+    /**\r
+     * Registers a resource to fetch a template\r
+     *\r
+     * @param string $type      name of resource\r
+     * @param array  $functions array of functions to handle resource\r
+     */\r
+    public function register_resource($type, $functions)\r
+    {\r
+        $this->registerResource($type, $functions);\r
+    }\r
+\r
+    /**\r
+     * Unregisters a resource\r
+     *\r
+     * @param string $type name of resource\r
+     */\r
+    public function unregister_resource($type)\r
+    {\r
+        $this->unregisterResource($type);\r
+    }\r
+\r
+    /**\r
+     * Registers a prefilter function to apply\r
+     * to a template before compiling\r
+     *\r
+     * @param callable $function\r
+     */\r
+    public function register_prefilter($function)\r
+    {\r
+        $this->registerFilter('pre', $function);\r
+    }\r
+\r
+    /**\r
+     * Unregisters a prefilter function\r
+     *\r
+     * @param callable $function\r
+     */\r
+    public function unregister_prefilter($function)\r
+    {\r
+        $this->unregisterFilter('pre', $function);\r
+    }\r
+\r
+    /**\r
+     * Registers a postfilter function to apply\r
+     * to a compiled template after compilation\r
+     *\r
+     * @param callable $function\r
+     */\r
+    public function register_postfilter($function)\r
+    {\r
+        $this->registerFilter('post', $function);\r
+    }\r
+\r
+    /**\r
+     * Unregisters a postfilter function\r
+     *\r
+     * @param callable $function\r
+     */\r
+    public function unregister_postfilter($function)\r
+    {\r
+        $this->unregisterFilter('post', $function);\r
+    }\r
+\r
+    /**\r
+     * Registers an output filter function to apply\r
+     * to a template output\r
+     *\r
+     * @param callable $function\r
+     */\r
+    public function register_outputfilter($function)\r
+    {\r
+        $this->registerFilter('output', $function);\r
+    }\r
+\r
+    /**\r
+     * Unregisters an outputfilter function\r
+     *\r
+     * @param callable $function\r
+     */\r
+    public function unregister_outputfilter($function)\r
+    {\r
+        $this->unregisterFilter('output', $function);\r
+    }\r
+\r
+    /**\r
+     * load a filter of specified type and name\r
+     *\r
+     * @param string $type filter type\r
+     * @param string $name filter name\r
+     */\r
+    public function load_filter($type, $name)\r
+    {\r
+        $this->loadFilter($type, $name);\r
+    }\r
+\r
+    /**\r
+     * clear cached content for the given template and cache id\r
+     *\r
+     * @param string $tpl_file   name of template file\r
+     * @param string $cache_id   name of cache_id\r
+     * @param string $compile_id name of compile_id\r
+     * @param string $exp_time   expiration time\r
+     * @return boolean\r
+     */\r
+    public function clear_cache($tpl_file = null, $cache_id = null, $compile_id = null, $exp_time = null)\r
+    {\r
+        return $this->clearCache($tpl_file, $cache_id, $compile_id, $exp_time);\r
+    }\r
+\r
+    /**\r
+     * clear the entire contents of cache (all templates)\r
+     *\r
+     * @param string $exp_time expire time\r
+     * @return boolean\r
+     */\r
+    public function clear_all_cache($exp_time = null)\r
+    {\r
+        return $this->clearCache(null, null, null, $exp_time);\r
+    }\r
+\r
+    /**\r
+     * test to see if valid cache exists for this template\r
+     *\r
+     * @param string $tpl_file name of template file\r
+     * @param string $cache_id\r
+     * @param string $compile_id\r
+     * @return boolean\r
+     */\r
+    public function is_cached($tpl_file, $cache_id = null, $compile_id = null)\r
+    {\r
+        return $this->isCached($tpl_file, $cache_id, $compile_id);\r
+    }\r
+\r
+    /**\r
+     * clear all the assigned template variables.\r
+     */\r
+    public function clear_all_assign()\r
+    {\r
+        $this->clearAllAssign();\r
+    }\r
+\r
+    /**\r
+     * clears compiled version of specified template resource,\r
+     * or all compiled template files if one is not specified.\r
+     * This function is for advanced use only, not normally needed.\r
+     *\r
+     * @param string $tpl_file\r
+     * @param string $compile_id\r
+     * @param string $exp_time\r
+     * @return boolean results of {@link smarty_core_rm_auto()}\r
+     */\r
+    public function clear_compiled_tpl($tpl_file = null, $compile_id = null, $exp_time = null)\r
+    {\r
+        return $this->clearCompiledTemplate($tpl_file, $compile_id, $exp_time);\r
+    }\r
+\r
+    /**\r
+     * Checks whether requested template exists.\r
+     *\r
+     * @param string $tpl_file\r
+     * @return boolean\r
+     */\r
+    public function template_exists($tpl_file)\r
+    {\r
+        return $this->templateExists($tpl_file);\r
+    }\r
+\r
+    /**\r
+     * Returns an array containing template variables\r
+     *\r
+     * @param string $name\r
+     * @return array\r
+     */\r
+    public function get_template_vars($name=null)\r
+    {\r
+        return $this->getTemplateVars($name);\r
+    }\r
+\r
+    /**\r
+     * Returns an array containing config variables\r
+     *\r
+     * @param string $name\r
+     * @return array\r
+     */\r
+    public function get_config_vars($name=null)\r
+    {\r
+        return $this->getConfigVars($name);\r
+    }\r
+\r
+    /**\r
+     * load configuration values\r
+     *\r
+     * @param string $file\r
+     * @param string $section\r
+     * @param string $scope\r
+     */\r
+    public function config_load($file, $section = null, $scope = 'global')\r
+    {\r
+        $this->ConfigLoad($file, $section, $scope);\r
+    }\r
+\r
+    /**\r
+     * return a reference to a registered object\r
+     *\r
+     * @param string $name\r
+     * @return object\r
+     */\r
+    public function get_registered_object($name)\r
+    {\r
+        return $this->getRegisteredObject($name);\r
+    }\r
+\r
+    /**\r
+     * clear configuration values\r
+     *\r
+     * @param string $var\r
+     */\r
+    public function clear_config($var = null)\r
+    {\r
+        $this->clearConfig($var);\r
+    }\r
+\r
+    /**\r
+     * trigger Smarty error\r
+     *\r
+     * @param string $error_msg\r
+     * @param integer $error_type\r
+     */\r
+    public function trigger_error($error_msg, $error_type = E_USER_WARNING)\r
+    {\r
+        trigger_error("Smarty error: $error_msg", $error_type);\r
+    }\r
+\r
+}\r
+\r
+/**\r
+ * Smarty {php}{/php} block function\r
+ *\r
+ * @param array   $params   parameter list\r
+ * @param string  $content  contents of the block\r
+ * @param object  $template template object\r
+ * @param boolean &$repeat  repeat flag\r
+ * @return string content re-formatted\r
+ */\r
+function smarty_php_tag($params, $content, $template, &$repeat)\r
+{\r
+    eval($content);\r
+    return '';\r
+}\r
+\r
+?>
\ No newline at end of file