mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-06 19:34:27 +02:00
major API update
This commit is contained in:
98
README
98
README
@@ -5,7 +5,103 @@ Author: Uwe Tews
|
||||
|
||||
AN INTRODUCTION TO SMARTY 3 BETA
|
||||
|
||||
The file structure is similar to Smarty 2:
|
||||
NOTICE for BETA 8:
|
||||
|
||||
The Smarty 3 API (as of beta 8) has been refactored to a syntax geared
|
||||
for consistency and modularity. The Smarty 2 API syntax is still supported, but
|
||||
will throw a deprecation notice. You can disable the notices, but it is highly
|
||||
recommended to adjust your syntax to Smarty 3, as the Smarty 2 syntax must run
|
||||
through an extra rerouting wrapper.
|
||||
|
||||
Basically, all Smarty methods now follow the "fooBarBaz" camel case syntax. Also,
|
||||
all Smarty properties now have getters and setters. So for example, the property
|
||||
$smarty->cache_dir can be set with $smarty->setCacheDir('foo/') and can be
|
||||
retrieved with $smarty->getCacheDir().
|
||||
|
||||
Some of the Smarty 3 APIs have been revoked such as the "is*" methods that were
|
||||
just duplicate functions of the now available "get*" methods.
|
||||
|
||||
Here is a rundown of the Smarty 3 API:
|
||||
|
||||
$smarty->fetch($template, $cache_id = null, $compile_id = null, $parent = null)
|
||||
$smarty->display($template, $cache_id = null, $compile_id = null, $parent = null)
|
||||
$smarty->isCached($template, $cache_id = null, $compile_id = null)
|
||||
$smarty->createData($parent = null)
|
||||
$smarty->createTemplate($template, $cache_id = null, $compile_id = null, $parent = null)
|
||||
$smarty->enableSecurity()
|
||||
$smarty->setTemplateDir($template_dir)
|
||||
$smarty->addTemplateDir($template_dir)
|
||||
$smarty->enableCaching()
|
||||
$smarty->templateExists($resource_name)
|
||||
$smarty->loadPlugin($plugin_name, $check = true)
|
||||
$smarty->loadFilter($type, $name)
|
||||
$smarty->setExceptionHandler($handler)
|
||||
$smarty->addPluginsDir($plugins_dir)
|
||||
$smarty->getGlobal($varname = null)
|
||||
$smarty->getRegisteredObject($name)
|
||||
$smarty->getDebugTemplate()
|
||||
$smarty->setDebugTemplate($tpl_name)
|
||||
$smarty->assign($tpl_var, $value = null, $nocache = false, $scope = SMARTY_LOCAL_SCOPE)
|
||||
$smarty->assignGlobal($varname, $value = null, $nocache = false)
|
||||
$smarty->assignByRef($tpl_var, &$value, $nocache = false, $scope = SMARTY_LOCAL_SCOPE)
|
||||
$smarty->append($tpl_var, $value = null, $merge = false, $nocache = false, $scope = SMARTY_LOCAL_SCOPE)
|
||||
$smarty->appendByRef($tpl_var, &$value, $merge = false)
|
||||
$smarty->clearAssign($tpl_var)
|
||||
$smarty->clearAllAssign()
|
||||
$smarty->configLoad($config_file, $sections = null)
|
||||
$smarty->getVariable($variable, $_ptr = null, $search_parents = true, $error_enable = true)
|
||||
$smarty->getConfigVariable($variable)
|
||||
$smarty->getStreamVariable($variable)
|
||||
$smarty->getConfigVars($varname = null)
|
||||
$smarty->clearConfig($varname = null)
|
||||
|
||||
// some API calls are moved into their own objects:
|
||||
|
||||
$smarty->cache->loadResource($type = null)
|
||||
$smarty->cache->clearAll($exp_time = null, $type = null)
|
||||
$smarty->cache->clear($template_name, $cache_id = null, $compile_id = null, $exp_time = null, $type = null)
|
||||
|
||||
$smarty->register->block($block_tag, $block_impl, $cacheable = true, $cache_attr = array())
|
||||
$smarty->register->compilerFunction($compiler_tag, $compiler_impl, $cacheable = true)
|
||||
$smarty->register->templateFunction($function_tag, $function_impl, $cacheable = true, $cache_attr = array())
|
||||
$smarty->register->modifier($modifier_name, $modifier_impl)
|
||||
$smarty->register->templateObject($object_name, $object_impl, $allowed = array(), $smarty_args = true, $block_methods = array())
|
||||
$smarty->register->outputFilter($function_name)
|
||||
$smarty->register->postFilter($function_name)
|
||||
$smarty->register->preFilter($function_name)
|
||||
$smarty->register->resource($resource_type, $function_names)
|
||||
$smarty->register->variableFilter($function_name)
|
||||
$smarty->register->defaultPluginHandler($function_name)
|
||||
$smarty->register->defaultTemplateHandler($function_name)
|
||||
|
||||
$smarty->unregister->block($block_tag)
|
||||
$smarty->unregister->compilerFunction($compiler_tag)
|
||||
$smarty->unregister->templateFunction($function_tag)
|
||||
$smarty->unregister->modifier($modifier)
|
||||
$smarty->unregister->templateObject($object_name)
|
||||
$smarty->unregister->outputFilter($function_name)
|
||||
$smarty->unregister->postFilter($function_name)
|
||||
$smarty->unregister->preFilter($function_name)
|
||||
$smarty->unregister->resource($resource_type)
|
||||
$smarty->unregister->variableFilter($function_name)
|
||||
|
||||
$smarty->utility->compileAllTemplates($extention = '.tpl', $force_compile = false, $time_limit = 0, $max_errors = null)
|
||||
$smarty->utility->clearCompiledTemplate($resource_name = null, $compile_id = null, $exp_time = null)
|
||||
$smarty->utility->getTemplateVars($varname = null, $_ptr = null, $search_parents = true)
|
||||
$smarty->utility->testInstall()
|
||||
|
||||
// then all the getters/setters, available for all properties. Here are a few:
|
||||
|
||||
$caching = $smarty->getCaching(); // get $smarty->caching
|
||||
$smarty->setCaching(true); // set $smarty->caching
|
||||
$smarty->setDeprecationNotices(false); // set $smarty->deprecation_notices
|
||||
$smarty->setCacheId($id); // set $smarty->cache_id
|
||||
$debugging = $smarty->getDebugging(); // get $smarty->debugging
|
||||
|
||||
|
||||
FILE STRUCTURE
|
||||
|
||||
The Smarty 3 file structure is similar to Smarty 2:
|
||||
|
||||
/libs/
|
||||
Smarty.class.php
|
||||
|
@@ -1,4 +1,10 @@
|
||||
= Known incompatibilities with Smarty 2 =
|
||||
|
||||
== Syntax ==
|
||||
|
||||
Smarty 3 API has a new syntax. Much of the Smarty 2 syntax is supported but
|
||||
deprecated. See the README that comes with Smarty 3 for more information.
|
||||
|
||||
== PHP Version ==
|
||||
Smarty 3 is PHP 5 only. It will not work with PHP 4.
|
||||
|
||||
|
@@ -184,6 +184,10 @@ class Smarty extends Smarty_Internal_Data {
|
||||
public $caching_type = 'file';
|
||||
// internal cache resource types
|
||||
public $cache_resource_types = array('file');
|
||||
// internal cache resource objects
|
||||
public $cache_resource_objects = array();
|
||||
// internal config properties
|
||||
public $properties = array();
|
||||
// config type
|
||||
public $default_config_type = 'file';
|
||||
// exception handler: array('ExceptionClass','ExceptionMethod');
|
||||
@@ -216,6 +220,8 @@ class Smarty extends Smarty_Internal_Data {
|
||||
public $_dir_perms = 0771;
|
||||
// smarty object reference
|
||||
public $smarty = null;
|
||||
// generate deprecated function call notices?
|
||||
public $deprecation_notices = true;
|
||||
|
||||
/**
|
||||
* Class constructor, initializes basic smarty properties
|
||||
@@ -268,7 +274,7 @@ class Smarty extends Smarty_Internal_Data {
|
||||
}
|
||||
}
|
||||
if (isset($_SERVER['SCRIPT_NAME'])) {
|
||||
$this->assign_global('SCRIPT_NAME', $_SERVER['SCRIPT_NAME']);
|
||||
$this->assignGlobal('SCRIPT_NAME', $_SERVER['SCRIPT_NAME']);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -342,7 +348,7 @@ class Smarty extends Smarty_Internal_Data {
|
||||
* @param mixed $compile_id compile id to be used with this template
|
||||
* @return boolean cache status
|
||||
*/
|
||||
public function is_cached($template, $cache_id = null, $compile_id = null) {
|
||||
public function isCached($template, $cache_id = null, $compile_id = null) {
|
||||
if (!($template instanceof $this->template_class)) {
|
||||
$template = $this->createTemplate ($template, $cache_id, $compile_id, $this);
|
||||
}
|
||||
@@ -431,6 +437,7 @@ class Smarty extends Smarty_Internal_Data {
|
||||
$this->template_dir = (array)$template_dir;
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds template directory(s) to existing ones
|
||||
*
|
||||
@@ -441,24 +448,7 @@ class Smarty extends Smarty_Internal_Data {
|
||||
$this->template_dir = array_unique($this->template_dir);
|
||||
return;
|
||||
}
|
||||
/**
|
||||
* Set compile directory
|
||||
*
|
||||
* @param string $compile_dir folder of compiled template sources
|
||||
*/
|
||||
public function setCompileDir($compile_dir) {
|
||||
$this->compile_dir = $compile_dir;
|
||||
return;
|
||||
}
|
||||
/**
|
||||
* Set cache directory
|
||||
*
|
||||
* @param string $cache_dir folder of cache files
|
||||
*/
|
||||
public function setCacheDir($cache_dir) {
|
||||
$this->cache_dir = $cache_dir;
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable Caching
|
||||
*/
|
||||
@@ -466,15 +456,21 @@ class Smarty extends Smarty_Internal_Data {
|
||||
$this->caching = SMARTY_CACHING_LIFETIME_CURRENT;
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set caching life time
|
||||
* Check if a template resource exists
|
||||
*
|
||||
* @param integer $lifetime lifetime of cached file in seconds
|
||||
* @param string $resource_name template name
|
||||
* @return boolean status
|
||||
*/
|
||||
public function setCacheLifetime($lifetime) {
|
||||
$this->cache_lifetime = $lifetime;
|
||||
return;
|
||||
function templateExists($resource_name)
|
||||
{
|
||||
// create template object
|
||||
$tpl = new $this->template_class($resource_name, $this);
|
||||
// check if it does exists
|
||||
return $tpl->isExisting();
|
||||
}
|
||||
|
||||
/**
|
||||
* Takes unknown classes and loads plugin files for them
|
||||
* class name format: Smarty_PluginType_PluginName
|
||||
@@ -523,6 +519,29 @@ class Smarty extends Smarty_Internal_Data {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* load a filter of specified type and name
|
||||
*
|
||||
* @param string $type filter type
|
||||
* @param string $name filter name
|
||||
* @return bool
|
||||
*/
|
||||
function loadFilter($type, $name)
|
||||
{
|
||||
$_plugin = "smarty_{$type}filter_{$name}";
|
||||
$_filter_name = $_plugin;
|
||||
if ($this->loadPlugin($_plugin)) {
|
||||
if (class_exists($_plugin, false)) {
|
||||
$_plugin = array($_plugin, 'execute');
|
||||
}
|
||||
if (is_callable($_plugin)) {
|
||||
return $this->registered_filters[$type][$_filter_name] = $_plugin;
|
||||
}
|
||||
}
|
||||
throw new Exception("{$type}filter \"{$name}\" not callable");
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the exception handler for Smarty.
|
||||
*
|
||||
@@ -534,35 +553,6 @@ class Smarty extends Smarty_Internal_Data {
|
||||
return set_exception_handler($handler);
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads cache resource.
|
||||
*
|
||||
* @return object of cache resource
|
||||
*/
|
||||
public function loadCacheResource($type = null) {
|
||||
if (!isset($type)) {
|
||||
$type = $this->caching_type;
|
||||
}
|
||||
// already loaded?
|
||||
if (isset($this->cache_resource_objects[$type])) {
|
||||
return $this->cache_resource_objects[$type];
|
||||
}
|
||||
if (in_array($type, $this->cache_resource_types)) {
|
||||
$cache_resource_class = 'Smarty_Internal_CacheResource_' . ucfirst($type);
|
||||
return $this->cache_resource_objects[$type] = new $cache_resource_class($this);
|
||||
}
|
||||
else {
|
||||
// try plugins dir
|
||||
$cache_resource_class = 'Smarty_CacheResource_' . ucfirst($type);
|
||||
if ($this->loadPlugin($cache_resource_class)) {
|
||||
return $this->cache_resource_objects[$type] = new $cache_resource_class($this);
|
||||
}
|
||||
else {
|
||||
throw new Exception("Unable to load cache resource '{$type}'");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* trigger Smarty error
|
||||
*
|
||||
@@ -573,6 +563,112 @@ class Smarty extends Smarty_Internal_Data {
|
||||
throw new Exception("Smarty error: $error_msg");
|
||||
}
|
||||
|
||||
/**
|
||||
* Return internal filter name
|
||||
*
|
||||
* @param callback $function_name
|
||||
*/
|
||||
public function _get_filter_name($function_name)
|
||||
{
|
||||
if (is_array($function_name)) {
|
||||
$_class_name = (is_object($function_name[0]) ?
|
||||
get_class($function_name[0]) : $function_name[0]);
|
||||
return $_class_name . '_' . $function_name[1];
|
||||
}
|
||||
else {
|
||||
return $function_name;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds directory of plugin files
|
||||
*
|
||||
* @param object $smarty
|
||||
* @param string $ |array $ plugins folder
|
||||
* @return
|
||||
*/
|
||||
function addPluginsDir($plugins_dir)
|
||||
{
|
||||
$this->plugins_dir = array_merge((array)$this->plugins_dir, (array)$plugins_dir);
|
||||
$this->plugins_dir = array_unique($this->plugins_dir);
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a single or all global variables
|
||||
*
|
||||
* @param object $smarty
|
||||
* @param string $varname variable name or null
|
||||
* @return string variable value or or array of variables
|
||||
*/
|
||||
function getGlobal($varname = null)
|
||||
{
|
||||
if (isset($varname)) {
|
||||
if (isset($this->global_tpl_vars[$varname])) {
|
||||
return $this->global_tpl_vars[$varname]->value;
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
} else {
|
||||
$_result = array();
|
||||
foreach ($this->global_tpl_vars AS $key => $var) {
|
||||
$_result[$key] = $var->value;
|
||||
}
|
||||
return $_result;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* return a reference to a registered object
|
||||
*
|
||||
* @param string $name object name
|
||||
* @return object
|
||||
*/
|
||||
function getRegisteredObject($name)
|
||||
{
|
||||
if (!isset($this->registered_objects[$name]))
|
||||
throw new Exception("'$name' is not a registered object");
|
||||
|
||||
if (!is_object($this->registered_objects[$name][0]))
|
||||
throw new Exception("registered '$name' is not an object");
|
||||
|
||||
return $this->registered_objects[$name][0];
|
||||
}
|
||||
|
||||
/**
|
||||
* return name of debugging template
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function getDebugTemplate()
|
||||
{
|
||||
return $this->debug_tpl;
|
||||
}
|
||||
|
||||
/**
|
||||
* set the debug template
|
||||
*
|
||||
* @param string $tpl_name
|
||||
* @return bool
|
||||
*/
|
||||
function setDebugTemplate($tpl_name)
|
||||
{
|
||||
return $this->debug_tpl = $tpl_name;
|
||||
}
|
||||
|
||||
/**
|
||||
* lazy loads (valid) property objects
|
||||
*
|
||||
* @param string $name property name
|
||||
*/
|
||||
public function __get($name) {
|
||||
if(in_array($name,array('register','unregister','utility','cache'))) {
|
||||
$class = "Smarty_Internal_".ucfirst($name);
|
||||
return new $class($this);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Takes unknown class methods and lazy loads sysplugin files for them
|
||||
* class name format: Smarty_Method_MethodName
|
||||
@@ -582,6 +678,40 @@ class Smarty extends Smarty_Internal_Data {
|
||||
* @param array $args aurgument array
|
||||
*/
|
||||
public function __call($name, $args) {
|
||||
static $camel_func;
|
||||
if(!isset($camel_func))
|
||||
$camel_func = create_function('$c', 'return "_" . strtolower($c[1]);');
|
||||
// PHP4 call to constructor?
|
||||
if (strtolower($name) == 'smarty') {
|
||||
throw new Exception('Please use parent::__construct() to call parent constuctor');
|
||||
return false;
|
||||
}
|
||||
|
||||
// see if this is a set/get for a property
|
||||
$first3 = strtolower(substr($name,0,3));
|
||||
if(in_array($first3,array('set','get')) && substr($name,3,1) !== '_') {
|
||||
// try to keep case correct for future PHP 6.0 case-sensitive class methods
|
||||
// lcfirst() not available < PHP 5.3.0, so improvise
|
||||
$property_name = strtolower(substr($name,3,1)).substr($name,4);
|
||||
// convert camel case to underscored name
|
||||
$property_name = preg_replace_callback('/([A-Z])/', $camel_func, $property_name);
|
||||
if(!property_exists($this,$property_name)) {
|
||||
throw new Exception("property '$property_name' does not exist.");
|
||||
return false;
|
||||
}
|
||||
if($first3 == 'get')
|
||||
return $this->$property_name;
|
||||
else
|
||||
return $this->$property_name = $args[0];
|
||||
}
|
||||
|
||||
// Smarty Backward Compatible wrapper
|
||||
if(!isset($this->wrapper)) {
|
||||
$this->wrapper = new Smarty_Internal_Wrapper($this);
|
||||
}
|
||||
return $this->wrapper->convert($name, $args);
|
||||
|
||||
/*
|
||||
$name = strtolower($name);
|
||||
if ($name == 'smarty') {
|
||||
throw new Exception('Please use parent::__construct() to call parent constuctor');
|
||||
@@ -594,6 +724,7 @@ class Smarty extends Smarty_Internal_Data {
|
||||
require_once(SMARTY_SYSPLUGINS_DIR . $function_name . '.php');
|
||||
}
|
||||
return call_user_func_array($function_name, array_merge(array($this), $args));
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -46,7 +46,7 @@ class Smarty_Internal_Data {
|
||||
* @param mixed $value the value to assign
|
||||
* @param boolean $nocache if true any output of this variable will be not cached
|
||||
*/
|
||||
public function assign_global($varname, $value = null, $nocache = false)
|
||||
public function assignGlobal($varname, $value = null, $nocache = false)
|
||||
{
|
||||
if ($varname != '') {
|
||||
$this->smarty->global_tpl_vars[$varname] = new Smarty_variable($value, $nocache);
|
||||
@@ -60,7 +60,7 @@ class Smarty_Internal_Data {
|
||||
* @param boolean $nocache if true any output of this variable will be not cached
|
||||
* @param boolean $scope the scope the variable will have (local,parent or root)
|
||||
*/
|
||||
public function assign_by_ref($tpl_var, &$value, $nocache = false, $scope = SMARTY_LOCAL_SCOPE)
|
||||
public function assignByRef($tpl_var, &$value, $nocache = false, $scope = SMARTY_LOCAL_SCOPE)
|
||||
{
|
||||
if ($tpl_var != '') {
|
||||
$this->tpl_vars[$tpl_var] = new Smarty_variable(null, $nocache, $scope);
|
||||
@@ -139,7 +139,7 @@ class Smarty_Internal_Data {
|
||||
* @param mixed $ &$value the referenced value to append
|
||||
* @param boolean $merge flag if array elements shall be merged
|
||||
*/
|
||||
public function append_by_ref($tpl_var, &$value, $merge = false)
|
||||
public function appendByRef($tpl_var, &$value, $merge = false)
|
||||
{
|
||||
if ($tpl_var != '' && isset($value)) {
|
||||
if (!isset($this->tpl_vars[$tpl_var])) {
|
||||
@@ -163,7 +163,7 @@ class Smarty_Internal_Data {
|
||||
*
|
||||
* @param string $ |array $tpl_var the template variable(s) to clear
|
||||
*/
|
||||
public function clear_assign($tpl_var)
|
||||
public function clearAssign($tpl_var)
|
||||
{
|
||||
if (is_array($tpl_var)) {
|
||||
foreach ($tpl_var as $curr_var) {
|
||||
@@ -177,7 +177,7 @@ class Smarty_Internal_Data {
|
||||
/**
|
||||
* clear all the assigned template variables.
|
||||
*/
|
||||
public function clear_all_assign()
|
||||
public function clearAllAssign()
|
||||
{
|
||||
$this->tpl_vars = array();
|
||||
}
|
||||
@@ -188,7 +188,7 @@ class Smarty_Internal_Data {
|
||||
* @param string $config_file filename
|
||||
* @param mixed $sections array of section names, single section or null
|
||||
*/
|
||||
public function config_load($config_file, $sections = null)
|
||||
public function configLoad($config_file, $sections = null)
|
||||
{
|
||||
// load Config class
|
||||
$config = new Smarty_Internal_Config($config_file, $this->smarty);
|
||||
@@ -282,7 +282,7 @@ class Smarty_Internal_Data {
|
||||
* @param string $varname variable name or null
|
||||
* @return string variable value or or array of variables
|
||||
*/
|
||||
function get_config_vars($varname = null)
|
||||
function getConfigVars($varname = null)
|
||||
{
|
||||
if (isset($varname)) {
|
||||
if (isset($this->config_vars[$varname])) {
|
||||
@@ -300,7 +300,7 @@ class Smarty_Internal_Data {
|
||||
*
|
||||
* @param string $varname variable name or null
|
||||
*/
|
||||
function clear_config($varname = null)
|
||||
function clearConfig($varname = null)
|
||||
{
|
||||
if (isset($varname)) {
|
||||
unset($this->config_vars[$varname]);
|
||||
|
@@ -104,7 +104,7 @@ class Smarty_Internal_Template extends Smarty_Internal_Data {
|
||||
}
|
||||
// load cache resource
|
||||
if (!$this->resource_object->isEvaluated && ($this->caching == SMARTY_CACHING_LIFETIME_CURRENT || $this->caching == SMARTY_CACHING_LIFETIME_SAVED)) {
|
||||
$this->cache_resource_object = $this->smarty->loadCacheResource();
|
||||
$this->cache_resource_object = $this->smarty->cache->loadResource();
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -1,31 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Smarty method _get_filter_name
|
||||
*
|
||||
* Return internal filter name
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage SmartyMethod
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
|
||||
/**
|
||||
* Return internal filter name
|
||||
*
|
||||
* @param object $smarty
|
||||
* @param callback $function
|
||||
*/
|
||||
function Smarty_Method__get_filter_name($smarty, $function)
|
||||
{
|
||||
if (is_array($function)) {
|
||||
$_class_name = (is_object($function[0]) ?
|
||||
get_class($function[0]) : $function[0]);
|
||||
return $_class_name . '_' . $function[1];
|
||||
}
|
||||
else {
|
||||
return $function;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
@@ -1,27 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Smarty method addPluginsDir
|
||||
*
|
||||
* Adds directory of plugin files
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage SmartyMethod
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
|
||||
/**
|
||||
* Adds directory of plugin files
|
||||
*
|
||||
* @param object $smarty
|
||||
* @param string $ |array $ plugins folder
|
||||
* @return
|
||||
*/
|
||||
function Smarty_Method_AddPluginsDir($smarty, $plugins_dir)
|
||||
{
|
||||
$smarty->plugins_dir = array_merge((array)$smarty->plugins_dir, (array)$plugins_dir);
|
||||
$smarty->plugins_dir = array_unique($smarty->plugins_dir);
|
||||
return;
|
||||
}
|
||||
|
||||
?>
|
@@ -1,29 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Smarty method Clear_All_Assign
|
||||
*
|
||||
* Deletes all assigned Smarty variables at current level
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage SmartyMethod
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
|
||||
/**
|
||||
* Delete Smarty variables
|
||||
*
|
||||
* @param object $smarty
|
||||
* @param object $data_object object which holds tpl_vars
|
||||
*/
|
||||
function Smarty_Method_Clear_All_Assign($smarty, $data_object = null)
|
||||
{
|
||||
if (isset($data_object)) {
|
||||
$ptr = $data_object;
|
||||
} else {
|
||||
$ptr = $smarty;
|
||||
}
|
||||
$ptr->tpl_vars = array();
|
||||
}
|
||||
|
||||
?>
|
@@ -1,29 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Smarty method Clear_All_Cache
|
||||
*
|
||||
* Empties the cache folder
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage SmartyMethod
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
|
||||
/**
|
||||
* Empty cache folder
|
||||
*
|
||||
* @param object $smarty
|
||||
* @param integer $exp_time expiration time
|
||||
* @param string $type resource type
|
||||
* @return integer number of cache files deleted
|
||||
*/
|
||||
function Smarty_Method_Clear_All_Cache($smarty, $exp_time = null, $type = null)
|
||||
{
|
||||
// load cache resource
|
||||
$cacheResource = $smarty->loadCacheResource($type);
|
||||
|
||||
return $cacheResource->clearAll($exp_time);
|
||||
}
|
||||
|
||||
?>
|
@@ -1,37 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Smarty method Clear_Assign
|
||||
*
|
||||
* Deletes a assigned Smarty variable or array of variables at current level
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage SmartyMethod
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
|
||||
/**
|
||||
* Delete a Smarty variable or array of variables
|
||||
*
|
||||
* @param object $smarty
|
||||
* @param string $ |array $varname variable name or array of variable names
|
||||
* @param object $data_object object which holds tpl_vars
|
||||
*/
|
||||
function Smarty_Method_Clear_Assign($smarty, $varname, $data_object = null)
|
||||
{
|
||||
foreach ((array)$varname as $variable) {
|
||||
if (isset($data_object)) {
|
||||
$ptr = $data_object;
|
||||
} else {
|
||||
$ptr = $smarty;
|
||||
} while ($ptr != null) {
|
||||
if (isset($ptr->tpl_vars[$variable])) {
|
||||
unset($ptr->tpl_vars[$variable]);
|
||||
}
|
||||
$ptr = $ptr->parent;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
?>
|
@@ -1,32 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Smarty method Clear_Cache
|
||||
*
|
||||
* Empties the cache for a specific template
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage SmartyMethod
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
|
||||
/**
|
||||
* Empty cache for a specific template
|
||||
*
|
||||
* @param object $smarty
|
||||
* @param string $template_name template name
|
||||
* @param string $cache_id cache id
|
||||
* @param string $compile_id compile id
|
||||
* @param integer $exp_time expiration time
|
||||
* @param string $type resource type
|
||||
* @return integer number of cache files deleted
|
||||
*/
|
||||
function Smarty_Method_Clear_Cache($smarty, $template_name, $cache_id = null, $compile_id = null, $exp_time = null, $type = null)
|
||||
{
|
||||
// load cache resource
|
||||
$cacheResource = $smarty->loadCacheResource($type);
|
||||
|
||||
return $cacheResource->clear($template_name, $cache_id, $compile_id, $exp_time);
|
||||
}
|
||||
|
||||
?>
|
@@ -1,65 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Smarty method Clear_Compiled_Tpl
|
||||
*
|
||||
* Deletes compiled template files
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage SmartyMethod
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
|
||||
/**
|
||||
* Delete compiled template file
|
||||
*
|
||||
* @param string $resource_name template name
|
||||
* @param string $compile_id compile id
|
||||
* @param integer $exp_time expiration time
|
||||
* @return integer number of template files deleted
|
||||
*/
|
||||
function Smarty_Method_Clear_Compiled_Tpl($smarty, $resource_name = null, $compile_id = null, $exp_time = null)
|
||||
{
|
||||
$_compile_id = isset($compile_id) ? preg_replace('![^\w\|]+!','_',$compile_id) : null;
|
||||
$_dir_sep = $smarty->use_sub_dirs ? DS : '^';
|
||||
if (isset($resource_name)) {
|
||||
$_resource_part_1 = $resource_name . '.php';
|
||||
$_resource_part_2 = $resource_name . '.cache' . '.php';
|
||||
} else {
|
||||
$_resource_part = '';
|
||||
}
|
||||
$_dir = $smarty->compile_dir;
|
||||
if ($smarty->use_sub_dirs && isset($_compile_id)) {
|
||||
$_dir .= $_compile_id . $_dir_sep;
|
||||
}
|
||||
if (isset($_compile_id)) {
|
||||
$_compile_id_part = $smarty->compile_dir . $_compile_id . $_dir_sep;
|
||||
}
|
||||
$_count = 0;
|
||||
$_compileDirs = new RecursiveDirectoryIterator($_dir);
|
||||
$_compile = new RecursiveIteratorIterator($_compileDirs, RecursiveIteratorIterator::CHILD_FIRST);
|
||||
foreach ($_compile as $_file) {
|
||||
if (strpos($_file, '.svn') !== false) continue;
|
||||
if ($_file->isDir()) {
|
||||
if (!$_compile->isDot()) {
|
||||
// delete folder if empty
|
||||
@rmdir($_file->getPathname());
|
||||
}
|
||||
} else {
|
||||
if ((!isset($_compile_id) || (strlen((string)$_file) > strlen($_compile_id_part) && substr_compare((string)$_file, $_compile_id_part, 0, strlen($_compile_id_part)) == 0)) &&
|
||||
(!isset($resource_name) || (strlen((string)$_file) > strlen($_resource_part_1) && substr_compare((string)$_file, $_resource_part_1, - strlen($_resource_part_1), strlen($_resource_part_1)) == 0) ||
|
||||
(strlen((string)$_file) > strlen($_resource_part_2) && substr_compare((string)$_file, $_resource_part_2, - strlen($_resource_part_2), strlen($_resource_part_2)) == 0))) {
|
||||
if (isset($exp_time)) {
|
||||
if (time() - @filemtime($_file) >= $exp_time) {
|
||||
$_count += @unlink((string) $_file) ? 1 : 0;
|
||||
}
|
||||
} else {
|
||||
$_count += @unlink((string) $_file) ? 1 : 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return $_count;
|
||||
}
|
||||
|
||||
?>
|
@@ -1,72 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Smarty method compile_dir
|
||||
*
|
||||
* Compiles all template files in an given directory
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage SmartyMethod
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
|
||||
/**
|
||||
* Compile all template files
|
||||
*
|
||||
* @param string $dir_name name of directories
|
||||
* @return integer number of template files deleted
|
||||
*/
|
||||
function Smarty_Method_Compile_Directory($smarty, $extention = '.tpl', $force_compile = false, $time_limit = 0, $max_errors = null)
|
||||
{
|
||||
function _get_time()
|
||||
{
|
||||
$_mtime = microtime();
|
||||
$_mtime = explode(" ", $_mtime);
|
||||
return (double)($_mtime[1]) + (double)($_mtime[0]);
|
||||
}
|
||||
// set default directory
|
||||
if ($dir_name === null) {
|
||||
$dir_name = $smarty->template_dir;
|
||||
}
|
||||
// switch off time limit
|
||||
if (function_exists('set_time_limit')) {
|
||||
@set_time_limit($time_limit);
|
||||
}
|
||||
$smarty->force_compile = $force_compile;
|
||||
$_count = 0;
|
||||
$_error_count = 0;
|
||||
// loop over array of template directories
|
||||
foreach((array)$smarty->template_dir as $_dir) {
|
||||
$_compileDirs = new RecursiveDirectoryIterator($_dir);
|
||||
$_compile = new RecursiveIteratorIterator($_compileDirs);
|
||||
foreach ($_compile as $_fileinfo) {
|
||||
if (strpos($_fileinfo, '.svn') !== false) continue;
|
||||
$_file = $_fileinfo->getFilename();
|
||||
if (!substr_compare($_file, $extention, - strlen($extention)) == 0) continue;
|
||||
if ($_fileinfo->getPath() == substr($_dir, 0, -1)) {
|
||||
$_template_file = $_file;
|
||||
} else {
|
||||
$_template_file = substr($_fileinfo->getPath(), strlen($_dir)) . '\\' . $_file;
|
||||
}
|
||||
echo '<br>', $_dir, '---', $_template_file;
|
||||
flush();
|
||||
$_start_time = _get_time();
|
||||
try {
|
||||
$_tpl = $smarty->createTemplate($_template_file);
|
||||
$_tpl->getCompiledTemplate();
|
||||
}
|
||||
catch (Exception $e) {
|
||||
echo 'Error: ', $e->getMessage(), "<br><br>";
|
||||
$_error_count++;
|
||||
}
|
||||
echo ' done in ', _get_time() - $_start_time, ' seconds';
|
||||
if ($max_errors !== null && $_error_count == $max_errors) {
|
||||
echo '<br><br>too many errors';
|
||||
exit();
|
||||
}
|
||||
}
|
||||
}
|
||||
return $_count;
|
||||
}
|
||||
|
||||
?>
|
@@ -1,23 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Smarty method DisableCacheModifyCheck
|
||||
*
|
||||
* Disable cache modify check
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage SmartyMethod
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* Disable cache modify check
|
||||
*/
|
||||
function Smarty_Method_DisableCacheModifyCheck($smarty)
|
||||
{
|
||||
$smarty->cache_modified_check = false;
|
||||
return ;
|
||||
}
|
||||
|
||||
?>
|
@@ -1,22 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Smarty method DisableCaching
|
||||
*
|
||||
* Disable caching
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage SmartyMethod
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
|
||||
/**
|
||||
* Disable caching
|
||||
*/
|
||||
function Smarty_Method_DisableCaching()
|
||||
{
|
||||
$this->smarty->caching = false;
|
||||
return;
|
||||
}
|
||||
|
||||
?>
|
@@ -1,24 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Smarty method DisableCompileCheck
|
||||
*
|
||||
* Disable compile checking
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage SmartyMethod
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
|
||||
/**
|
||||
* Disable compile checking
|
||||
*
|
||||
* @param object $smarty
|
||||
*/
|
||||
function Smarty_Method_DisableCompileCheck($smarty)
|
||||
{
|
||||
$smarty->compile_check = false;
|
||||
return;
|
||||
}
|
||||
|
||||
?>
|
@@ -1,22 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Smarty method DisableConfigBooleanize
|
||||
*
|
||||
* Disable config booleanize mode
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage SmartyMethod
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
|
||||
/**
|
||||
* Disable config booleanize mode
|
||||
*/
|
||||
function Smarty_Method_DisableConfigBooleanize($smarty)
|
||||
{
|
||||
$this->smarty->config_booleanize = false;
|
||||
return;
|
||||
}
|
||||
|
||||
?>
|
@@ -1,21 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Smarty method DisableConfigOverwrite
|
||||
*
|
||||
* Disable config overwrite mode
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage SmartyMethod
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
|
||||
/**
|
||||
* Disable config overwrite mode
|
||||
*/
|
||||
function Smarty_Method_DisableConfigOverwrite($smarty)
|
||||
{
|
||||
$smarty->config_overwrite = false;
|
||||
return ;
|
||||
}
|
||||
?>
|
@@ -1,21 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Smarty method DisableConfigReadHidden
|
||||
*
|
||||
* Disable config read hidden mode
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage SmartyMethod
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
|
||||
/**
|
||||
* Disable config read hidden mode
|
||||
*/
|
||||
function Smarty_Method_DisableConfigReadHidden ($smarty)
|
||||
{
|
||||
$this->smarty->config_read_hidden = false;
|
||||
return;
|
||||
}
|
||||
?>
|
@@ -1,21 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Smarty method DisableDebugging
|
||||
*
|
||||
* Disable debugging
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage SmartyMethod
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
|
||||
/**
|
||||
* Disable debugging
|
||||
*/
|
||||
function Smarty_Method_DisableDebugging($smarty)
|
||||
{
|
||||
$smarty->debugging = false;
|
||||
return;
|
||||
}
|
||||
?>
|
@@ -1,22 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Smarty method DisableDebuggingUrlCtrl
|
||||
*
|
||||
* Disable possibility to Disable debugging by SMARTY_DEBUG attribute
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage SmartyMethod
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
|
||||
/**
|
||||
* Disable possibility to Disable debugging by SMARTY_DEBUG attribute
|
||||
*/
|
||||
function Smarty_Method_DisableDebuggingUrlCtrl($smarty)
|
||||
{
|
||||
$smarty->debugging_ctrl = 'none';
|
||||
return;
|
||||
}
|
||||
|
||||
?>
|
@@ -1,22 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Smarty method DisableDefaultTimezone
|
||||
*
|
||||
* Disable setting of default timezone
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage SmartyMethod
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
|
||||
/**
|
||||
* Disable setting of default timezone
|
||||
*/
|
||||
function Smarty_Method_DisableDefaultTimezone($smarty)
|
||||
{
|
||||
$smarty->set_timezone = false;
|
||||
return;
|
||||
}
|
||||
|
||||
?>
|
@@ -1,22 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Smarty method DisableForceCompile
|
||||
*
|
||||
* Disable forced compiling
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage SmartyMethod
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
|
||||
/**
|
||||
* Disable forced compiling
|
||||
*/
|
||||
function Smarty_Method_DisableForceCompile($smarty)
|
||||
{
|
||||
$smarty->force_compile = false;
|
||||
return;
|
||||
}
|
||||
|
||||
?>
|
@@ -1,22 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Smarty method DisableVariableFilter
|
||||
*
|
||||
* Disable filter on variable output
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage SmartyMethod
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
|
||||
/**
|
||||
* Disable filter on variable output
|
||||
*/
|
||||
function Smarty_Method_DisableVariableFilter($smarty)
|
||||
{
|
||||
$smarty->variable_filter = false;
|
||||
return;
|
||||
}
|
||||
|
||||
?>
|
@@ -1,22 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Smarty method EnableCacheModifyCheck
|
||||
*
|
||||
* Enable cache modify check
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage SmartyMethod
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
|
||||
/**
|
||||
* Enable cache modify check
|
||||
*/
|
||||
function Smarty_Method_EnableCacheModifyCheck($smarty)
|
||||
{
|
||||
$smarty->cache_modified_check = true;
|
||||
return;
|
||||
}
|
||||
|
||||
?>
|
@@ -1,22 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Smarty method EnableCompileCheck
|
||||
*
|
||||
* Enable compile checking
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage SmartyMethod
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
|
||||
/**
|
||||
* Enable compile checking
|
||||
*/
|
||||
function Smarty_Method_EnableCompileCheck($smarty)
|
||||
{
|
||||
$smarty->compile_check = true;
|
||||
return;
|
||||
}
|
||||
|
||||
?>
|
@@ -1,22 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Smarty method EnableConfigBooleanize
|
||||
*
|
||||
* Enable config booleanize mode
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage SmartyMethod
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
|
||||
/**
|
||||
* Enable config booleanize mode
|
||||
*/
|
||||
function Smarty_Method_EnableConfigBooleanize($smarty)
|
||||
{
|
||||
$smarty->config_booleanize = true;
|
||||
return;
|
||||
}
|
||||
|
||||
?>
|
@@ -1,22 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Smarty method EnableConfigOverwrite
|
||||
*
|
||||
* Enable config overwrite mode
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage SmartyMethod
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
|
||||
/**
|
||||
* Enable config overwrite mode
|
||||
*/
|
||||
function Smarty_Method_EnableConfigOverwrite($smarty)
|
||||
{
|
||||
$smarty->config_overwrite = true;
|
||||
return;
|
||||
}
|
||||
|
||||
?>
|
@@ -1,22 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Smarty method EnableConfigReadHidden
|
||||
*
|
||||
* Enable config read hidden mode
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage SmartyMethod
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
|
||||
/**
|
||||
* Enable config read hidden mode
|
||||
*/
|
||||
function Smarty_Method_EnableConfigReadHidden($smarty)
|
||||
{
|
||||
$this->smarty->config_read_hidden = true;
|
||||
return;
|
||||
}
|
||||
|
||||
?>
|
@@ -1,22 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Smarty method EnableDebugging
|
||||
*
|
||||
* Enable debugging
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage SmartyMethod
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
|
||||
/**
|
||||
* Enable debugging
|
||||
*/
|
||||
function Smarty_Method_EnableDebugging($smarty)
|
||||
{
|
||||
$this->smarty->debugging = true;
|
||||
return;
|
||||
}
|
||||
|
||||
?>
|
@@ -1,22 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Smarty method EnableDebuggingUrlCtrl
|
||||
*
|
||||
* Enable possibility to enable debugging by SMARTY_DEBUG attribute
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage SmartyMethod
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
|
||||
/**
|
||||
* Enable possibility to enable debugging by SMARTY_DEBUG attribute
|
||||
*/
|
||||
function Smarty_Method_EnableDebuggingUrlCtrl($smarty)
|
||||
{
|
||||
$smarty->debugging_ctrl = 'URL';
|
||||
return;
|
||||
}
|
||||
|
||||
?>
|
@@ -1,22 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Smarty method EnableDefaultTimezone
|
||||
*
|
||||
* Enable setting of default timezone
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage SmartyMethod
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
|
||||
/**
|
||||
* Enable setting of default timezone
|
||||
*/
|
||||
function Smarty_Method_EnableDefaultTimezone($smarty)
|
||||
{
|
||||
$this->smarty->set_timezone = true;
|
||||
return;
|
||||
}
|
||||
|
||||
?>
|
@@ -1,22 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Smarty method EnableForceCompile
|
||||
*
|
||||
* Enable forced compiling
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage SmartyMethod
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
|
||||
/**
|
||||
* Enable forced compiling
|
||||
*/
|
||||
function Smarty_Method_EnableForceCompile($smarty)
|
||||
{
|
||||
$smarty->force_compile = true;
|
||||
return;
|
||||
}
|
||||
|
||||
?>
|
@@ -1,22 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Smarty method EnableVariableFilter
|
||||
*
|
||||
* Enable filter on variable output
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage SmartyMethod
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
|
||||
/**
|
||||
* Enable filter on variable output
|
||||
*/
|
||||
function Smarty_Method_EnableVariableFilter($smarty)
|
||||
{
|
||||
$smarty->variable_filter = true;
|
||||
return;
|
||||
}
|
||||
|
||||
?>
|
@@ -1,37 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Smarty method Get_Global
|
||||
*
|
||||
* Returns a single or all global variables
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage SmartyMethod
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
|
||||
/**
|
||||
* Returns a single or all global variables
|
||||
*
|
||||
* @param object $smarty
|
||||
* @param string $varname variable name or null
|
||||
* @return string variable value or or array of variables
|
||||
*/
|
||||
function Smarty_Method_Get_Global($smarty, $varname = null)
|
||||
{
|
||||
if (isset($varname)) {
|
||||
if (isset($smarty->global_tpl_vars[$varname])) {
|
||||
return $smarty->global_tpl_vars[$varname]->value;
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
} else {
|
||||
$_result = array();
|
||||
foreach ($smarty->global_tpl_vars AS $key => $var) {
|
||||
$_result[$key] = $var->value;
|
||||
}
|
||||
return $_result;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
@@ -1,34 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Smarty method Get_Registered_Object
|
||||
*
|
||||
* Registers a PHP object
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage SmartyMethod
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
|
||||
/**
|
||||
* Returns a reference to a registered object
|
||||
*/
|
||||
|
||||
/**
|
||||
* return a reference to a registered object
|
||||
*
|
||||
* @param string $name
|
||||
* @return object
|
||||
*/
|
||||
function Smarty_Method_Get_Registered_Object($smarty, $name)
|
||||
{
|
||||
if (!isset($smarty->registered_objects[$name]))
|
||||
throw new Exception("'$name' is not a registered object");
|
||||
|
||||
if (!is_object($smarty->registered_objects[$name][0]))
|
||||
throw new Exception("registered '$name' is not an object");
|
||||
|
||||
return $smarty->registered_objects[$name][0];
|
||||
}
|
||||
|
||||
?>
|
@@ -1,56 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Smarty method Get_Template_Vars
|
||||
*
|
||||
* Returns a single or all template variables
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage SmartyMethod
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
|
||||
/**
|
||||
* Returns a single or all template variables
|
||||
*/
|
||||
|
||||
/**
|
||||
* Returns a single or all template variables
|
||||
*
|
||||
* @param string $varname variable name or null
|
||||
* @return string variable value or or array of variables
|
||||
*/
|
||||
function Smarty_Method_Get_Template_Vars($smarty, $varname = null, $_ptr = null, $search_parents = true)
|
||||
{
|
||||
if (isset($varname)) {
|
||||
$_var = $smarty->getVariable($varname, $_ptr, $search_parents);
|
||||
if (is_object($_var)) {
|
||||
return $_var->value;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
} else {
|
||||
$_result = array();
|
||||
if ($_ptr === null) {
|
||||
$_ptr = $smarty;
|
||||
} while ($_ptr !== null) {
|
||||
foreach ($_ptr->tpl_vars AS $key => $var) {
|
||||
$_result[$key] = $var->value;
|
||||
}
|
||||
// not found, try at parent
|
||||
if ($search_parents) {
|
||||
$_ptr = $_ptr->parent;
|
||||
} else {
|
||||
$_ptr = null;
|
||||
}
|
||||
}
|
||||
if ($search_parents) {
|
||||
foreach ($smarty->global_tpl_vars AS $key => $var) {
|
||||
$_result[$key] = $var->value;
|
||||
}
|
||||
}
|
||||
return $_result;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
@@ -1,27 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Smarty method GetCacheDir
|
||||
*
|
||||
* Returns directory of cache files
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage SmartyMethod
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
|
||||
/**
|
||||
* Returns directory of cache files
|
||||
*/
|
||||
|
||||
/**
|
||||
* Returns directory of cache files
|
||||
*
|
||||
* @return array cache folder
|
||||
*/
|
||||
function Smarty_Method_GetCacheDir($smarty)
|
||||
{
|
||||
return $this->smarty->cache_dir;
|
||||
}
|
||||
|
||||
?>
|
@@ -1,28 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Smarty method GetCacheLifetime
|
||||
*
|
||||
* Returns lifetime of cache files
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage SmartyMethod
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
|
||||
/**
|
||||
* Smarty class getCacheLifetime
|
||||
*
|
||||
* Returns lifetime of cache files
|
||||
*/
|
||||
/**
|
||||
* Returns lifetime of cache files
|
||||
*
|
||||
* @return integer cache file lifetime
|
||||
*/
|
||||
function Smarty_Method_GetCacheLifetime($smarty)
|
||||
{
|
||||
return $smarty->cache_lifetime;
|
||||
}
|
||||
|
||||
?>
|
@@ -1,27 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Smarty method GetCompileDir
|
||||
*
|
||||
* Returns directory of compiled templates
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage SmartyMethod
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
|
||||
/**
|
||||
* Returns directory of compiled templates
|
||||
*/
|
||||
|
||||
/**
|
||||
* Returns directory of compiled templates
|
||||
*
|
||||
* @return array compiled template folder
|
||||
*/
|
||||
function Smarty_Method_GetCompileDir($smarty)
|
||||
{
|
||||
return $this->smarty->compile_dir;
|
||||
}
|
||||
|
||||
?>
|
@@ -1,27 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Smarty method GetConfigDir
|
||||
*
|
||||
* Returns directory of config files
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage SmartyMethod
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
|
||||
/**
|
||||
* Returns directory of config files
|
||||
*/
|
||||
|
||||
/**
|
||||
* Returns directory of config files
|
||||
*
|
||||
* @return array config folder
|
||||
*/
|
||||
function Smarty_Method_GetConfigDir($smarty)
|
||||
{
|
||||
return $smarty->config_dir;
|
||||
}
|
||||
|
||||
?>
|
@@ -1,27 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Smarty method GetDebugTemplate
|
||||
*
|
||||
* Returns debug template filepath
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage SmartyMethod
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
|
||||
/**
|
||||
* Returns debug template filepath
|
||||
*/
|
||||
|
||||
/**
|
||||
* Returns directory of cache files
|
||||
*
|
||||
* @return string debug template filepath
|
||||
*/
|
||||
function Smarty_Method_GetDebugTemplate($smarty)
|
||||
{
|
||||
return $smarty->debug_tpl;
|
||||
}
|
||||
|
||||
?>
|
@@ -1,27 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Smarty method GetPluginsDir
|
||||
*
|
||||
* Returns directory of plugins
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage SmartyMethod
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
|
||||
/**
|
||||
* Returns directory of plugins
|
||||
*/
|
||||
|
||||
/**
|
||||
* Returns directory of plugins
|
||||
*
|
||||
* @return array plugins folder
|
||||
*/
|
||||
function Smarty_Method_GetPluginsDir($smarty)
|
||||
{
|
||||
return $smarty->plugins_dir;
|
||||
}
|
||||
|
||||
?>
|
@@ -1,27 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Smarty method GetTemplateDir
|
||||
*
|
||||
* Returns template directory
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage SmartyMethod
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
|
||||
/**
|
||||
* Returns template directory
|
||||
*/
|
||||
|
||||
/**
|
||||
* Returns template directory
|
||||
*
|
||||
* @return array template folders
|
||||
*/
|
||||
function Smarty_Method_GetTemplateDir($smarty)
|
||||
{
|
||||
return $smarty->template_dir;
|
||||
}
|
||||
|
||||
?>
|
@@ -1,23 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Smarty method GetVariableFilter
|
||||
*
|
||||
* get status of filter on variable output
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage SmartyMethod
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
|
||||
/**
|
||||
* Smarty class getVariableFilter
|
||||
*
|
||||
* get status of filter on variable output
|
||||
*/
|
||||
function Smarty_Method_GetVariableFilter($smarty)
|
||||
{
|
||||
return $smarty->variable_filter;
|
||||
}
|
||||
|
||||
?>
|
@@ -1,21 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Smarty method IsCacheModifyCheck
|
||||
*
|
||||
* is cache modify check
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage SmartyMethod
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
|
||||
/**
|
||||
* is cache modify check
|
||||
*/
|
||||
function Smarty_Method_IsCacheModifyCheck()
|
||||
{
|
||||
return $smarty->cache_modified_check;
|
||||
}
|
||||
|
||||
?>
|
@@ -1,21 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Smarty method IsCaching
|
||||
*
|
||||
* is caching
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage SmartyMethod
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
|
||||
/**
|
||||
* is caching
|
||||
*/
|
||||
function Smarty_Method_IsCaching($smarty)
|
||||
{
|
||||
return $smarty->caching;
|
||||
}
|
||||
|
||||
?>
|
@@ -1,21 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Smarty method IsCompileCheck
|
||||
*
|
||||
* is compile checking
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage SmartyMethod
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
|
||||
/**
|
||||
* is compile checking
|
||||
*/
|
||||
function Smarty_Method_IsCompileCheck($smarty)
|
||||
{
|
||||
return $smarty->compile_check;
|
||||
}
|
||||
|
||||
?>
|
@@ -1,21 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Smarty method IsConfigBooleanize
|
||||
*
|
||||
* is config booleanize mode
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage SmartyMethod
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
|
||||
/**
|
||||
* is config booleanize mode
|
||||
*/
|
||||
function Smarty_Method_IsConfigBooleanize($smarty)
|
||||
{
|
||||
return $smarty->config_booleanize;
|
||||
}
|
||||
|
||||
?>
|
@@ -1,21 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Smarty method IsConfigOverwrite
|
||||
*
|
||||
* is config overwrite mode
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage SmartyMethod
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
|
||||
/**
|
||||
* is config overwrite mode
|
||||
*/
|
||||
function Smarty_Method_IsConfigOverwrite($smarty)
|
||||
{
|
||||
return $smarty->config_overwrite;
|
||||
}
|
||||
|
||||
?>
|
@@ -1,21 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Smarty method IsConfigReadHidden
|
||||
*
|
||||
* is config read hidden mode
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage SmartyMethod
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* is config read hidden mode
|
||||
*/
|
||||
function Smarty_Method_IsConfigReadHidden($smarty)
|
||||
{
|
||||
return $smarty->config_read_hidden;
|
||||
}
|
||||
?>
|
@@ -1,21 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Smarty method IsDebugging
|
||||
*
|
||||
* is debugging
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage SmartyMethod
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
|
||||
/**
|
||||
* is debugging
|
||||
*/
|
||||
function Smarty_Method_IsDebugging($smarty)
|
||||
{
|
||||
return $smarty->debugging;
|
||||
}
|
||||
|
||||
?>
|
@@ -1,21 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Smarty method IsDebuggingUrlCtrl
|
||||
*
|
||||
* is possibility to is debugging by SMARTY_DEBUG attribute
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage SmartyMethod
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
|
||||
/**
|
||||
* is possibility to is debugging by SMARTY_DEBUG attribute
|
||||
*/
|
||||
function Smarty_Method_IsDebuggingUrlCtrl($smarty)
|
||||
{
|
||||
return $smarty->debugging_ctrl != 'none';
|
||||
}
|
||||
|
||||
?>
|
@@ -1,21 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Smarty method IsDefaultTimezone
|
||||
*
|
||||
* is setting of default timezone
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage SmartyMethod
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
|
||||
/**
|
||||
* is setting of default timezone
|
||||
*/
|
||||
function Smarty_Method_IsDefaultTimezone($smarty)
|
||||
{
|
||||
return $smarty->set_timezone = false;
|
||||
}
|
||||
|
||||
?>
|
@@ -1,23 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Smarty method IsForceCompile
|
||||
*
|
||||
* is forced compiling
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage SmartyMethod
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* is forced compiling
|
||||
*/
|
||||
function Smarty_Method_IsForceCompile($smarty)
|
||||
{
|
||||
return $smarty->force_compile;
|
||||
}
|
||||
|
||||
|
||||
?>
|
@@ -1,35 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Smarty method Load_Filter
|
||||
*
|
||||
* Loads a filter plugin
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage SmartyMethod
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
|
||||
/**
|
||||
* load a filter of specified type and name
|
||||
*
|
||||
* @param string $type filter type
|
||||
* @param string $name filter name
|
||||
*/
|
||||
function Smarty_Method_Load_Filter($smarty, $type, $name)
|
||||
{
|
||||
$_plugin = "smarty_{$type}filter_{$name}";
|
||||
$_filter_name = $_plugin;
|
||||
if ($smarty->loadPlugin($_plugin)) {
|
||||
if (class_exists($_plugin, false)) {
|
||||
$_plugin = array($_plugin, 'execute');
|
||||
}
|
||||
if (is_callable($_plugin)) {
|
||||
$smarty->registered_filters[$type][$_filter_name] = $_plugin;
|
||||
return;
|
||||
}
|
||||
}
|
||||
throw new Exception("{$type}filter \"{$name}\" not callable");
|
||||
}
|
||||
|
||||
?>
|
@@ -1,36 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Smarty method Register_Block
|
||||
*
|
||||
* Registers a PHP function as Smarty block function plugin
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage SmartyMethod
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
|
||||
/**
|
||||
* Register a PHP function as Smarty block function plugin
|
||||
*/
|
||||
|
||||
/**
|
||||
* Registers block function to be used in templates
|
||||
*
|
||||
* @param string $block_tag name of template block
|
||||
* @param string $block_impl PHP function to register
|
||||
* @param boolean $cacheable if true (default) this fuction is cachable
|
||||
*/
|
||||
function Smarty_Method_Register_Block($smarty, $block_tag, $block_impl, $cacheable = true, $cache_attr = array())
|
||||
{
|
||||
if (isset($smarty->registered_plugins['block'][$block_tag])) {
|
||||
throw new Exception("Plugin tag \"{$block_tag}\" already registered");
|
||||
} elseif (!is_callable($block_impl)) {
|
||||
throw new Exception("Plugin \"{$block_tag}\" not callable");
|
||||
} else {
|
||||
$smarty->registered_plugins['block'][$block_tag] =
|
||||
array($block_impl, $cacheable, $cache_attr);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
@@ -1,35 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Smarty method Register_Compiler_Function
|
||||
*
|
||||
* Registers a PHP function as Smarty compiler function plugin
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage SmartyMethod
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
|
||||
/**
|
||||
* Register a PHP function as Smarty compiler function plugin
|
||||
*/
|
||||
|
||||
/**
|
||||
* Registers compiler function
|
||||
*
|
||||
* @param string $compiler_tag of template function
|
||||
* @param string $compiler_impl name of PHP function to register
|
||||
*/
|
||||
function Smarty_Method_Register_Compiler_Function($smarty, $compiler_tag, $compiler_impl, $cacheable = true)
|
||||
{
|
||||
if (isset($smarty->registered_plugins['compiler'][$compiler_tag])) {
|
||||
throw new Exception("Plugin tag \"{$compiler_tag}\" already registered");
|
||||
} elseif (!is_callable($compiler_impl)) {
|
||||
throw new Exception("Plugin \"{$compiler_tag}\" not callable");
|
||||
} else {
|
||||
$smarty->registered_plugins['compiler'][$compiler_tag] =
|
||||
array($compiler_impl, $cacheable);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
@@ -1,33 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Smarty method Register_Function
|
||||
*
|
||||
* Registers a PHP function as Smarty function plugin
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage SmartyMethod
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
|
||||
/**
|
||||
* Registers custom function to be used in templates
|
||||
*
|
||||
* @param object $smarty
|
||||
* @param string $function_tag the name of the template function
|
||||
* @param string $function_impl the name of the PHP function to register
|
||||
* @param boolean $cacheable if true (default) this fuction is cachable
|
||||
*/
|
||||
function Smarty_Method_Register_Function($smarty, $function_tag, $function_impl, $cacheable = true, $cache_attr = array())
|
||||
{
|
||||
if (isset($smarty->registered_plugins['function'][$function_tag])) {
|
||||
throw new Exception("Plugin tag \"{$function_tag}\" already registered");
|
||||
} elseif (!is_callable($function_impl)) {
|
||||
throw new Exception("Plugin \"{$function_tag}\" not callable");
|
||||
} else {
|
||||
$smarty->registered_plugins['function'][$function_tag] =
|
||||
array($function_impl, $cacheable, $cache_attr);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
@@ -1,31 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Smarty method Register_Modifier
|
||||
*
|
||||
* Registers a PHP function as Smarty modifier plugin
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage SmartyMethod
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
|
||||
/**
|
||||
* Registers modifier to be used in templates
|
||||
*
|
||||
* @param object $smarty
|
||||
* @param string $modifier name of template modifier
|
||||
* @param string $modifier_impl name of PHP function to register
|
||||
*/
|
||||
function Smarty_Method_Register_Modifier($smarty, $modifier, $modifier_impl)
|
||||
{
|
||||
if (isset($smarty->registered_plugins['modifier'][$modifier])) {
|
||||
throw new Exception("Plugin \"{$modifier}\" already registered");
|
||||
} elseif (!is_callable($modifier_impl)) {
|
||||
throw new Exception("Plugin \"{$modifier}\" not callable");
|
||||
} else {
|
||||
$smarty->registered_plugins['modifier'][$modifier] =
|
||||
array($modifier_impl);
|
||||
}
|
||||
}
|
||||
?>
|
@@ -1,46 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Smarty method Register_Object
|
||||
*
|
||||
* Registers a PHP object
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage SmartyMethod
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
|
||||
/**
|
||||
* Registers object to be used in templates
|
||||
*
|
||||
* @param object $smarty
|
||||
* @param string $object name of template object
|
||||
* @param object $ &$object_impl the referenced PHP object to register
|
||||
* @param null $ |array $allowed list of allowed methods (empty = all)
|
||||
* @param boolean $smarty_args smarty argument format, else traditional
|
||||
* @param null $ |array $block_functs list of methods that are block format
|
||||
*/
|
||||
function Smarty_Method_Register_Object($smarty, $object, $object_impl, $allowed = array(), $smarty_args = true, $block_methods = array())
|
||||
{
|
||||
// test if allowed methodes callable
|
||||
if (!empty($allowed)) {
|
||||
foreach ((array)$allowed as $methode) {
|
||||
if (!is_callable(array($object_impl, $methode))) {
|
||||
throw new Exception("Undefined methode '$methode' in registered object");
|
||||
}
|
||||
}
|
||||
}
|
||||
// test if block methodes callable
|
||||
if (!empty($block_methods)) {
|
||||
foreach ((array)$block_methods as $methode) {
|
||||
if (!is_callable(array($object_impl, $methode))) {
|
||||
throw new Exception("Undefined methode '$methode' in registered object");
|
||||
}
|
||||
}
|
||||
}
|
||||
// register the object
|
||||
$smarty->registered_objects[$object] =
|
||||
array($object_impl, (array)$allowed, (boolean)$smarty_args, (array)$block_methods);
|
||||
}
|
||||
|
||||
?>
|
@@ -1,25 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Smarty method Register_Outputfilter
|
||||
*
|
||||
* Registers a PHP function as outputfilter
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage SmartyMethod
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
|
||||
/**
|
||||
* Registers an output filter function to apply
|
||||
* to a template output
|
||||
*
|
||||
* @param object $smarty
|
||||
* @param callback $function
|
||||
*/
|
||||
function Smarty_Method_Register_Outputfilter($smarty, $function)
|
||||
{
|
||||
$smarty->registered_filters['output'][$smarty->_get_filter_name($function)] = $function;
|
||||
}
|
||||
|
||||
?>
|
@@ -1,25 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Smarty method Register_Postfilter
|
||||
*
|
||||
* Registers a PHP function as postfilter
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage SmartyMethod
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
|
||||
/**
|
||||
* Registers a postfilter function to apply
|
||||
* to a compiled template after compilation
|
||||
*
|
||||
* @param object $smarty
|
||||
* @param callback $function
|
||||
*/
|
||||
function Smarty_Method_Register_Postfilter($smarty, $function)
|
||||
{
|
||||
$smarty->registered_filters['post'][$smarty->_get_filter_name($function)] = $function;
|
||||
}
|
||||
|
||||
?>
|
@@ -1,25 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Smarty method Register_Prefilter
|
||||
*
|
||||
* Registers a PHP function as prefilter
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage SmartyMethod
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
|
||||
/**
|
||||
* Registers a prefilter function to apply
|
||||
* to a template before compiling
|
||||
*
|
||||
* @param object $smarty
|
||||
* @param callback $function
|
||||
*/
|
||||
function Smarty_Method_Register_Prefilter($smarty, $function)
|
||||
{
|
||||
$smarty->registered_filters['pre'][$smarty->_get_filter_name($function)] = $function;
|
||||
}
|
||||
|
||||
?>
|
@@ -1,33 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Smarty method Register_Resource
|
||||
*
|
||||
* Registers a Smarty template resource
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage SmartyMethod
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
|
||||
/**
|
||||
* Registers a resource to fetch a template
|
||||
*
|
||||
* @param object $smarty
|
||||
* @param string $type name of resource
|
||||
* @param array $functions array of functions to handle resource
|
||||
*/
|
||||
function Smarty_Method_Register_Resource($smarty, $type, $functions)
|
||||
{
|
||||
if (count($functions) == 4) {
|
||||
$smarty->_plugins['resource'][$type] =
|
||||
array($functions, false);
|
||||
} elseif (count($functions) == 5) {
|
||||
$smarty->_plugins['resource'][$type] =
|
||||
array(array(array(&$functions[0], $functions[1]) , array(&$functions[0], $functions[2]) , array(&$functions[0], $functions[3]) , array(&$functions[0], $functions[4])) , false);
|
||||
} else {
|
||||
throw new Exception("malformed function-list for '$type' in register_resource");
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
@@ -1,25 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Smarty method Register_Variablefilter
|
||||
*
|
||||
* Registers a PHP function as an output filter for variables
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage SmartyMethod
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
|
||||
/**
|
||||
* Registers an output filter function which
|
||||
* runs over any variable output
|
||||
*
|
||||
* @param object $smarty
|
||||
* @param callback $function
|
||||
*/
|
||||
function Smarty_Method_Register_Variablefilter($smarty, $function)
|
||||
{
|
||||
$smarty->registered_filters['variable'][$smarty->_get_filter_name($function)] = $function;
|
||||
}
|
||||
|
||||
?>
|
@@ -1,28 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Smarty method RegisterDefaultPluginhandlerHandler
|
||||
*
|
||||
* Registers a default plugin handler
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage SmartyMethod
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
|
||||
/**
|
||||
* Registers a default plugin handler
|
||||
*
|
||||
* @param object $smarty
|
||||
* @param string $ |array $plugin class/methode name
|
||||
*/
|
||||
function Smarty_Method_RegisterDefaultPluginHandler($smarty, $plugin)
|
||||
{
|
||||
if (is_callable($plugin)) {
|
||||
$smarty->default_plugin_handler_func = $plugin;
|
||||
} else {
|
||||
throw new Exception('Default plugin handler "' . $plugin . '" not callable');
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
@@ -1,28 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Smarty method RegisterDefaultTemplateHandler
|
||||
*
|
||||
* Registers a default template handler
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage SmartyMethod
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
|
||||
/**
|
||||
* Registers a default template handler
|
||||
*
|
||||
* @param object $smarty
|
||||
* @param string $ |array $function class/methode name
|
||||
*/
|
||||
function Smarty_Method_RegisterDefaultTemplateHandler($smarty, $function)
|
||||
{
|
||||
if (is_callable($function)) {
|
||||
$smarty->default_template_handler_func = $function;
|
||||
} else {
|
||||
throw new Exception('Default template handler "' . $function . '" not callable');
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
@@ -1,26 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Smarty method SetConfigDir
|
||||
*
|
||||
* Sets directory of config files
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage SmartyMethod
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
|
||||
/**
|
||||
* Sets directory of config files
|
||||
*
|
||||
* @param object $smarty
|
||||
* @param string $ config folder
|
||||
* @return
|
||||
*/
|
||||
function Smarty_Method_SetConfigDir($smarty, $config_dir)
|
||||
{
|
||||
$this->smarty->config_dir = $config_dir;
|
||||
return;
|
||||
}
|
||||
|
||||
?>
|
@@ -1,28 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Smarty method SetDebugTemplate
|
||||
*
|
||||
* Sets debug template filepath
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage SmartyMethod
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
|
||||
/**
|
||||
* Sets debug template filepath
|
||||
*/
|
||||
|
||||
/**
|
||||
* Sets debug template filepath
|
||||
*
|
||||
* @param string $ array debug template filepath
|
||||
*/
|
||||
function Smarty_Method_SetDebugTemplate($smarty, $debug_tpl)
|
||||
{
|
||||
$smarty->debug_tpl = $debug_tpl;
|
||||
return;
|
||||
}
|
||||
|
||||
?>
|
@@ -1,29 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Smarty method SetPluginsDir
|
||||
*
|
||||
* Sets directory of plugin files
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage SmartyMethod
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
|
||||
/**
|
||||
* Sets directory of plugin files
|
||||
*/
|
||||
|
||||
/**
|
||||
* Sets directory of plugin files
|
||||
*
|
||||
* @param string $ plugins folder
|
||||
* @return
|
||||
*/
|
||||
function Smarty_Method_SetPluginsDir($smarty, $plugins_dir)
|
||||
{
|
||||
$smarty->plugins_dir = (array)$plugins_dir;
|
||||
return;
|
||||
}
|
||||
|
||||
?>
|
@@ -1,31 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Smarty method Template_Exists
|
||||
*
|
||||
* Checks if a template resource exists
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage SmartyMethod
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
|
||||
/**
|
||||
* Checks if a template resource exists
|
||||
*/
|
||||
|
||||
/**
|
||||
* Check if a template resource exists
|
||||
*
|
||||
* @param string $resource_name template name
|
||||
* @return boolean status
|
||||
*/
|
||||
function Smarty_Method_Template_Exists($smarty, $resource_name)
|
||||
{
|
||||
// create template object
|
||||
$tpl = new $smarty->template_class($resource_name, $smarty);
|
||||
// check if it does exists
|
||||
return $tpl->isExisting();
|
||||
}
|
||||
|
||||
?>
|
@@ -1,77 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Smarty plugin
|
||||
*
|
||||
* @ignore
|
||||
* @package Smarty
|
||||
* @subpackage plugins
|
||||
*/
|
||||
|
||||
function Smarty_Method_Test($smarty)
|
||||
{
|
||||
echo "<PRE>\n";
|
||||
|
||||
echo "Smarty Installation test...\n";
|
||||
|
||||
echo "Testing template directory...\n";
|
||||
|
||||
foreach((array)$smarty->template_dir as $template_dir) {
|
||||
if (!is_dir($template_dir))
|
||||
echo "FAILED: $template_dir is not a directory.\n";
|
||||
elseif (!is_readable($template_dir))
|
||||
echo "FAILED: $template_dir is not readable.\n";
|
||||
else
|
||||
echo "$template_dir is OK.\n";
|
||||
}
|
||||
|
||||
echo "Testing compile directory...\n";
|
||||
|
||||
if (!is_dir($smarty->compile_dir))
|
||||
echo "FAILED: $smarty->compile_dir is not a directory.\n";
|
||||
elseif (!is_readable($smarty->compile_dir))
|
||||
echo "FAILED: $smarty->compile_dir is not readable.\n";
|
||||
elseif (!is_writable($smarty->compile_dir))
|
||||
echo "FAILED: $smarty->compile_dir is not writable.\n";
|
||||
else
|
||||
echo "{$smarty->compile_dir} is OK.\n";
|
||||
|
||||
echo "Testing plugins directory...\n";
|
||||
|
||||
foreach((array)$smarty->plugins_dir as $plugin_dir) {
|
||||
if (!is_dir($plugin_dir))
|
||||
echo "FAILED: $plugin_dir is not a directory.\n";
|
||||
elseif (!is_readable($plugin_dir))
|
||||
echo "FAILED: $plugin_dir is not readable.\n";
|
||||
else
|
||||
echo "$plugin_dir is OK.\n";
|
||||
}
|
||||
|
||||
echo "Testing cache directory...\n";
|
||||
|
||||
if (!is_dir($smarty->cache_dir))
|
||||
echo "FAILED: $smarty->cache_dir is not a directory.\n";
|
||||
elseif (!is_readable($smarty->cache_dir))
|
||||
echo "FAILED: $smarty->cache_dir is not readable.\n";
|
||||
elseif (!is_writable($smarty->cache_dir))
|
||||
echo "FAILED: $smarty->cache_dir is not writable.\n";
|
||||
else
|
||||
echo "{$smarty->cache_dir} is OK.\n";
|
||||
|
||||
echo "Testing configs directory...\n";
|
||||
|
||||
if (!is_dir($smarty->config_dir))
|
||||
echo "FAILED: $smarty->config_dir is not a directory.\n";
|
||||
elseif (!is_readable($smarty->config_dir))
|
||||
echo "FAILED: $smarty->config_dir is not readable.\n";
|
||||
else
|
||||
echo "{$smarty->config_dir} is OK.\n";
|
||||
|
||||
echo "Tests complete.\n";
|
||||
|
||||
echo "</PRE>\n";
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
?>
|
@@ -1,29 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Smarty method Unregister_Block
|
||||
*
|
||||
* Unregister a Smarty block function plugin
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage SmartyMethod
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
|
||||
/**
|
||||
* Unregister a Smarty block function plugin
|
||||
*/
|
||||
|
||||
/**
|
||||
* Unregisters block function
|
||||
*
|
||||
* @param string $block_tag name of template function
|
||||
*/
|
||||
function Smarty_Method_Unregister_Block($smarty, $block_tag)
|
||||
{
|
||||
if (isset($smarty->registered_plugins['block'][$block_tag])) {
|
||||
unset($smarty->registered_plugins['block'][$block_tag]);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
@@ -1,29 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Smarty method Unregister_Compiler_Function
|
||||
*
|
||||
* Unregister a Smarty compiler function plugin
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage SmartyMethod
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
|
||||
/**
|
||||
* Unregister a Smarty compiler function plugin
|
||||
*/
|
||||
|
||||
/**
|
||||
* Unregisters compiler function
|
||||
*
|
||||
* @param string $compiler_tag name of template function
|
||||
*/
|
||||
function Smarty_Method_Unregister_Compiler_Function($smarty, $compiler_tag)
|
||||
{
|
||||
if (isset($smarty->registered_plugins['compiler'][$compiler_tag])) {
|
||||
unset($smarty->registered_plugins['compiler'][$compiler_tag]);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
@@ -1,29 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Smarty method Unregister_Function
|
||||
*
|
||||
* Unregister a Smarty function plugin
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage SmartyMethod
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
|
||||
/**
|
||||
* Unregister a Smarty function plugin
|
||||
*/
|
||||
|
||||
/**
|
||||
* Unregisters custom function
|
||||
*
|
||||
* @param string $function_tag name of template function
|
||||
*/
|
||||
function Smarty_Method_Unregister_Function($smarty, $function_tag)
|
||||
{
|
||||
if (isset($smarty->registered_plugins['function'][$function_tag])) {
|
||||
unset($smarty->registered_plugins['function'][$function_tag]);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
@@ -1,29 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Smarty method Unregister_Modifier
|
||||
*
|
||||
* Unregister a Smarty modifier plugin
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage SmartyMethod
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
|
||||
/**
|
||||
* Unregister a Smarty modifier plugin
|
||||
*/
|
||||
|
||||
/**
|
||||
* Unregisters modifier
|
||||
*
|
||||
* @param string $modifier name of template modifier
|
||||
*/
|
||||
function Smarty_Method_Unregister_Modifier($smarty, $modifier)
|
||||
{
|
||||
if (isset($smarty->registered_plugins['modifier'][$modifier])) {
|
||||
unset($smarty->registered_plugins['modifier'][$modifier]);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
@@ -1,28 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Smarty method Unregister_Object
|
||||
*
|
||||
* Unregister a PHP object
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage SmartyMethod
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* Unregister a PHP object
|
||||
*/
|
||||
|
||||
/**
|
||||
* Unregisters object
|
||||
*
|
||||
* @param string $object name of template object
|
||||
*/
|
||||
function Smarty_Method_Unregister_Object($smarty, $object)
|
||||
{
|
||||
unset($smarty->registered_objects[$object]);
|
||||
}
|
||||
|
||||
?>
|
@@ -1,28 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Smarty method Unregister_Outputfilter
|
||||
*
|
||||
* Unregister a outputfilter
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage SmartyMethod
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
|
||||
/**
|
||||
* Unregister a outputfilter
|
||||
*/
|
||||
|
||||
/**
|
||||
* Registers an output filter function to apply
|
||||
* to a template output
|
||||
*
|
||||
* @param callback $function
|
||||
*/
|
||||
function Smarty_Method_Unregister_Outputfilter($smarty, $function)
|
||||
{
|
||||
unset($smarty->registered_filters['output'][$smarty->_get_filter_name($function)]);
|
||||
}
|
||||
|
||||
?>
|
@@ -1,27 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Smarty method Unregister_Postfilter
|
||||
*
|
||||
* Unregister a postfilter
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage SmartyMethod
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
|
||||
/**
|
||||
* Unregister a postfilter
|
||||
*/
|
||||
|
||||
/**
|
||||
* Unregisters a postfilter function
|
||||
*
|
||||
* @param callback $function
|
||||
*/
|
||||
function Smarty_Method_Unregister_Postfilter($smarty, $function)
|
||||
{
|
||||
unset($smarty->registered_filters['post'][$smarty->_get_filter_name($function)]);
|
||||
}
|
||||
|
||||
?>
|
@@ -1,27 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Smarty method Unregister_Prefilter
|
||||
*
|
||||
* Unregister a prefilter
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage SmartyMethod
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
|
||||
/**
|
||||
* Unregister a prefilter
|
||||
*/
|
||||
|
||||
/**
|
||||
* Unregisters a prefilter function
|
||||
*
|
||||
* @param callback $function
|
||||
*/
|
||||
function Smarty_Method_Unregister_Prefilter($smarty, $function)
|
||||
{
|
||||
unset($smarty->registered_filters['pre'][$smarty->_get_filter_name($function)]);
|
||||
}
|
||||
|
||||
?>
|
@@ -1,27 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Smarty method Unregister_Resource
|
||||
*
|
||||
* Unregister a template resource
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage SmartyMethod
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
|
||||
/**
|
||||
* Unregister a template resource
|
||||
*/
|
||||
|
||||
/**
|
||||
* Unregisters a resource
|
||||
*
|
||||
* @param string $type name of resource
|
||||
*/
|
||||
function Smarty_Method_Unregister_Resource($smarty, $type)
|
||||
{
|
||||
unset($smarty->plugins['resource'][$type]);
|
||||
}
|
||||
|
||||
?>
|
@@ -1,27 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Smarty method Unregister_Variablefilter
|
||||
*
|
||||
* Unregister a variablefilter
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage SmartyMethod
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
|
||||
/**
|
||||
* Unregister a variablefilter
|
||||
*/
|
||||
|
||||
/**
|
||||
* Unregisters a variablefilter function
|
||||
*
|
||||
* @param callback $function
|
||||
*/
|
||||
function Smarty_Method_Unregister_Variablefilter($smarty, $function)
|
||||
{
|
||||
unset($smarty->registered_filters['variable'][$smarty->_get_filter_name($function)]);
|
||||
}
|
||||
|
||||
?>
|
Reference in New Issue
Block a user