mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-04 18:34:27 +02:00
Update PSR-2
This commit is contained in:
@@ -2,7 +2,9 @@
|
|||||||
"name": "smarty/smarty",
|
"name": "smarty/smarty",
|
||||||
"type": "library",
|
"type": "library",
|
||||||
"description": "Smarty - the compiling PHP template engine",
|
"description": "Smarty - the compiling PHP template engine",
|
||||||
"keywords": ["templating"],
|
"keywords": [
|
||||||
|
"templating"
|
||||||
|
],
|
||||||
"homepage": "http://www.smarty.net",
|
"homepage": "http://www.smarty.net",
|
||||||
"license": "LGPL-3.0",
|
"license": "LGPL-3.0",
|
||||||
"authors": [
|
"authors": [
|
||||||
@@ -28,12 +30,13 @@
|
|||||||
"php": ">=5.2"
|
"php": ">=5.2"
|
||||||
},
|
},
|
||||||
"autoload": {
|
"autoload": {
|
||||||
"files": ["libs/bootstrap.php"]
|
"files": [
|
||||||
|
"libs/bootstrap.php"
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"extra": {
|
"extra": {
|
||||||
"branch-alias": {
|
"branch-alias": {
|
||||||
"dev-master": "3.1.x-dev"
|
"dev-master": "3.1.x-dev"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
|
@@ -17,11 +17,15 @@ $smarty->cache_lifetime = 120;
|
|||||||
$smarty->assign("Name", "Fred Irving Johnathan Bradley Peppergill", true);
|
$smarty->assign("Name", "Fred Irving Johnathan Bradley Peppergill", true);
|
||||||
$smarty->assign("FirstName", array("John", "Mary", "James", "Henry"));
|
$smarty->assign("FirstName", array("John", "Mary", "James", "Henry"));
|
||||||
$smarty->assign("LastName", array("Doe", "Smith", "Johnson", "Case"));
|
$smarty->assign("LastName", array("Doe", "Smith", "Johnson", "Case"));
|
||||||
$smarty->assign("Class", array(array("A", "B", "C", "D"), array("E", "F", "G", "H"), array("I", "J", "K", "L"),
|
$smarty->assign(
|
||||||
array("M", "N", "O", "P")));
|
"Class", array(array("A", "B", "C", "D"), array("E", "F", "G", "H"), array("I", "J", "K", "L"),
|
||||||
|
array("M", "N", "O", "P"))
|
||||||
|
);
|
||||||
|
|
||||||
$smarty->assign("contacts", array(array("phone" => "1", "fax" => "2", "cell" => "3"),
|
$smarty->assign(
|
||||||
array("phone" => "555-4444", "fax" => "555-3333", "cell" => "760-1234")));
|
"contacts", array(array("phone" => "1", "fax" => "2", "cell" => "3"),
|
||||||
|
array("phone" => "555-4444", "fax" => "555-3333", "cell" => "760-1234"))
|
||||||
|
);
|
||||||
|
|
||||||
$smarty->assign("option_values", array("NY", "NE", "KS", "IA", "OK", "TX"));
|
$smarty->assign("option_values", array("NY", "NE", "KS", "IA", "OK", "TX"));
|
||||||
$smarty->assign("option_output", array("New York", "Nebraska", "Kansas", "Iowa", "Oklahoma", "Texas"));
|
$smarty->assign("option_output", array("New York", "Nebraska", "Kansas", "Iowa", "Oklahoma", "Texas"));
|
||||||
|
@@ -22,7 +22,7 @@ class Smarty_CacheResource_Apc extends Smarty_CacheResource_KeyValueStore
|
|||||||
/**
|
/**
|
||||||
* Read values for a set of keys from cache
|
* Read values for a set of keys from cache
|
||||||
*
|
*
|
||||||
* @param array $keys list of keys to fetch
|
* @param array $keys list of keys to fetch
|
||||||
*
|
*
|
||||||
* @return array list of values with the given keys used as indexes
|
* @return array list of values with the given keys used as indexes
|
||||||
* @return boolean true on success, false on failure
|
* @return boolean true on success, false on failure
|
||||||
@@ -41,8 +41,8 @@ class Smarty_CacheResource_Apc extends Smarty_CacheResource_KeyValueStore
|
|||||||
/**
|
/**
|
||||||
* Save values for a set of keys to cache
|
* Save values for a set of keys to cache
|
||||||
*
|
*
|
||||||
* @param array $keys list of values to save
|
* @param array $keys list of values to save
|
||||||
* @param int $expire expiration time
|
* @param int $expire expiration time
|
||||||
*
|
*
|
||||||
* @return boolean true on success, false on failure
|
* @return boolean true on success, false on failure
|
||||||
*/
|
*/
|
||||||
@@ -58,7 +58,7 @@ class Smarty_CacheResource_Apc extends Smarty_CacheResource_KeyValueStore
|
|||||||
/**
|
/**
|
||||||
* Remove values from cache
|
* Remove values from cache
|
||||||
*
|
*
|
||||||
* @param array $keys list of keys to delete
|
* @param array $keys list of keys to delete
|
||||||
*
|
*
|
||||||
* @return boolean true on success, false on failure
|
* @return boolean true on success, false on failure
|
||||||
*/
|
*/
|
||||||
|
@@ -32,7 +32,7 @@ class Smarty_CacheResource_Memcache extends Smarty_CacheResource_KeyValueStore
|
|||||||
/**
|
/**
|
||||||
* Read values for a set of keys from cache
|
* Read values for a set of keys from cache
|
||||||
*
|
*
|
||||||
* @param array $keys list of keys to fetch
|
* @param array $keys list of keys to fetch
|
||||||
*
|
*
|
||||||
* @return array list of values with the given keys used as indexes
|
* @return array list of values with the given keys used as indexes
|
||||||
* @return boolean true on success, false on failure
|
* @return boolean true on success, false on failure
|
||||||
@@ -57,8 +57,8 @@ class Smarty_CacheResource_Memcache extends Smarty_CacheResource_KeyValueStore
|
|||||||
/**
|
/**
|
||||||
* Save values for a set of keys to cache
|
* Save values for a set of keys to cache
|
||||||
*
|
*
|
||||||
* @param array $keys list of values to save
|
* @param array $keys list of values to save
|
||||||
* @param int $expire expiration time
|
* @param int $expire expiration time
|
||||||
*
|
*
|
||||||
* @return boolean true on success, false on failure
|
* @return boolean true on success, false on failure
|
||||||
*/
|
*/
|
||||||
@@ -75,7 +75,7 @@ class Smarty_CacheResource_Memcache extends Smarty_CacheResource_KeyValueStore
|
|||||||
/**
|
/**
|
||||||
* Remove values from cache
|
* Remove values from cache
|
||||||
*
|
*
|
||||||
* @param array $keys list of keys to delete
|
* @param array $keys list of keys to delete
|
||||||
*
|
*
|
||||||
* @return boolean true on success, false on failure
|
* @return boolean true on success, false on failure
|
||||||
*/
|
*/
|
||||||
|
@@ -43,19 +43,21 @@ class Smarty_CacheResource_Mysql extends Smarty_CacheResource_Custom
|
|||||||
}
|
}
|
||||||
$this->fetch = $this->db->prepare('SELECT modified, content FROM output_cache WHERE id = :id');
|
$this->fetch = $this->db->prepare('SELECT modified, content FROM output_cache WHERE id = :id');
|
||||||
$this->fetchTimestamp = $this->db->prepare('SELECT modified FROM output_cache WHERE id = :id');
|
$this->fetchTimestamp = $this->db->prepare('SELECT modified FROM output_cache WHERE id = :id');
|
||||||
$this->save = $this->db->prepare('REPLACE INTO output_cache (id, name, cache_id, compile_id, content)
|
$this->save = $this->db->prepare(
|
||||||
VALUES (:id, :name, :cache_id, :compile_id, :content)');
|
'REPLACE INTO output_cache (id, name, cache_id, compile_id, content)
|
||||||
|
VALUES (:id, :name, :cache_id, :compile_id, :content)'
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* fetch cached content and its modification time from data source
|
* fetch cached content and its modification time from data source
|
||||||
*
|
*
|
||||||
* @param string $id unique cache content identifier
|
* @param string $id unique cache content identifier
|
||||||
* @param string $name template name
|
* @param string $name template name
|
||||||
* @param string $cache_id cache id
|
* @param string $cache_id cache id
|
||||||
* @param string $compile_id compile id
|
* @param string $compile_id compile id
|
||||||
* @param string $content cached content
|
* @param string $content cached content
|
||||||
* @param integer $mtime cache modification timestamp (epoch)
|
* @param integer $mtime cache modification timestamp (epoch)
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
@@ -78,10 +80,10 @@ class Smarty_CacheResource_Mysql extends Smarty_CacheResource_Custom
|
|||||||
*
|
*
|
||||||
* @note implementing this method is optional. Only implement it if modification times can be accessed faster than loading the complete cached content.
|
* @note implementing this method is optional. Only implement it if modification times can be accessed faster than loading the complete cached content.
|
||||||
*
|
*
|
||||||
* @param string $id unique cache content identifier
|
* @param string $id unique cache content identifier
|
||||||
* @param string $name template name
|
* @param string $name template name
|
||||||
* @param string $cache_id cache id
|
* @param string $cache_id cache id
|
||||||
* @param string $compile_id compile id
|
* @param string $compile_id compile id
|
||||||
*
|
*
|
||||||
* @return integer|boolean timestamp (epoch) the template was modified, or false if not found
|
* @return integer|boolean timestamp (epoch) the template was modified, or false if not found
|
||||||
*/
|
*/
|
||||||
@@ -97,19 +99,21 @@ class Smarty_CacheResource_Mysql extends Smarty_CacheResource_Custom
|
|||||||
/**
|
/**
|
||||||
* Save content to cache
|
* Save content to cache
|
||||||
*
|
*
|
||||||
* @param string $id unique cache content identifier
|
* @param string $id unique cache content identifier
|
||||||
* @param string $name template name
|
* @param string $name template name
|
||||||
* @param string $cache_id cache id
|
* @param string $cache_id cache id
|
||||||
* @param string $compile_id compile id
|
* @param string $compile_id compile id
|
||||||
* @param integer|null $exp_time seconds till expiration time in seconds or null
|
* @param integer|null $exp_time seconds till expiration time in seconds or null
|
||||||
* @param string $content content to cache
|
* @param string $content content to cache
|
||||||
*
|
*
|
||||||
* @return boolean success
|
* @return boolean success
|
||||||
*/
|
*/
|
||||||
protected function save($id, $name, $cache_id, $compile_id, $exp_time, $content)
|
protected function save($id, $name, $cache_id, $compile_id, $exp_time, $content)
|
||||||
{
|
{
|
||||||
$this->save->execute(array('id' => $id, 'name' => $name, 'cache_id' => $cache_id, 'compile_id' => $compile_id,
|
$this->save->execute(
|
||||||
'content' => $content,));
|
array('id' => $id, 'name' => $name, 'cache_id' => $cache_id, 'compile_id' => $compile_id,
|
||||||
|
'content' => $content,)
|
||||||
|
);
|
||||||
|
|
||||||
return !!$this->save->rowCount();
|
return !!$this->save->rowCount();
|
||||||
}
|
}
|
||||||
@@ -117,10 +121,10 @@ class Smarty_CacheResource_Mysql extends Smarty_CacheResource_Custom
|
|||||||
/**
|
/**
|
||||||
* Delete content from cache
|
* Delete content from cache
|
||||||
*
|
*
|
||||||
* @param string $name template name
|
* @param string $name template name
|
||||||
* @param string $cache_id cache id
|
* @param string $cache_id cache id
|
||||||
* @param string $compile_id compile id
|
* @param string $compile_id compile id
|
||||||
* @param integer|null $exp_time seconds till expiration or null
|
* @param integer|null $exp_time seconds till expiration or null
|
||||||
*
|
*
|
||||||
* @return integer number of deleted caches
|
* @return integer number of deleted caches
|
||||||
*/
|
*/
|
||||||
|
@@ -165,12 +165,12 @@ class Smarty_CacheResource_Pdo extends Smarty_CacheResource_Custom
|
|||||||
/**
|
/**
|
||||||
* fetch cached content and its modification time from data source
|
* fetch cached content and its modification time from data source
|
||||||
*
|
*
|
||||||
* @param string $id unique cache content identifier
|
* @param string $id unique cache content identifier
|
||||||
* @param string $name template name
|
* @param string $name template name
|
||||||
* @param string|null $cache_id cache id
|
* @param string|null $cache_id cache id
|
||||||
* @param string|null $compile_id compile id
|
* @param string|null $compile_id compile id
|
||||||
* @param string $content cached content
|
* @param string $content cached content
|
||||||
* @param integer $mtime cache modification timestamp (epoch)
|
* @param integer $mtime cache modification timestamp (epoch)
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
* @access protected
|
* @access protected
|
||||||
@@ -197,10 +197,10 @@ class Smarty_CacheResource_Pdo extends Smarty_CacheResource_Custom
|
|||||||
* {@internal implementing this method is optional.
|
* {@internal implementing this method is optional.
|
||||||
* Only implement it if modification times can be accessed faster than loading the complete cached content.}}
|
* Only implement it if modification times can be accessed faster than loading the complete cached content.}}
|
||||||
*
|
*
|
||||||
* @param string $id unique cache content identifier
|
* @param string $id unique cache content identifier
|
||||||
* @param string $name template name
|
* @param string $name template name
|
||||||
* @param string|null $cache_id cache id
|
* @param string|null $cache_id cache id
|
||||||
* @param string|null $compile_id compile id
|
* @param string|null $compile_id compile id
|
||||||
*
|
*
|
||||||
* @return integer|boolean timestamp (epoch) the template was modified, or false if not found
|
* @return integer|boolean timestamp (epoch) the template was modified, or false if not found
|
||||||
* @access protected
|
* @access protected
|
||||||
@@ -269,10 +269,10 @@ class Smarty_CacheResource_Pdo extends Smarty_CacheResource_Custom
|
|||||||
/**
|
/**
|
||||||
* Delete content from cache
|
* Delete content from cache
|
||||||
*
|
*
|
||||||
* @param string|null $name template name
|
* @param string|null $name template name
|
||||||
* @param string|null $cache_id cache id
|
* @param string|null $cache_id cache id
|
||||||
* @param string|null $compile_id compile id
|
* @param string|null $compile_id compile id
|
||||||
* @param integer|null|-1 $exp_time seconds till expiration or null
|
* @param integer|null|-1 $exp_time seconds till expiration or null
|
||||||
*
|
*
|
||||||
* @return integer number of deleted caches
|
* @return integer number of deleted caches
|
||||||
* @access protected
|
* @access protected
|
||||||
@@ -324,4 +324,4 @@ class Smarty_CacheResource_Pdo extends Smarty_CacheResource_Custom
|
|||||||
return (is_null($this->database)) ? "`{$this->table}`" : "`{$this->database}`.`{$this->table}`";
|
return (is_null($this->database)) ? "`{$this->table}`" : "`{$this->database}`.`{$this->table}`";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -40,4 +40,4 @@ class Smarty_CacheResource_Pdo_Gzip extends Smarty_CacheResource_Pdo
|
|||||||
return gzinflate($content);
|
return gzinflate($content);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -13,8 +13,8 @@ class Smarty_Resource_Extendsall extends Smarty_Internal_Resource_Extends
|
|||||||
/**
|
/**
|
||||||
* populate Source Object with meta data from Resource
|
* populate Source Object with meta data from Resource
|
||||||
*
|
*
|
||||||
* @param Smarty_Template_Source $source source object
|
* @param Smarty_Template_Source $source source object
|
||||||
* @param Smarty_Internal_Template $_template template object
|
* @param Smarty_Internal_Template $_template template object
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
|
@@ -43,9 +43,9 @@ class Smarty_Resource_Mysql extends Smarty_Resource_Custom
|
|||||||
/**
|
/**
|
||||||
* Fetch a template and its modification time from database
|
* Fetch a template and its modification time from database
|
||||||
*
|
*
|
||||||
* @param string $name template name
|
* @param string $name template name
|
||||||
* @param string $source template source
|
* @param string $source template source
|
||||||
* @param integer $mtime template modification timestamp (epoch)
|
* @param integer $mtime template modification timestamp (epoch)
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
@@ -68,7 +68,7 @@ class Smarty_Resource_Mysql extends Smarty_Resource_Custom
|
|||||||
*
|
*
|
||||||
* @note implementing this method is optional. Only implement it if modification times can be accessed faster than loading the comple template source.
|
* @note implementing this method is optional. Only implement it if modification times can be accessed faster than loading the comple template source.
|
||||||
*
|
*
|
||||||
* @param string $name template name
|
* @param string $name template name
|
||||||
*
|
*
|
||||||
* @return integer timestamp (epoch) the template was modified
|
* @return integer timestamp (epoch) the template was modified
|
||||||
*/
|
*/
|
||||||
|
@@ -41,9 +41,9 @@ class Smarty_Resource_Mysqls extends Smarty_Resource_Custom
|
|||||||
/**
|
/**
|
||||||
* Fetch a template and its modification time from database
|
* Fetch a template and its modification time from database
|
||||||
*
|
*
|
||||||
* @param string $name template name
|
* @param string $name template name
|
||||||
* @param string $source template source
|
* @param string $source template source
|
||||||
* @param integer $mtime template modification timestamp (epoch)
|
* @param integer $mtime template modification timestamp (epoch)
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
|
@@ -2,14 +2,14 @@
|
|||||||
/**
|
/**
|
||||||
* Smarty Autoloader
|
* Smarty Autoloader
|
||||||
*
|
*
|
||||||
* @package Smarty
|
* @package Smarty
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Smarty Autoloader
|
* Smarty Autoloader
|
||||||
*
|
*
|
||||||
* @package Smarty
|
* @package Smarty
|
||||||
* @author Uwe Tews
|
* @author Uwe Tews
|
||||||
* Usage:
|
* Usage:
|
||||||
* require_once '...path/Autoloader.php';
|
* require_once '...path/Autoloader.php';
|
||||||
* Smarty_Autoloader::register();
|
* Smarty_Autoloader::register();
|
||||||
@@ -20,7 +20,7 @@
|
|||||||
*/
|
*/
|
||||||
class Smarty_Autoloader
|
class Smarty_Autoloader
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Filepath to Smarty root
|
* Filepath to Smarty root
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
@@ -54,8 +54,8 @@ class Smarty_Autoloader
|
|||||||
if (!defined('SMARTY_SPL_AUTOLOAD')) {
|
if (!defined('SMARTY_SPL_AUTOLOAD')) {
|
||||||
define('SMARTY_SPL_AUTOLOAD', 0);
|
define('SMARTY_SPL_AUTOLOAD', 0);
|
||||||
}
|
}
|
||||||
if (SMARTY_SPL_AUTOLOAD &&
|
if (SMARTY_SPL_AUTOLOAD
|
||||||
set_include_path(get_include_path() . PATH_SEPARATOR . SMARTY_SYSPLUGINS_DIR) !== false
|
&& set_include_path(get_include_path() . PATH_SEPARATOR . SMARTY_SYSPLUGINS_DIR) !== false
|
||||||
) {
|
) {
|
||||||
$registeredAutoLoadFunctions = spl_autoload_functions();
|
$registeredAutoLoadFunctions = spl_autoload_functions();
|
||||||
if (!isset($registeredAutoLoadFunctions[ 'spl_autoload' ])) {
|
if (!isset($registeredAutoLoadFunctions[ 'spl_autoload' ])) {
|
||||||
|
@@ -276,10 +276,10 @@ class Smarty extends Smarty_Internal_TemplateBase
|
|||||||
*/
|
*/
|
||||||
public $force_compile = false;
|
public $force_compile = false;
|
||||||
/**
|
/**
|
||||||
* use sub dirs for compiled/cached files?
|
* use sub dirs for compiled/cached files?
|
||||||
*
|
*
|
||||||
* @var boolean
|
* @var boolean
|
||||||
*/
|
*/
|
||||||
public $use_sub_dirs = false;
|
public $use_sub_dirs = false;
|
||||||
/**
|
/**
|
||||||
* allow ambiguous resources (that are made unique by the resource handler)
|
* allow ambiguous resources (that are made unique by the resource handler)
|
||||||
@@ -618,7 +618,7 @@ class Smarty extends Smarty_Internal_TemplateBase
|
|||||||
/**
|
/**
|
||||||
* Enable error handler to mute expected messages
|
* Enable error handler to mute expected messages
|
||||||
*
|
*
|
||||||
* @return boolean
|
* @return boolean
|
||||||
* @deprecated
|
* @deprecated
|
||||||
*/
|
*/
|
||||||
public static function muteExpectedErrors()
|
public static function muteExpectedErrors()
|
||||||
@@ -639,7 +639,7 @@ class Smarty extends Smarty_Internal_TemplateBase
|
|||||||
/**
|
/**
|
||||||
* Check if a template resource exists
|
* Check if a template resource exists
|
||||||
*
|
*
|
||||||
* @param string $resource_name template name
|
* @param string $resource_name template name
|
||||||
*
|
*
|
||||||
* @return bool status
|
* @return bool status
|
||||||
* @throws \SmartyException
|
* @throws \SmartyException
|
||||||
@@ -654,7 +654,7 @@ class Smarty extends Smarty_Internal_TemplateBase
|
|||||||
/**
|
/**
|
||||||
* Loads security class and enables security
|
* Loads security class and enables security
|
||||||
*
|
*
|
||||||
* @param string|Smarty_Security $security_class if a string is used, it must be class-name
|
* @param string|Smarty_Security $security_class if a string is used, it must be class-name
|
||||||
*
|
*
|
||||||
* @return Smarty current Smarty instance for chaining
|
* @return Smarty current Smarty instance for chaining
|
||||||
* @throws SmartyException when an invalid class name is provided
|
* @throws SmartyException when an invalid class name is provided
|
||||||
@@ -679,9 +679,9 @@ class Smarty extends Smarty_Internal_TemplateBase
|
|||||||
/**
|
/**
|
||||||
* Add template directory(s)
|
* Add template directory(s)
|
||||||
*
|
*
|
||||||
* @param string|array $template_dir directory(s) of template sources
|
* @param string|array $template_dir directory(s) of template sources
|
||||||
* @param string $key of the array element to assign the template dir to
|
* @param string $key of the array element to assign the template dir to
|
||||||
* @param bool $isConfig true for config_dir
|
* @param bool $isConfig true for config_dir
|
||||||
*
|
*
|
||||||
* @return Smarty current Smarty instance for chaining
|
* @return Smarty current Smarty instance for chaining
|
||||||
*/
|
*/
|
||||||
@@ -747,8 +747,8 @@ class Smarty extends Smarty_Internal_TemplateBase
|
|||||||
/**
|
/**
|
||||||
* Set template directory
|
* Set template directory
|
||||||
*
|
*
|
||||||
* @param string|array $template_dir directory(s) of template sources
|
* @param string|array $template_dir directory(s) of template sources
|
||||||
* @param bool $isConfig true for config_dir
|
* @param bool $isConfig true for config_dir
|
||||||
*
|
*
|
||||||
* @return \Smarty current Smarty instance for chaining
|
* @return \Smarty current Smarty instance for chaining
|
||||||
*/
|
*/
|
||||||
@@ -846,7 +846,7 @@ class Smarty extends Smarty_Internal_TemplateBase
|
|||||||
/**
|
/**
|
||||||
* Set plugins directory
|
* Set plugins directory
|
||||||
*
|
*
|
||||||
* @param string|array $plugins_dir directory(s) of plugins
|
* @param string|array $plugins_dir directory(s) of plugins
|
||||||
*
|
*
|
||||||
* @return Smarty current Smarty instance for chaining
|
* @return Smarty current Smarty instance for chaining
|
||||||
*/
|
*/
|
||||||
@@ -901,7 +901,7 @@ class Smarty extends Smarty_Internal_TemplateBase
|
|||||||
/**
|
/**
|
||||||
* Set cache directory
|
* Set cache directory
|
||||||
*
|
*
|
||||||
* @param string $cache_dir directory to store cached templates in
|
* @param string $cache_dir directory to store cached templates in
|
||||||
*
|
*
|
||||||
* @return Smarty current Smarty instance for chaining
|
* @return Smarty current Smarty instance for chaining
|
||||||
*/
|
*/
|
||||||
@@ -915,11 +915,11 @@ class Smarty extends Smarty_Internal_TemplateBase
|
|||||||
/**
|
/**
|
||||||
* creates a template object
|
* creates a template object
|
||||||
*
|
*
|
||||||
* @param string $template the resource handle of the template file
|
* @param string $template the resource handle of the template file
|
||||||
* @param mixed $cache_id cache id to be used with this template
|
* @param mixed $cache_id cache id to be used with this template
|
||||||
* @param mixed $compile_id compile id to be used with this template
|
* @param mixed $compile_id compile id to be used with this template
|
||||||
* @param object $parent next higher level of Smarty variables
|
* @param object $parent next higher level of Smarty variables
|
||||||
* @param boolean $do_clone flag is Smarty object shall be cloned
|
* @param boolean $do_clone flag is Smarty object shall be cloned
|
||||||
*
|
*
|
||||||
* @return \Smarty_Internal_Template template object
|
* @return \Smarty_Internal_Template template object
|
||||||
* @throws \SmartyException
|
* @throws \SmartyException
|
||||||
@@ -981,8 +981,8 @@ class Smarty extends Smarty_Internal_TemplateBase
|
|||||||
* class name format: Smarty_PluginType_PluginName
|
* class name format: Smarty_PluginType_PluginName
|
||||||
* plugin filename format: plugintype.pluginname.php
|
* plugin filename format: plugintype.pluginname.php
|
||||||
*
|
*
|
||||||
* @param string $plugin_name class plugin name to load
|
* @param string $plugin_name class plugin name to load
|
||||||
* @param bool $check check if already loaded
|
* @param bool $check check if already loaded
|
||||||
*
|
*
|
||||||
* @throws SmartyException
|
* @throws SmartyException
|
||||||
* @return string |boolean filepath of loaded file or false
|
* @return string |boolean filepath of loaded file or false
|
||||||
@@ -1005,11 +1005,11 @@ class Smarty extends Smarty_Internal_TemplateBase
|
|||||||
* @throws \SmartyException
|
* @throws \SmartyException
|
||||||
*/
|
*/
|
||||||
public function _getTemplateId($template_name,
|
public function _getTemplateId($template_name,
|
||||||
$cache_id = null,
|
$cache_id = null,
|
||||||
$compile_id = null,
|
$compile_id = null,
|
||||||
$caching = null,
|
$caching = null,
|
||||||
Smarty_Internal_Template $template = null)
|
Smarty_Internal_Template $template = null
|
||||||
{
|
) {
|
||||||
$template_name = (strpos($template_name, ':') === false) ? "{$this->default_resource_type}:{$template_name}" :
|
$template_name = (strpos($template_name, ':') === false) ? "{$this->default_resource_type}:{$template_name}" :
|
||||||
$template_name;
|
$template_name;
|
||||||
$cache_id = $cache_id === null ? $this->cache_id : $cache_id;
|
$cache_id = $cache_id === null ? $this->cache_id : $cache_id;
|
||||||
@@ -1033,10 +1033,11 @@ class Smarty extends Smarty_Internal_TemplateBase
|
|||||||
* - remove /./ and /../
|
* - remove /./ and /../
|
||||||
* - make it absolute if required
|
* - make it absolute if required
|
||||||
*
|
*
|
||||||
* @param string $path file path
|
* @param string $path file path
|
||||||
* @param bool $realpath if true - convert to absolute
|
* @param bool $realpath if true - convert to absolute
|
||||||
* false - convert to relative
|
* false - convert to relative
|
||||||
* null - keep as it is but remove /./ /../
|
* null - keep as it is but
|
||||||
|
* remove /./ /../
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
@@ -1045,9 +1046,11 @@ class Smarty extends Smarty_Internal_TemplateBase
|
|||||||
$nds = array('/' => '\\', '\\' => '/');
|
$nds = array('/' => '\\', '\\' => '/');
|
||||||
// normalize DIRECTORY_SEPARATOR
|
// normalize DIRECTORY_SEPARATOR
|
||||||
//$path = str_replace(array($nds[DIRECTORY_SEPARATOR], DIRECTORY_SEPARATOR . '.' . DIRECTORY_SEPARATOR), DIRECTORY_SEPARATOR, $path);
|
//$path = str_replace(array($nds[DIRECTORY_SEPARATOR], DIRECTORY_SEPARATOR . '.' . DIRECTORY_SEPARATOR), DIRECTORY_SEPARATOR, $path);
|
||||||
preg_match('%^(?<root>(?:[[:alpha:]]:[\\\\]|/|[\\\\]{2}[[:alpha:]]+|[[:print:]]{2,}:[/]{2}|[\\\\])?)(?<path>(.*))$%u',
|
preg_match(
|
||||||
$path,
|
'%^(?<root>(?:[[:alpha:]]:[\\\\]|/|[\\\\]{2}[[:alpha:]]+|[[:print:]]{2,}:[/]{2}|[\\\\])?)(?<path>(.*))$%u',
|
||||||
$parts);
|
$path,
|
||||||
|
$parts
|
||||||
|
);
|
||||||
$path = $parts[ 'path' ];
|
$path = $parts[ 'path' ];
|
||||||
if ($parts[ 'root' ] === '\\') {
|
if ($parts[ 'root' ] === '\\') {
|
||||||
$parts[ 'root' ] = substr(getcwd(), 0, 2) . $parts[ 'root' ];
|
$parts[ 'root' ] = substr(getcwd(), 0, 2) . $parts[ 'root' ];
|
||||||
@@ -1058,8 +1061,9 @@ class Smarty extends Smarty_Internal_TemplateBase
|
|||||||
}
|
}
|
||||||
do {
|
do {
|
||||||
$path = preg_replace(
|
$path = preg_replace(
|
||||||
array('#[\\\\/]{2}#', '#[\\\\/][.][\\\\/]#', '#[\\\\/]([^\\\\/.]+)[\\\\/][.][.][\\\\/]#'),
|
array('#[\\\\/]{2}#', '#[\\\\/][.][\\\\/]#', '#[\\\\/]([^\\\\/.]+)[\\\\/][.][.][\\\\/]#'),
|
||||||
DIRECTORY_SEPARATOR, $path, -1, $count);
|
DIRECTORY_SEPARATOR, $path, -1, $count
|
||||||
|
);
|
||||||
} while($count > 0);
|
} while($count > 0);
|
||||||
return $realpath !== false ? $parts[ 'root' ] . $path : str_ireplace(getcwd(), '.', $parts[ 'root' ] . $path);
|
return $realpath !== false ? $parts[ 'root' ] . $path : str_ireplace(getcwd(), '.', $parts[ 'root' ] . $path);
|
||||||
}
|
}
|
||||||
@@ -1254,7 +1258,7 @@ class Smarty extends Smarty_Internal_TemplateBase
|
|||||||
* Calls the appropriate getter function.
|
* Calls the appropriate getter function.
|
||||||
* Issues an E_USER_NOTICE if no valid getter is found.
|
* Issues an E_USER_NOTICE if no valid getter is found.
|
||||||
*
|
*
|
||||||
* @param string $name property name
|
* @param string $name property name
|
||||||
*
|
*
|
||||||
* @return mixed
|
* @return mixed
|
||||||
* @throws \SmartyException
|
* @throws \SmartyException
|
||||||
@@ -1265,12 +1269,14 @@ class Smarty extends Smarty_Internal_TemplateBase
|
|||||||
$method = 'get' . $this->accessMap[ $name ];
|
$method = 'get' . $this->accessMap[ $name ];
|
||||||
return $this->{$method}();
|
return $this->{$method}();
|
||||||
} else {if (isset($this->_cache[ $name ])) {
|
} else {if (isset($this->_cache[ $name ])) {
|
||||||
return $this->_cache[ $name ];
|
return $this->_cache[ $name ];
|
||||||
} else {if (in_array($name, $this->obsoleteProperties)) {
|
} else {if (in_array($name, $this->obsoleteProperties)) {
|
||||||
return null;
|
return null;
|
||||||
} else {
|
} else {
|
||||||
trigger_error('Undefined property: ' . get_class($this) . '::$' . $name, E_USER_NOTICE);
|
trigger_error('Undefined property: ' . get_class($this) . '::$' . $name, E_USER_NOTICE);
|
||||||
}}}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1290,14 +1296,15 @@ class Smarty extends Smarty_Internal_TemplateBase
|
|||||||
$method = 'set' . $this->accessMap[ $name ];
|
$method = 'set' . $this->accessMap[ $name ];
|
||||||
$this->{$method}($value);
|
$this->{$method}($value);
|
||||||
} else {if (in_array($name, $this->obsoleteProperties)) {
|
} else {if (in_array($name, $this->obsoleteProperties)) {
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
if (is_object($value) && method_exists($value, $name)) {
|
if (is_object($value) && method_exists($value, $name)) {
|
||||||
$this->$name = $value;
|
$this->$name = $value;
|
||||||
} else {
|
} else {
|
||||||
trigger_error('Undefined property: ' . get_class($this) . '::$' . $name, E_USER_NOTICE);
|
trigger_error('Undefined property: ' . get_class($this) . '::$' . $name, E_USER_NOTICE);
|
||||||
}
|
}
|
||||||
}}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1320,7 +1327,6 @@ class Smarty extends Smarty_Internal_TemplateBase
|
|||||||
* Normalize template_dir or config_dir
|
* Normalize template_dir or config_dir
|
||||||
*
|
*
|
||||||
* @param bool $isConfig true for config_dir
|
* @param bool $isConfig true for config_dir
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
private function _normalizeTemplateConfig($isConfig)
|
private function _normalizeTemplateConfig($isConfig)
|
||||||
{
|
{
|
||||||
|
@@ -28,7 +28,7 @@
|
|||||||
/**
|
/**
|
||||||
* @ignore
|
* @ignore
|
||||||
*/
|
*/
|
||||||
require_once(dirname(__FILE__) . '/Smarty.class.php');
|
require_once dirname(__FILE__) . '/Smarty.class.php';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Smarty Backward Compatibility Wrapper Class
|
* Smarty Backward Compatibility Wrapper Class
|
||||||
@@ -53,7 +53,6 @@ class SmartyBC extends Smarty
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize new SmartyBC object
|
* Initialize new SmartyBC object
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
@@ -127,12 +126,12 @@ class SmartyBC extends Smarty
|
|||||||
* @param boolean $smarty_args smarty argument format, else traditional
|
* @param boolean $smarty_args smarty argument format, else traditional
|
||||||
* @param array $block_methods list of methods that are block format
|
* @param array $block_methods list of methods that are block format
|
||||||
*
|
*
|
||||||
* @throws SmartyException
|
* @throws SmartyException
|
||||||
* @internal param array $block_functs list of methods that are block format
|
* @internal param array $block_functs list of methods that are block format
|
||||||
*/
|
*/
|
||||||
public function register_object($object, $object_impl, $allowed = array(), $smarty_args = true,
|
public function register_object($object, $object_impl, $allowed = array(), $smarty_args = true,
|
||||||
$block_methods = array())
|
$block_methods = array()
|
||||||
{
|
) {
|
||||||
settype($allowed, 'array');
|
settype($allowed, 'array');
|
||||||
settype($smarty_args, 'boolean');
|
settype($smarty_args, 'boolean');
|
||||||
$this->registerObject($object, $object_impl, $allowed, $smarty_args, $block_methods);
|
$this->registerObject($object, $object_impl, $allowed, $smarty_args, $block_methods);
|
||||||
@@ -151,8 +150,8 @@ class SmartyBC extends Smarty
|
|||||||
/**
|
/**
|
||||||
* Registers block function to be used in templates
|
* Registers block function to be used in templates
|
||||||
*
|
*
|
||||||
* @param string $block name of template block
|
* @param string $block name of template block
|
||||||
* @param string $block_impl PHP function to register
|
* @param string $block_impl PHP function to register
|
||||||
* @param bool $cacheable
|
* @param bool $cacheable
|
||||||
* @param mixed $cache_attrs
|
* @param mixed $cache_attrs
|
||||||
*
|
*
|
||||||
@@ -326,10 +325,10 @@ class SmartyBC extends Smarty
|
|||||||
/**
|
/**
|
||||||
* clear cached content for the given template and cache id
|
* clear cached content for the given template and cache id
|
||||||
*
|
*
|
||||||
* @param string $tpl_file name of template file
|
* @param string $tpl_file name of template file
|
||||||
* @param string $cache_id name of cache_id
|
* @param string $cache_id name of cache_id
|
||||||
* @param string $compile_id name of compile_id
|
* @param string $compile_id name of compile_id
|
||||||
* @param string $exp_time expiration time
|
* @param string $exp_time expiration time
|
||||||
*
|
*
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
@@ -341,7 +340,7 @@ class SmartyBC extends Smarty
|
|||||||
/**
|
/**
|
||||||
* clear the entire contents of cache (all templates)
|
* clear the entire contents of cache (all templates)
|
||||||
*
|
*
|
||||||
* @param string $exp_time expire time
|
* @param string $exp_time expire time
|
||||||
*
|
*
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
@@ -353,9 +352,9 @@ class SmartyBC extends Smarty
|
|||||||
/**
|
/**
|
||||||
* test to see if valid cache exists for this template
|
* test to see if valid cache exists for this template
|
||||||
*
|
*
|
||||||
* @param string $tpl_file name of template file
|
* @param string $tpl_file name of template file
|
||||||
* @param string $cache_id
|
* @param string $cache_id
|
||||||
* @param string $compile_id
|
* @param string $compile_id
|
||||||
*
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
* @throws \Exception
|
* @throws \Exception
|
||||||
@@ -379,9 +378,9 @@ class SmartyBC extends Smarty
|
|||||||
* or all compiled template files if one is not specified.
|
* or all compiled template files if one is not specified.
|
||||||
* This function is for advanced use only, not normally needed.
|
* This function is for advanced use only, not normally needed.
|
||||||
*
|
*
|
||||||
* @param string $tpl_file
|
* @param string $tpl_file
|
||||||
* @param string $compile_id
|
* @param string $compile_id
|
||||||
* @param string $exp_time
|
* @param string $exp_time
|
||||||
*
|
*
|
||||||
* @return boolean results of {@link smarty_core_rm_auto()}
|
* @return boolean results of {@link smarty_core_rm_auto()}
|
||||||
*/
|
*/
|
||||||
@@ -393,7 +392,7 @@ class SmartyBC extends Smarty
|
|||||||
/**
|
/**
|
||||||
* Checks whether requested template exists.
|
* Checks whether requested template exists.
|
||||||
*
|
*
|
||||||
* @param string $tpl_file
|
* @param string $tpl_file
|
||||||
*
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
* @throws \SmartyException
|
* @throws \SmartyException
|
||||||
@@ -406,7 +405,7 @@ class SmartyBC extends Smarty
|
|||||||
/**
|
/**
|
||||||
* Returns an array containing template variables
|
* Returns an array containing template variables
|
||||||
*
|
*
|
||||||
* @param string $name
|
* @param string $name
|
||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
@@ -418,7 +417,7 @@ class SmartyBC extends Smarty
|
|||||||
/**
|
/**
|
||||||
* Returns an array containing config variables
|
* Returns an array containing config variables
|
||||||
*
|
*
|
||||||
* @param string $name
|
* @param string $name
|
||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
@@ -442,7 +441,7 @@ class SmartyBC extends Smarty
|
|||||||
/**
|
/**
|
||||||
* return a reference to a registered object
|
* return a reference to a registered object
|
||||||
*
|
*
|
||||||
* @param string $name
|
* @param string $name
|
||||||
*
|
*
|
||||||
* @return object
|
* @return object
|
||||||
*/
|
*/
|
||||||
|
@@ -12,6 +12,6 @@
|
|||||||
* Load and register Smarty Autoloader
|
* Load and register Smarty Autoloader
|
||||||
*/
|
*/
|
||||||
if (!class_exists('Smarty_Autoloader')) {
|
if (!class_exists('Smarty_Autoloader')) {
|
||||||
require dirname(__FILE__) . '/Autoloader.php';
|
include dirname(__FILE__) . '/Autoloader.php';
|
||||||
}
|
}
|
||||||
Smarty_Autoloader::register(true);
|
Smarty_Autoloader::register(true);
|
||||||
|
@@ -20,8 +20,7 @@
|
|||||||
* - indent_char - string (" ")
|
* - indent_char - string (" ")
|
||||||
* - wrap_boundary - boolean (true)
|
* - wrap_boundary - boolean (true)
|
||||||
*
|
*
|
||||||
*
|
* @link http://www.smarty.net/manual/en/language.function.textformat.php {textformat}
|
||||||
* @link http://www.smarty.net/manual/en/language.function.textformat.php {textformat}
|
|
||||||
* (Smarty online manual)
|
* (Smarty online manual)
|
||||||
*
|
*
|
||||||
* @param array $params parameters
|
* @param array $params parameters
|
||||||
@@ -39,8 +38,10 @@ function smarty_block_textformat($params, $content, Smarty_Internal_Template $te
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (Smarty::$_MBSTRING) {
|
if (Smarty::$_MBSTRING) {
|
||||||
$template->_checkPlugins(array(array('function' => 'smarty_modifier_mb_wordwrap',
|
$template->_checkPlugins(
|
||||||
'file' => SMARTY_PLUGINS_DIR . 'modifier.mb_wordwrap.php')));
|
array(array('function' => 'smarty_modifier_mb_wordwrap',
|
||||||
|
'file' => SMARTY_PLUGINS_DIR . 'modifier.mb_wordwrap.php'))
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
$style = null;
|
$style = null;
|
||||||
@@ -54,25 +55,25 @@ function smarty_block_textformat($params, $content, Smarty_Internal_Template $te
|
|||||||
|
|
||||||
foreach ($params as $_key => $_val) {
|
foreach ($params as $_key => $_val) {
|
||||||
switch ($_key) {
|
switch ($_key) {
|
||||||
case 'style':
|
case 'style':
|
||||||
case 'indent_char':
|
case 'indent_char':
|
||||||
case 'wrap_char':
|
case 'wrap_char':
|
||||||
case 'assign':
|
case 'assign':
|
||||||
$$_key = (string) $_val;
|
$$_key = (string) $_val;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'indent':
|
case 'indent':
|
||||||
case 'indent_first':
|
case 'indent_first':
|
||||||
case 'wrap':
|
case 'wrap':
|
||||||
$$_key = (int) $_val;
|
$$_key = (int) $_val;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'wrap_cut':
|
case 'wrap_cut':
|
||||||
$$_key = (bool) $_val;
|
$$_key = (bool) $_val;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
trigger_error("textformat: unknown attribute '{$_key}'");
|
trigger_error("textformat: unknown attribute '{$_key}'");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -88,10 +89,12 @@ function smarty_block_textformat($params, $content, Smarty_Internal_Template $te
|
|||||||
}
|
}
|
||||||
// convert mult. spaces & special chars to single space
|
// convert mult. spaces & special chars to single space
|
||||||
$_paragraph =
|
$_paragraph =
|
||||||
preg_replace(array('!\s+!' . Smarty::$_UTF8_MODIFIER,
|
preg_replace(
|
||||||
|
array('!\s+!' . Smarty::$_UTF8_MODIFIER,
|
||||||
'!(^\s+)|(\s+$)!' . Smarty::$_UTF8_MODIFIER),
|
'!(^\s+)|(\s+$)!' . Smarty::$_UTF8_MODIFIER),
|
||||||
array(' ',
|
array(' ',
|
||||||
''), $_paragraph);
|
''), $_paragraph
|
||||||
|
);
|
||||||
// indent first line
|
// indent first line
|
||||||
if ($indent_first > 0) {
|
if ($indent_first > 0) {
|
||||||
$_paragraph = str_repeat($indent_char, $indent_first) . $_paragraph;
|
$_paragraph = str_repeat($indent_char, $indent_first) . $_paragraph;
|
||||||
|
@@ -29,14 +29,13 @@
|
|||||||
* {cycle name=row values="one,two,three" reset=true}
|
* {cycle name=row values="one,two,three" reset=true}
|
||||||
* {cycle name=row}
|
* {cycle name=row}
|
||||||
*
|
*
|
||||||
*
|
* @link http://www.smarty.net/manual/en/language.function.cycle.php {cycle}
|
||||||
* @link http://www.smarty.net/manual/en/language.function.cycle.php {cycle}
|
|
||||||
* (Smarty online manual)
|
* (Smarty online manual)
|
||||||
* @author Monte Ohrt <monte at ohrt dot com>
|
* @author Monte Ohrt <monte at ohrt dot com>
|
||||||
* @author credit to Mark Priatel <mpriatel@rogers.com>
|
* @author credit to Mark Priatel <mpriatel@rogers.com>
|
||||||
* @author credit to Gerard <gerard@interfold.com>
|
* @author credit to Gerard <gerard@interfold.com>
|
||||||
* @author credit to Jason Sweat <jsweat_php@yahoo.com>
|
* @author credit to Jason Sweat <jsweat_php@yahoo.com>
|
||||||
* @version 1.3
|
* @version 1.3
|
||||||
*
|
*
|
||||||
* @param array $params parameters
|
* @param array $params parameters
|
||||||
* @param Smarty_Internal_Template $template template object
|
* @param Smarty_Internal_Template $template template object
|
||||||
|
@@ -81,73 +81,73 @@ function smarty_function_fetch($params, $template)
|
|||||||
// loop through parameters, setup headers
|
// loop through parameters, setup headers
|
||||||
foreach ($params as $param_key => $param_value) {
|
foreach ($params as $param_key => $param_value) {
|
||||||
switch ($param_key) {
|
switch ($param_key) {
|
||||||
case 'file':
|
case 'file':
|
||||||
case 'assign':
|
case 'assign':
|
||||||
case 'assign_headers':
|
case 'assign_headers':
|
||||||
break;
|
break;
|
||||||
case 'user':
|
case 'user':
|
||||||
if (!empty($param_value)) {
|
if (!empty($param_value)) {
|
||||||
$user = $param_value;
|
$user = $param_value;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'pass':
|
case 'pass':
|
||||||
if (!empty($param_value)) {
|
if (!empty($param_value)) {
|
||||||
$pass = $param_value;
|
$pass = $param_value;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'accept':
|
case 'accept':
|
||||||
if (!empty($param_value)) {
|
if (!empty($param_value)) {
|
||||||
$accept = $param_value;
|
$accept = $param_value;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'header':
|
case 'header':
|
||||||
if (!empty($param_value)) {
|
if (!empty($param_value)) {
|
||||||
if (!preg_match('![\w\d-]+: .+!', $param_value)) {
|
if (!preg_match('![\w\d-]+: .+!', $param_value)) {
|
||||||
trigger_error("[plugin] invalid header format '{$param_value}'", E_USER_NOTICE);
|
trigger_error("[plugin] invalid header format '{$param_value}'", E_USER_NOTICE);
|
||||||
|
|
||||||
return;
|
|
||||||
} else {
|
|
||||||
$extra_headers[] = $param_value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 'proxy_host':
|
|
||||||
if (!empty($param_value)) {
|
|
||||||
$proxy_host = $param_value;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 'proxy_port':
|
|
||||||
if (!preg_match('!\D!', $param_value)) {
|
|
||||||
$proxy_port = (int) $param_value;
|
|
||||||
} else {
|
|
||||||
trigger_error("[plugin] invalid value for attribute '{$param_key }'", E_USER_NOTICE);
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 'agent':
|
|
||||||
if (!empty($param_value)) {
|
|
||||||
$agent = $param_value;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 'referer':
|
|
||||||
if (!empty($param_value)) {
|
|
||||||
$referer = $param_value;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 'timeout':
|
|
||||||
if (!preg_match('!\D!', $param_value)) {
|
|
||||||
$timeout = (int) $param_value;
|
|
||||||
} else {
|
} else {
|
||||||
trigger_error("[plugin] invalid value for attribute '{$param_key}'", E_USER_NOTICE);
|
$extra_headers[] = $param_value;
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
break;
|
}
|
||||||
default:
|
break;
|
||||||
trigger_error("[plugin] unrecognized attribute '{$param_key}'", E_USER_NOTICE);
|
case 'proxy_host':
|
||||||
|
if (!empty($param_value)) {
|
||||||
|
$proxy_host = $param_value;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 'proxy_port':
|
||||||
|
if (!preg_match('!\D!', $param_value)) {
|
||||||
|
$proxy_port = (int) $param_value;
|
||||||
|
} else {
|
||||||
|
trigger_error("[plugin] invalid value for attribute '{$param_key }'", E_USER_NOTICE);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 'agent':
|
||||||
|
if (!empty($param_value)) {
|
||||||
|
$agent = $param_value;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 'referer':
|
||||||
|
if (!empty($param_value)) {
|
||||||
|
$referer = $param_value;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 'timeout':
|
||||||
|
if (!preg_match('!\D!', $param_value)) {
|
||||||
|
$timeout = (int) $param_value;
|
||||||
|
} else {
|
||||||
|
trigger_error("[plugin] invalid value for attribute '{$param_key}'", E_USER_NOTICE);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
trigger_error("[plugin] unrecognized attribute '{$param_key}'", E_USER_NOTICE);
|
||||||
|
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!empty($proxy_host) && !empty($proxy_port)) {
|
if (!empty($proxy_host) && !empty($proxy_port)) {
|
||||||
|
@@ -29,24 +29,25 @@
|
|||||||
* - assign (optional) - assign the output as an array to this variable
|
* - assign (optional) - assign the output as an array to this variable
|
||||||
* - escape (optional) - escape the content (not value), defaults to true
|
* - escape (optional) - escape the content (not value), defaults to true
|
||||||
*
|
*
|
||||||
*
|
* @link http://www.smarty.net/manual/en/language.function.html.checkboxes.php {html_checkboxes}
|
||||||
* @link http://www.smarty.net/manual/en/language.function.html.checkboxes.php {html_checkboxes}
|
|
||||||
* (Smarty online manual)
|
* (Smarty online manual)
|
||||||
* @author Christopher Kvarme <christopher.kvarme@flashjab.com>
|
* @author Christopher Kvarme <christopher.kvarme@flashjab.com>
|
||||||
* @author credits to Monte Ohrt <monte at ohrt dot com>
|
* @author credits to Monte Ohrt <monte at ohrt dot com>
|
||||||
* @version 1.0
|
* @version 1.0
|
||||||
*
|
*
|
||||||
* @param array $params parameters
|
* @param array $params parameters
|
||||||
* @param Smarty_Internal_Template $template template object
|
* @param Smarty_Internal_Template $template template object
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
* @uses smarty_function_escape_special_chars()
|
* @uses smarty_function_escape_special_chars()
|
||||||
* @throws \SmartyException
|
* @throws \SmartyException
|
||||||
*/
|
*/
|
||||||
function smarty_function_html_checkboxes($params, Smarty_Internal_Template $template)
|
function smarty_function_html_checkboxes($params, Smarty_Internal_Template $template)
|
||||||
{
|
{
|
||||||
$template->_checkPlugins(array(array('function' => 'smarty_function_escape_special_chars',
|
$template->_checkPlugins(
|
||||||
'file' => SMARTY_PLUGINS_DIR . 'shared.escape_special_chars.php')));
|
array(array('function' => 'smarty_function_escape_special_chars',
|
||||||
|
'file' => SMARTY_PLUGINS_DIR . 'shared.escape_special_chars.php'))
|
||||||
|
);
|
||||||
|
|
||||||
$name = 'checkbox';
|
$name = 'checkbox';
|
||||||
$values = null;
|
$values = null;
|
||||||
@@ -62,91 +63,99 @@ function smarty_function_html_checkboxes($params, Smarty_Internal_Template $temp
|
|||||||
|
|
||||||
foreach ($params as $_key => $_val) {
|
foreach ($params as $_key => $_val) {
|
||||||
switch ($_key) {
|
switch ($_key) {
|
||||||
case 'name':
|
case 'name':
|
||||||
case 'separator':
|
case 'separator':
|
||||||
$$_key = (string) $_val;
|
$$_key = (string) $_val;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'escape':
|
case 'escape':
|
||||||
case 'labels':
|
case 'labels':
|
||||||
case 'label_ids':
|
case 'label_ids':
|
||||||
$$_key = (bool) $_val;
|
$$_key = (bool) $_val;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'options':
|
case 'options':
|
||||||
$$_key = (array) $_val;
|
$$_key = (array) $_val;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'values':
|
case 'values':
|
||||||
case 'output':
|
case 'output':
|
||||||
$$_key = array_values((array) $_val);
|
$$_key = array_values((array) $_val);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'checked':
|
case 'checked':
|
||||||
case 'selected':
|
case 'selected':
|
||||||
if (is_array($_val)) {
|
if (is_array($_val)) {
|
||||||
$selected = array();
|
$selected = array();
|
||||||
foreach ($_val as $_sel) {
|
foreach ($_val as $_sel) {
|
||||||
if (is_object($_sel)) {
|
if (is_object($_sel)) {
|
||||||
if (method_exists($_sel, '__toString')) {
|
if (method_exists($_sel, '__toString')) {
|
||||||
$_sel = smarty_function_escape_special_chars((string) $_sel->__toString());
|
$_sel = smarty_function_escape_special_chars((string) $_sel->__toString());
|
||||||
} else {
|
|
||||||
trigger_error('html_checkboxes: selected attribute contains an object of class \'' .
|
|
||||||
get_class($_sel) . '\' without __toString() method', E_USER_NOTICE);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
$_sel = smarty_function_escape_special_chars((string) $_sel);
|
trigger_error(
|
||||||
|
'html_checkboxes: selected attribute contains an object of class \'' .
|
||||||
|
get_class($_sel) . '\' without __toString() method', E_USER_NOTICE
|
||||||
|
);
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
$selected[ $_sel ] = true;
|
|
||||||
}
|
|
||||||
} elseif (is_object($_val)) {
|
|
||||||
if (method_exists($_val, '__toString')) {
|
|
||||||
$selected = smarty_function_escape_special_chars((string) $_val->__toString());
|
|
||||||
} else {
|
} else {
|
||||||
trigger_error('html_checkboxes: selected attribute is an object of class \'' . get_class($_val) .
|
$_sel = smarty_function_escape_special_chars((string) $_sel);
|
||||||
'\' without __toString() method', E_USER_NOTICE);
|
|
||||||
}
|
}
|
||||||
|
$selected[ $_sel ] = true;
|
||||||
|
}
|
||||||
|
} elseif (is_object($_val)) {
|
||||||
|
if (method_exists($_val, '__toString')) {
|
||||||
|
$selected = smarty_function_escape_special_chars((string) $_val->__toString());
|
||||||
} else {
|
} else {
|
||||||
$selected = smarty_function_escape_special_chars((string) $_val);
|
trigger_error(
|
||||||
|
'html_checkboxes: selected attribute is an object of class \'' . get_class($_val) .
|
||||||
|
'\' without __toString() method', E_USER_NOTICE
|
||||||
|
);
|
||||||
}
|
}
|
||||||
break;
|
} else {
|
||||||
|
$selected = smarty_function_escape_special_chars((string) $_val);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
case 'checkboxes':
|
case 'checkboxes':
|
||||||
trigger_error('html_checkboxes: the use of the "checkboxes" attribute is deprecated, use "options" instead',
|
trigger_error(
|
||||||
E_USER_WARNING);
|
'html_checkboxes: the use of the "checkboxes" attribute is deprecated, use "options" instead',
|
||||||
$options = (array) $_val;
|
E_USER_WARNING
|
||||||
break;
|
);
|
||||||
|
$options = (array) $_val;
|
||||||
|
break;
|
||||||
|
|
||||||
case 'assign':
|
case 'assign':
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'strict':
|
case 'strict':
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'disabled':
|
case 'disabled':
|
||||||
case 'readonly':
|
case 'readonly':
|
||||||
if (!empty($params[ 'strict' ])) {
|
if (!empty($params[ 'strict' ])) {
|
||||||
if (!is_scalar($_val)) {
|
if (!is_scalar($_val)) {
|
||||||
trigger_error("html_options: {$_key} attribute must be a scalar, only boolean true or string '{$_key}' will actually add the attribute",
|
trigger_error(
|
||||||
E_USER_NOTICE);
|
"html_options: {$_key} attribute must be a scalar, only boolean true or string '{$_key}' will actually add the attribute",
|
||||||
}
|
E_USER_NOTICE
|
||||||
|
);
|
||||||
if ($_val === true || $_val === $_key) {
|
|
||||||
$extra .= ' ' . $_key . '="' . smarty_function_escape_special_chars($_key) . '"';
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($_val === true || $_val === $_key) {
|
||||||
|
$extra .= ' ' . $_key . '="' . smarty_function_escape_special_chars($_key) . '"';
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
// omit break; to fall through!
|
// omit break; to fall through!
|
||||||
|
|
||||||
default:
|
default:
|
||||||
if (!is_array($_val)) {
|
if (!is_array($_val)) {
|
||||||
$extra .= ' ' . $_key . '="' . smarty_function_escape_special_chars($_val) . '"';
|
$extra .= ' ' . $_key . '="' . smarty_function_escape_special_chars($_val) . '"';
|
||||||
} else {
|
} else {
|
||||||
trigger_error("html_checkboxes: extra attribute '{$_key}' cannot be an array", E_USER_NOTICE);
|
trigger_error("html_checkboxes: extra attribute '{$_key}' cannot be an array", E_USER_NOTICE);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -159,15 +168,19 @@ function smarty_function_html_checkboxes($params, Smarty_Internal_Template $temp
|
|||||||
if (isset($options)) {
|
if (isset($options)) {
|
||||||
foreach ($options as $_key => $_val) {
|
foreach ($options as $_key => $_val) {
|
||||||
$_html_result[] =
|
$_html_result[] =
|
||||||
smarty_function_html_checkboxes_output($name, $_key, $_val, $selected, $extra, $separator, $labels,
|
smarty_function_html_checkboxes_output(
|
||||||
$label_ids, $escape);
|
$name, $_key, $_val, $selected, $extra, $separator, $labels,
|
||||||
|
$label_ids, $escape
|
||||||
|
);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
foreach ($values as $_i => $_key) {
|
foreach ($values as $_i => $_key) {
|
||||||
$_val = isset($output[ $_i ]) ? $output[ $_i ] : '';
|
$_val = isset($output[ $_i ]) ? $output[ $_i ] : '';
|
||||||
$_html_result[] =
|
$_html_result[] =
|
||||||
smarty_function_html_checkboxes_output($name, $_key, $_val, $selected, $extra, $separator, $labels,
|
smarty_function_html_checkboxes_output(
|
||||||
$label_ids, $escape);
|
$name, $_key, $_val, $selected, $extra, $separator, $labels,
|
||||||
|
$label_ids, $escape
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -186,21 +199,23 @@ function smarty_function_html_checkboxes($params, Smarty_Internal_Template $temp
|
|||||||
* @param $separator
|
* @param $separator
|
||||||
* @param $labels
|
* @param $labels
|
||||||
* @param $label_ids
|
* @param $label_ids
|
||||||
* @param bool $escape
|
* @param bool $escape
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
function smarty_function_html_checkboxes_output($name, $value, $output, $selected, $extra, $separator, $labels,
|
function smarty_function_html_checkboxes_output($name, $value, $output, $selected, $extra, $separator, $labels,
|
||||||
$label_ids, $escape = true)
|
$label_ids, $escape = true
|
||||||
{
|
) {
|
||||||
$_output = '';
|
$_output = '';
|
||||||
|
|
||||||
if (is_object($value)) {
|
if (is_object($value)) {
|
||||||
if (method_exists($value, '__toString')) {
|
if (method_exists($value, '__toString')) {
|
||||||
$value = (string) $value->__toString();
|
$value = (string) $value->__toString();
|
||||||
} else {
|
} else {
|
||||||
trigger_error('html_options: value is an object of class \'' . get_class($value) .
|
trigger_error(
|
||||||
'\' without __toString() method', E_USER_NOTICE);
|
'html_options: value is an object of class \'' . get_class($value) .
|
||||||
|
'\' without __toString() method', E_USER_NOTICE
|
||||||
|
);
|
||||||
|
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
@@ -212,8 +227,10 @@ function smarty_function_html_checkboxes_output($name, $value, $output, $selecte
|
|||||||
if (method_exists($output, '__toString')) {
|
if (method_exists($output, '__toString')) {
|
||||||
$output = (string) $output->__toString();
|
$output = (string) $output->__toString();
|
||||||
} else {
|
} else {
|
||||||
trigger_error('html_options: output is an object of class \'' . get_class($output) .
|
trigger_error(
|
||||||
'\' without __toString() method', E_USER_NOTICE);
|
'html_options: output is an object of class \'' . get_class($output) .
|
||||||
|
'\' without __toString() method', E_USER_NOTICE
|
||||||
|
);
|
||||||
|
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
@@ -223,8 +240,12 @@ function smarty_function_html_checkboxes_output($name, $value, $output, $selecte
|
|||||||
|
|
||||||
if ($labels) {
|
if ($labels) {
|
||||||
if ($label_ids) {
|
if ($label_ids) {
|
||||||
$_id = smarty_function_escape_special_chars(preg_replace('![^\w\-\.]!' . Smarty::$_UTF8_MODIFIER, '_',
|
$_id = smarty_function_escape_special_chars(
|
||||||
$name . '_' . $value));
|
preg_replace(
|
||||||
|
'![^\w\-\.]!' . Smarty::$_UTF8_MODIFIER, '_',
|
||||||
|
$name . '_' . $value
|
||||||
|
)
|
||||||
|
);
|
||||||
$_output .= '<label for="' . $_id . '">';
|
$_output .= '<label for="' . $_id . '">';
|
||||||
} else {
|
} else {
|
||||||
$_output .= '<label>';
|
$_output .= '<label>';
|
||||||
|
@@ -22,7 +22,6 @@
|
|||||||
* - basedir - (optional) - base directory for absolute paths, default is environment variable DOCUMENT_ROOT
|
* - basedir - (optional) - base directory for absolute paths, default is environment variable DOCUMENT_ROOT
|
||||||
* - path_prefix - prefix for path output (optional, default empty)
|
* - path_prefix - prefix for path output (optional, default empty)
|
||||||
*
|
*
|
||||||
*
|
|
||||||
* @link http://www.smarty.net/manual/en/language.function.html.image.php {html_image}
|
* @link http://www.smarty.net/manual/en/language.function.html.image.php {html_image}
|
||||||
* (Smarty online manual)
|
* (Smarty online manual)
|
||||||
* @author Monte Ohrt <monte at ohrt dot com>
|
* @author Monte Ohrt <monte at ohrt dot com>
|
||||||
@@ -34,12 +33,14 @@
|
|||||||
*
|
*
|
||||||
* @throws SmartyException
|
* @throws SmartyException
|
||||||
* @return string
|
* @return string
|
||||||
* @uses smarty_function_escape_special_chars()
|
* @uses smarty_function_escape_special_chars()
|
||||||
*/
|
*/
|
||||||
function smarty_function_html_image($params, Smarty_Internal_Template $template)
|
function smarty_function_html_image($params, Smarty_Internal_Template $template)
|
||||||
{
|
{
|
||||||
$template->_checkPlugins(array(array('function' => 'smarty_function_escape_special_chars',
|
$template->_checkPlugins(
|
||||||
'file' => SMARTY_PLUGINS_DIR . 'shared.escape_special_chars.php')));
|
array(array('function' => 'smarty_function_escape_special_chars',
|
||||||
|
'file' => SMARTY_PLUGINS_DIR . 'shared.escape_special_chars.php'))
|
||||||
|
);
|
||||||
|
|
||||||
$alt = '';
|
$alt = '';
|
||||||
$file = '';
|
$file = '';
|
||||||
@@ -52,36 +53,36 @@ function smarty_function_html_image($params, Smarty_Internal_Template $template)
|
|||||||
$basedir = isset($_SERVER[ 'DOCUMENT_ROOT' ]) ? $_SERVER[ 'DOCUMENT_ROOT' ] : '';
|
$basedir = isset($_SERVER[ 'DOCUMENT_ROOT' ]) ? $_SERVER[ 'DOCUMENT_ROOT' ] : '';
|
||||||
foreach ($params as $_key => $_val) {
|
foreach ($params as $_key => $_val) {
|
||||||
switch ($_key) {
|
switch ($_key) {
|
||||||
case 'file':
|
case 'file':
|
||||||
case 'height':
|
case 'height':
|
||||||
case 'width':
|
case 'width':
|
||||||
case 'dpi':
|
case 'dpi':
|
||||||
case 'path_prefix':
|
case 'path_prefix':
|
||||||
case 'basedir':
|
case 'basedir':
|
||||||
$$_key = $_val;
|
$$_key = $_val;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'alt':
|
case 'alt':
|
||||||
if (!is_array($_val)) {
|
if (!is_array($_val)) {
|
||||||
$$_key = smarty_function_escape_special_chars($_val);
|
$$_key = smarty_function_escape_special_chars($_val);
|
||||||
} else {
|
} else {
|
||||||
throw new SmartyException ("html_image: extra attribute '{$_key}' cannot be an array", E_USER_NOTICE);
|
throw new SmartyException("html_image: extra attribute '{$_key}' cannot be an array", E_USER_NOTICE);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'link':
|
case 'link':
|
||||||
case 'href':
|
case 'href':
|
||||||
$prefix = '<a href="' . $_val . '">';
|
$prefix = '<a href="' . $_val . '">';
|
||||||
$suffix = '</a>';
|
$suffix = '</a>';
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
if (!is_array($_val)) {
|
if (!is_array($_val)) {
|
||||||
$extra .= ' ' . $_key . '="' . smarty_function_escape_special_chars($_val) . '"';
|
$extra .= ' ' . $_key . '="' . smarty_function_escape_special_chars($_val) . '"';
|
||||||
} else {
|
} else {
|
||||||
throw new SmartyException ("html_image: extra attribute '{$_key}' cannot be an array", E_USER_NOTICE);
|
throw new SmartyException("html_image: extra attribute '{$_key}' cannot be an array", E_USER_NOTICE);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -21,24 +21,25 @@
|
|||||||
* - id (optional) - string default not set
|
* - id (optional) - string default not set
|
||||||
* - class (optional) - string default not set
|
* - class (optional) - string default not set
|
||||||
*
|
*
|
||||||
*
|
* @link http://www.smarty.net/manual/en/language.function.html.options.php {html_image}
|
||||||
* @link http://www.smarty.net/manual/en/language.function.html.options.php {html_image}
|
|
||||||
* (Smarty online manual)
|
* (Smarty online manual)
|
||||||
* @author Monte Ohrt <monte at ohrt dot com>
|
* @author Monte Ohrt <monte at ohrt dot com>
|
||||||
* @author Ralf Strehle (minor optimization) <ralf dot strehle at yahoo dot de>
|
* @author Ralf Strehle (minor optimization) <ralf dot strehle at yahoo dot de>
|
||||||
*
|
*
|
||||||
* @param array $params parameters
|
* @param array $params parameters
|
||||||
*
|
*
|
||||||
* @param \Smarty_Internal_Template $template
|
* @param \Smarty_Internal_Template $template
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
* @uses smarty_function_escape_special_chars()
|
* @uses smarty_function_escape_special_chars()
|
||||||
* @throws \SmartyException
|
* @throws \SmartyException
|
||||||
*/
|
*/
|
||||||
function smarty_function_html_options($params, Smarty_Internal_Template $template)
|
function smarty_function_html_options($params, Smarty_Internal_Template $template)
|
||||||
{
|
{
|
||||||
$template->_checkPlugins(array(array('function' => 'smarty_function_escape_special_chars',
|
$template->_checkPlugins(
|
||||||
'file' => SMARTY_PLUGINS_DIR . 'shared.escape_special_chars.php')));
|
array(array('function' => 'smarty_function_escape_special_chars',
|
||||||
|
'file' => SMARTY_PLUGINS_DIR . 'shared.escape_special_chars.php'))
|
||||||
|
);
|
||||||
|
|
||||||
$name = null;
|
$name = null;
|
||||||
$values = null;
|
$values = null;
|
||||||
@@ -52,76 +53,82 @@ function smarty_function_html_options($params, Smarty_Internal_Template $templat
|
|||||||
|
|
||||||
foreach ($params as $_key => $_val) {
|
foreach ($params as $_key => $_val) {
|
||||||
switch ($_key) {
|
switch ($_key) {
|
||||||
case 'name':
|
case 'name':
|
||||||
case 'class':
|
case 'class':
|
||||||
case 'id':
|
case 'id':
|
||||||
$$_key = (string) $_val;
|
$$_key = (string) $_val;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'options':
|
case 'options':
|
||||||
$options = (array) $_val;
|
$options = (array) $_val;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'values':
|
case 'values':
|
||||||
case 'output':
|
case 'output':
|
||||||
$$_key = array_values((array) $_val);
|
$$_key = array_values((array) $_val);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'selected':
|
case 'selected':
|
||||||
if (is_array($_val)) {
|
if (is_array($_val)) {
|
||||||
$selected = array();
|
$selected = array();
|
||||||
foreach ($_val as $_sel) {
|
foreach ($_val as $_sel) {
|
||||||
if (is_object($_sel)) {
|
if (is_object($_sel)) {
|
||||||
if (method_exists($_sel, '__toString')) {
|
if (method_exists($_sel, '__toString')) {
|
||||||
$_sel = smarty_function_escape_special_chars((string) $_sel->__toString());
|
$_sel = smarty_function_escape_special_chars((string) $_sel->__toString());
|
||||||
} else {
|
|
||||||
trigger_error('html_options: selected attribute contains an object of class \'' .
|
|
||||||
get_class($_sel) . '\' without __toString() method', E_USER_NOTICE);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
$_sel = smarty_function_escape_special_chars((string) $_sel);
|
trigger_error(
|
||||||
|
'html_options: selected attribute contains an object of class \'' .
|
||||||
|
get_class($_sel) . '\' without __toString() method', E_USER_NOTICE
|
||||||
|
);
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
$selected[ $_sel ] = true;
|
|
||||||
}
|
|
||||||
} elseif (is_object($_val)) {
|
|
||||||
if (method_exists($_val, '__toString')) {
|
|
||||||
$selected = smarty_function_escape_special_chars((string) $_val->__toString());
|
|
||||||
} else {
|
} else {
|
||||||
trigger_error('html_options: selected attribute is an object of class \'' . get_class($_val) .
|
$_sel = smarty_function_escape_special_chars((string) $_sel);
|
||||||
'\' without __toString() method', E_USER_NOTICE);
|
|
||||||
}
|
}
|
||||||
|
$selected[ $_sel ] = true;
|
||||||
|
}
|
||||||
|
} elseif (is_object($_val)) {
|
||||||
|
if (method_exists($_val, '__toString')) {
|
||||||
|
$selected = smarty_function_escape_special_chars((string) $_val->__toString());
|
||||||
} else {
|
} else {
|
||||||
$selected = smarty_function_escape_special_chars((string) $_val);
|
trigger_error(
|
||||||
|
'html_options: selected attribute is an object of class \'' . get_class($_val) .
|
||||||
|
'\' without __toString() method', E_USER_NOTICE
|
||||||
|
);
|
||||||
}
|
}
|
||||||
break;
|
} else {
|
||||||
|
$selected = smarty_function_escape_special_chars((string) $_val);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
case 'strict':
|
case 'strict':
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'disabled':
|
case 'disabled':
|
||||||
case 'readonly':
|
case 'readonly':
|
||||||
if (!empty($params[ 'strict' ])) {
|
if (!empty($params[ 'strict' ])) {
|
||||||
if (!is_scalar($_val)) {
|
if (!is_scalar($_val)) {
|
||||||
trigger_error("html_options: {$_key} attribute must be a scalar, only boolean true or string '{$_key}' will actually add the attribute",
|
trigger_error(
|
||||||
E_USER_NOTICE);
|
"html_options: {$_key} attribute must be a scalar, only boolean true or string '{$_key}' will actually add the attribute",
|
||||||
}
|
E_USER_NOTICE
|
||||||
|
);
|
||||||
if ($_val === true || $_val === $_key) {
|
|
||||||
$extra .= ' ' . $_key . '="' . smarty_function_escape_special_chars($_key) . '"';
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($_val === true || $_val === $_key) {
|
||||||
|
$extra .= ' ' . $_key . '="' . smarty_function_escape_special_chars($_key) . '"';
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
// omit break; to fall through!
|
// omit break; to fall through!
|
||||||
|
|
||||||
default:
|
default:
|
||||||
if (!is_array($_val)) {
|
if (!is_array($_val)) {
|
||||||
$extra .= ' ' . $_key . '="' . smarty_function_escape_special_chars($_val) . '"';
|
$extra .= ' ' . $_key . '="' . smarty_function_escape_special_chars($_val) . '"';
|
||||||
} else {
|
} else {
|
||||||
trigger_error("html_options: extra attribute '{$_key}' cannot be an array", E_USER_NOTICE);
|
trigger_error("html_options: extra attribute '{$_key}' cannot be an array", E_USER_NOTICE);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -183,8 +190,10 @@ function smarty_function_html_options_optoutput($key, $value, $selected, $id, $c
|
|||||||
if (method_exists($value, '__toString')) {
|
if (method_exists($value, '__toString')) {
|
||||||
$value = smarty_function_escape_special_chars((string) $value->__toString());
|
$value = smarty_function_escape_special_chars((string) $value->__toString());
|
||||||
} else {
|
} else {
|
||||||
trigger_error('html_options: value is an object of class \'' . get_class($value) .
|
trigger_error(
|
||||||
'\' without __toString() method', E_USER_NOTICE);
|
'html_options: value is an object of class \'' . get_class($value) .
|
||||||
|
'\' without __toString() method', E_USER_NOTICE
|
||||||
|
);
|
||||||
|
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
@@ -196,8 +205,10 @@ function smarty_function_html_options_optoutput($key, $value, $selected, $id, $c
|
|||||||
} else {
|
} else {
|
||||||
$_idx = 0;
|
$_idx = 0;
|
||||||
$_html_result =
|
$_html_result =
|
||||||
smarty_function_html_options_optgroup($key, $value, $selected, !empty($id) ? ($id . '-' . $idx) : null,
|
smarty_function_html_options_optgroup(
|
||||||
$class, $_idx);
|
$key, $value, $selected, !empty($id) ? ($id . '-' . $idx) : null,
|
||||||
|
$class, $_idx
|
||||||
|
);
|
||||||
$idx ++;
|
$idx ++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -29,7 +29,6 @@
|
|||||||
* {html_radios values=$ids name='box' separator='<br>' output=$names}
|
* {html_radios values=$ids name='box' separator='<br>' output=$names}
|
||||||
* {html_radios values=$ids checked=$checked separator='<br>' output=$names}
|
* {html_radios values=$ids checked=$checked separator='<br>' output=$names}
|
||||||
*
|
*
|
||||||
*
|
|
||||||
* @link http://smarty.php.net/manual/en/language.function.html.radios.php {html_radios}
|
* @link http://smarty.php.net/manual/en/language.function.html.radios.php {html_radios}
|
||||||
* (Smarty online manual)
|
* (Smarty online manual)
|
||||||
* @author Christopher Kvarme <christopher.kvarme@flashjab.com>
|
* @author Christopher Kvarme <christopher.kvarme@flashjab.com>
|
||||||
@@ -40,13 +39,15 @@
|
|||||||
* @param Smarty_Internal_Template $template template object
|
* @param Smarty_Internal_Template $template template object
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
* @uses smarty_function_escape_special_chars()
|
* @uses smarty_function_escape_special_chars()
|
||||||
* @throws \SmartyException
|
* @throws \SmartyException
|
||||||
*/
|
*/
|
||||||
function smarty_function_html_radios($params, Smarty_Internal_Template $template)
|
function smarty_function_html_radios($params, Smarty_Internal_Template $template)
|
||||||
{
|
{
|
||||||
$template->_checkPlugins(array(array('function' => 'smarty_function_escape_special_chars',
|
$template->_checkPlugins(
|
||||||
'file' => SMARTY_PLUGINS_DIR . 'shared.escape_special_chars.php')));
|
array(array('function' => 'smarty_function_escape_special_chars',
|
||||||
|
'file' => SMARTY_PLUGINS_DIR . 'shared.escape_special_chars.php'))
|
||||||
|
);
|
||||||
|
|
||||||
$name = 'radio';
|
$name = 'radio';
|
||||||
$values = null;
|
$values = null;
|
||||||
@@ -61,77 +62,83 @@ function smarty_function_html_radios($params, Smarty_Internal_Template $template
|
|||||||
|
|
||||||
foreach ($params as $_key => $_val) {
|
foreach ($params as $_key => $_val) {
|
||||||
switch ($_key) {
|
switch ($_key) {
|
||||||
case 'name':
|
case 'name':
|
||||||
case 'separator':
|
case 'separator':
|
||||||
$$_key = (string) $_val;
|
$$_key = (string) $_val;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'checked':
|
case 'checked':
|
||||||
case 'selected':
|
case 'selected':
|
||||||
if (is_array($_val)) {
|
if (is_array($_val)) {
|
||||||
trigger_error('html_radios: the "' . $_key . '" attribute cannot be an array', E_USER_WARNING);
|
trigger_error('html_radios: the "' . $_key . '" attribute cannot be an array', E_USER_WARNING);
|
||||||
} elseif (is_object($_val)) {
|
} elseif (is_object($_val)) {
|
||||||
if (method_exists($_val, '__toString')) {
|
if (method_exists($_val, '__toString')) {
|
||||||
$selected = smarty_function_escape_special_chars((string) $_val->__toString());
|
$selected = smarty_function_escape_special_chars((string) $_val->__toString());
|
||||||
} else {
|
|
||||||
trigger_error('html_radios: selected attribute is an object of class \'' . get_class($_val) .
|
|
||||||
'\' without __toString() method', E_USER_NOTICE);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
$selected = (string) $_val;
|
trigger_error(
|
||||||
|
'html_radios: selected attribute is an object of class \'' . get_class($_val) .
|
||||||
|
'\' without __toString() method', E_USER_NOTICE
|
||||||
|
);
|
||||||
}
|
}
|
||||||
break;
|
} else {
|
||||||
|
$selected = (string) $_val;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
case 'escape':
|
case 'escape':
|
||||||
case 'labels':
|
case 'labels':
|
||||||
case 'label_ids':
|
case 'label_ids':
|
||||||
$$_key = (bool) $_val;
|
$$_key = (bool) $_val;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'options':
|
case 'options':
|
||||||
$$_key = (array) $_val;
|
$$_key = (array) $_val;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'values':
|
case 'values':
|
||||||
case 'output':
|
case 'output':
|
||||||
$$_key = array_values((array) $_val);
|
$$_key = array_values((array) $_val);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'radios':
|
case 'radios':
|
||||||
trigger_error('html_radios: the use of the "radios" attribute is deprecated, use "options" instead',
|
trigger_error(
|
||||||
E_USER_WARNING);
|
'html_radios: the use of the "radios" attribute is deprecated, use "options" instead',
|
||||||
$options = (array) $_val;
|
E_USER_WARNING
|
||||||
break;
|
);
|
||||||
|
$options = (array) $_val;
|
||||||
|
break;
|
||||||
|
|
||||||
case 'assign':
|
case 'assign':
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'strict':
|
case 'strict':
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'disabled':
|
case 'disabled':
|
||||||
case 'readonly':
|
case 'readonly':
|
||||||
if (!empty($params[ 'strict' ])) {
|
if (!empty($params[ 'strict' ])) {
|
||||||
if (!is_scalar($_val)) {
|
if (!is_scalar($_val)) {
|
||||||
trigger_error("html_options: {$_key} attribute must be a scalar, only boolean true or string '$_key' will actually add the attribute",
|
trigger_error(
|
||||||
E_USER_NOTICE);
|
"html_options: {$_key} attribute must be a scalar, only boolean true or string '$_key' will actually add the attribute",
|
||||||
}
|
E_USER_NOTICE
|
||||||
|
);
|
||||||
if ($_val === true || $_val === $_key) {
|
|
||||||
$extra .= ' ' . $_key . '="' . smarty_function_escape_special_chars($_key) . '"';
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($_val === true || $_val === $_key) {
|
||||||
|
$extra .= ' ' . $_key . '="' . smarty_function_escape_special_chars($_key) . '"';
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
// omit break; to fall through!
|
// omit break; to fall through!
|
||||||
|
|
||||||
default:
|
default:
|
||||||
if (!is_array($_val)) {
|
if (!is_array($_val)) {
|
||||||
$extra .= ' ' . $_key . '="' . smarty_function_escape_special_chars($_val) . '"';
|
$extra .= ' ' . $_key . '="' . smarty_function_escape_special_chars($_val) . '"';
|
||||||
} else {
|
} else {
|
||||||
trigger_error("html_radios: extra attribute '{$_key}' cannot be an array", E_USER_NOTICE);
|
trigger_error("html_radios: extra attribute '{$_key}' cannot be an array", E_USER_NOTICE);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -146,15 +153,19 @@ function smarty_function_html_radios($params, Smarty_Internal_Template $template
|
|||||||
if (isset($options)) {
|
if (isset($options)) {
|
||||||
foreach ($options as $_key => $_val) {
|
foreach ($options as $_key => $_val) {
|
||||||
$_html_result[] =
|
$_html_result[] =
|
||||||
smarty_function_html_radios_output($name, $_key, $_val, $selected, $extra, $separator, $labels,
|
smarty_function_html_radios_output(
|
||||||
$label_ids, $escape);
|
$name, $_key, $_val, $selected, $extra, $separator, $labels,
|
||||||
|
$label_ids, $escape
|
||||||
|
);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
foreach ($values as $_i => $_key) {
|
foreach ($values as $_i => $_key) {
|
||||||
$_val = isset($output[ $_i ]) ? $output[ $_i ] : '';
|
$_val = isset($output[ $_i ]) ? $output[ $_i ] : '';
|
||||||
$_html_result[] =
|
$_html_result[] =
|
||||||
smarty_function_html_radios_output($name, $_key, $_val, $selected, $extra, $separator, $labels,
|
smarty_function_html_radios_output(
|
||||||
$label_ids, $escape);
|
$name, $_key, $_val, $selected, $extra, $separator, $labels,
|
||||||
|
$label_ids, $escape
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -178,16 +189,18 @@ function smarty_function_html_radios($params, Smarty_Internal_Template $template
|
|||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
function smarty_function_html_radios_output($name, $value, $output, $selected, $extra, $separator, $labels, $label_ids,
|
function smarty_function_html_radios_output($name, $value, $output, $selected, $extra, $separator, $labels, $label_ids,
|
||||||
$escape)
|
$escape
|
||||||
{
|
) {
|
||||||
$_output = '';
|
$_output = '';
|
||||||
|
|
||||||
if (is_object($value)) {
|
if (is_object($value)) {
|
||||||
if (method_exists($value, '__toString')) {
|
if (method_exists($value, '__toString')) {
|
||||||
$value = (string) $value->__toString();
|
$value = (string) $value->__toString();
|
||||||
} else {
|
} else {
|
||||||
trigger_error('html_options: value is an object of class \'' . get_class($value) .
|
trigger_error(
|
||||||
'\' without __toString() method', E_USER_NOTICE);
|
'html_options: value is an object of class \'' . get_class($value) .
|
||||||
|
'\' without __toString() method', E_USER_NOTICE
|
||||||
|
);
|
||||||
|
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
@@ -199,8 +212,10 @@ function smarty_function_html_radios_output($name, $value, $output, $selected, $
|
|||||||
if (method_exists($output, '__toString')) {
|
if (method_exists($output, '__toString')) {
|
||||||
$output = (string) $output->__toString();
|
$output = (string) $output->__toString();
|
||||||
} else {
|
} else {
|
||||||
trigger_error('html_options: output is an object of class \'' . get_class($output) .
|
trigger_error(
|
||||||
'\' without __toString() method', E_USER_NOTICE);
|
'html_options: output is an object of class \'' . get_class($output) .
|
||||||
|
'\' without __toString() method', E_USER_NOTICE
|
||||||
|
);
|
||||||
|
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
@@ -210,8 +225,12 @@ function smarty_function_html_radios_output($name, $value, $output, $selected, $
|
|||||||
|
|
||||||
if ($labels) {
|
if ($labels) {
|
||||||
if ($label_ids) {
|
if ($label_ids) {
|
||||||
$_id = smarty_function_escape_special_chars(preg_replace('![^\w\-\.]!' . Smarty::$_UTF8_MODIFIER, '_',
|
$_id = smarty_function_escape_special_chars(
|
||||||
$name . '_' . $value));
|
preg_replace(
|
||||||
|
'![^\w\-\.]!' . Smarty::$_UTF8_MODIFIER, '_',
|
||||||
|
$name . '_' . $value
|
||||||
|
)
|
||||||
|
);
|
||||||
$_output .= '<label for="' . $_id . '">';
|
$_output .= '<label for="' . $_id . '">';
|
||||||
} else {
|
} else {
|
||||||
$_output .= '<label>';
|
$_output .= '<label>';
|
||||||
|
@@ -28,15 +28,14 @@
|
|||||||
* - 2.0 complete rewrite for performance,
|
* - 2.0 complete rewrite for performance,
|
||||||
* added attributes month_names, *_id
|
* added attributes month_names, *_id
|
||||||
*
|
*
|
||||||
*
|
* @link http://www.smarty.net/manual/en/language.function.html.select.date.php {html_select_date}
|
||||||
* @link http://www.smarty.net/manual/en/language.function.html.select.date.php {html_select_date}
|
|
||||||
* (Smarty online manual)
|
* (Smarty online manual)
|
||||||
* @version 2.0
|
* @version 2.0
|
||||||
* @author Andrei Zmievski
|
* @author Andrei Zmievski
|
||||||
* @author Monte Ohrt <monte at ohrt dot com>
|
* @author Monte Ohrt <monte at ohrt dot com>
|
||||||
* @author Rodney Rehm
|
* @author Rodney Rehm
|
||||||
*
|
*
|
||||||
* @param array $params parameters
|
* @param array $params parameters
|
||||||
*
|
*
|
||||||
* @param \Smarty_Internal_Template $template
|
* @param \Smarty_Internal_Template $template
|
||||||
*
|
*
|
||||||
@@ -45,8 +44,10 @@
|
|||||||
*/
|
*/
|
||||||
function smarty_function_html_select_date($params, Smarty_Internal_Template $template)
|
function smarty_function_html_select_date($params, Smarty_Internal_Template $template)
|
||||||
{
|
{
|
||||||
$template->_checkPlugins(array(array('function' => 'smarty_function_escape_special_chars',
|
$template->_checkPlugins(
|
||||||
'file' => SMARTY_PLUGINS_DIR . 'shared.escape_special_chars.php')));
|
array(array('function' => 'smarty_function_escape_special_chars',
|
||||||
|
'file' => SMARTY_PLUGINS_DIR . 'shared.escape_special_chars.php'))
|
||||||
|
);
|
||||||
// generate timestamps used for month names only
|
// generate timestamps used for month names only
|
||||||
static $_month_timestamps = null;
|
static $_month_timestamps = null;
|
||||||
static $_current_year = null;
|
static $_current_year = null;
|
||||||
@@ -109,66 +110,68 @@ function smarty_function_html_select_date($params, Smarty_Internal_Template $tem
|
|||||||
|
|
||||||
foreach ($params as $_key => $_value) {
|
foreach ($params as $_key => $_value) {
|
||||||
switch ($_key) {
|
switch ($_key) {
|
||||||
case 'time':
|
case 'time':
|
||||||
if (!is_array($_value) && $_value !== null) {
|
if (!is_array($_value) && $_value !== null) {
|
||||||
$template->_checkPlugins(array(array('function' => 'smarty_make_timestamp',
|
$template->_checkPlugins(
|
||||||
'file' => SMARTY_PLUGINS_DIR . 'shared.make_timestamp.php')));
|
array(array('function' => 'smarty_make_timestamp',
|
||||||
$time = smarty_make_timestamp($_value);
|
'file' => SMARTY_PLUGINS_DIR . 'shared.make_timestamp.php'))
|
||||||
}
|
);
|
||||||
break;
|
$time = smarty_make_timestamp($_value);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
case 'month_names':
|
case 'month_names':
|
||||||
if (is_array($_value) && count($_value) === 12) {
|
if (is_array($_value) && count($_value) === 12) {
|
||||||
$$_key = $_value;
|
$$_key = $_value;
|
||||||
} else {
|
} else {
|
||||||
trigger_error('html_select_date: month_names must be an array of 12 strings', E_USER_NOTICE);
|
trigger_error('html_select_date: month_names must be an array of 12 strings', E_USER_NOTICE);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'prefix':
|
case 'prefix':
|
||||||
case 'field_array':
|
case 'field_array':
|
||||||
case 'start_year':
|
case 'start_year':
|
||||||
case 'end_year':
|
case 'end_year':
|
||||||
case 'day_format':
|
case 'day_format':
|
||||||
case 'day_value_format':
|
case 'day_value_format':
|
||||||
case 'month_format':
|
case 'month_format':
|
||||||
case 'month_value_format':
|
case 'month_value_format':
|
||||||
case 'day_size':
|
case 'day_size':
|
||||||
case 'month_size':
|
case 'month_size':
|
||||||
case 'year_size':
|
case 'year_size':
|
||||||
case 'all_extra':
|
case 'all_extra':
|
||||||
case 'day_extra':
|
case 'day_extra':
|
||||||
case 'month_extra':
|
case 'month_extra':
|
||||||
case 'year_extra':
|
case 'year_extra':
|
||||||
case 'field_order':
|
case 'field_order':
|
||||||
case 'field_separator':
|
case 'field_separator':
|
||||||
case 'option_separator':
|
case 'option_separator':
|
||||||
case 'all_empty':
|
case 'all_empty':
|
||||||
case 'month_empty':
|
case 'month_empty':
|
||||||
case 'day_empty':
|
case 'day_empty':
|
||||||
case 'year_empty':
|
case 'year_empty':
|
||||||
case 'all_id':
|
case 'all_id':
|
||||||
case 'month_id':
|
case 'month_id':
|
||||||
case 'day_id':
|
case 'day_id':
|
||||||
case 'year_id':
|
case 'year_id':
|
||||||
$$_key = (string) $_value;
|
$$_key = (string) $_value;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'display_days':
|
case 'display_days':
|
||||||
case 'display_months':
|
case 'display_months':
|
||||||
case 'display_years':
|
case 'display_years':
|
||||||
case 'year_as_text':
|
case 'year_as_text':
|
||||||
case 'reverse_years':
|
case 'reverse_years':
|
||||||
$$_key = (bool) $_value;
|
$$_key = (bool) $_value;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
if (!is_array($_value)) {
|
if (!is_array($_value)) {
|
||||||
$extra_attrs .= ' ' . $_key . '="' . smarty_function_escape_special_chars($_value) . '"';
|
$extra_attrs .= ' ' . $_key . '="' . smarty_function_escape_special_chars($_value) . '"';
|
||||||
} else {
|
} else {
|
||||||
trigger_error("html_select_date: extra attribute '{$_key}' cannot be an array", E_USER_NOTICE);
|
trigger_error("html_select_date: extra attribute '{$_key}' cannot be an array", E_USER_NOTICE);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -250,10 +253,12 @@ function smarty_function_html_select_date($params, Smarty_Internal_Template $tem
|
|||||||
} else {
|
} else {
|
||||||
$_html_years = '<select name="' . $_name . '"';
|
$_html_years = '<select name="' . $_name . '"';
|
||||||
if ($year_id !== null || $all_id !== null) {
|
if ($year_id !== null || $all_id !== null) {
|
||||||
$_html_years .= ' id="' . smarty_function_escape_special_chars($year_id !== null ?
|
$_html_years .= ' id="' . smarty_function_escape_special_chars(
|
||||||
|
$year_id !== null ?
|
||||||
($year_id ? $year_id : $_name) :
|
($year_id ? $year_id : $_name) :
|
||||||
($all_id ? ($all_id . $_name) :
|
($all_id ? ($all_id . $_name) :
|
||||||
$_name)) . '"';
|
$_name)
|
||||||
|
) . '"';
|
||||||
}
|
}
|
||||||
if ($year_size) {
|
if ($year_size) {
|
||||||
$_html_years .= ' size="' . $year_size . '"';
|
$_html_years .= ' size="' . $year_size . '"';
|
||||||
@@ -288,10 +293,12 @@ function smarty_function_html_select_date($params, Smarty_Internal_Template $tem
|
|||||||
|
|
||||||
$_html_months = '<select name="' . $_name . '"';
|
$_html_months = '<select name="' . $_name . '"';
|
||||||
if ($month_id !== null || $all_id !== null) {
|
if ($month_id !== null || $all_id !== null) {
|
||||||
$_html_months .= ' id="' . smarty_function_escape_special_chars($month_id !== null ?
|
$_html_months .= ' id="' . smarty_function_escape_special_chars(
|
||||||
|
$month_id !== null ?
|
||||||
($month_id ? $month_id : $_name) :
|
($month_id ? $month_id : $_name) :
|
||||||
($all_id ? ($all_id . $_name) :
|
($all_id ? ($all_id . $_name) :
|
||||||
$_name)) . '"';
|
$_name)
|
||||||
|
) . '"';
|
||||||
}
|
}
|
||||||
if ($month_size) {
|
if ($month_size) {
|
||||||
$_html_months .= ' size="' . $month_size . '"';
|
$_html_months .= ' size="' . $month_size . '"';
|
||||||
@@ -329,8 +336,10 @@ function smarty_function_html_select_date($params, Smarty_Internal_Template $tem
|
|||||||
$_html_days = '<select name="' . $_name . '"';
|
$_html_days = '<select name="' . $_name . '"';
|
||||||
if ($day_id !== null || $all_id !== null) {
|
if ($day_id !== null || $all_id !== null) {
|
||||||
$_html_days .= ' id="' .
|
$_html_days .= ' id="' .
|
||||||
smarty_function_escape_special_chars($day_id !== null ? ($day_id ? $day_id : $_name) :
|
smarty_function_escape_special_chars(
|
||||||
($all_id ? ($all_id . $_name) : $_name)) . '"';
|
$day_id !== null ? ($day_id ? $day_id : $_name) :
|
||||||
|
($all_id ? ($all_id . $_name) : $_name)
|
||||||
|
) . '"';
|
||||||
}
|
}
|
||||||
if ($day_size) {
|
if ($day_size) {
|
||||||
$_html_days .= ' size="' . $day_size . '"';
|
$_html_days .= ' size="' . $day_size . '"';
|
||||||
@@ -357,35 +366,35 @@ function smarty_function_html_select_date($params, Smarty_Internal_Template $tem
|
|||||||
$_html = '';
|
$_html = '';
|
||||||
for ($i = 0; $i <= 2; $i ++) {
|
for ($i = 0; $i <= 2; $i ++) {
|
||||||
switch ($field_order[ $i ]) {
|
switch ($field_order[ $i ]) {
|
||||||
case 'Y':
|
case 'Y':
|
||||||
case 'y':
|
case 'y':
|
||||||
if (isset($_html_years)) {
|
if (isset($_html_years)) {
|
||||||
if ($_html) {
|
if ($_html) {
|
||||||
$_html .= $field_separator;
|
$_html .= $field_separator;
|
||||||
}
|
|
||||||
$_html .= $_html_years;
|
|
||||||
}
|
}
|
||||||
break;
|
$_html .= $_html_years;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
case 'm':
|
case 'm':
|
||||||
case 'M':
|
case 'M':
|
||||||
if (isset($_html_months)) {
|
if (isset($_html_months)) {
|
||||||
if ($_html) {
|
if ($_html) {
|
||||||
$_html .= $field_separator;
|
$_html .= $field_separator;
|
||||||
}
|
|
||||||
$_html .= $_html_months;
|
|
||||||
}
|
}
|
||||||
break;
|
$_html .= $_html_months;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
case 'd':
|
case 'd':
|
||||||
case 'D':
|
case 'D':
|
||||||
if (isset($_html_days)) {
|
if (isset($_html_days)) {
|
||||||
if ($_html) {
|
if ($_html) {
|
||||||
$_html .= $field_separator;
|
$_html .= $field_separator;
|
||||||
}
|
|
||||||
$_html .= $_html_days;
|
|
||||||
}
|
}
|
||||||
break;
|
$_html .= $_html_days;
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -11,23 +11,25 @@
|
|||||||
* Name: html_select_time
|
* Name: html_select_time
|
||||||
* Purpose: Prints the dropdowns for time selection
|
* Purpose: Prints the dropdowns for time selection
|
||||||
*
|
*
|
||||||
* @link http://www.smarty.net/manual/en/language.function.html.select.time.php {html_select_time}
|
* @link http://www.smarty.net/manual/en/language.function.html.select.time.php {html_select_time}
|
||||||
* (Smarty online manual)
|
* (Smarty online manual)
|
||||||
* @author Roberto Berto <roberto@berto.net>
|
* @author Roberto Berto <roberto@berto.net>
|
||||||
* @author Monte Ohrt <monte AT ohrt DOT com>
|
* @author Monte Ohrt <monte AT ohrt DOT com>
|
||||||
*
|
*
|
||||||
* @param array $params parameters
|
* @param array $params parameters
|
||||||
*
|
*
|
||||||
* @param \Smarty_Internal_Template $template
|
* @param \Smarty_Internal_Template $template
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
* @uses smarty_make_timestamp()
|
* @uses smarty_make_timestamp()
|
||||||
* @throws \SmartyException
|
* @throws \SmartyException
|
||||||
*/
|
*/
|
||||||
function smarty_function_html_select_time($params, Smarty_Internal_Template $template)
|
function smarty_function_html_select_time($params, Smarty_Internal_Template $template)
|
||||||
{
|
{
|
||||||
$template->_checkPlugins(array(array('function' => 'smarty_function_escape_special_chars',
|
$template->_checkPlugins(
|
||||||
'file' => SMARTY_PLUGINS_DIR . 'shared.escape_special_chars.php')));
|
array(array('function' => 'smarty_function_escape_special_chars',
|
||||||
|
'file' => SMARTY_PLUGINS_DIR . 'shared.escape_special_chars.php'))
|
||||||
|
);
|
||||||
$prefix = 'Time_';
|
$prefix = 'Time_';
|
||||||
$field_array = null;
|
$field_array = null;
|
||||||
$field_separator = "\n";
|
$field_separator = "\n";
|
||||||
@@ -76,72 +78,74 @@ function smarty_function_html_select_time($params, Smarty_Internal_Template $tem
|
|||||||
|
|
||||||
foreach ($params as $_key => $_value) {
|
foreach ($params as $_key => $_value) {
|
||||||
switch ($_key) {
|
switch ($_key) {
|
||||||
case 'time':
|
case 'time':
|
||||||
if (!is_array($_value) && $_value !== null) {
|
if (!is_array($_value) && $_value !== null) {
|
||||||
$template->_checkPlugins(array(array('function' => 'smarty_make_timestamp',
|
$template->_checkPlugins(
|
||||||
'file' => SMARTY_PLUGINS_DIR . 'shared.make_timestamp.php')));
|
array(array('function' => 'smarty_make_timestamp',
|
||||||
$time = smarty_make_timestamp($_value);
|
'file' => SMARTY_PLUGINS_DIR . 'shared.make_timestamp.php'))
|
||||||
}
|
);
|
||||||
break;
|
$time = smarty_make_timestamp($_value);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
case 'prefix':
|
case 'prefix':
|
||||||
case 'field_array':
|
case 'field_array':
|
||||||
|
|
||||||
case 'field_separator':
|
case 'field_separator':
|
||||||
case 'option_separator':
|
case 'option_separator':
|
||||||
|
|
||||||
case 'all_extra':
|
case 'all_extra':
|
||||||
case 'hour_extra':
|
case 'hour_extra':
|
||||||
case 'minute_extra':
|
case 'minute_extra':
|
||||||
case 'second_extra':
|
case 'second_extra':
|
||||||
case 'meridian_extra':
|
case 'meridian_extra':
|
||||||
|
|
||||||
case 'all_empty':
|
case 'all_empty':
|
||||||
case 'hour_empty':
|
case 'hour_empty':
|
||||||
case 'minute_empty':
|
case 'minute_empty':
|
||||||
case 'second_empty':
|
case 'second_empty':
|
||||||
case 'meridian_empty':
|
case 'meridian_empty':
|
||||||
|
|
||||||
case 'all_id':
|
case 'all_id':
|
||||||
case 'hour_id':
|
case 'hour_id':
|
||||||
case 'minute_id':
|
case 'minute_id':
|
||||||
case 'second_id':
|
case 'second_id':
|
||||||
case 'meridian_id':
|
case 'meridian_id':
|
||||||
|
|
||||||
case 'hour_format':
|
case 'hour_format':
|
||||||
case 'hour_value_format':
|
case 'hour_value_format':
|
||||||
case 'minute_format':
|
case 'minute_format':
|
||||||
case 'minute_value_format':
|
case 'minute_value_format':
|
||||||
case 'second_format':
|
case 'second_format':
|
||||||
case 'second_value_format':
|
case 'second_value_format':
|
||||||
$$_key = (string) $_value;
|
$$_key = (string) $_value;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'display_hours':
|
case 'display_hours':
|
||||||
case 'display_minutes':
|
case 'display_minutes':
|
||||||
case 'display_seconds':
|
case 'display_seconds':
|
||||||
case 'display_meridian':
|
case 'display_meridian':
|
||||||
case 'use_24_hours':
|
case 'use_24_hours':
|
||||||
$$_key = (bool) $_value;
|
$$_key = (bool) $_value;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'minute_interval':
|
case 'minute_interval':
|
||||||
case 'second_interval':
|
case 'second_interval':
|
||||||
|
|
||||||
case 'hour_size':
|
case 'hour_size':
|
||||||
case 'minute_size':
|
case 'minute_size':
|
||||||
case 'second_size':
|
case 'second_size':
|
||||||
case 'meridian_size':
|
case 'meridian_size':
|
||||||
$$_key = (int) $_value;
|
$$_key = (int) $_value;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
if (!is_array($_value)) {
|
if (!is_array($_value)) {
|
||||||
$extra_attrs .= ' ' . $_key . '="' . smarty_function_escape_special_chars($_value) . '"';
|
$extra_attrs .= ' ' . $_key . '="' . smarty_function_escape_special_chars($_value) . '"';
|
||||||
} else {
|
} else {
|
||||||
trigger_error("html_select_date: extra attribute '{$_key}' cannot be an array", E_USER_NOTICE);
|
trigger_error("html_select_date: extra attribute '{$_key}' cannot be an array", E_USER_NOTICE);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -203,8 +207,10 @@ function smarty_function_html_select_time($params, Smarty_Internal_Template $tem
|
|||||||
$_html_hours = '<select name="' . $_name . '"';
|
$_html_hours = '<select name="' . $_name . '"';
|
||||||
if ($hour_id !== null || $all_id !== null) {
|
if ($hour_id !== null || $all_id !== null) {
|
||||||
$_html_hours .= ' id="' .
|
$_html_hours .= ' id="' .
|
||||||
smarty_function_escape_special_chars($hour_id !== null ? ($hour_id ? $hour_id : $_name) :
|
smarty_function_escape_special_chars(
|
||||||
($all_id ? ($all_id . $_name) : $_name)) . '"';
|
$hour_id !== null ? ($hour_id ? $hour_id : $_name) :
|
||||||
|
($all_id ? ($all_id . $_name) : $_name)
|
||||||
|
) . '"';
|
||||||
}
|
}
|
||||||
if ($hour_size) {
|
if ($hour_size) {
|
||||||
$_html_hours .= ' size="' . $hour_size . '"';
|
$_html_hours .= ' size="' . $hour_size . '"';
|
||||||
@@ -249,10 +255,12 @@ function smarty_function_html_select_time($params, Smarty_Internal_Template $tem
|
|||||||
|
|
||||||
$_html_minutes = '<select name="' . $_name . '"';
|
$_html_minutes = '<select name="' . $_name . '"';
|
||||||
if ($minute_id !== null || $all_id !== null) {
|
if ($minute_id !== null || $all_id !== null) {
|
||||||
$_html_minutes .= ' id="' . smarty_function_escape_special_chars($minute_id !== null ?
|
$_html_minutes .= ' id="' . smarty_function_escape_special_chars(
|
||||||
|
$minute_id !== null ?
|
||||||
($minute_id ? $minute_id : $_name) :
|
($minute_id ? $minute_id : $_name) :
|
||||||
($all_id ? ($all_id . $_name) :
|
($all_id ? ($all_id . $_name) :
|
||||||
$_name)) . '"';
|
$_name)
|
||||||
|
) . '"';
|
||||||
}
|
}
|
||||||
if ($minute_size) {
|
if ($minute_size) {
|
||||||
$_html_minutes .= ' size="' . $minute_size . '"';
|
$_html_minutes .= ' size="' . $minute_size . '"';
|
||||||
@@ -290,10 +298,12 @@ function smarty_function_html_select_time($params, Smarty_Internal_Template $tem
|
|||||||
|
|
||||||
$_html_seconds = '<select name="' . $_name . '"';
|
$_html_seconds = '<select name="' . $_name . '"';
|
||||||
if ($second_id !== null || $all_id !== null) {
|
if ($second_id !== null || $all_id !== null) {
|
||||||
$_html_seconds .= ' id="' . smarty_function_escape_special_chars($second_id !== null ?
|
$_html_seconds .= ' id="' . smarty_function_escape_special_chars(
|
||||||
|
$second_id !== null ?
|
||||||
($second_id ? $second_id : $_name) :
|
($second_id ? $second_id : $_name) :
|
||||||
($all_id ? ($all_id . $_name) :
|
($all_id ? ($all_id . $_name) :
|
||||||
$_name)) . '"';
|
$_name)
|
||||||
|
) . '"';
|
||||||
}
|
}
|
||||||
if ($second_size) {
|
if ($second_size) {
|
||||||
$_html_seconds .= ' size="' . $second_size . '"';
|
$_html_seconds .= ' size="' . $second_size . '"';
|
||||||
@@ -331,11 +341,13 @@ function smarty_function_html_select_time($params, Smarty_Internal_Template $tem
|
|||||||
|
|
||||||
$_html_meridian = '<select name="' . $_name . '"';
|
$_html_meridian = '<select name="' . $_name . '"';
|
||||||
if ($meridian_id !== null || $all_id !== null) {
|
if ($meridian_id !== null || $all_id !== null) {
|
||||||
$_html_meridian .= ' id="' . smarty_function_escape_special_chars($meridian_id !== null ?
|
$_html_meridian .= ' id="' . smarty_function_escape_special_chars(
|
||||||
|
$meridian_id !== null ?
|
||||||
($meridian_id ? $meridian_id :
|
($meridian_id ? $meridian_id :
|
||||||
$_name) :
|
$_name) :
|
||||||
($all_id ? ($all_id . $_name) :
|
($all_id ? ($all_id . $_name) :
|
||||||
$_name)) . '"';
|
$_name)
|
||||||
|
) . '"';
|
||||||
}
|
}
|
||||||
if ($meridian_size) {
|
if ($meridian_size) {
|
||||||
$_html_meridian .= ' size="' . $meridian_size . '"';
|
$_html_meridian .= ' size="' . $meridian_size . '"';
|
||||||
|
@@ -35,12 +35,11 @@
|
|||||||
* {table loop=$data cols=4 tr_attr='"bgcolor=red"'}
|
* {table loop=$data cols=4 tr_attr='"bgcolor=red"'}
|
||||||
* {table loop=$data cols="first,second,third" tr_attr=$colors}
|
* {table loop=$data cols="first,second,third" tr_attr=$colors}
|
||||||
*
|
*
|
||||||
*
|
* @author Monte Ohrt <monte at ohrt dot com>
|
||||||
* @author Monte Ohrt <monte at ohrt dot com>
|
* @author credit to Messju Mohr <messju at lammfellpuschen dot de>
|
||||||
* @author credit to Messju Mohr <messju at lammfellpuschen dot de>
|
* @author credit to boots <boots dot smarty at yahoo dot com>
|
||||||
* @author credit to boots <boots dot smarty at yahoo dot com>
|
* @version 1.1
|
||||||
* @version 1.1
|
* @link http://www.smarty.net/manual/en/language.function.html.table.php {html_table}
|
||||||
* @link http://www.smarty.net/manual/en/language.function.html.table.php {html_table}
|
|
||||||
* (Smarty online manual)
|
* (Smarty online manual)
|
||||||
*
|
*
|
||||||
* @param array $params parameters
|
* @param array $params parameters
|
||||||
@@ -70,42 +69,42 @@ function smarty_function_html_table($params)
|
|||||||
|
|
||||||
foreach ($params as $_key => $_value) {
|
foreach ($params as $_key => $_value) {
|
||||||
switch ($_key) {
|
switch ($_key) {
|
||||||
case 'loop':
|
case 'loop':
|
||||||
$$_key = (array) $_value;
|
$$_key = (array) $_value;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'cols':
|
case 'cols':
|
||||||
if (is_array($_value) && !empty($_value)) {
|
if (is_array($_value) && !empty($_value)) {
|
||||||
$cols = $_value;
|
$cols = $_value;
|
||||||
$cols_count = count($_value);
|
$cols_count = count($_value);
|
||||||
} elseif (!is_numeric($_value) && is_string($_value) && !empty($_value)) {
|
} elseif (!is_numeric($_value) && is_string($_value) && !empty($_value)) {
|
||||||
$cols = explode(',', $_value);
|
$cols = explode(',', $_value);
|
||||||
$cols_count = count($cols);
|
$cols_count = count($cols);
|
||||||
} elseif (!empty($_value)) {
|
} elseif (!empty($_value)) {
|
||||||
$cols_count = (int) $_value;
|
$cols_count = (int) $_value;
|
||||||
} else {
|
} else {
|
||||||
$cols_count = $cols;
|
$cols_count = $cols;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'rows':
|
case 'rows':
|
||||||
$$_key = (int) $_value;
|
$$_key = (int) $_value;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'table_attr':
|
case 'table_attr':
|
||||||
case 'trailpad':
|
case 'trailpad':
|
||||||
case 'hdir':
|
case 'hdir':
|
||||||
case 'vdir':
|
case 'vdir':
|
||||||
case 'inner':
|
case 'inner':
|
||||||
case 'caption':
|
case 'caption':
|
||||||
$$_key = (string) $_value;
|
$$_key = (string) $_value;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'tr_attr':
|
case 'tr_attr':
|
||||||
case 'td_attr':
|
case 'td_attr':
|
||||||
case 'th_attr':
|
case 'th_attr':
|
||||||
$$_key = $_value;
|
$$_key = $_value;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -37,12 +37,11 @@
|
|||||||
* {mailto address="me@domain.com" cc="you@domain.com,they@domain.com"}
|
* {mailto address="me@domain.com" cc="you@domain.com,they@domain.com"}
|
||||||
* {mailto address="me@domain.com" extra='class="mailto"'}
|
* {mailto address="me@domain.com" extra='class="mailto"'}
|
||||||
*
|
*
|
||||||
*
|
* @link http://www.smarty.net/manual/en/language.function.mailto.php {mailto}
|
||||||
* @link http://www.smarty.net/manual/en/language.function.mailto.php {mailto}
|
|
||||||
* (Smarty online manual)
|
* (Smarty online manual)
|
||||||
* @version 1.2
|
* @version 1.2
|
||||||
* @author Monte Ohrt <monte at ohrt dot com>
|
* @author Monte Ohrt <monte at ohrt dot com>
|
||||||
* @author credits to Jason Sweat (added cc, bcc and subject functionality)
|
* @author credits to Jason Sweat (added cc, bcc and subject functionality)
|
||||||
*
|
*
|
||||||
* @param array $params parameters
|
* @param array $params parameters
|
||||||
*
|
*
|
||||||
@@ -70,24 +69,24 @@ function smarty_function_mailto($params)
|
|||||||
$mail_parms = array();
|
$mail_parms = array();
|
||||||
foreach ($params as $var => $value) {
|
foreach ($params as $var => $value) {
|
||||||
switch ($var) {
|
switch ($var) {
|
||||||
case 'cc':
|
case 'cc':
|
||||||
case 'bcc':
|
case 'bcc':
|
||||||
case 'followupto':
|
case 'followupto':
|
||||||
if (!empty($value)) {
|
if (!empty($value)) {
|
||||||
$mail_parms[] = $var . '=' . str_replace($search, $replace, rawurlencode($value));
|
$mail_parms[] = $var . '=' . str_replace($search, $replace, rawurlencode($value));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'subject':
|
case 'subject':
|
||||||
case 'newsgroups':
|
case 'newsgroups':
|
||||||
$mail_parms[] = $var . '=' . rawurlencode($value);
|
$mail_parms[] = $var . '=' . rawurlencode($value);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'extra':
|
case 'extra':
|
||||||
case 'text':
|
case 'text':
|
||||||
$$var = $value;
|
$$var = $value;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -97,8 +96,10 @@ function smarty_function_mailto($params)
|
|||||||
|
|
||||||
$encode = (empty($params[ 'encode' ])) ? 'none' : $params[ 'encode' ];
|
$encode = (empty($params[ 'encode' ])) ? 'none' : $params[ 'encode' ];
|
||||||
if (!isset($_allowed_encoding[ $encode ])) {
|
if (!isset($_allowed_encoding[ $encode ])) {
|
||||||
trigger_error("mailto: 'encode' parameter must be none, javascript, javascript_charcode or hex",
|
trigger_error(
|
||||||
E_USER_WARNING);
|
"mailto: 'encode' parameter must be none, javascript, javascript_charcode or hex",
|
||||||
|
E_USER_WARNING
|
||||||
|
);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@@ -13,9 +13,9 @@
|
|||||||
* Name: math
|
* Name: math
|
||||||
* Purpose: handle math computations in template
|
* Purpose: handle math computations in template
|
||||||
*
|
*
|
||||||
* @link http://www.smarty.net/manual/en/language.function.math.php {math}
|
* @link http://www.smarty.net/manual/en/language.function.math.php {math}
|
||||||
* (Smarty online manual)
|
* (Smarty online manual)
|
||||||
* @author Monte Ohrt <monte at ohrt dot com>
|
* @author Monte Ohrt <monte at ohrt dot com>
|
||||||
*
|
*
|
||||||
* @param array $params parameters
|
* @param array $params parameters
|
||||||
* @param Smarty_Internal_Template $template template object
|
* @param Smarty_Internal_Template $template template object
|
||||||
|
@@ -29,23 +29,32 @@ function smarty_modifier_capitalize($string, $uc_digits = false, $lc_rest = fals
|
|||||||
$upper_string = mb_convert_case($string, MB_CASE_TITLE, Smarty::$_CHARSET);
|
$upper_string = mb_convert_case($string, MB_CASE_TITLE, Smarty::$_CHARSET);
|
||||||
} else {
|
} else {
|
||||||
// uppercase word breaks
|
// uppercase word breaks
|
||||||
$upper_string = preg_replace_callback("!(^|[^\p{L}'])([\p{Ll}])!S" . Smarty::$_UTF8_MODIFIER,
|
$upper_string = preg_replace_callback(
|
||||||
'smarty_mod_cap_mbconvert_cb', $string);
|
"!(^|[^\p{L}'])([\p{Ll}])!S" . Smarty::$_UTF8_MODIFIER,
|
||||||
|
'smarty_mod_cap_mbconvert_cb', $string
|
||||||
|
);
|
||||||
}
|
}
|
||||||
// check uc_digits case
|
// check uc_digits case
|
||||||
if (!$uc_digits) {
|
if (!$uc_digits) {
|
||||||
if (preg_match_all("!\b([\p{L}]*[\p{N}]+[\p{L}]*)\b!" . Smarty::$_UTF8_MODIFIER, $string, $matches,
|
if (preg_match_all(
|
||||||
PREG_OFFSET_CAPTURE)) {
|
"!\b([\p{L}]*[\p{N}]+[\p{L}]*)\b!" . Smarty::$_UTF8_MODIFIER, $string, $matches,
|
||||||
|
PREG_OFFSET_CAPTURE
|
||||||
|
)
|
||||||
|
) {
|
||||||
foreach ($matches[ 1 ] as $match) {
|
foreach ($matches[ 1 ] as $match) {
|
||||||
$upper_string =
|
$upper_string =
|
||||||
substr_replace($upper_string, mb_strtolower($match[ 0 ], Smarty::$_CHARSET), $match[ 1 ],
|
substr_replace(
|
||||||
strlen($match[ 0 ]));
|
$upper_string, mb_strtolower($match[ 0 ], Smarty::$_CHARSET), $match[ 1 ],
|
||||||
|
strlen($match[ 0 ])
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$upper_string =
|
$upper_string =
|
||||||
preg_replace_callback("!((^|\s)['\"])(\w)!" . Smarty::$_UTF8_MODIFIER, 'smarty_mod_cap_mbconvert2_cb',
|
preg_replace_callback(
|
||||||
$upper_string);
|
"!((^|\s)['\"])(\w)!" . Smarty::$_UTF8_MODIFIER, 'smarty_mod_cap_mbconvert2_cb',
|
||||||
|
$upper_string
|
||||||
|
);
|
||||||
return $upper_string;
|
return $upper_string;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -55,20 +64,27 @@ function smarty_modifier_capitalize($string, $uc_digits = false, $lc_rest = fals
|
|||||||
}
|
}
|
||||||
// uppercase (including hyphenated words)
|
// uppercase (including hyphenated words)
|
||||||
$upper_string =
|
$upper_string =
|
||||||
preg_replace_callback("!(^|[^\p{L}'])([\p{Ll}])!S" . Smarty::$_UTF8_MODIFIER, 'smarty_mod_cap_ucfirst_cb',
|
preg_replace_callback(
|
||||||
$string);
|
"!(^|[^\p{L}'])([\p{Ll}])!S" . Smarty::$_UTF8_MODIFIER, 'smarty_mod_cap_ucfirst_cb',
|
||||||
|
$string
|
||||||
|
);
|
||||||
// check uc_digits case
|
// check uc_digits case
|
||||||
if (!$uc_digits) {
|
if (!$uc_digits) {
|
||||||
if (preg_match_all("!\b([\p{L}]*[\p{N}]+[\p{L}]*)\b!" . Smarty::$_UTF8_MODIFIER, $string, $matches,
|
if (preg_match_all(
|
||||||
PREG_OFFSET_CAPTURE)) {
|
"!\b([\p{L}]*[\p{N}]+[\p{L}]*)\b!" . Smarty::$_UTF8_MODIFIER, $string, $matches,
|
||||||
|
PREG_OFFSET_CAPTURE
|
||||||
|
)
|
||||||
|
) {
|
||||||
foreach ($matches[ 1 ] as $match) {
|
foreach ($matches[ 1 ] as $match) {
|
||||||
$upper_string =
|
$upper_string =
|
||||||
substr_replace($upper_string, strtolower($match[ 0 ]), $match[ 1 ], strlen($match[ 0 ]));
|
substr_replace($upper_string, strtolower($match[ 0 ]), $match[ 1 ], strlen($match[ 0 ]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$upper_string = preg_replace_callback("!((^|\s)['\"])(\w)!" . Smarty::$_UTF8_MODIFIER, 'smarty_mod_cap_ucfirst2_cb',
|
$upper_string = preg_replace_callback(
|
||||||
$upper_string);
|
"!((^|\s)['\"])(\w)!" . Smarty::$_UTF8_MODIFIER, 'smarty_mod_cap_ucfirst2_cb',
|
||||||
|
$upper_string
|
||||||
|
);
|
||||||
return $upper_string;
|
return $upper_string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -38,7 +38,7 @@ function smarty_modifier_date_format($string, $format = null, $default_date = ''
|
|||||||
static $is_loaded = false;
|
static $is_loaded = false;
|
||||||
if (!$is_loaded) {
|
if (!$is_loaded) {
|
||||||
if (!is_callable('smarty_make_timestamp')) {
|
if (!is_callable('smarty_make_timestamp')) {
|
||||||
require_once(SMARTY_PLUGINS_DIR . 'shared.make_timestamp.php');
|
include_once SMARTY_PLUGINS_DIR . 'shared.make_timestamp.php';
|
||||||
}
|
}
|
||||||
$is_loaded = true;
|
$is_loaded = true;
|
||||||
}
|
}
|
||||||
|
@@ -26,86 +26,86 @@ function smarty_modifier_debug_print_var($var, $max = 10, $length = 40, $depth =
|
|||||||
{
|
{
|
||||||
$_replace = array("\n" => '\n', "\r" => '\r', "\t" => '\t');
|
$_replace = array("\n" => '\n', "\r" => '\r', "\t" => '\t');
|
||||||
switch (gettype($var)) {
|
switch (gettype($var)) {
|
||||||
case 'array' :
|
case 'array' :
|
||||||
$results = '<b>Array (' . count($var) . ')</b>';
|
$results = '<b>Array (' . count($var) . ')</b>';
|
||||||
if ($depth === $max) {
|
if ($depth === $max) {
|
||||||
break;
|
|
||||||
}
|
|
||||||
foreach ($var as $curr_key => $curr_val) {
|
|
||||||
$results .= '<br>' . str_repeat(' ', $depth * 2) . '<b>' . strtr($curr_key, $_replace) .
|
|
||||||
'</b> => ' .
|
|
||||||
smarty_modifier_debug_print_var($curr_val, $max, $length, ++ $depth, $objects);
|
|
||||||
$depth --;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
foreach ($var as $curr_key => $curr_val) {
|
||||||
|
$results .= '<br>' . str_repeat(' ', $depth * 2) . '<b>' . strtr($curr_key, $_replace) .
|
||||||
|
'</b> => ' .
|
||||||
|
smarty_modifier_debug_print_var($curr_val, $max, $length, ++ $depth, $objects);
|
||||||
|
$depth --;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
case 'object' :
|
case 'object' :
|
||||||
$object_vars = get_object_vars($var);
|
$object_vars = get_object_vars($var);
|
||||||
$results = '<b>' . get_class($var) . ' Object (' . count($object_vars) . ')</b>';
|
$results = '<b>' . get_class($var) . ' Object (' . count($object_vars) . ')</b>';
|
||||||
if (in_array($var, $objects)) {
|
if (in_array($var, $objects)) {
|
||||||
$results .= ' called recursive';
|
$results .= ' called recursive';
|
||||||
break;
|
|
||||||
}
|
|
||||||
if ($depth === $max) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
$objects[] = $var;
|
|
||||||
foreach ($object_vars as $curr_key => $curr_val) {
|
|
||||||
$results .= '<br>' . str_repeat(' ', $depth * 2) . '<b> ->' . strtr($curr_key, $_replace) .
|
|
||||||
'</b> = ' . smarty_modifier_debug_print_var($curr_val, $max, $length, ++ $depth, $objects);
|
|
||||||
$depth --;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case 'boolean' :
|
if ($depth === $max) {
|
||||||
case 'NULL' :
|
|
||||||
case 'resource' :
|
|
||||||
if (true === $var) {
|
|
||||||
$results = 'true';
|
|
||||||
} elseif (false === $var) {
|
|
||||||
$results = 'false';
|
|
||||||
} elseif (null === $var) {
|
|
||||||
$results = 'null';
|
|
||||||
} else {
|
|
||||||
$results = htmlspecialchars((string) $var);
|
|
||||||
}
|
|
||||||
$results = '<i>' . $results . '</i>';
|
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
$objects[] = $var;
|
||||||
|
foreach ($object_vars as $curr_key => $curr_val) {
|
||||||
|
$results .= '<br>' . str_repeat(' ', $depth * 2) . '<b> ->' . strtr($curr_key, $_replace) .
|
||||||
|
'</b> = ' . smarty_modifier_debug_print_var($curr_val, $max, $length, ++ $depth, $objects);
|
||||||
|
$depth --;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
case 'integer' :
|
case 'boolean' :
|
||||||
case 'float' :
|
case 'NULL' :
|
||||||
|
case 'resource' :
|
||||||
|
if (true === $var) {
|
||||||
|
$results = 'true';
|
||||||
|
} elseif (false === $var) {
|
||||||
|
$results = 'false';
|
||||||
|
} elseif (null === $var) {
|
||||||
|
$results = 'null';
|
||||||
|
} else {
|
||||||
$results = htmlspecialchars((string) $var);
|
$results = htmlspecialchars((string) $var);
|
||||||
break;
|
}
|
||||||
|
$results = '<i>' . $results . '</i>';
|
||||||
|
break;
|
||||||
|
|
||||||
case 'string' :
|
case 'integer' :
|
||||||
$results = strtr($var, $_replace);
|
case 'float' :
|
||||||
if (Smarty::$_MBSTRING) {
|
$results = htmlspecialchars((string) $var);
|
||||||
if (mb_strlen($var, Smarty::$_CHARSET) > $length) {
|
break;
|
||||||
$results = mb_substr($var, 0, $length - 3, Smarty::$_CHARSET) . '...';
|
|
||||||
}
|
case 'string' :
|
||||||
} else {
|
$results = strtr($var, $_replace);
|
||||||
if (isset($var[ $length ])) {
|
if (Smarty::$_MBSTRING) {
|
||||||
$results = substr($var, 0, $length - 3) . '...';
|
if (mb_strlen($var, Smarty::$_CHARSET) > $length) {
|
||||||
}
|
$results = mb_substr($var, 0, $length - 3, Smarty::$_CHARSET) . '...';
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
$results = htmlspecialchars('"' . $results . '"', ENT_QUOTES, Smarty::$_CHARSET);
|
if (isset($var[ $length ])) {
|
||||||
break;
|
$results = substr($var, 0, $length - 3) . '...';
|
||||||
|
|
||||||
case 'unknown type' :
|
|
||||||
default :
|
|
||||||
$results = strtr((string) $var, $_replace);
|
|
||||||
if (Smarty::$_MBSTRING) {
|
|
||||||
if (mb_strlen($results, Smarty::$_CHARSET) > $length) {
|
|
||||||
$results = mb_substr($results, 0, $length - 3, Smarty::$_CHARSET) . '...';
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (strlen($results) > $length) {
|
|
||||||
$results = substr($results, 0, $length - 3) . '...';
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$results = htmlspecialchars($results, ENT_QUOTES, Smarty::$_CHARSET);
|
$results = htmlspecialchars('"' . $results . '"', ENT_QUOTES, Smarty::$_CHARSET);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'unknown type' :
|
||||||
|
default :
|
||||||
|
$results = strtr((string) $var, $_replace);
|
||||||
|
if (Smarty::$_MBSTRING) {
|
||||||
|
if (mb_strlen($results, Smarty::$_CHARSET) > $length) {
|
||||||
|
$results = mb_substr($results, 0, $length - 3, Smarty::$_CHARSET) . '...';
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (strlen($results) > $length) {
|
||||||
|
$results = substr($results, 0, $length - 3) . '...';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$results = htmlspecialchars($results, ENT_QUOTES, Smarty::$_CHARSET);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $results;
|
return $results;
|
||||||
|
@@ -36,200 +36,212 @@ function smarty_modifier_escape($string, $esc_type = 'html', $char_set = null, $
|
|||||||
}
|
}
|
||||||
|
|
||||||
switch ($esc_type) {
|
switch ($esc_type) {
|
||||||
case 'html':
|
case 'html':
|
||||||
|
if ($_double_encode) {
|
||||||
|
// php >=5.3.2 - go native
|
||||||
|
return htmlspecialchars($string, ENT_QUOTES, $char_set, $double_encode);
|
||||||
|
} else {
|
||||||
|
if ($double_encode) {
|
||||||
|
// php <5.2.3 - only handle double encoding
|
||||||
|
return htmlspecialchars($string, ENT_QUOTES, $char_set);
|
||||||
|
} else {
|
||||||
|
// php <5.2.3 - prevent double encoding
|
||||||
|
$string = preg_replace('!&(#?\w+);!', '%%%SMARTY_START%%%\\1%%%SMARTY_END%%%', $string);
|
||||||
|
$string = htmlspecialchars($string, ENT_QUOTES, $char_set);
|
||||||
|
$string = str_replace(
|
||||||
|
array('%%%SMARTY_START%%%',
|
||||||
|
'%%%SMARTY_END%%%'), array('&',
|
||||||
|
';'), $string
|
||||||
|
);
|
||||||
|
|
||||||
|
return $string;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
case 'htmlall':
|
||||||
|
if (Smarty::$_MBSTRING) {
|
||||||
|
// mb_convert_encoding ignores htmlspecialchars()
|
||||||
if ($_double_encode) {
|
if ($_double_encode) {
|
||||||
// php >=5.3.2 - go native
|
// php >=5.3.2 - go native
|
||||||
return htmlspecialchars($string, ENT_QUOTES, $char_set, $double_encode);
|
$string = htmlspecialchars($string, ENT_QUOTES, $char_set, $double_encode);
|
||||||
} else {
|
} else {
|
||||||
if ($double_encode) {
|
if ($double_encode) {
|
||||||
// php <5.2.3 - only handle double encoding
|
// php <5.2.3 - only handle double encoding
|
||||||
return htmlspecialchars($string, ENT_QUOTES, $char_set);
|
$string = htmlspecialchars($string, ENT_QUOTES, $char_set);
|
||||||
} else {
|
} else {
|
||||||
// php <5.2.3 - prevent double encoding
|
// php <5.2.3 - prevent double encoding
|
||||||
$string = preg_replace('!&(#?\w+);!', '%%%SMARTY_START%%%\\1%%%SMARTY_END%%%', $string);
|
$string = preg_replace('!&(#?\w+);!', '%%%SMARTY_START%%%\\1%%%SMARTY_END%%%', $string);
|
||||||
$string = htmlspecialchars($string, ENT_QUOTES, $char_set);
|
$string = htmlspecialchars($string, ENT_QUOTES, $char_set);
|
||||||
$string = str_replace(array('%%%SMARTY_START%%%',
|
$string =
|
||||||
'%%%SMARTY_END%%%'), array('&',
|
str_replace(
|
||||||
';'), $string);
|
array('%%%SMARTY_START%%%',
|
||||||
|
'%%%SMARTY_END%%%'), array('&',
|
||||||
|
';'), $string
|
||||||
|
);
|
||||||
|
|
||||||
return $string;
|
return $string;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
case 'htmlall':
|
// htmlentities() won't convert everything, so use mb_convert_encoding
|
||||||
if (Smarty::$_MBSTRING) {
|
return mb_convert_encoding($string, 'HTML-ENTITIES', $char_set);
|
||||||
// mb_convert_encoding ignores htmlspecialchars()
|
}
|
||||||
if ($_double_encode) {
|
|
||||||
// php >=5.3.2 - go native
|
|
||||||
$string = htmlspecialchars($string, ENT_QUOTES, $char_set, $double_encode);
|
|
||||||
} else {
|
|
||||||
if ($double_encode) {
|
|
||||||
// php <5.2.3 - only handle double encoding
|
|
||||||
$string = htmlspecialchars($string, ENT_QUOTES, $char_set);
|
|
||||||
} else {
|
|
||||||
// php <5.2.3 - prevent double encoding
|
|
||||||
$string = preg_replace('!&(#?\w+);!', '%%%SMARTY_START%%%\\1%%%SMARTY_END%%%', $string);
|
|
||||||
$string = htmlspecialchars($string, ENT_QUOTES, $char_set);
|
|
||||||
$string =
|
|
||||||
str_replace(array('%%%SMARTY_START%%%',
|
|
||||||
'%%%SMARTY_END%%%'), array('&',
|
|
||||||
';'), $string);
|
|
||||||
|
|
||||||
return $string;
|
// no MBString fallback
|
||||||
}
|
if ($_double_encode) {
|
||||||
}
|
return htmlentities($string, ENT_QUOTES, $char_set, $double_encode);
|
||||||
|
} else {
|
||||||
// htmlentities() won't convert everything, so use mb_convert_encoding
|
if ($double_encode) {
|
||||||
return mb_convert_encoding($string, 'HTML-ENTITIES', $char_set);
|
return htmlentities($string, ENT_QUOTES, $char_set);
|
||||||
}
|
|
||||||
|
|
||||||
// no MBString fallback
|
|
||||||
if ($_double_encode) {
|
|
||||||
return htmlentities($string, ENT_QUOTES, $char_set, $double_encode);
|
|
||||||
} else {
|
} else {
|
||||||
if ($double_encode) {
|
$string = preg_replace('!&(#?\w+);!', '%%%SMARTY_START%%%\\1%%%SMARTY_END%%%', $string);
|
||||||
return htmlentities($string, ENT_QUOTES, $char_set);
|
$string = htmlentities($string, ENT_QUOTES, $char_set);
|
||||||
} else {
|
$string = str_replace(
|
||||||
$string = preg_replace('!&(#?\w+);!', '%%%SMARTY_START%%%\\1%%%SMARTY_END%%%', $string);
|
array('%%%SMARTY_START%%%',
|
||||||
$string = htmlentities($string, ENT_QUOTES, $char_set);
|
'%%%SMARTY_END%%%'), array('&',
|
||||||
$string = str_replace(array('%%%SMARTY_START%%%',
|
';'), $string
|
||||||
'%%%SMARTY_END%%%'), array('&',
|
);
|
||||||
';'), $string);
|
|
||||||
|
|
||||||
return $string;
|
return $string;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
case 'url':
|
case 'url':
|
||||||
return rawurlencode($string);
|
return rawurlencode($string);
|
||||||
|
|
||||||
case 'urlpathinfo':
|
case 'urlpathinfo':
|
||||||
return str_replace('%2F', '/', rawurlencode($string));
|
return str_replace('%2F', '/', rawurlencode($string));
|
||||||
|
|
||||||
case 'quotes':
|
case 'quotes':
|
||||||
// escape unescaped single quotes
|
// escape unescaped single quotes
|
||||||
return preg_replace("%(?<!\\\\)'%", "\\'", $string);
|
return preg_replace("%(?<!\\\\)'%", "\\'", $string);
|
||||||
|
|
||||||
case 'hex':
|
case 'hex':
|
||||||
// escape every byte into hex
|
// escape every byte into hex
|
||||||
// Note that the UTF-8 encoded character ä will be represented as %c3%a4
|
// Note that the UTF-8 encoded character ä will be represented as %c3%a4
|
||||||
|
$return = '';
|
||||||
|
$_length = strlen($string);
|
||||||
|
for ($x = 0; $x < $_length; $x ++) {
|
||||||
|
$return .= '%' . bin2hex($string[ $x ]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $return;
|
||||||
|
|
||||||
|
case 'hexentity':
|
||||||
|
$return = '';
|
||||||
|
if (Smarty::$_MBSTRING) {
|
||||||
|
if (!$is_loaded_1) {
|
||||||
|
if (!is_callable('smarty_mb_to_unicode')) {
|
||||||
|
include_once SMARTY_PLUGINS_DIR . 'shared.mb_unicode.php';
|
||||||
|
}
|
||||||
|
$is_loaded_1 = true;
|
||||||
|
}
|
||||||
$return = '';
|
$return = '';
|
||||||
$_length = strlen($string);
|
foreach (smarty_mb_to_unicode($string, Smarty::$_CHARSET) as $unicode) {
|
||||||
for ($x = 0; $x < $_length; $x ++) {
|
$return .= '&#x' . strtoupper(dechex($unicode)) . ';';
|
||||||
$return .= '%' . bin2hex($string[ $x ]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $return;
|
return $return;
|
||||||
|
}
|
||||||
|
// no MBString fallback
|
||||||
|
$_length = strlen($string);
|
||||||
|
for ($x = 0; $x < $_length; $x ++) {
|
||||||
|
$return .= '&#x' . bin2hex($string[ $x ]) . ';';
|
||||||
|
}
|
||||||
|
|
||||||
case 'hexentity':
|
return $return;
|
||||||
$return = '';
|
|
||||||
if (Smarty::$_MBSTRING) {
|
|
||||||
if (!$is_loaded_1) {
|
|
||||||
if (!is_callable('smarty_mb_to_unicode')) {
|
|
||||||
require_once(SMARTY_PLUGINS_DIR . 'shared.mb_unicode.php');
|
|
||||||
}
|
|
||||||
$is_loaded_1 = true;
|
|
||||||
}
|
|
||||||
$return = '';
|
|
||||||
foreach (smarty_mb_to_unicode($string, Smarty::$_CHARSET) as $unicode) {
|
|
||||||
$return .= '&#x' . strtoupper(dechex($unicode)) . ';';
|
|
||||||
}
|
|
||||||
|
|
||||||
return $return;
|
case 'decentity':
|
||||||
|
$return = '';
|
||||||
|
if (Smarty::$_MBSTRING) {
|
||||||
|
if (!$is_loaded_1) {
|
||||||
|
if (!is_callable('smarty_mb_to_unicode')) {
|
||||||
|
include_once SMARTY_PLUGINS_DIR . 'shared.mb_unicode.php';
|
||||||
|
}
|
||||||
|
$is_loaded_1 = true;
|
||||||
}
|
}
|
||||||
// no MBString fallback
|
$return = '';
|
||||||
$_length = strlen($string);
|
foreach (smarty_mb_to_unicode($string, Smarty::$_CHARSET) as $unicode) {
|
||||||
for ($x = 0; $x < $_length; $x ++) {
|
$return .= '&#' . $unicode . ';';
|
||||||
$return .= '&#x' . bin2hex($string[ $x ]) . ';';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $return;
|
return $return;
|
||||||
|
}
|
||||||
|
// no MBString fallback
|
||||||
|
$_length = strlen($string);
|
||||||
|
for ($x = 0; $x < $_length; $x ++) {
|
||||||
|
$return .= '&#' . ord($string[ $x ]) . ';';
|
||||||
|
}
|
||||||
|
|
||||||
case 'decentity':
|
return $return;
|
||||||
$return = '';
|
|
||||||
if (Smarty::$_MBSTRING) {
|
|
||||||
if (!$is_loaded_1) {
|
|
||||||
if (!is_callable('smarty_mb_to_unicode')) {
|
|
||||||
require_once(SMARTY_PLUGINS_DIR . 'shared.mb_unicode.php');
|
|
||||||
}
|
|
||||||
$is_loaded_1 = true;
|
|
||||||
}
|
|
||||||
$return = '';
|
|
||||||
foreach (smarty_mb_to_unicode($string, Smarty::$_CHARSET) as $unicode) {
|
|
||||||
$return .= '&#' . $unicode . ';';
|
|
||||||
}
|
|
||||||
|
|
||||||
return $return;
|
case 'javascript':
|
||||||
}
|
// escape quotes and backslashes, newlines, etc.
|
||||||
// no MBString fallback
|
return strtr(
|
||||||
$_length = strlen($string);
|
$string, array('\\' => '\\\\',
|
||||||
for ($x = 0; $x < $_length; $x ++) {
|
|
||||||
$return .= '&#' . ord($string[ $x ]) . ';';
|
|
||||||
}
|
|
||||||
|
|
||||||
return $return;
|
|
||||||
|
|
||||||
case 'javascript':
|
|
||||||
// escape quotes and backslashes, newlines, etc.
|
|
||||||
return strtr($string, array('\\' => '\\\\',
|
|
||||||
"'" => "\\'",
|
"'" => "\\'",
|
||||||
'"' => '\\"',
|
'"' => '\\"',
|
||||||
"\r" => '\\r',
|
"\r" => '\\r',
|
||||||
"\n" => '\\n',
|
"\n" => '\\n',
|
||||||
'</' => '<\/'));
|
'</' => '<\/')
|
||||||
|
);
|
||||||
|
|
||||||
case 'mail':
|
case 'mail':
|
||||||
if (Smarty::$_MBSTRING) {
|
if (Smarty::$_MBSTRING) {
|
||||||
if (!$is_loaded_2) {
|
if (!$is_loaded_2) {
|
||||||
if (!is_callable('smarty_mb_str_replace')) {
|
if (!is_callable('smarty_mb_str_replace')) {
|
||||||
require_once(SMARTY_PLUGINS_DIR . 'shared.mb_str_replace.php');
|
include_once SMARTY_PLUGINS_DIR . 'shared.mb_str_replace.php';
|
||||||
}
|
|
||||||
$is_loaded_2 = true;
|
|
||||||
}
|
}
|
||||||
return smarty_mb_str_replace(array('@',
|
$is_loaded_2 = true;
|
||||||
'.'), array(' [AT] ',
|
|
||||||
' [DOT] '), $string);
|
|
||||||
}
|
}
|
||||||
// no MBString fallback
|
return smarty_mb_str_replace(
|
||||||
return str_replace(array('@',
|
array('@',
|
||||||
|
'.'), array(' [AT] ',
|
||||||
|
' [DOT] '), $string
|
||||||
|
);
|
||||||
|
}
|
||||||
|
// no MBString fallback
|
||||||
|
return str_replace(
|
||||||
|
array('@',
|
||||||
'.'), array(' [AT] ',
|
'.'), array(' [AT] ',
|
||||||
' [DOT] '), $string);
|
' [DOT] '), $string
|
||||||
|
);
|
||||||
|
|
||||||
case 'nonstd':
|
case 'nonstd':
|
||||||
// escape non-standard chars, such as ms document quotes
|
// escape non-standard chars, such as ms document quotes
|
||||||
$return = '';
|
$return = '';
|
||||||
if (Smarty::$_MBSTRING) {
|
if (Smarty::$_MBSTRING) {
|
||||||
if (!$is_loaded_1) {
|
if (!$is_loaded_1) {
|
||||||
if (!is_callable('smarty_mb_to_unicode')) {
|
if (!is_callable('smarty_mb_to_unicode')) {
|
||||||
require_once(SMARTY_PLUGINS_DIR . 'shared.mb_unicode.php');
|
include_once SMARTY_PLUGINS_DIR . 'shared.mb_unicode.php';
|
||||||
}
|
|
||||||
$is_loaded_1 = true;
|
|
||||||
}
|
}
|
||||||
foreach (smarty_mb_to_unicode($string, Smarty::$_CHARSET) as $unicode) {
|
$is_loaded_1 = true;
|
||||||
if ($unicode >= 126) {
|
|
||||||
$return .= '&#' . $unicode . ';';
|
|
||||||
} else {
|
|
||||||
$return .= chr($unicode);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return $return;
|
|
||||||
}
|
}
|
||||||
|
foreach (smarty_mb_to_unicode($string, Smarty::$_CHARSET) as $unicode) {
|
||||||
$_length = strlen($string);
|
if ($unicode >= 126) {
|
||||||
for ($_i = 0; $_i < $_length; $_i ++) {
|
$return .= '&#' . $unicode . ';';
|
||||||
$_ord = ord(substr($string, $_i, 1));
|
|
||||||
// non-standard char, escape it
|
|
||||||
if ($_ord >= 126) {
|
|
||||||
$return .= '&#' . $_ord . ';';
|
|
||||||
} else {
|
} else {
|
||||||
$return .= substr($string, $_i, 1);
|
$return .= chr($unicode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $return;
|
return $return;
|
||||||
|
}
|
||||||
|
|
||||||
default:
|
$_length = strlen($string);
|
||||||
return $string;
|
for ($_i = 0; $_i < $_length; $_i ++) {
|
||||||
|
$_ord = ord(substr($string, $_i, 1));
|
||||||
|
// non-standard char, escape it
|
||||||
|
if ($_ord >= 126) {
|
||||||
|
$return .= '&#' . $_ord . ';';
|
||||||
|
} else {
|
||||||
|
$return .= substr($string, $_i, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $return;
|
||||||
|
|
||||||
|
default:
|
||||||
|
return $string;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -11,13 +11,12 @@
|
|||||||
* Name: mb_wordwrap
|
* Name: mb_wordwrap
|
||||||
* Purpose: Wrap a string to a given number of characters
|
* Purpose: Wrap a string to a given number of characters
|
||||||
*
|
*
|
||||||
|
* @link http://php.net/manual/en/function.wordwrap.php for similarity
|
||||||
* @link http://php.net/manual/en/function.wordwrap.php for similarity
|
|
||||||
*
|
*
|
||||||
* @param string $str the string to wrap
|
* @param string $str the string to wrap
|
||||||
* @param int $width the width of the output
|
* @param int $width the width of the output
|
||||||
* @param string $break the character used to break the line
|
* @param string $break the character used to break the line
|
||||||
* @param boolean $cut ignored parameter, just for the sake of
|
* @param boolean $cut ignored parameter, just for the sake of
|
||||||
*
|
*
|
||||||
* @return string wrapped string
|
* @return string wrapped string
|
||||||
* @author Rodney Rehm
|
* @author Rodney Rehm
|
||||||
@@ -36,10 +35,12 @@ function smarty_modifier_mb_wordwrap($str, $width = 75, $break = "\n", $cut = fa
|
|||||||
$_tokens = array($_token);
|
$_tokens = array($_token);
|
||||||
if ($token_length > $width) {
|
if ($token_length > $width) {
|
||||||
if ($cut) {
|
if ($cut) {
|
||||||
$_tokens = preg_split('!(.{' . $width . '})!S' . Smarty::$_UTF8_MODIFIER,
|
$_tokens = preg_split(
|
||||||
$_token,
|
'!(.{' . $width . '})!S' . Smarty::$_UTF8_MODIFIER,
|
||||||
-1,
|
$_token,
|
||||||
PREG_SPLIT_NO_EMPTY + PREG_SPLIT_DELIM_CAPTURE);
|
-1,
|
||||||
|
PREG_SPLIT_NO_EMPTY + PREG_SPLIT_DELIM_CAPTURE
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -12,9 +12,9 @@
|
|||||||
* Name: regex_replace
|
* Name: regex_replace
|
||||||
* Purpose: regular expression search/replace
|
* Purpose: regular expression search/replace
|
||||||
*
|
*
|
||||||
* @link http://smarty.php.net/manual/en/language.modifier.regex.replace.php
|
* @link http://smarty.php.net/manual/en/language.modifier.regex.replace.php
|
||||||
* regex_replace (Smarty online manual)
|
* regex_replace (Smarty online manual)
|
||||||
* @author Monte Ohrt <monte at ohrt dot com>
|
* @author Monte Ohrt <monte at ohrt dot com>
|
||||||
*
|
*
|
||||||
* @param string $string input string
|
* @param string $string input string
|
||||||
* @param string|array $search regular expression(s) to search for
|
* @param string|array $search regular expression(s) to search for
|
||||||
|
@@ -28,7 +28,7 @@ function smarty_modifier_replace($string, $search, $replace)
|
|||||||
if (Smarty::$_MBSTRING) {
|
if (Smarty::$_MBSTRING) {
|
||||||
if (!$is_loaded) {
|
if (!$is_loaded) {
|
||||||
if (!is_callable('smarty_mb_str_replace')) {
|
if (!is_callable('smarty_mb_str_replace')) {
|
||||||
require_once(SMARTY_PLUGINS_DIR . 'shared.mb_str_replace.php');
|
include_once SMARTY_PLUGINS_DIR . 'shared.mb_str_replace.php';
|
||||||
}
|
}
|
||||||
$is_loaded = true;
|
$is_loaded = true;
|
||||||
}
|
}
|
||||||
|
@@ -35,8 +35,10 @@ function smarty_modifier_truncate($string, $length = 80, $etc = '...', $break_wo
|
|||||||
if (mb_strlen($string, Smarty::$_CHARSET) > $length) {
|
if (mb_strlen($string, Smarty::$_CHARSET) > $length) {
|
||||||
$length -= min($length, mb_strlen($etc, Smarty::$_CHARSET));
|
$length -= min($length, mb_strlen($etc, Smarty::$_CHARSET));
|
||||||
if (!$break_words && !$middle) {
|
if (!$break_words && !$middle) {
|
||||||
$string = preg_replace('/\s+?(\S+)?$/' . Smarty::$_UTF8_MODIFIER, '',
|
$string = preg_replace(
|
||||||
mb_substr($string, 0, $length + 1, Smarty::$_CHARSET));
|
'/\s+?(\S+)?$/' . Smarty::$_UTF8_MODIFIER, '',
|
||||||
|
mb_substr($string, 0, $length + 1, Smarty::$_CHARSET)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
if (!$middle) {
|
if (!$middle) {
|
||||||
return mb_substr($string, 0, $length, Smarty::$_CHARSET) . $etc;
|
return mb_substr($string, 0, $length, Smarty::$_CHARSET) . $etc;
|
||||||
|
@@ -15,9 +15,9 @@
|
|||||||
* Input: string to catenate
|
* Input: string to catenate
|
||||||
* Example: {$var|cat:"foo"}
|
* Example: {$var|cat:"foo"}
|
||||||
*
|
*
|
||||||
* @link http://smarty.php.net/manual/en/language.modifier.cat.php cat
|
* @link http://smarty.php.net/manual/en/language.modifier.cat.php cat
|
||||||
* (Smarty online manual)
|
* (Smarty online manual)
|
||||||
* @author Uwe Tews
|
* @author Uwe Tews
|
||||||
*
|
*
|
||||||
* @param array $params parameters
|
* @param array $params parameters
|
||||||
*
|
*
|
||||||
|
@@ -12,9 +12,9 @@
|
|||||||
* Name: count_paragraphs
|
* Name: count_paragraphs
|
||||||
* Purpose: count the number of paragraphs in a text
|
* Purpose: count the number of paragraphs in a text
|
||||||
*
|
*
|
||||||
* @link http://www.smarty.net/manual/en/language.modifier.count.paragraphs.php
|
* @link http://www.smarty.net/manual/en/language.modifier.count.paragraphs.php
|
||||||
* count_paragraphs (Smarty online manual)
|
* count_paragraphs (Smarty online manual)
|
||||||
* @author Uwe Tews
|
* @author Uwe Tews
|
||||||
*
|
*
|
||||||
* @param array $params parameters
|
* @param array $params parameters
|
||||||
*
|
*
|
||||||
|
@@ -12,9 +12,9 @@
|
|||||||
* Name: count_sentences
|
* Name: count_sentences
|
||||||
* Purpose: count the number of sentences in a text
|
* Purpose: count the number of sentences in a text
|
||||||
*
|
*
|
||||||
* @link http://www.smarty.net/manual/en/language.modifier.count.paragraphs.php
|
* @link http://www.smarty.net/manual/en/language.modifier.count.paragraphs.php
|
||||||
* count_sentences (Smarty online manual)
|
* count_sentences (Smarty online manual)
|
||||||
* @author Uwe Tews
|
* @author Uwe Tews
|
||||||
*
|
*
|
||||||
* @param array $params parameters
|
* @param array $params parameters
|
||||||
*
|
*
|
||||||
|
@@ -14,8 +14,8 @@
|
|||||||
* @link http://www.smarty.net/docsv2/en/language.modifier.escape count_characters (Smarty online manual)
|
* @link http://www.smarty.net/docsv2/en/language.modifier.escape count_characters (Smarty online manual)
|
||||||
* @author Rodney Rehm
|
* @author Rodney Rehm
|
||||||
*
|
*
|
||||||
* @param array $params parameters
|
* @param array $params parameters
|
||||||
* @param Smarty_Internal_TemplateCompilerBase $compiler
|
* @param Smarty_Internal_TemplateCompilerBase $compiler
|
||||||
*
|
*
|
||||||
* @return string with compiled code
|
* @return string with compiled code
|
||||||
* @throws \SmartyException
|
* @throws \SmartyException
|
||||||
@@ -24,8 +24,10 @@ function smarty_modifiercompiler_escape($params, Smarty_Internal_TemplateCompile
|
|||||||
{
|
{
|
||||||
static $_double_encode = null;
|
static $_double_encode = null;
|
||||||
static $is_loaded = false;
|
static $is_loaded = false;
|
||||||
$compiler->template->_checkPlugins(array(array('function' => 'smarty_literal_compiler_param',
|
$compiler->template->_checkPlugins(
|
||||||
'file' => SMARTY_PLUGINS_DIR . 'shared.literal_compiler_param.php')));
|
array(array('function' => 'smarty_literal_compiler_param',
|
||||||
|
'file' => SMARTY_PLUGINS_DIR . 'shared.literal_compiler_param.php'))
|
||||||
|
);
|
||||||
if ($_double_encode === null) {
|
if ($_double_encode === null) {
|
||||||
$_double_encode = version_compare(PHP_VERSION, '5.2.3', '>=');
|
$_double_encode = version_compare(PHP_VERSION, '5.2.3', '>=');
|
||||||
}
|
}
|
||||||
@@ -40,57 +42,57 @@ function smarty_modifiercompiler_escape($params, Smarty_Internal_TemplateCompile
|
|||||||
}
|
}
|
||||||
|
|
||||||
switch ($esc_type) {
|
switch ($esc_type) {
|
||||||
case 'html':
|
case 'html':
|
||||||
if ($_double_encode) {
|
if ($_double_encode) {
|
||||||
return 'htmlspecialchars(' . $params[ 0 ] . ', ENT_QUOTES, ' . var_export($char_set, true) . ', ' .
|
return 'htmlspecialchars(' . $params[ 0 ] . ', ENT_QUOTES, ' . var_export($char_set, true) . ', ' .
|
||||||
var_export($double_encode, true) . ')';
|
var_export($double_encode, true) . ')';
|
||||||
} elseif ($double_encode) {
|
} elseif ($double_encode) {
|
||||||
return 'htmlspecialchars(' . $params[ 0 ] . ', ENT_QUOTES, ' . var_export($char_set, true) . ')';
|
return 'htmlspecialchars(' . $params[ 0 ] . ', ENT_QUOTES, ' . var_export($char_set, true) . ')';
|
||||||
} else {
|
} else {
|
||||||
// fall back to modifier.escape.php
|
// fall back to modifier.escape.php
|
||||||
}
|
}
|
||||||
|
|
||||||
case 'htmlall':
|
case 'htmlall':
|
||||||
if (Smarty::$_MBSTRING) {
|
if (Smarty::$_MBSTRING) {
|
||||||
if ($_double_encode) {
|
|
||||||
// php >=5.2.3 - go native
|
|
||||||
return 'mb_convert_encoding(htmlspecialchars(' . $params[ 0 ] . ', ENT_QUOTES, ' .
|
|
||||||
var_export($char_set, true) . ', ' . var_export($double_encode, true) .
|
|
||||||
'), "HTML-ENTITIES", ' . var_export($char_set, true) . ')';
|
|
||||||
} elseif ($double_encode) {
|
|
||||||
// php <5.2.3 - only handle double encoding
|
|
||||||
return 'mb_convert_encoding(htmlspecialchars(' . $params[ 0 ] . ', ENT_QUOTES, ' .
|
|
||||||
var_export($char_set, true) . '), "HTML-ENTITIES", ' . var_export($char_set, true) . ')';
|
|
||||||
} else {
|
|
||||||
// fall back to modifier.escape.php
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// no MBString fallback
|
|
||||||
if ($_double_encode) {
|
if ($_double_encode) {
|
||||||
// php >=5.2.3 - go native
|
// php >=5.2.3 - go native
|
||||||
return 'htmlentities(' . $params[ 0 ] . ', ENT_QUOTES, ' . var_export($char_set, true) . ', ' .
|
return 'mb_convert_encoding(htmlspecialchars(' . $params[ 0 ] . ', ENT_QUOTES, ' .
|
||||||
var_export($double_encode, true) . ')';
|
var_export($char_set, true) . ', ' . var_export($double_encode, true) .
|
||||||
|
'), "HTML-ENTITIES", ' . var_export($char_set, true) . ')';
|
||||||
} elseif ($double_encode) {
|
} elseif ($double_encode) {
|
||||||
// php <5.2.3 - only handle double encoding
|
// php <5.2.3 - only handle double encoding
|
||||||
return 'htmlentities(' . $params[ 0 ] . ', ENT_QUOTES, ' . var_export($char_set, true) . ')';
|
return 'mb_convert_encoding(htmlspecialchars(' . $params[ 0 ] . ', ENT_QUOTES, ' .
|
||||||
|
var_export($char_set, true) . '), "HTML-ENTITIES", ' . var_export($char_set, true) . ')';
|
||||||
} else {
|
} else {
|
||||||
// fall back to modifier.escape.php
|
// fall back to modifier.escape.php
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
case 'url':
|
// no MBString fallback
|
||||||
return 'rawurlencode(' . $params[ 0 ] . ')';
|
if ($_double_encode) {
|
||||||
|
// php >=5.2.3 - go native
|
||||||
|
return 'htmlentities(' . $params[ 0 ] . ', ENT_QUOTES, ' . var_export($char_set, true) . ', ' .
|
||||||
|
var_export($double_encode, true) . ')';
|
||||||
|
} elseif ($double_encode) {
|
||||||
|
// php <5.2.3 - only handle double encoding
|
||||||
|
return 'htmlentities(' . $params[ 0 ] . ', ENT_QUOTES, ' . var_export($char_set, true) . ')';
|
||||||
|
} else {
|
||||||
|
// fall back to modifier.escape.php
|
||||||
|
}
|
||||||
|
|
||||||
case 'urlpathinfo':
|
case 'url':
|
||||||
return 'str_replace("%2F", "/", rawurlencode(' . $params[ 0 ] . '))';
|
return 'rawurlencode(' . $params[ 0 ] . ')';
|
||||||
|
|
||||||
case 'quotes':
|
case 'urlpathinfo':
|
||||||
// escape unescaped single quotes
|
return 'str_replace("%2F", "/", rawurlencode(' . $params[ 0 ] . '))';
|
||||||
return 'preg_replace("%(?<!\\\\\\\\)\'%", "\\\'",' . $params[ 0 ] . ')';
|
|
||||||
|
|
||||||
case 'javascript':
|
case 'quotes':
|
||||||
// escape quotes and backslashes, newlines, etc.
|
// escape unescaped single quotes
|
||||||
return 'strtr(' . $params[ 0 ] .
|
return 'preg_replace("%(?<!\\\\\\\\)\'%", "\\\'",' . $params[ 0 ] . ')';
|
||||||
|
|
||||||
|
case 'javascript':
|
||||||
|
// escape quotes and backslashes, newlines, etc.
|
||||||
|
return 'strtr(' . $params[ 0 ] .
|
||||||
', array("\\\\" => "\\\\\\\\", "\'" => "\\\\\'", "\"" => "\\\\\"", "\\r" => "\\\\r", "\\n" => "\\\n", "</" => "<\/" ))';
|
', array("\\\\" => "\\\\\\\\", "\'" => "\\\\\'", "\"" => "\\\\\"", "\\r" => "\\\\r", "\\n" => "\\\n", "</" => "<\/" ))';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -12,7 +12,7 @@
|
|||||||
* Name: noprint
|
* Name: noprint
|
||||||
* Purpose: return an empty string
|
* Purpose: return an empty string
|
||||||
*
|
*
|
||||||
* @author Uwe Tews
|
* @author Uwe Tews
|
||||||
* @return string with compiled code
|
* @return string with compiled code
|
||||||
*/
|
*/
|
||||||
function smarty_modifiercompiler_noprint()
|
function smarty_modifiercompiler_noprint()
|
||||||
|
@@ -30,21 +30,21 @@ function smarty_modifiercompiler_unescape($params)
|
|||||||
}
|
}
|
||||||
|
|
||||||
switch (trim($params[ 1 ], '"\'')) {
|
switch (trim($params[ 1 ], '"\'')) {
|
||||||
case 'entity':
|
case 'entity':
|
||||||
case 'htmlall':
|
case 'htmlall':
|
||||||
if (Smarty::$_MBSTRING) {
|
if (Smarty::$_MBSTRING) {
|
||||||
return 'mb_convert_encoding(' . $params[ 0 ] . ', ' . $params[ 2 ] . ', \'HTML-ENTITIES\')';
|
return 'mb_convert_encoding(' . $params[ 0 ] . ', ' . $params[ 2 ] . ', \'HTML-ENTITIES\')';
|
||||||
}
|
}
|
||||||
|
|
||||||
return 'html_entity_decode(' . $params[ 0 ] . ', ENT_NOQUOTES, ' . $params[ 2 ] . ')';
|
return 'html_entity_decode(' . $params[ 0 ] . ', ENT_NOQUOTES, ' . $params[ 2 ] . ')';
|
||||||
|
|
||||||
case 'html':
|
case 'html':
|
||||||
return 'htmlspecialchars_decode(' . $params[ 0 ] . ', ENT_QUOTES)';
|
return 'htmlspecialchars_decode(' . $params[ 0 ] . ', ENT_QUOTES)';
|
||||||
|
|
||||||
case 'url':
|
case 'url':
|
||||||
return 'rawurldecode(' . $params[ 0 ] . ')';
|
return 'rawurldecode(' . $params[ 0 ] . ')';
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return $params[ 0 ];
|
return $params[ 0 ];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -14,7 +14,7 @@
|
|||||||
* @link http://smarty.php.net/manual/en/language.modifier.wordwrap.php wordwrap (Smarty online manual)
|
* @link http://smarty.php.net/manual/en/language.modifier.wordwrap.php wordwrap (Smarty online manual)
|
||||||
* @author Uwe Tews
|
* @author Uwe Tews
|
||||||
*
|
*
|
||||||
* @param array $params parameters
|
* @param array $params parameters
|
||||||
* @param \Smarty_Internal_TemplateCompilerBase $compiler
|
* @param \Smarty_Internal_TemplateCompilerBase $compiler
|
||||||
*
|
*
|
||||||
* @return string with compiled code
|
* @return string with compiled code
|
||||||
@@ -33,7 +33,7 @@ function smarty_modifiercompiler_wordwrap($params, Smarty_Internal_TemplateCompi
|
|||||||
}
|
}
|
||||||
$function = 'wordwrap';
|
$function = 'wordwrap';
|
||||||
if (Smarty::$_MBSTRING) {
|
if (Smarty::$_MBSTRING) {
|
||||||
$function = $compiler->getPlugin('mb_wordwrap','modifier');
|
$function = $compiler->getPlugin('mb_wordwrap', 'modifier');
|
||||||
}
|
}
|
||||||
return $function . '(' . $params[ 0 ] . ',' . $params[ 1 ] . ',' . $params[ 2 ] . ',' . $params[ 3 ] . ')';
|
return $function . '(' . $params[ 0 ] . ',' . $params[ 1 ] . ',' . $params[ 2 ] . ',' . $params[ 3 ] . ')';
|
||||||
}
|
}
|
||||||
|
@@ -10,12 +10,12 @@
|
|||||||
* Smarty trimwhitespace outputfilter plugin
|
* Smarty trimwhitespace outputfilter plugin
|
||||||
* Trim unnecessary whitespace from HTML markup.
|
* Trim unnecessary whitespace from HTML markup.
|
||||||
*
|
*
|
||||||
* @author Rodney Rehm
|
* @author Rodney Rehm
|
||||||
*
|
*
|
||||||
* @param string $source input string
|
* @param string $source input string
|
||||||
*
|
*
|
||||||
* @return string filtered output
|
* @return string filtered output
|
||||||
* @todo substr_replace() is not overloaded by mbstring.func_overload - so this function might fail!
|
* @todo substr_replace() is not overloaded by mbstring.func_overload - so this function might fail!
|
||||||
*/
|
*/
|
||||||
function smarty_outputfilter_trimwhitespace($source)
|
function smarty_outputfilter_trimwhitespace($source)
|
||||||
{
|
{
|
||||||
@@ -27,8 +27,11 @@ function smarty_outputfilter_trimwhitespace($source)
|
|||||||
$source = preg_replace('/\015\012|\015|\012/', "\n", $source);
|
$source = preg_replace('/\015\012|\015|\012/', "\n", $source);
|
||||||
|
|
||||||
// capture Internet Explorer and KnockoutJS Conditional Comments
|
// capture Internet Explorer and KnockoutJS Conditional Comments
|
||||||
if (preg_match_all('#<!--((\[[^\]]+\]>.*?<!\[[^\]]+\])|(\s*/?ko\s+.+))-->#is', $source, $matches,
|
if (preg_match_all(
|
||||||
PREG_OFFSET_CAPTURE | PREG_SET_ORDER)) {
|
'#<!--((\[[^\]]+\]>.*?<!\[[^\]]+\])|(\s*/?ko\s+.+))-->#is', $source, $matches,
|
||||||
|
PREG_OFFSET_CAPTURE | PREG_SET_ORDER
|
||||||
|
)
|
||||||
|
) {
|
||||||
foreach ($matches as $match) {
|
foreach ($matches as $match) {
|
||||||
$store[] = $match[ 0 ][ 0 ];
|
$store[] = $match[ 0 ][ 0 ];
|
||||||
$_length = strlen($match[ 0 ][ 0 ]);
|
$_length = strlen($match[ 0 ][ 0 ]);
|
||||||
@@ -46,8 +49,11 @@ function smarty_outputfilter_trimwhitespace($source)
|
|||||||
|
|
||||||
// capture html elements not to be messed with
|
// capture html elements not to be messed with
|
||||||
$_offset = 0;
|
$_offset = 0;
|
||||||
if (preg_match_all('#(<script[^>]*>.*?</script[^>]*>)|(<textarea[^>]*>.*?</textarea[^>]*>)|(<pre[^>]*>.*?</pre[^>]*>)#is',
|
if (preg_match_all(
|
||||||
$source, $matches, PREG_OFFSET_CAPTURE | PREG_SET_ORDER)) {
|
'#(<script[^>]*>.*?</script[^>]*>)|(<textarea[^>]*>.*?</textarea[^>]*>)|(<pre[^>]*>.*?</pre[^>]*>)#is',
|
||||||
|
$source, $matches, PREG_OFFSET_CAPTURE | PREG_SET_ORDER
|
||||||
|
)
|
||||||
|
) {
|
||||||
foreach ($matches as $match) {
|
foreach ($matches as $match) {
|
||||||
$store[] = $match[ 0 ][ 0 ];
|
$store[] = $match[ 0 ][ 0 ];
|
||||||
$_length = strlen($match[ 0 ][ 0 ]);
|
$_length = strlen($match[ 0 ][ 0 ]);
|
||||||
|
@@ -12,9 +12,9 @@
|
|||||||
* Purpose: used by other smarty functions to escape
|
* Purpose: used by other smarty functions to escape
|
||||||
* special chars except for already escaped ones
|
* special chars except for already escaped ones
|
||||||
*
|
*
|
||||||
* @author Monte Ohrt <monte at ohrt dot com>
|
* @author Monte Ohrt <monte at ohrt dot com>
|
||||||
*
|
*
|
||||||
* @param string $string text that should by escaped
|
* @param string $string text that should by escaped
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
|
@@ -25,8 +25,10 @@ function smarty_literal_compiler_param($params, $index, $default = null)
|
|||||||
}
|
}
|
||||||
// test if param is a literal
|
// test if param is a literal
|
||||||
if (!preg_match('/^([\'"]?)[a-zA-Z0-9-]+(\\1)$/', $params[ $index ])) {
|
if (!preg_match('/^([\'"]?)[a-zA-Z0-9-]+(\\1)$/', $params[ $index ])) {
|
||||||
throw new SmartyException('$param[' . $index .
|
throw new SmartyException(
|
||||||
'] is not a literal and is thus not evaluatable at compile time');
|
'$param[' . $index .
|
||||||
|
'] is not a literal and is thus not evaluatable at compile time'
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
$t = null;
|
$t = null;
|
||||||
|
@@ -10,7 +10,7 @@
|
|||||||
* Function: smarty_make_timestamp
|
* Function: smarty_make_timestamp
|
||||||
* Purpose: used by other smarty functions to make a timestamp from a string.
|
* Purpose: used by other smarty functions to make a timestamp from a string.
|
||||||
*
|
*
|
||||||
* @author Monte Ohrt <monte at ohrt dot com>
|
* @author Monte Ohrt <monte at ohrt dot com>
|
||||||
*
|
*
|
||||||
* @param DateTime|int|string $string date object, timestamp or string that can be converted using strtotime()
|
* @param DateTime|int|string $string date object, timestamp or string that can be converted using strtotime()
|
||||||
*
|
*
|
||||||
@@ -21,14 +21,16 @@ function smarty_make_timestamp($string)
|
|||||||
if (empty($string)) {
|
if (empty($string)) {
|
||||||
// use "now":
|
// use "now":
|
||||||
return time();
|
return time();
|
||||||
} elseif ($string instanceof DateTime ||
|
} elseif ($string instanceof DateTime
|
||||||
(interface_exists('DateTimeInterface', false) && $string instanceof DateTimeInterface)
|
|| (interface_exists('DateTimeInterface', false) && $string instanceof DateTimeInterface)
|
||||||
) {
|
) {
|
||||||
return (int) $string->format('U'); // PHP 5.2 BC
|
return (int) $string->format('U'); // PHP 5.2 BC
|
||||||
} elseif (strlen($string) === 14 && ctype_digit($string)) {
|
} elseif (strlen($string) === 14 && ctype_digit($string)) {
|
||||||
// it is mysql timestamp format of YYYYMMDDHHMMSS?
|
// it is mysql timestamp format of YYYYMMDDHHMMSS?
|
||||||
return mktime(substr($string, 8, 2), substr($string, 10, 2), substr($string, 12, 2), substr($string, 4, 2),
|
return mktime(
|
||||||
substr($string, 6, 2), substr($string, 0, 4));
|
substr($string, 8, 2), substr($string, 10, 2), substr($string, 12, 2), substr($string, 4, 2),
|
||||||
|
substr($string, 6, 2), substr($string, 0, 4)
|
||||||
|
);
|
||||||
} elseif (is_numeric($string)) {
|
} elseif (is_numeric($string)) {
|
||||||
// it is a numeric string, we handle it as timestamp
|
// it is a numeric string, we handle it as timestamp
|
||||||
return (int) $string;
|
return (int) $string;
|
||||||
|
@@ -9,10 +9,10 @@ if (!function_exists('smarty_mb_str_replace')) {
|
|||||||
/**
|
/**
|
||||||
* Multibyte string replace
|
* Multibyte string replace
|
||||||
*
|
*
|
||||||
* @param string|string[] $search the string to be searched
|
* @param string|string[] $search the string to be searched
|
||||||
* @param string|string[] $replace the replacement string
|
* @param string|string[] $replace the replacement string
|
||||||
* @param string $subject the source string
|
* @param string $subject the source string
|
||||||
* @param int &$count number of matches found
|
* @param int &$count number of matches found
|
||||||
*
|
*
|
||||||
* @return string replaced string
|
* @return string replaced string
|
||||||
* @author Rodney Rehm
|
* @author Rodney Rehm
|
||||||
|
@@ -9,7 +9,7 @@
|
|||||||
/**
|
/**
|
||||||
* convert characters to their decimal unicode equivalents
|
* convert characters to their decimal unicode equivalents
|
||||||
*
|
*
|
||||||
* @link http://www.ibm.com/developerworks/library/os-php-unicode/index.html#listing3 for inspiration
|
* @link http://www.ibm.com/developerworks/library/os-php-unicode/index.html#listing3 for inspiration
|
||||||
*
|
*
|
||||||
* @param string $string characters to calculate unicode of
|
* @param string $string characters to calculate unicode of
|
||||||
* @param string $encoding encoding of $string, if null mb_internal_encoding() is used
|
* @param string $encoding encoding of $string, if null mb_internal_encoding() is used
|
||||||
@@ -31,7 +31,7 @@ function smarty_mb_to_unicode($string, $encoding = null)
|
|||||||
/**
|
/**
|
||||||
* convert unicodes to the character of given encoding
|
* convert unicodes to the character of given encoding
|
||||||
*
|
*
|
||||||
* @link http://www.ibm.com/developerworks/library/os-php-unicode/index.html#listing3 for inspiration
|
* @link http://www.ibm.com/developerworks/library/os-php-unicode/index.html#listing3 for inspiration
|
||||||
*
|
*
|
||||||
* @param integer|array $unicode single unicode or list of unicodes to convert
|
* @param integer|array $unicode single unicode or list of unicodes to convert
|
||||||
* @param string $encoding encoding of returned string, if null mb_internal_encoding() is used
|
* @param string $encoding encoding of returned string, if null mb_internal_encoding() is used
|
||||||
|
@@ -8,7 +8,7 @@
|
|||||||
/**
|
/**
|
||||||
* Smarty htmlspecialchars variablefilter plugin
|
* Smarty htmlspecialchars variablefilter plugin
|
||||||
*
|
*
|
||||||
* @param string $source input string
|
* @param string $source input string
|
||||||
* @param \Smarty_Internal_Template $template
|
* @param \Smarty_Internal_Template $template
|
||||||
*
|
*
|
||||||
* @return string filtered output
|
* @return string filtered output
|
||||||
|
@@ -51,7 +51,8 @@ abstract class Smarty_CacheResource
|
|||||||
* @return boolean true or false if the cached content does not exist
|
* @return boolean true or false if the cached content does not exist
|
||||||
*/
|
*/
|
||||||
abstract public function process(Smarty_Internal_Template $_template, Smarty_Template_Cached $cached = null,
|
abstract public function process(Smarty_Internal_Template $_template, Smarty_Template_Cached $cached = null,
|
||||||
$update = false);
|
$update = false
|
||||||
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Write the rendered template output to cache
|
* Write the rendered template output to cache
|
||||||
@@ -66,7 +67,7 @@ abstract class Smarty_CacheResource
|
|||||||
/**
|
/**
|
||||||
* Read cached template from cache
|
* Read cached template from cache
|
||||||
*
|
*
|
||||||
* @param Smarty_Internal_Template $_template template object
|
* @param Smarty_Internal_Template $_template template object
|
||||||
*
|
*
|
||||||
* @return string content
|
* @return string content
|
||||||
*/
|
*/
|
||||||
|
@@ -18,12 +18,12 @@ abstract class Smarty_CacheResource_Custom extends Smarty_CacheResource
|
|||||||
/**
|
/**
|
||||||
* fetch cached content and its modification time from data source
|
* fetch cached content and its modification time from data source
|
||||||
*
|
*
|
||||||
* @param string $id unique cache content identifier
|
* @param string $id unique cache content identifier
|
||||||
* @param string $name template name
|
* @param string $name template name
|
||||||
* @param string $cache_id cache id
|
* @param string $cache_id cache id
|
||||||
* @param string $compile_id compile id
|
* @param string $compile_id compile id
|
||||||
* @param string $content cached content
|
* @param string $content cached content
|
||||||
* @param integer $mtime cache modification timestamp (epoch)
|
* @param integer $mtime cache modification timestamp (epoch)
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
@@ -34,10 +34,10 @@ abstract class Smarty_CacheResource_Custom extends Smarty_CacheResource
|
|||||||
* {@internal implementing this method is optional.
|
* {@internal implementing this method is optional.
|
||||||
* Only implement it if modification times can be accessed faster than loading the complete cached content.}}
|
* Only implement it if modification times can be accessed faster than loading the complete cached content.}}
|
||||||
*
|
*
|
||||||
* @param string $id unique cache content identifier
|
* @param string $id unique cache content identifier
|
||||||
* @param string $name template name
|
* @param string $name template name
|
||||||
* @param string $cache_id cache id
|
* @param string $cache_id cache id
|
||||||
* @param string $compile_id compile id
|
* @param string $compile_id compile id
|
||||||
*
|
*
|
||||||
* @return integer|boolean timestamp (epoch) the template was modified, or false if not found
|
* @return integer|boolean timestamp (epoch) the template was modified, or false if not found
|
||||||
*/
|
*/
|
||||||
@@ -49,12 +49,12 @@ abstract class Smarty_CacheResource_Custom extends Smarty_CacheResource
|
|||||||
/**
|
/**
|
||||||
* Save content to cache
|
* Save content to cache
|
||||||
*
|
*
|
||||||
* @param string $id unique cache content identifier
|
* @param string $id unique cache content identifier
|
||||||
* @param string $name template name
|
* @param string $name template name
|
||||||
* @param string $cache_id cache id
|
* @param string $cache_id cache id
|
||||||
* @param string $compile_id compile id
|
* @param string $compile_id compile id
|
||||||
* @param integer|null $exp_time seconds till expiration or null
|
* @param integer|null $exp_time seconds till expiration or null
|
||||||
* @param string $content content to cache
|
* @param string $content content to cache
|
||||||
*
|
*
|
||||||
* @return boolean success
|
* @return boolean success
|
||||||
*/
|
*/
|
||||||
@@ -63,10 +63,10 @@ abstract class Smarty_CacheResource_Custom extends Smarty_CacheResource
|
|||||||
/**
|
/**
|
||||||
* Delete content from cache
|
* Delete content from cache
|
||||||
*
|
*
|
||||||
* @param string|null $name template name
|
* @param string|null $name template name
|
||||||
* @param string|null $cache_id cache id
|
* @param string|null $cache_id cache id
|
||||||
* @param string|null $compile_id compile id
|
* @param string|null $compile_id compile id
|
||||||
* @param integer|null $exp_time seconds till expiration time in seconds or null
|
* @param integer|null $exp_time seconds till expiration time in seconds or null
|
||||||
*
|
*
|
||||||
* @return integer number of deleted caches
|
* @return integer number of deleted caches
|
||||||
*/
|
*/
|
||||||
@@ -75,8 +75,8 @@ abstract class Smarty_CacheResource_Custom extends Smarty_CacheResource
|
|||||||
/**
|
/**
|
||||||
* populate Cached Object with meta data from Resource
|
* populate Cached Object with meta data from Resource
|
||||||
*
|
*
|
||||||
* @param Smarty_Template_Cached $cached cached object
|
* @param Smarty_Template_Cached $cached cached object
|
||||||
* @param Smarty_Internal_Template $_template template object
|
* @param Smarty_Internal_Template $_template template object
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
@@ -110,8 +110,10 @@ abstract class Smarty_CacheResource_Custom extends Smarty_CacheResource
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$timestamp = null;
|
$timestamp = null;
|
||||||
$this->fetch($cached->filepath, $cached->source->name, $cached->cache_id, $cached->compile_id, $cached->content,
|
$this->fetch(
|
||||||
$timestamp);
|
$cached->filepath, $cached->source->name, $cached->cache_id, $cached->compile_id, $cached->content,
|
||||||
|
$timestamp
|
||||||
|
);
|
||||||
$cached->timestamp = isset($timestamp) ? $timestamp : false;
|
$cached->timestamp = isset($timestamp) ? $timestamp : false;
|
||||||
$cached->exists = !!$cached->timestamp;
|
$cached->exists = !!$cached->timestamp;
|
||||||
}
|
}
|
||||||
@@ -120,22 +122,24 @@ abstract class Smarty_CacheResource_Custom extends Smarty_CacheResource
|
|||||||
* Read the cached template and process the header
|
* Read the cached template and process the header
|
||||||
*
|
*
|
||||||
* @param \Smarty_Internal_Template $_smarty_tpl do not change variable name, is used by compiled template
|
* @param \Smarty_Internal_Template $_smarty_tpl do not change variable name, is used by compiled template
|
||||||
* @param Smarty_Template_Cached $cached cached object
|
* @param Smarty_Template_Cached $cached cached object
|
||||||
* @param boolean $update flag if called because cache update
|
* @param boolean $update flag if called because cache update
|
||||||
*
|
*
|
||||||
* @return boolean true or false if the cached content does not exist
|
* @return boolean true or false if the cached content does not exist
|
||||||
*/
|
*/
|
||||||
public function process(Smarty_Internal_Template $_smarty_tpl, Smarty_Template_Cached $cached = null,
|
public function process(Smarty_Internal_Template $_smarty_tpl, Smarty_Template_Cached $cached = null,
|
||||||
$update = false)
|
$update = false
|
||||||
{
|
) {
|
||||||
if (!$cached) {
|
if (!$cached) {
|
||||||
$cached = $_smarty_tpl->cached;
|
$cached = $_smarty_tpl->cached;
|
||||||
}
|
}
|
||||||
$content = $cached->content ? $cached->content : null;
|
$content = $cached->content ? $cached->content : null;
|
||||||
$timestamp = $cached->timestamp ? $cached->timestamp : null;
|
$timestamp = $cached->timestamp ? $cached->timestamp : null;
|
||||||
if ($content === null || !$timestamp) {
|
if ($content === null || !$timestamp) {
|
||||||
$this->fetch($_smarty_tpl->cached->filepath, $_smarty_tpl->source->name, $_smarty_tpl->cache_id,
|
$this->fetch(
|
||||||
$_smarty_tpl->compile_id, $content, $timestamp);
|
$_smarty_tpl->cached->filepath, $_smarty_tpl->source->name, $_smarty_tpl->cache_id,
|
||||||
|
$_smarty_tpl->compile_id, $content, $timestamp
|
||||||
|
);
|
||||||
}
|
}
|
||||||
if (isset($content)) {
|
if (isset($content)) {
|
||||||
eval('?>' . $content);
|
eval('?>' . $content);
|
||||||
@@ -149,21 +153,23 @@ abstract class Smarty_CacheResource_Custom extends Smarty_CacheResource
|
|||||||
/**
|
/**
|
||||||
* Write the rendered template output to cache
|
* Write the rendered template output to cache
|
||||||
*
|
*
|
||||||
* @param Smarty_Internal_Template $_template template object
|
* @param Smarty_Internal_Template $_template template object
|
||||||
* @param string $content content to cache
|
* @param string $content content to cache
|
||||||
*
|
*
|
||||||
* @return boolean success
|
* @return boolean success
|
||||||
*/
|
*/
|
||||||
public function writeCachedContent(Smarty_Internal_Template $_template, $content)
|
public function writeCachedContent(Smarty_Internal_Template $_template, $content)
|
||||||
{
|
{
|
||||||
return $this->save($_template->cached->filepath, $_template->source->name, $_template->cache_id,
|
return $this->save(
|
||||||
$_template->compile_id, $_template->cache_lifetime, $content);
|
$_template->cached->filepath, $_template->source->name, $_template->cache_id,
|
||||||
|
$_template->compile_id, $_template->cache_lifetime, $content
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Read cached template from cache
|
* Read cached template from cache
|
||||||
*
|
*
|
||||||
* @param Smarty_Internal_Template $_template template object
|
* @param Smarty_Internal_Template $_template template object
|
||||||
*
|
*
|
||||||
* @return string|boolean content
|
* @return string|boolean content
|
||||||
*/
|
*/
|
||||||
@@ -173,8 +179,10 @@ abstract class Smarty_CacheResource_Custom extends Smarty_CacheResource
|
|||||||
$timestamp = null;
|
$timestamp = null;
|
||||||
if ($content === null) {
|
if ($content === null) {
|
||||||
$timestamp = null;
|
$timestamp = null;
|
||||||
$this->fetch($_template->cached->filepath, $_template->source->name, $_template->cache_id,
|
$this->fetch(
|
||||||
$_template->compile_id, $content, $timestamp);
|
$_template->cached->filepath, $_template->source->name, $_template->cache_id,
|
||||||
|
$_template->compile_id, $content, $timestamp
|
||||||
|
);
|
||||||
}
|
}
|
||||||
if (isset($content)) {
|
if (isset($content)) {
|
||||||
return $content;
|
return $content;
|
||||||
@@ -185,8 +193,8 @@ abstract class Smarty_CacheResource_Custom extends Smarty_CacheResource
|
|||||||
/**
|
/**
|
||||||
* Empty cache
|
* Empty cache
|
||||||
*
|
*
|
||||||
* @param Smarty $smarty Smarty object
|
* @param Smarty $smarty Smarty object
|
||||||
* @param integer $exp_time expiration time (number of seconds, not timestamp)
|
* @param integer $exp_time expiration time (number of seconds, not timestamp)
|
||||||
*
|
*
|
||||||
* @return integer number of cache files deleted
|
* @return integer number of cache files deleted
|
||||||
*/
|
*/
|
||||||
@@ -198,11 +206,11 @@ abstract class Smarty_CacheResource_Custom extends Smarty_CacheResource
|
|||||||
/**
|
/**
|
||||||
* Empty cache for a specific template
|
* Empty cache for a specific template
|
||||||
*
|
*
|
||||||
* @param Smarty $smarty Smarty object
|
* @param Smarty $smarty Smarty object
|
||||||
* @param string $resource_name template name
|
* @param string $resource_name template name
|
||||||
* @param string $cache_id cache id
|
* @param string $cache_id cache id
|
||||||
* @param string $compile_id compile id
|
* @param string $compile_id compile id
|
||||||
* @param integer $exp_time expiration time (number of seconds, not timestamp)
|
* @param integer $exp_time expiration time (number of seconds, not timestamp)
|
||||||
*
|
*
|
||||||
* @return int number of cache files deleted
|
* @return int number of cache files deleted
|
||||||
* @throws \SmartyException
|
* @throws \SmartyException
|
||||||
@@ -226,8 +234,8 @@ abstract class Smarty_CacheResource_Custom extends Smarty_CacheResource
|
|||||||
/**
|
/**
|
||||||
* Check is cache is locked for this template
|
* Check is cache is locked for this template
|
||||||
*
|
*
|
||||||
* @param Smarty $smarty Smarty object
|
* @param Smarty $smarty Smarty object
|
||||||
* @param Smarty_Template_Cached $cached cached object
|
* @param Smarty_Template_Cached $cached cached object
|
||||||
*
|
*
|
||||||
* @return boolean true or false if cache is locked
|
* @return boolean true or false if cache is locked
|
||||||
*/
|
*/
|
||||||
|
@@ -47,8 +47,8 @@ abstract class Smarty_CacheResource_KeyValueStore extends Smarty_CacheResource
|
|||||||
/**
|
/**
|
||||||
* populate Cached Object with meta data from Resource
|
* populate Cached Object with meta data from Resource
|
||||||
*
|
*
|
||||||
* @param Smarty_Template_Cached $cached cached object
|
* @param Smarty_Template_Cached $cached cached object
|
||||||
* @param Smarty_Internal_Template $_template template object
|
* @param Smarty_Internal_Template $_template template object
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
@@ -63,14 +63,16 @@ abstract class Smarty_CacheResource_KeyValueStore extends Smarty_CacheResource
|
|||||||
/**
|
/**
|
||||||
* populate Cached Object with timestamp and exists from Resource
|
* populate Cached Object with timestamp and exists from Resource
|
||||||
*
|
*
|
||||||
* @param Smarty_Template_Cached $cached cached object
|
* @param Smarty_Template_Cached $cached cached object
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function populateTimestamp(Smarty_Template_Cached $cached)
|
public function populateTimestamp(Smarty_Template_Cached $cached)
|
||||||
{
|
{
|
||||||
if (!$this->fetch($cached->filepath, $cached->source->name, $cached->cache_id, $cached->compile_id, $content,
|
if (!$this->fetch(
|
||||||
$timestamp, $cached->source->uid)
|
$cached->filepath, $cached->source->name, $cached->cache_id, $cached->compile_id, $content,
|
||||||
|
$timestamp, $cached->source->uid
|
||||||
|
)
|
||||||
) {
|
) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -83,22 +85,24 @@ abstract class Smarty_CacheResource_KeyValueStore extends Smarty_CacheResource
|
|||||||
* Read the cached template and process the header
|
* Read the cached template and process the header
|
||||||
*
|
*
|
||||||
* @param \Smarty_Internal_Template $_smarty_tpl do not change variable name, is used by compiled template
|
* @param \Smarty_Internal_Template $_smarty_tpl do not change variable name, is used by compiled template
|
||||||
* @param Smarty_Template_Cached $cached cached object
|
* @param Smarty_Template_Cached $cached cached object
|
||||||
* @param boolean $update flag if called because cache update
|
* @param boolean $update flag if called because cache update
|
||||||
*
|
*
|
||||||
* @return boolean true or false if the cached content does not exist
|
* @return boolean true or false if the cached content does not exist
|
||||||
*/
|
*/
|
||||||
public function process(Smarty_Internal_Template $_smarty_tpl, Smarty_Template_Cached $cached = null,
|
public function process(Smarty_Internal_Template $_smarty_tpl, Smarty_Template_Cached $cached = null,
|
||||||
$update = false)
|
$update = false
|
||||||
{
|
) {
|
||||||
if (!$cached) {
|
if (!$cached) {
|
||||||
$cached = $_smarty_tpl->cached;
|
$cached = $_smarty_tpl->cached;
|
||||||
}
|
}
|
||||||
$content = $cached->content ? $cached->content : null;
|
$content = $cached->content ? $cached->content : null;
|
||||||
$timestamp = $cached->timestamp ? $cached->timestamp : null;
|
$timestamp = $cached->timestamp ? $cached->timestamp : null;
|
||||||
if ($content === null || !$timestamp) {
|
if ($content === null || !$timestamp) {
|
||||||
if (!$this->fetch($_smarty_tpl->cached->filepath, $_smarty_tpl->source->name, $_smarty_tpl->cache_id,
|
if (!$this->fetch(
|
||||||
$_smarty_tpl->compile_id, $content, $timestamp, $_smarty_tpl->source->uid)
|
$_smarty_tpl->cached->filepath, $_smarty_tpl->source->name, $_smarty_tpl->cache_id,
|
||||||
|
$_smarty_tpl->compile_id, $content, $timestamp, $_smarty_tpl->source->uid
|
||||||
|
)
|
||||||
) {
|
) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -115,8 +119,8 @@ abstract class Smarty_CacheResource_KeyValueStore extends Smarty_CacheResource
|
|||||||
/**
|
/**
|
||||||
* Write the rendered template output to cache
|
* Write the rendered template output to cache
|
||||||
*
|
*
|
||||||
* @param Smarty_Internal_Template $_template template object
|
* @param Smarty_Internal_Template $_template template object
|
||||||
* @param string $content content to cache
|
* @param string $content content to cache
|
||||||
*
|
*
|
||||||
* @return boolean success
|
* @return boolean success
|
||||||
*/
|
*/
|
||||||
@@ -130,7 +134,7 @@ abstract class Smarty_CacheResource_KeyValueStore extends Smarty_CacheResource
|
|||||||
/**
|
/**
|
||||||
* Read cached template from cache
|
* Read cached template from cache
|
||||||
*
|
*
|
||||||
* @param Smarty_Internal_Template $_template template object
|
* @param Smarty_Internal_Template $_template template object
|
||||||
*
|
*
|
||||||
* @return string|false content
|
* @return string|false content
|
||||||
*/
|
*/
|
||||||
@@ -139,8 +143,10 @@ abstract class Smarty_CacheResource_KeyValueStore extends Smarty_CacheResource
|
|||||||
$content = $_template->cached->content ? $_template->cached->content : null;
|
$content = $_template->cached->content ? $_template->cached->content : null;
|
||||||
$timestamp = null;
|
$timestamp = null;
|
||||||
if ($content === null) {
|
if ($content === null) {
|
||||||
if (!$this->fetch($_template->cached->filepath, $_template->source->name, $_template->cache_id,
|
if (!$this->fetch(
|
||||||
$_template->compile_id, $content, $timestamp, $_template->source->uid)
|
$_template->cached->filepath, $_template->source->name, $_template->cache_id,
|
||||||
|
$_template->compile_id, $content, $timestamp, $_template->source->uid
|
||||||
|
)
|
||||||
) {
|
) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -155,12 +161,12 @@ abstract class Smarty_CacheResource_KeyValueStore extends Smarty_CacheResource
|
|||||||
* Empty cache
|
* Empty cache
|
||||||
* {@internal the $exp_time argument is ignored altogether }}
|
* {@internal the $exp_time argument is ignored altogether }}
|
||||||
*
|
*
|
||||||
* @param Smarty $smarty Smarty object
|
* @param Smarty $smarty Smarty object
|
||||||
* @param integer $exp_time expiration time [being ignored]
|
* @param integer $exp_time expiration time [being ignored]
|
||||||
*
|
*
|
||||||
* @return integer number of cache files deleted [always -1]
|
* @return integer number of cache files deleted [always -1]
|
||||||
* @uses purge() to clear the whole store
|
* @uses purge() to clear the whole store
|
||||||
* @uses invalidate() to mark everything outdated if purge() is inapplicable
|
* @uses invalidate() to mark everything outdated if purge() is inapplicable
|
||||||
*/
|
*/
|
||||||
public function clearAll(Smarty $smarty, $exp_time = null)
|
public function clearAll(Smarty $smarty, $exp_time = null)
|
||||||
{
|
{
|
||||||
@@ -174,17 +180,17 @@ abstract class Smarty_CacheResource_KeyValueStore extends Smarty_CacheResource
|
|||||||
* Empty cache for a specific template
|
* Empty cache for a specific template
|
||||||
* {@internal the $exp_time argument is ignored altogether}}
|
* {@internal the $exp_time argument is ignored altogether}}
|
||||||
*
|
*
|
||||||
* @param Smarty $smarty Smarty object
|
* @param Smarty $smarty Smarty object
|
||||||
* @param string $resource_name template name
|
* @param string $resource_name template name
|
||||||
* @param string $cache_id cache id
|
* @param string $cache_id cache id
|
||||||
* @param string $compile_id compile id
|
* @param string $compile_id compile id
|
||||||
* @param integer $exp_time expiration time [being ignored]
|
* @param integer $exp_time expiration time [being ignored]
|
||||||
*
|
*
|
||||||
* @return int number of cache files deleted [always -1]
|
* @return int number of cache files deleted [always -1]
|
||||||
* @throws \SmartyException
|
* @throws \SmartyException
|
||||||
* @uses buildCachedFilepath() to generate the CacheID
|
* @uses buildCachedFilepath() to generate the CacheID
|
||||||
* @uses invalidate() to mark CacheIDs parent chain as outdated
|
* @uses invalidate() to mark CacheIDs parent chain as outdated
|
||||||
* @uses delete() to remove CacheID from cache
|
* @uses delete() to remove CacheID from cache
|
||||||
*/
|
*/
|
||||||
public function clear(Smarty $smarty, $resource_name, $cache_id, $compile_id, $exp_time)
|
public function clear(Smarty $smarty, $resource_name, $cache_id, $compile_id, $exp_time)
|
||||||
{
|
{
|
||||||
@@ -199,12 +205,11 @@ abstract class Smarty_CacheResource_KeyValueStore extends Smarty_CacheResource
|
|||||||
/**
|
/**
|
||||||
* Get template's unique ID
|
* Get template's unique ID
|
||||||
*
|
*
|
||||||
* @param Smarty $smarty Smarty object
|
* @param Smarty $smarty Smarty object
|
||||||
* @param string $resource_name template name
|
* @param string $resource_name template name
|
||||||
*
|
*
|
||||||
* @return string filepath of cache file
|
* @return string filepath of cache file
|
||||||
* @throws \SmartyException
|
* @throws \SmartyException
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
protected function getTemplateUid(Smarty $smarty, $resource_name)
|
protected function getTemplateUid(Smarty $smarty, $resource_name)
|
||||||
{
|
{
|
||||||
@@ -220,7 +225,7 @@ abstract class Smarty_CacheResource_KeyValueStore extends Smarty_CacheResource
|
|||||||
/**
|
/**
|
||||||
* Sanitize CacheID components
|
* Sanitize CacheID components
|
||||||
*
|
*
|
||||||
* @param string $string CacheID component to sanitize
|
* @param string $string CacheID component to sanitize
|
||||||
*
|
*
|
||||||
* @return string sanitized CacheID component
|
* @return string sanitized CacheID component
|
||||||
*/
|
*/
|
||||||
@@ -236,19 +241,19 @@ abstract class Smarty_CacheResource_KeyValueStore extends Smarty_CacheResource
|
|||||||
/**
|
/**
|
||||||
* Fetch and prepare a cache object.
|
* Fetch and prepare a cache object.
|
||||||
*
|
*
|
||||||
* @param string $cid CacheID to fetch
|
* @param string $cid CacheID to fetch
|
||||||
* @param string $resource_name template name
|
* @param string $resource_name template name
|
||||||
* @param string $cache_id cache id
|
* @param string $cache_id cache id
|
||||||
* @param string $compile_id compile id
|
* @param string $compile_id compile id
|
||||||
* @param string $content cached content
|
* @param string $content cached content
|
||||||
* @param integer &$timestamp cached timestamp (epoch)
|
* @param integer &$timestamp cached timestamp (epoch)
|
||||||
* @param string $resource_uid resource's uid
|
* @param string $resource_uid resource's uid
|
||||||
*
|
*
|
||||||
* @return boolean success
|
* @return boolean success
|
||||||
*/
|
*/
|
||||||
protected function fetch($cid, $resource_name = null, $cache_id = null, $compile_id = null, &$content = null,
|
protected function fetch($cid, $resource_name = null, $cache_id = null, $compile_id = null, &$content = null,
|
||||||
&$timestamp = null, $resource_uid = null)
|
&$timestamp = null, $resource_uid = null
|
||||||
{
|
) {
|
||||||
$t = $this->read(array($cid));
|
$t = $this->read(array($cid));
|
||||||
$content = !empty($t[ $cid ]) ? $t[ $cid ] : null;
|
$content = !empty($t[ $cid ]) ? $t[ $cid ] : null;
|
||||||
$timestamp = null;
|
$timestamp = null;
|
||||||
@@ -281,7 +286,7 @@ abstract class Smarty_CacheResource_KeyValueStore extends Smarty_CacheResource
|
|||||||
/**
|
/**
|
||||||
* Extract the timestamp the $content was cached
|
* Extract the timestamp the $content was cached
|
||||||
*
|
*
|
||||||
* @param string &$content the cached content
|
* @param string &$content the cached content
|
||||||
*
|
*
|
||||||
* @return float the microtime the content was cached
|
* @return float the microtime the content was cached
|
||||||
*/
|
*/
|
||||||
@@ -298,17 +303,17 @@ abstract class Smarty_CacheResource_KeyValueStore extends Smarty_CacheResource
|
|||||||
/**
|
/**
|
||||||
* Invalidate CacheID
|
* Invalidate CacheID
|
||||||
*
|
*
|
||||||
* @param string $cid CacheID
|
* @param string $cid CacheID
|
||||||
* @param string $resource_name template name
|
* @param string $resource_name template name
|
||||||
* @param string $cache_id cache id
|
* @param string $cache_id cache id
|
||||||
* @param string $compile_id compile id
|
* @param string $compile_id compile id
|
||||||
* @param string $resource_uid source's uid
|
* @param string $resource_uid source's uid
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
protected function invalidate($cid = null, $resource_name = null, $cache_id = null, $compile_id = null,
|
protected function invalidate($cid = null, $resource_name = null, $cache_id = null, $compile_id = null,
|
||||||
$resource_uid = null)
|
$resource_uid = null
|
||||||
{
|
) {
|
||||||
$now = microtime(true);
|
$now = microtime(true);
|
||||||
$key = null;
|
$key = null;
|
||||||
// invalidate everything
|
// invalidate everything
|
||||||
@@ -339,17 +344,17 @@ abstract class Smarty_CacheResource_KeyValueStore extends Smarty_CacheResource
|
|||||||
/**
|
/**
|
||||||
* Determine the latest timestamp known to the invalidation chain
|
* Determine the latest timestamp known to the invalidation chain
|
||||||
*
|
*
|
||||||
* @param string $cid CacheID to determine latest invalidation timestamp of
|
* @param string $cid CacheID to determine latest invalidation timestamp of
|
||||||
* @param string $resource_name template name
|
* @param string $resource_name template name
|
||||||
* @param string $cache_id cache id
|
* @param string $cache_id cache id
|
||||||
* @param string $compile_id compile id
|
* @param string $compile_id compile id
|
||||||
* @param string $resource_uid source's filepath
|
* @param string $resource_uid source's filepath
|
||||||
*
|
*
|
||||||
* @return float the microtime the CacheID was invalidated
|
* @return float the microtime the CacheID was invalidated
|
||||||
*/
|
*/
|
||||||
protected function getLatestInvalidationTimestamp($cid, $resource_name = null, $cache_id = null, $compile_id = null,
|
protected function getLatestInvalidationTimestamp($cid, $resource_name = null, $cache_id = null, $compile_id = null,
|
||||||
$resource_uid = null)
|
$resource_uid = null
|
||||||
{
|
) {
|
||||||
// abort if there is no CacheID
|
// abort if there is no CacheID
|
||||||
if (false && !$cid) {
|
if (false && !$cid) {
|
||||||
return 0;
|
return 0;
|
||||||
@@ -373,18 +378,18 @@ abstract class Smarty_CacheResource_KeyValueStore extends Smarty_CacheResource
|
|||||||
* Translate a CacheID into the list of applicable InvalidationKeys.
|
* Translate a CacheID into the list of applicable InvalidationKeys.
|
||||||
* Splits 'some|chain|into|an|array' into array( '#clearAll#', 'some', 'some|chain', 'some|chain|into', ... )
|
* Splits 'some|chain|into|an|array' into array( '#clearAll#', 'some', 'some|chain', 'some|chain|into', ... )
|
||||||
*
|
*
|
||||||
* @param string $cid CacheID to translate
|
* @param string $cid CacheID to translate
|
||||||
* @param string $resource_name template name
|
* @param string $resource_name template name
|
||||||
* @param string $cache_id cache id
|
* @param string $cache_id cache id
|
||||||
* @param string $compile_id compile id
|
* @param string $compile_id compile id
|
||||||
* @param string $resource_uid source's filepath
|
* @param string $resource_uid source's filepath
|
||||||
*
|
*
|
||||||
* @return array list of InvalidationKeys
|
* @return array list of InvalidationKeys
|
||||||
* @uses $invalidationKeyPrefix to prepend to each InvalidationKey
|
* @uses $invalidationKeyPrefix to prepend to each InvalidationKey
|
||||||
*/
|
*/
|
||||||
protected function listInvalidationKeys($cid, $resource_name = null, $cache_id = null, $compile_id = null,
|
protected function listInvalidationKeys($cid, $resource_name = null, $cache_id = null, $compile_id = null,
|
||||||
$resource_uid = null)
|
$resource_uid = null
|
||||||
{
|
) {
|
||||||
$t = array('IVK#ALL');
|
$t = array('IVK#ALL');
|
||||||
$_name = $_compile = '#';
|
$_name = $_compile = '#';
|
||||||
if ($resource_name) {
|
if ($resource_name) {
|
||||||
@@ -425,8 +430,8 @@ abstract class Smarty_CacheResource_KeyValueStore extends Smarty_CacheResource
|
|||||||
/**
|
/**
|
||||||
* Check is cache is locked for this template
|
* Check is cache is locked for this template
|
||||||
*
|
*
|
||||||
* @param Smarty $smarty Smarty object
|
* @param Smarty $smarty Smarty object
|
||||||
* @param Smarty_Template_Cached $cached cached object
|
* @param Smarty_Template_Cached $cached cached object
|
||||||
*
|
*
|
||||||
* @return boolean true or false if cache is locked
|
* @return boolean true or false if cache is locked
|
||||||
*/
|
*/
|
||||||
@@ -471,7 +476,7 @@ abstract class Smarty_CacheResource_KeyValueStore extends Smarty_CacheResource
|
|||||||
/**
|
/**
|
||||||
* Read values for a set of keys from cache
|
* Read values for a set of keys from cache
|
||||||
*
|
*
|
||||||
* @param array $keys list of keys to fetch
|
* @param array $keys list of keys to fetch
|
||||||
*
|
*
|
||||||
* @return array list of values with the given keys used as indexes
|
* @return array list of values with the given keys used as indexes
|
||||||
*/
|
*/
|
||||||
@@ -480,8 +485,8 @@ abstract class Smarty_CacheResource_KeyValueStore extends Smarty_CacheResource
|
|||||||
/**
|
/**
|
||||||
* Save values for a set of keys to cache
|
* Save values for a set of keys to cache
|
||||||
*
|
*
|
||||||
* @param array $keys list of values to save
|
* @param array $keys list of values to save
|
||||||
* @param int $expire expiration time
|
* @param int $expire expiration time
|
||||||
*
|
*
|
||||||
* @return boolean true on success, false on failure
|
* @return boolean true on success, false on failure
|
||||||
*/
|
*/
|
||||||
@@ -490,7 +495,7 @@ abstract class Smarty_CacheResource_KeyValueStore extends Smarty_CacheResource
|
|||||||
/**
|
/**
|
||||||
* Remove values from cache
|
* Remove values from cache
|
||||||
*
|
*
|
||||||
* @param array $keys list of keys to delete
|
* @param array $keys list of keys to delete
|
||||||
*
|
*
|
||||||
* @return boolean true on success, false on failure
|
* @return boolean true on success, false on failure
|
||||||
*/
|
*/
|
||||||
|
@@ -87,4 +87,4 @@ class Smarty_Internal_Block
|
|||||||
public function callBlock(Smarty_Internal_Template $tpl)
|
public function callBlock(Smarty_Internal_Template $tpl)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -32,11 +32,13 @@ class Smarty_Internal_CacheResource_File extends Smarty_CacheResource
|
|||||||
$_filepath = sha1($source->uid . $smarty->_joined_template_dir);
|
$_filepath = sha1($source->uid . $smarty->_joined_template_dir);
|
||||||
$cached->filepath = $smarty->getCacheDir();
|
$cached->filepath = $smarty->getCacheDir();
|
||||||
if (isset($_template->cache_id)) {
|
if (isset($_template->cache_id)) {
|
||||||
$cached->filepath .= preg_replace(array('![^\w|]+!',
|
$cached->filepath .= preg_replace(
|
||||||
|
array('![^\w|]+!',
|
||||||
'![|]+!'),
|
'![|]+!'),
|
||||||
array('_',
|
array('_',
|
||||||
$_compile_dir_sep),
|
$_compile_dir_sep),
|
||||||
$_template->cache_id) . $_compile_dir_sep;
|
$_template->cache_id
|
||||||
|
) . $_compile_dir_sep;
|
||||||
}
|
}
|
||||||
if (isset($_template->compile_id)) {
|
if (isset($_template->compile_id)) {
|
||||||
$cached->filepath .= preg_replace('![^\w]+!', '_', $_template->compile_id) . $_compile_dir_sep;
|
$cached->filepath .= preg_replace('![^\w]+!', '_', $_template->compile_id) . $_compile_dir_sep;
|
||||||
@@ -88,9 +90,9 @@ class Smarty_Internal_CacheResource_File extends Smarty_CacheResource
|
|||||||
* @return boolean true or false if the cached content does not exist
|
* @return boolean true or false if the cached content does not exist
|
||||||
*/
|
*/
|
||||||
public function process(Smarty_Internal_Template $_smarty_tpl,
|
public function process(Smarty_Internal_Template $_smarty_tpl,
|
||||||
Smarty_Template_Cached $cached = null,
|
Smarty_Template_Cached $cached = null,
|
||||||
$update = false)
|
$update = false
|
||||||
{
|
) {
|
||||||
$_smarty_tpl->cached->valid = false;
|
$_smarty_tpl->cached->valid = false;
|
||||||
if ($update && defined('HHVM_VERSION')) {
|
if ($update && defined('HHVM_VERSION')) {
|
||||||
eval('?>' . file_get_contents($_smarty_tpl->cached->filepath));
|
eval('?>' . file_get_contents($_smarty_tpl->cached->filepath));
|
||||||
@@ -111,12 +113,14 @@ class Smarty_Internal_CacheResource_File extends Smarty_CacheResource
|
|||||||
*/
|
*/
|
||||||
public function writeCachedContent(Smarty_Internal_Template $_template, $content)
|
public function writeCachedContent(Smarty_Internal_Template $_template, $content)
|
||||||
{
|
{
|
||||||
if ($_template->smarty->ext->_writeFile->writeFile($_template->cached->filepath,
|
if ($_template->smarty->ext->_writeFile->writeFile(
|
||||||
$content,
|
$_template->cached->filepath,
|
||||||
$_template->smarty) === true
|
$content,
|
||||||
|
$_template->smarty
|
||||||
|
) === true
|
||||||
) {
|
) {
|
||||||
if (function_exists('opcache_invalidate') &&
|
if (function_exists('opcache_invalidate')
|
||||||
(!function_exists('ini_get') || strlen(ini_get('opcache.restrict_api'))) < 1
|
&& (!function_exists('ini_get') || strlen(ini_get('opcache.restrict_api'))) < 1
|
||||||
) {
|
) {
|
||||||
opcache_invalidate($_template->cached->filepath, true);
|
opcache_invalidate($_template->cached->filepath, true);
|
||||||
} else if (function_exists('apc_compile_file')) {
|
} else if (function_exists('apc_compile_file')) {
|
||||||
@@ -135,7 +139,7 @@ class Smarty_Internal_CacheResource_File extends Smarty_CacheResource
|
|||||||
/**
|
/**
|
||||||
* Read cached template from cache
|
* Read cached template from cache
|
||||||
*
|
*
|
||||||
* @param Smarty_Internal_Template $_template template object
|
* @param Smarty_Internal_Template $_template template object
|
||||||
*
|
*
|
||||||
* @return string content
|
* @return string content
|
||||||
*/
|
*/
|
||||||
|
@@ -19,9 +19,9 @@ class Smarty_Internal_Compile_Append extends Smarty_Internal_Compile_Assign
|
|||||||
/**
|
/**
|
||||||
* Compiles code for the {append} tag
|
* Compiles code for the {append} tag
|
||||||
*
|
*
|
||||||
* @param array $args array with attributes from parser
|
* @param array $args array with attributes from parser
|
||||||
* @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
|
* @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
|
||||||
* @param array $parameter array with compilation parameter
|
* @param array $parameter array with compilation parameter
|
||||||
*
|
*
|
||||||
* @return string compiled code
|
* @return string compiled code
|
||||||
* @throws \SmartyCompilerException
|
* @throws \SmartyCompilerException
|
||||||
|
@@ -24,7 +24,7 @@ class Smarty_Internal_Compile_Assign extends Smarty_Internal_CompileBase
|
|||||||
*/
|
*/
|
||||||
public $option_flags = array('nocache', 'noscope');
|
public $option_flags = array('nocache', 'noscope');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Valid scope names
|
* Valid scope names
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
@@ -36,9 +36,9 @@ class Smarty_Internal_Compile_Assign extends Smarty_Internal_CompileBase
|
|||||||
/**
|
/**
|
||||||
* Compiles code for the {assign} tag
|
* Compiles code for the {assign} tag
|
||||||
*
|
*
|
||||||
* @param array $args array with attributes from parser
|
* @param array $args array with attributes from parser
|
||||||
* @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
|
* @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
|
||||||
* @param array $parameter array with compilation parameter
|
* @param array $parameter array with compilation parameter
|
||||||
*
|
*
|
||||||
* @return string compiled code
|
* @return string compiled code
|
||||||
* @throws \SmartyCompilerException
|
* @throws \SmartyCompilerException
|
||||||
|
@@ -47,10 +47,9 @@ class Smarty_Internal_Compile_Block extends Smarty_Internal_Compile_Shared_Inher
|
|||||||
/**
|
/**
|
||||||
* Compiles code for the {block} tag
|
* Compiles code for the {block} tag
|
||||||
*
|
*
|
||||||
* @param array $args array with attributes from parser
|
* @param array $args array with attributes from parser
|
||||||
* @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
|
* @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
|
||||||
* @param array $parameter array with compilation parameter
|
* @param array $parameter array with compilation parameter
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter)
|
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter)
|
||||||
{
|
{
|
||||||
@@ -72,11 +71,13 @@ class Smarty_Internal_Compile_Block extends Smarty_Internal_Compile_Shared_Inher
|
|||||||
$compiler->_cache[ 'blockClass' ][ $compiler->_cache[ 'blockNesting' ] ] = $_className;
|
$compiler->_cache[ 'blockClass' ][ $compiler->_cache[ 'blockNesting' ] ] = $_className;
|
||||||
$compiler->_cache[ 'blockParams' ][ $compiler->_cache[ 'blockNesting' ] ] = array();
|
$compiler->_cache[ 'blockParams' ][ $compiler->_cache[ 'blockNesting' ] ] = array();
|
||||||
$compiler->_cache[ 'blockParams' ][ 1 ][ 'subBlocks' ][ trim($_attr[ 'name' ], '"\'') ][] = $_className;
|
$compiler->_cache[ 'blockParams' ][ 1 ][ 'subBlocks' ][ trim($_attr[ 'name' ], '"\'') ][] = $_className;
|
||||||
$this->openTag($compiler,
|
$this->openTag(
|
||||||
'block',
|
$compiler,
|
||||||
array($_attr, $compiler->nocache, $compiler->parser->current_buffer,
|
'block',
|
||||||
|
array($_attr, $compiler->nocache, $compiler->parser->current_buffer,
|
||||||
$compiler->template->compiled->has_nocache_code,
|
$compiler->template->compiled->has_nocache_code,
|
||||||
$compiler->template->caching));
|
$compiler->template->caching)
|
||||||
|
);
|
||||||
$compiler->saveRequiredPlugins(true);
|
$compiler->saveRequiredPlugins(true);
|
||||||
$compiler->nocache = $compiler->nocache | $compiler->tag_nocache;
|
$compiler->nocache = $compiler->nocache | $compiler->tag_nocache;
|
||||||
$compiler->parser->current_buffer = new Smarty_Internal_ParseTree_Template();
|
$compiler->parser->current_buffer = new Smarty_Internal_ParseTree_Template();
|
||||||
@@ -86,16 +87,15 @@ class Smarty_Internal_Compile_Block extends Smarty_Internal_Compile_Shared_Inher
|
|||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Smarty Internal Plugin Compile BlockClose Class
|
* Smarty Internal Plugin Compile BlockClose Class
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
class Smarty_Internal_Compile_Blockclose extends Smarty_Internal_Compile_Shared_Inheritance
|
class Smarty_Internal_Compile_Blockclose extends Smarty_Internal_Compile_Shared_Inheritance
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Compiles code for the {/block} tag
|
* Compiles code for the {/block} tag
|
||||||
*
|
*
|
||||||
* @param array $args array with attributes from parser
|
* @param array $args array with attributes from parser
|
||||||
* @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
|
* @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
|
||||||
* @param array $parameter array with compilation parameter
|
* @param array $parameter array with compilation parameter
|
||||||
*
|
*
|
||||||
* @return bool true
|
* @return bool true
|
||||||
*/
|
*/
|
||||||
@@ -124,7 +124,7 @@ class Smarty_Internal_Compile_Blockclose extends Smarty_Internal_Compile_Shared_
|
|||||||
$output .= "class {$_className} extends Smarty_Internal_Block\n";
|
$output .= "class {$_className} extends Smarty_Internal_Block\n";
|
||||||
$output .= "{\n";
|
$output .= "{\n";
|
||||||
foreach ($_block as $property => $value) {
|
foreach ($_block as $property => $value) {
|
||||||
$output .= "public \${$property} = " . var_export($value,true) .";\n";
|
$output .= "public \${$property} = " . var_export($value, true) .";\n";
|
||||||
}
|
}
|
||||||
$output .= "public function callBlock(Smarty_Internal_Template \$_smarty_tpl) {\n";
|
$output .= "public function callBlock(Smarty_Internal_Template \$_smarty_tpl) {\n";
|
||||||
$output .= $compiler->compileRequiredPlugins();
|
$output .= $compiler->compileRequiredPlugins();
|
||||||
@@ -136,9 +136,13 @@ class Smarty_Internal_Compile_Blockclose extends Smarty_Internal_Compile_Shared_
|
|||||||
$output .= "ob_start();\n";
|
$output .= "ob_start();\n";
|
||||||
}
|
}
|
||||||
$output .= "?>\n";
|
$output .= "?>\n";
|
||||||
$compiler->parser->current_buffer->append_subtree($compiler->parser,
|
$compiler->parser->current_buffer->append_subtree(
|
||||||
new Smarty_Internal_ParseTree_Tag($compiler->parser,
|
$compiler->parser,
|
||||||
$output));
|
new Smarty_Internal_ParseTree_Tag(
|
||||||
|
$compiler->parser,
|
||||||
|
$output
|
||||||
|
)
|
||||||
|
);
|
||||||
$compiler->parser->current_buffer->append_subtree($compiler->parser, $_functionCode);
|
$compiler->parser->current_buffer->append_subtree($compiler->parser, $_functionCode);
|
||||||
$output = "<?php\n";
|
$output = "<?php\n";
|
||||||
if (isset($_assign)) {
|
if (isset($_assign)) {
|
||||||
@@ -148,9 +152,13 @@ class Smarty_Internal_Compile_Blockclose extends Smarty_Internal_Compile_Shared_
|
|||||||
$output .= "}\n";
|
$output .= "}\n";
|
||||||
$output .= "/* {/block {$_name}} */\n\n";
|
$output .= "/* {/block {$_name}} */\n\n";
|
||||||
$output .= "?>\n";
|
$output .= "?>\n";
|
||||||
$compiler->parser->current_buffer->append_subtree($compiler->parser,
|
$compiler->parser->current_buffer->append_subtree(
|
||||||
new Smarty_Internal_ParseTree_Tag($compiler->parser,
|
$compiler->parser,
|
||||||
$output));
|
new Smarty_Internal_ParseTree_Tag(
|
||||||
|
$compiler->parser,
|
||||||
|
$output
|
||||||
|
)
|
||||||
|
);
|
||||||
$compiler->blockOrFunctionCode .= $compiler->parser->current_buffer->to_smarty_php($compiler->parser);
|
$compiler->blockOrFunctionCode .= $compiler->parser->current_buffer->to_smarty_php($compiler->parser);
|
||||||
$compiler->parser->current_buffer = new Smarty_Internal_ParseTree_Template();
|
$compiler->parser->current_buffer = new Smarty_Internal_ParseTree_Template();
|
||||||
// restore old status
|
// restore old status
|
||||||
|
@@ -21,4 +21,4 @@ class Smarty_Internal_Compile_Block_Child extends Smarty_Internal_Compile_Child
|
|||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
public $tag = 'block_child';
|
public $tag = 'block_child';
|
||||||
}
|
}
|
||||||
|
@@ -28,4 +28,4 @@ class Smarty_Internal_Compile_Block_Parent extends Smarty_Internal_Compile_Child
|
|||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
public $blockType = 'Parent';
|
public $blockType = 'Parent';
|
||||||
}
|
}
|
||||||
|
@@ -33,16 +33,16 @@ class Smarty_Internal_Compile_Break extends Smarty_Internal_CompileBase
|
|||||||
public $shorttag_order = array('levels');
|
public $shorttag_order = array('levels');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tag name may be overloaded by Smarty_Internal_Compile_Continue
|
* Tag name may be overloaded by Smarty_Internal_Compile_Continue
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
public $tag = 'break';
|
public $tag = 'break';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Compiles code for the {break} tag
|
* Compiles code for the {break} tag
|
||||||
*
|
*
|
||||||
* @param array $args array with attributes from parser
|
* @param array $args array with attributes from parser
|
||||||
* @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
|
* @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
|
||||||
*
|
*
|
||||||
* @return string compiled code
|
* @return string compiled code
|
||||||
@@ -67,7 +67,7 @@ class Smarty_Internal_Compile_Break extends Smarty_Internal_CompileBase
|
|||||||
/**
|
/**
|
||||||
* check attributes and return array of break and foreach levels
|
* check attributes and return array of break and foreach levels
|
||||||
*
|
*
|
||||||
* @param array $args array with attributes from parser
|
* @param array $args array with attributes from parser
|
||||||
* @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
|
* @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
|
||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
|
@@ -43,8 +43,8 @@ class Smarty_Internal_Compile_Call extends Smarty_Internal_CompileBase
|
|||||||
/**
|
/**
|
||||||
* Compiles the calls of user defined tags defined by {function}
|
* Compiles the calls of user defined tags defined by {function}
|
||||||
*
|
*
|
||||||
* @param array $args array with attributes from parser
|
* @param array $args array with attributes from parser
|
||||||
* @param object $compiler compiler object
|
* @param object $compiler compiler object
|
||||||
*
|
*
|
||||||
* @return string compiled code
|
* @return string compiled code
|
||||||
*/
|
*/
|
||||||
|
@@ -35,9 +35,9 @@ class Smarty_Internal_Compile_Capture extends Smarty_Internal_CompileBase
|
|||||||
/**
|
/**
|
||||||
* Compiles code for the {$smarty.capture.xxx}
|
* Compiles code for the {$smarty.capture.xxx}
|
||||||
*
|
*
|
||||||
* @param array $args array with attributes from parser
|
* @param array $args array with attributes from parser
|
||||||
* @param \Smarty_Internal_TemplateCompilerBase$compiler compiler object
|
* @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
|
||||||
* @param array $parameter array with compilation parameter
|
* @param array $parameter array with compilation parameter
|
||||||
*
|
*
|
||||||
* @return string compiled code
|
* @return string compiled code
|
||||||
* @throws \SmartyCompilerException
|
* @throws \SmartyCompilerException
|
||||||
@@ -55,9 +55,9 @@ class Smarty_Internal_Compile_Capture extends Smarty_Internal_CompileBase
|
|||||||
/**
|
/**
|
||||||
* Compiles code for the {capture} tag
|
* Compiles code for the {capture} tag
|
||||||
*
|
*
|
||||||
* @param array $args array with attributes from parser
|
* @param array $args array with attributes from parser
|
||||||
* @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
|
* @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
|
||||||
* @param null $parameter
|
* @param null $parameter
|
||||||
*
|
*
|
||||||
* @return string compiled code
|
* @return string compiled code
|
||||||
*/
|
*/
|
||||||
@@ -90,9 +90,9 @@ class Smarty_Internal_Compile_CaptureClose extends Smarty_Internal_CompileBase
|
|||||||
/**
|
/**
|
||||||
* Compiles code for the {/capture} tag
|
* Compiles code for the {/capture} tag
|
||||||
*
|
*
|
||||||
* @param array $args array with attributes from parser
|
* @param array $args array with attributes from parser
|
||||||
* @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
|
* @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
|
||||||
* @param null $parameter
|
* @param null $parameter
|
||||||
*
|
*
|
||||||
* @return string compiled code
|
* @return string compiled code
|
||||||
*/
|
*/
|
||||||
|
@@ -40,9 +40,9 @@ class Smarty_Internal_Compile_Child extends Smarty_Internal_CompileBase
|
|||||||
/**
|
/**
|
||||||
* Compiles code for the {child} tag
|
* Compiles code for the {child} tag
|
||||||
*
|
*
|
||||||
* @param array $args array with attributes from parser
|
* @param array $args array with attributes from parser
|
||||||
* @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
|
* @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
|
||||||
* @param array $parameter array with compilation parameter
|
* @param array $parameter array with compilation parameter
|
||||||
*
|
*
|
||||||
* @return string compiled code
|
* @return string compiled code
|
||||||
* @throws \SmartyCompilerException
|
* @throws \SmartyCompilerException
|
||||||
@@ -53,8 +53,10 @@ class Smarty_Internal_Compile_Child extends Smarty_Internal_CompileBase
|
|||||||
$_attr = $this->getAttributes($compiler, $args);
|
$_attr = $this->getAttributes($compiler, $args);
|
||||||
$tag = isset($parameter[0]) ? "'{$parameter[0]}'" : "'{{$this->tag}}'";
|
$tag = isset($parameter[0]) ? "'{$parameter[0]}'" : "'{{$this->tag}}'";
|
||||||
if (!isset($compiler->_cache[ 'blockNesting' ])) {
|
if (!isset($compiler->_cache[ 'blockNesting' ])) {
|
||||||
$compiler->trigger_template_error("{$tag} used outside {block} tags ",
|
$compiler->trigger_template_error(
|
||||||
$compiler->parser->lex->taglineno);
|
"{$tag} used outside {block} tags ",
|
||||||
|
$compiler->parser->lex->taglineno
|
||||||
|
);
|
||||||
}
|
}
|
||||||
$compiler->has_code = true;
|
$compiler->has_code = true;
|
||||||
$compiler->suppressNocacheProcessing = true;
|
$compiler->suppressNocacheProcessing = true;
|
||||||
@@ -74,4 +76,4 @@ class Smarty_Internal_Compile_Child extends Smarty_Internal_CompileBase
|
|||||||
$output .="?>\n";
|
$output .="?>\n";
|
||||||
return $output;
|
return $output;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -60,7 +60,7 @@ class Smarty_Internal_Compile_Config_Load extends Smarty_Internal_CompileBase
|
|||||||
/**
|
/**
|
||||||
* Compiles code for the {config_load} tag
|
* Compiles code for the {config_load} tag
|
||||||
*
|
*
|
||||||
* @param array $args array with attributes from parser
|
* @param array $args array with attributes from parser
|
||||||
* @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
|
* @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
|
||||||
*
|
*
|
||||||
* @return string compiled code
|
* @return string compiled code
|
||||||
|
@@ -17,9 +17,9 @@
|
|||||||
class Smarty_Internal_Compile_Continue extends Smarty_Internal_Compile_Break
|
class Smarty_Internal_Compile_Continue extends Smarty_Internal_Compile_Break
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Tag name
|
* Tag name
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
public $tag = 'continue';
|
public $tag = 'continue';
|
||||||
}
|
}
|
||||||
|
@@ -20,8 +20,8 @@ class Smarty_Internal_Compile_Debug extends Smarty_Internal_CompileBase
|
|||||||
/**
|
/**
|
||||||
* Compiles code for the {debug} tag
|
* Compiles code for the {debug} tag
|
||||||
*
|
*
|
||||||
* @param array $args array with attributes from parser
|
* @param array $args array with attributes from parser
|
||||||
* @param object $compiler compiler object
|
* @param object $compiler compiler object
|
||||||
*
|
*
|
||||||
* @return string compiled code
|
* @return string compiled code
|
||||||
*/
|
*/
|
||||||
|
@@ -43,8 +43,8 @@ class Smarty_Internal_Compile_Eval extends Smarty_Internal_CompileBase
|
|||||||
/**
|
/**
|
||||||
* Compiles code for the {eval} tag
|
* Compiles code for the {eval} tag
|
||||||
*
|
*
|
||||||
* @param array $args array with attributes from parser
|
* @param array $args array with attributes from parser
|
||||||
* @param object $compiler compiler object
|
* @param object $compiler compiler object
|
||||||
*
|
*
|
||||||
* @return string compiled code
|
* @return string compiled code
|
||||||
*/
|
*/
|
||||||
|
@@ -108,28 +108,34 @@ class Smarty_Internal_Compile_Extends extends Smarty_Internal_Compile_Shared_Inh
|
|||||||
$inlineUids = $match[ 1 ];
|
$inlineUids = $match[ 1 ];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$compiler->parser->template_postfix[] = new Smarty_Internal_ParseTree_Tag($compiler->parser,
|
$compiler->parser->template_postfix[] = new Smarty_Internal_ParseTree_Tag(
|
||||||
'<?php $_smarty_tpl->inheritance->endChild($_smarty_tpl' .
|
$compiler->parser,
|
||||||
|
'<?php $_smarty_tpl->inheritance->endChild($_smarty_tpl' .
|
||||||
(isset($template) ?
|
(isset($template) ?
|
||||||
", {$template}{$inlineUids}" :
|
", {$template}{$inlineUids}" :
|
||||||
'') . ");\n?>");
|
'') . ");\n?>"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add code for including subtemplate to end of template
|
* Add code for including subtemplate to end of template
|
||||||
*
|
*
|
||||||
* @param \Smarty_Internal_TemplateCompilerBase $compiler
|
* @param \Smarty_Internal_TemplateCompilerBase $compiler
|
||||||
* @param string $template subtemplate name
|
* @param string $template subtemplate name
|
||||||
*
|
*
|
||||||
* @throws \SmartyCompilerException
|
* @throws \SmartyCompilerException
|
||||||
* @throws \SmartyException
|
* @throws \SmartyException
|
||||||
*/
|
*/
|
||||||
private function compileInclude(Smarty_Internal_TemplateCompilerBase $compiler, $template)
|
private function compileInclude(Smarty_Internal_TemplateCompilerBase $compiler, $template)
|
||||||
{
|
{
|
||||||
$compiler->parser->template_postfix[] = new Smarty_Internal_ParseTree_Tag($compiler->parser,
|
$compiler->parser->template_postfix[] = new Smarty_Internal_ParseTree_Tag(
|
||||||
$compiler->compileTag('include',
|
$compiler->parser,
|
||||||
array($template,
|
$compiler->compileTag(
|
||||||
array('scope' => 'parent'))));
|
'include',
|
||||||
|
array($template,
|
||||||
|
array('scope' => 'parent'))
|
||||||
|
)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -26,9 +26,9 @@ class Smarty_Internal_Compile_For extends Smarty_Internal_CompileBase
|
|||||||
* The parser is generating different sets of attribute by which this compiler can
|
* The parser is generating different sets of attribute by which this compiler can
|
||||||
* determine which syntax is used.
|
* determine which syntax is used.
|
||||||
*
|
*
|
||||||
* @param array $args array with attributes from parser
|
* @param array $args array with attributes from parser
|
||||||
* @param object $compiler compiler object
|
* @param object $compiler compiler object
|
||||||
* @param array $parameter array with compilation parameter
|
* @param array $parameter array with compilation parameter
|
||||||
*
|
*
|
||||||
* @return string compiled code
|
* @return string compiled code
|
||||||
*/
|
*/
|
||||||
@@ -113,9 +113,9 @@ class Smarty_Internal_Compile_Forelse extends Smarty_Internal_CompileBase
|
|||||||
/**
|
/**
|
||||||
* Compiles code for the {forelse} tag
|
* Compiles code for the {forelse} tag
|
||||||
*
|
*
|
||||||
* @param array $args array with attributes from parser
|
* @param array $args array with attributes from parser
|
||||||
* @param object $compiler compiler object
|
* @param object $compiler compiler object
|
||||||
* @param array $parameter array with compilation parameter
|
* @param array $parameter array with compilation parameter
|
||||||
*
|
*
|
||||||
* @return string compiled code
|
* @return string compiled code
|
||||||
*/
|
*/
|
||||||
@@ -142,9 +142,9 @@ class Smarty_Internal_Compile_Forclose extends Smarty_Internal_CompileBase
|
|||||||
/**
|
/**
|
||||||
* Compiles code for the {/for} tag
|
* Compiles code for the {/for} tag
|
||||||
*
|
*
|
||||||
* @param array $args array with attributes from parser
|
* @param array $args array with attributes from parser
|
||||||
* @param object $compiler compiler object
|
* @param object $compiler compiler object
|
||||||
* @param array $parameter array with compilation parameter
|
* @param array $parameter array with compilation parameter
|
||||||
*
|
*
|
||||||
* @return string compiled code
|
* @return string compiled code
|
||||||
*/
|
*/
|
||||||
|
@@ -78,7 +78,7 @@ class Smarty_Internal_Compile_Foreach extends Smarty_Internal_Compile_Private_Fo
|
|||||||
/**
|
/**
|
||||||
* Compiles code for the {foreach} tag
|
* Compiles code for the {foreach} tag
|
||||||
*
|
*
|
||||||
* @param array $args array with attributes from parser
|
* @param array $args array with attributes from parser
|
||||||
* @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
|
* @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
|
||||||
*
|
*
|
||||||
* @return string compiled code
|
* @return string compiled code
|
||||||
@@ -119,8 +119,10 @@ class Smarty_Internal_Compile_Foreach extends Smarty_Internal_Compile_Private_Fo
|
|||||||
if ($fromName) {
|
if ($fromName) {
|
||||||
foreach (array('item', 'key') as $a) {
|
foreach (array('item', 'key') as $a) {
|
||||||
if (isset($attributes[ $a ]) && $attributes[ $a ] === $fromName) {
|
if (isset($attributes[ $a ]) && $attributes[ $a ] === $fromName) {
|
||||||
$compiler->trigger_template_error("'{$a}' and 'from' may not have same variable name '{$fromName}'",
|
$compiler->trigger_template_error(
|
||||||
null, true);
|
"'{$a}' and 'from' may not have same variable name '{$fromName}'",
|
||||||
|
null, true
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -187,8 +189,10 @@ class Smarty_Internal_Compile_Foreach extends Smarty_Internal_Compile_Private_Fo
|
|||||||
}
|
}
|
||||||
$needTotal = isset($itemAttr[ 'total' ]);
|
$needTotal = isset($itemAttr[ 'total' ]);
|
||||||
// Register tag
|
// Register tag
|
||||||
$this->openTag($compiler, 'foreach',
|
$this->openTag(
|
||||||
array('foreach', $compiler->nocache, $local, $itemVar, empty($itemAttr) ? 1 : 2));
|
$compiler, 'foreach',
|
||||||
|
array('foreach', $compiler->nocache, $local, $itemVar, empty($itemAttr) ? 1 : 2)
|
||||||
|
);
|
||||||
// maybe nocache because of nocache variables
|
// maybe nocache because of nocache variables
|
||||||
$compiler->nocache = $compiler->nocache | $compiler->tag_nocache;
|
$compiler->nocache = $compiler->nocache | $compiler->tag_nocache;
|
||||||
// generate output code
|
// generate output code
|
||||||
@@ -277,7 +281,7 @@ class Smarty_Internal_Compile_Foreachelse extends Smarty_Internal_CompileBase
|
|||||||
/**
|
/**
|
||||||
* Compiles code for the {foreachelse} tag
|
* Compiles code for the {foreachelse} tag
|
||||||
*
|
*
|
||||||
* @param array $args array with attributes from parser
|
* @param array $args array with attributes from parser
|
||||||
* @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
|
* @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
|
||||||
*
|
*
|
||||||
* @return string compiled code
|
* @return string compiled code
|
||||||
@@ -309,12 +313,12 @@ class Smarty_Internal_Compile_Foreachclose extends Smarty_Internal_CompileBase
|
|||||||
/**
|
/**
|
||||||
* Compiles code for the {/foreach} tag
|
* Compiles code for the {/foreach} tag
|
||||||
*
|
*
|
||||||
* @param array $args array with attributes from parser
|
* @param array $args array with attributes from parser
|
||||||
* @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
|
* @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
|
||||||
*
|
*
|
||||||
* @return string compiled code
|
* @return string compiled code
|
||||||
* @throws \SmartyCompilerException
|
* @throws \SmartyCompilerException
|
||||||
*/
|
*/
|
||||||
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler)
|
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler)
|
||||||
{
|
{
|
||||||
$compiler->loopNesting --;
|
$compiler->loopNesting --;
|
||||||
|
@@ -44,7 +44,7 @@ class Smarty_Internal_Compile_Function extends Smarty_Internal_CompileBase
|
|||||||
/**
|
/**
|
||||||
* Compiles code for the {function} tag
|
* Compiles code for the {function} tag
|
||||||
*
|
*
|
||||||
* @param array $args array with attributes from parser
|
* @param array $args array with attributes from parser
|
||||||
* @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
|
* @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
|
||||||
*
|
*
|
||||||
* @return bool true
|
* @return bool true
|
||||||
@@ -91,7 +91,7 @@ class Smarty_Internal_Compile_Functionclose extends Smarty_Internal_CompileBase
|
|||||||
/**
|
/**
|
||||||
* Compiles code for the {/function} tag
|
* Compiles code for the {/function} tag
|
||||||
*
|
*
|
||||||
* @param array $args array with attributes from parser
|
* @param array $args array with attributes from parser
|
||||||
* @param object|\Smarty_Internal_TemplateCompilerBase $compiler compiler object
|
* @param object|\Smarty_Internal_TemplateCompilerBase $compiler compiler object
|
||||||
*
|
*
|
||||||
* @return bool true
|
* @return bool true
|
||||||
@@ -143,9 +143,13 @@ class Smarty_Internal_Compile_Functionclose extends Smarty_Internal_CompileBase
|
|||||||
$output .= "echo \"/*%%SmartyNocache:{$compiler->template->compiled->nocache_hash}%%*/<?php ";
|
$output .= "echo \"/*%%SmartyNocache:{$compiler->template->compiled->nocache_hash}%%*/<?php ";
|
||||||
$output .= "\\\$_smarty_tpl->smarty->ext->_tplFunction->saveTemplateVariables(\\\$_smarty_tpl, '{$_name}');\nforeach (\$params as \\\$key => \\\$value) {\n\\\$_smarty_tpl->tpl_vars[\\\$key] = new Smarty_Variable(\\\$value, \\\$_smarty_tpl->isRenderingCache);\n}\n?>";
|
$output .= "\\\$_smarty_tpl->smarty->ext->_tplFunction->saveTemplateVariables(\\\$_smarty_tpl, '{$_name}');\nforeach (\$params as \\\$key => \\\$value) {\n\\\$_smarty_tpl->tpl_vars[\\\$key] = new Smarty_Variable(\\\$value, \\\$_smarty_tpl->isRenderingCache);\n}\n?>";
|
||||||
$output .= "/*/%%SmartyNocache:{$compiler->template->compiled->nocache_hash}%%*/\";?>";
|
$output .= "/*/%%SmartyNocache:{$compiler->template->compiled->nocache_hash}%%*/\";?>";
|
||||||
$compiler->parser->current_buffer->append_subtree($compiler->parser,
|
$compiler->parser->current_buffer->append_subtree(
|
||||||
new Smarty_Internal_ParseTree_Tag($compiler->parser,
|
$compiler->parser,
|
||||||
$output));
|
new Smarty_Internal_ParseTree_Tag(
|
||||||
|
$compiler->parser,
|
||||||
|
$output
|
||||||
|
)
|
||||||
|
);
|
||||||
$compiler->parser->current_buffer->append_subtree($compiler->parser, $_functionCode);
|
$compiler->parser->current_buffer->append_subtree($compiler->parser, $_functionCode);
|
||||||
$output = "<?php echo \"/*%%SmartyNocache:{$compiler->template->compiled->nocache_hash}%%*/<?php ";
|
$output = "<?php echo \"/*%%SmartyNocache:{$compiler->template->compiled->nocache_hash}%%*/<?php ";
|
||||||
$output .= "\\\$_smarty_tpl->smarty->ext->_tplFunction->restoreTemplateVariables(\\\$_smarty_tpl, '{$_name}');?>\n";
|
$output .= "\\\$_smarty_tpl->smarty->ext->_tplFunction->restoreTemplateVariables(\\\$_smarty_tpl, '{$_name}');?>\n";
|
||||||
@@ -154,13 +158,21 @@ class Smarty_Internal_Compile_Functionclose extends Smarty_Internal_CompileBase
|
|||||||
$output .= "}\n}\n";
|
$output .= "}\n}\n";
|
||||||
$output .= "/*/ {$_funcName}_nocache */\n\n";
|
$output .= "/*/ {$_funcName}_nocache */\n\n";
|
||||||
$output .= "?>\n";
|
$output .= "?>\n";
|
||||||
$compiler->parser->current_buffer->append_subtree($compiler->parser,
|
$compiler->parser->current_buffer->append_subtree(
|
||||||
new Smarty_Internal_ParseTree_Tag($compiler->parser,
|
$compiler->parser,
|
||||||
$output));
|
new Smarty_Internal_ParseTree_Tag(
|
||||||
$_functionCode = new Smarty_Internal_ParseTree_Tag($compiler->parser,
|
$compiler->parser,
|
||||||
preg_replace_callback("/((<\?php )?echo '\/\*%%SmartyNocache:{$compiler->template->compiled->nocache_hash}%%\*\/([\S\s]*?)\/\*\/%%SmartyNocache:{$compiler->template->compiled->nocache_hash}%%\*\/';(\?>\n)?)/",
|
$output
|
||||||
array($this, 'removeNocache'),
|
)
|
||||||
$_functionCode->to_smarty_php($compiler->parser)));
|
);
|
||||||
|
$_functionCode = new Smarty_Internal_ParseTree_Tag(
|
||||||
|
$compiler->parser,
|
||||||
|
preg_replace_callback(
|
||||||
|
"/((<\?php )?echo '\/\*%%SmartyNocache:{$compiler->template->compiled->nocache_hash}%%\*\/([\S\s]*?)\/\*\/%%SmartyNocache:{$compiler->template->compiled->nocache_hash}%%\*\/';(\?>\n)?)/",
|
||||||
|
array($this, 'removeNocache'),
|
||||||
|
$_functionCode->to_smarty_php($compiler->parser)
|
||||||
|
)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
$compiler->parent_compiler->tpl_function[ $_name ][ 'call_name' ] = $_funcName;
|
$compiler->parent_compiler->tpl_function[ $_name ][ 'call_name' ] = $_funcName;
|
||||||
$output = "<?php\n";
|
$output = "<?php\n";
|
||||||
@@ -171,18 +183,26 @@ class Smarty_Internal_Compile_Functionclose extends Smarty_Internal_CompileBase
|
|||||||
$output .= "foreach (\$params as \$key => \$value) {\n\$_smarty_tpl->tpl_vars[\$key] = new Smarty_Variable(\$value, \$_smarty_tpl->isRenderingCache);\n}\n";
|
$output .= "foreach (\$params as \$key => \$value) {\n\$_smarty_tpl->tpl_vars[\$key] = new Smarty_Variable(\$value, \$_smarty_tpl->isRenderingCache);\n}\n";
|
||||||
$output .= $compiler->compileCheckPlugins(array_merge($compiler->required_plugins[ 'compiled' ], $compiler->required_plugins[ 'nocache' ]));
|
$output .= $compiler->compileCheckPlugins(array_merge($compiler->required_plugins[ 'compiled' ], $compiler->required_plugins[ 'nocache' ]));
|
||||||
$output .= "?>\n";
|
$output .= "?>\n";
|
||||||
$compiler->parser->current_buffer->append_subtree($compiler->parser,
|
$compiler->parser->current_buffer->append_subtree(
|
||||||
new Smarty_Internal_ParseTree_Tag($compiler->parser,
|
$compiler->parser,
|
||||||
$output));
|
new Smarty_Internal_ParseTree_Tag(
|
||||||
|
$compiler->parser,
|
||||||
|
$output
|
||||||
|
)
|
||||||
|
);
|
||||||
$compiler->parser->current_buffer->append_subtree($compiler->parser, $_functionCode);
|
$compiler->parser->current_buffer->append_subtree($compiler->parser, $_functionCode);
|
||||||
$output = "<?php\n}}\n";
|
$output = "<?php\n}}\n";
|
||||||
$output .= "/*/ {$_funcName} */\n\n";
|
$output .= "/*/ {$_funcName} */\n\n";
|
||||||
$output .= "?>\n";
|
$output .= "?>\n";
|
||||||
$compiler->parser->current_buffer->append_subtree($compiler->parser,
|
$compiler->parser->current_buffer->append_subtree(
|
||||||
new Smarty_Internal_ParseTree_Tag($compiler->parser,
|
$compiler->parser,
|
||||||
$output));
|
new Smarty_Internal_ParseTree_Tag(
|
||||||
|
$compiler->parser,
|
||||||
|
$output
|
||||||
|
)
|
||||||
|
);
|
||||||
$compiler->parent_compiler->blockOrFunctionCode .= $compiler->parser->current_buffer->to_smarty_php($compiler->parser);
|
$compiler->parent_compiler->blockOrFunctionCode .= $compiler->parser->current_buffer->to_smarty_php($compiler->parser);
|
||||||
// restore old buffer
|
// restore old buffer
|
||||||
$compiler->parser->current_buffer = $saved_data[ 1 ];
|
$compiler->parser->current_buffer = $saved_data[ 1 ];
|
||||||
// restore old status
|
// restore old status
|
||||||
$compiler->restoreRequiredPlugins();
|
$compiler->restoreRequiredPlugins();
|
||||||
@@ -201,8 +221,10 @@ class Smarty_Internal_Compile_Functionclose extends Smarty_Internal_CompileBase
|
|||||||
function removeNocache($match)
|
function removeNocache($match)
|
||||||
{
|
{
|
||||||
$code =
|
$code =
|
||||||
preg_replace("/((<\?php )?echo '\/\*%%SmartyNocache:{$this->compiler->template->compiled->nocache_hash}%%\*\/)|(\/\*\/%%SmartyNocache:{$this->compiler->template->compiled->nocache_hash}%%\*\/';(\?>\n)?)/",
|
preg_replace(
|
||||||
'', $match[ 0 ]);
|
"/((<\?php )?echo '\/\*%%SmartyNocache:{$this->compiler->template->compiled->nocache_hash}%%\*\/)|(\/\*\/%%SmartyNocache:{$this->compiler->template->compiled->nocache_hash}%%\*\/';(\?>\n)?)/",
|
||||||
|
'', $match[ 0 ]
|
||||||
|
);
|
||||||
$code = str_replace(array('\\\'', '\\\\\''), array('\'', '\\\''), $code);
|
$code = str_replace(array('\\\'', '\\\\\''), array('\'', '\\\''), $code);
|
||||||
return $code;
|
return $code;
|
||||||
}
|
}
|
||||||
|
@@ -55,8 +55,10 @@ class Smarty_Internal_Compile_If extends Smarty_Internal_CompileBase
|
|||||||
$assignCompiler = new Smarty_Internal_Compile_Assign();
|
$assignCompiler = new Smarty_Internal_Compile_Assign();
|
||||||
if (is_array($parameter[ 'if condition' ][ 'var' ])) {
|
if (is_array($parameter[ 'if condition' ][ 'var' ])) {
|
||||||
$assignAttr[][ 'var' ] = $parameter[ 'if condition' ][ 'var' ][ 'var' ];
|
$assignAttr[][ 'var' ] = $parameter[ 'if condition' ][ 'var' ][ 'var' ];
|
||||||
$_output .= $assignCompiler->compile($assignAttr, $compiler,
|
$_output .= $assignCompiler->compile(
|
||||||
array('smarty_internal_index' => $parameter[ 'if condition' ][ 'var' ][ 'smarty_internal_index' ]));
|
$assignAttr, $compiler,
|
||||||
|
array('smarty_internal_index' => $parameter[ 'if condition' ][ 'var' ][ 'smarty_internal_index' ])
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
$assignAttr[][ 'var' ] = $parameter[ 'if condition' ][ 'var' ];
|
$assignAttr[][ 'var' ] = $parameter[ 'if condition' ][ 'var' ];
|
||||||
$_output .= $assignCompiler->compile($assignAttr, $compiler, array());
|
$_output .= $assignCompiler->compile($assignAttr, $compiler, array());
|
||||||
@@ -84,7 +86,7 @@ class Smarty_Internal_Compile_Else extends Smarty_Internal_CompileBase
|
|||||||
* @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
|
* @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
|
||||||
*
|
*
|
||||||
* @return string compiled code
|
* @return string compiled code
|
||||||
*/
|
*/
|
||||||
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler)
|
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler)
|
||||||
{
|
{
|
||||||
list($nesting, $compiler->tag_nocache) = $this->closeTag($compiler, array('if', 'elseif'));
|
list($nesting, $compiler->tag_nocache) = $this->closeTag($compiler, array('if', 'elseif'));
|
||||||
@@ -143,8 +145,10 @@ class Smarty_Internal_Compile_Elseif extends Smarty_Internal_CompileBase
|
|||||||
$assignAttr[][ 'value' ] = $prefixVar;
|
$assignAttr[][ 'value' ] = $prefixVar;
|
||||||
if (is_array($parameter[ 'if condition' ][ 'var' ])) {
|
if (is_array($parameter[ 'if condition' ][ 'var' ])) {
|
||||||
$assignAttr[][ 'var' ] = $parameter[ 'if condition' ][ 'var' ][ 'var' ];
|
$assignAttr[][ 'var' ] = $parameter[ 'if condition' ][ 'var' ][ 'var' ];
|
||||||
$assignCode .= $assignCompiler->compile($assignAttr, $compiler,
|
$assignCode .= $assignCompiler->compile(
|
||||||
array('smarty_internal_index' => $parameter[ 'if condition' ][ 'var' ][ 'smarty_internal_index' ]));
|
$assignAttr, $compiler,
|
||||||
|
array('smarty_internal_index' => $parameter[ 'if condition' ][ 'var' ][ 'smarty_internal_index' ])
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
$assignAttr[][ 'var' ] = $parameter[ 'if condition' ][ 'var' ];
|
$assignAttr[][ 'var' ] = $parameter[ 'if condition' ][ 'var' ];
|
||||||
$assignCode .= $assignCompiler->compile($assignAttr, $compiler, array());
|
$assignCode .= $assignCompiler->compile($assignAttr, $compiler, array());
|
||||||
|
@@ -59,8 +59,8 @@ class Smarty_Internal_Compile_Include extends Smarty_Internal_CompileBase
|
|||||||
/**
|
/**
|
||||||
* Compiles code for the {include} tag
|
* Compiles code for the {include} tag
|
||||||
*
|
*
|
||||||
* @param array $args array with attributes from parser
|
* @param array $args array with attributes from parser
|
||||||
* @param Smarty_Internal_SmartyTemplateCompiler $compiler compiler object
|
* @param Smarty_Internal_SmartyTemplateCompiler $compiler compiler object
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
* @throws \Exception
|
* @throws \Exception
|
||||||
@@ -91,8 +91,7 @@ class Smarty_Internal_Compile_Include extends Smarty_Internal_CompileBase
|
|||||||
$compiled->includes[ $fullResourceName ]++;
|
$compiled->includes[ $fullResourceName ]++;
|
||||||
$cache_tpl = true;
|
$cache_tpl = true;
|
||||||
} else {
|
} else {
|
||||||
if ("{$compiler->template->source->type}:{$compiler->template->source->name}" ==
|
if ("{$compiler->template->source->type}:{$compiler->template->source->name}" == $fullResourceName
|
||||||
$fullResourceName
|
|
||||||
) {
|
) {
|
||||||
// recursive call of current template
|
// recursive call of current template
|
||||||
$compiled->includes[ $fullResourceName ] = 2;
|
$compiled->includes[ $fullResourceName ] = 2;
|
||||||
@@ -193,9 +192,11 @@ class Smarty_Internal_Compile_Include extends Smarty_Internal_CompileBase
|
|||||||
$t_hash = sha1($c_id . ($_caching ? '--caching' : '--nocaching'));
|
$t_hash = sha1($c_id . ($_caching ? '--caching' : '--nocaching'));
|
||||||
$compiler->smarty->allow_ambiguous_resources = true;
|
$compiler->smarty->allow_ambiguous_resources = true;
|
||||||
/* @var Smarty_Internal_Template $tpl */
|
/* @var Smarty_Internal_Template $tpl */
|
||||||
$tpl = new $compiler->smarty->template_class (trim($fullResourceName, '"\''), $compiler->smarty,
|
$tpl = new $compiler->smarty->template_class(
|
||||||
$compiler->template, $compiler->template->cache_id, $c_id,
|
trim($fullResourceName, '"\''), $compiler->smarty,
|
||||||
$_caching);
|
$compiler->template, $compiler->template->cache_id, $c_id,
|
||||||
|
$_caching
|
||||||
|
);
|
||||||
$uid = $tpl->source->type . $tpl->source->uid;
|
$uid = $tpl->source->type . $tpl->source->uid;
|
||||||
if (!isset($compiler->parent_compiler->mergedSubTemplatesData[ $uid ][ $t_hash ])) {
|
if (!isset($compiler->parent_compiler->mergedSubTemplatesData[ $uid ][ $t_hash ])) {
|
||||||
$has_compiled_template = $this->compileInlineTemplate($compiler, $tpl, $t_hash);
|
$has_compiled_template = $this->compileInlineTemplate($compiler, $tpl, $t_hash);
|
||||||
@@ -269,16 +270,16 @@ class Smarty_Internal_Compile_Include extends Smarty_Internal_CompileBase
|
|||||||
*
|
*
|
||||||
* @param \Smarty_Internal_SmartyTemplateCompiler $compiler
|
* @param \Smarty_Internal_SmartyTemplateCompiler $compiler
|
||||||
* @param \Smarty_Internal_Template $tpl
|
* @param \Smarty_Internal_Template $tpl
|
||||||
* @param string $t_hash
|
* @param string $t_hash
|
||||||
*
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
* @throws \Exception
|
* @throws \Exception
|
||||||
* @throws \SmartyException
|
* @throws \SmartyException
|
||||||
*/
|
*/
|
||||||
public function compileInlineTemplate(Smarty_Internal_SmartyTemplateCompiler $compiler,
|
public function compileInlineTemplate(Smarty_Internal_SmartyTemplateCompiler $compiler,
|
||||||
Smarty_Internal_Template $tpl,
|
Smarty_Internal_Template $tpl,
|
||||||
$t_hash)
|
$t_hash
|
||||||
{
|
) {
|
||||||
$uid = $tpl->source->type . $tpl->source->uid;
|
$uid = $tpl->source->type . $tpl->source->uid;
|
||||||
if (!($tpl->source->handler->uncompiled) && $tpl->source->exists) {
|
if (!($tpl->source->handler->uncompiled) && $tpl->source->exists) {
|
||||||
$compiler->parent_compiler->mergedSubTemplatesData[ $uid ][ $t_hash ][ 'uid' ] = $tpl->source->uid;
|
$compiler->parent_compiler->mergedSubTemplatesData[ $uid ][ $t_hash ][ 'uid' ] = $tpl->source->uid;
|
||||||
@@ -317,9 +318,11 @@ class Smarty_Internal_Compile_Include extends Smarty_Internal_CompileBase
|
|||||||
if ($tpl->compiled->has_nocache_code) {
|
if ($tpl->compiled->has_nocache_code) {
|
||||||
// replace nocache_hash
|
// replace nocache_hash
|
||||||
$compiled_code =
|
$compiled_code =
|
||||||
str_replace("{$tpl->compiled->nocache_hash}",
|
str_replace(
|
||||||
$compiler->template->compiled->nocache_hash,
|
"{$tpl->compiled->nocache_hash}",
|
||||||
$compiled_code);
|
$compiler->template->compiled->nocache_hash,
|
||||||
|
$compiled_code
|
||||||
|
);
|
||||||
$compiler->template->compiled->has_nocache_code = true;
|
$compiler->template->compiled->has_nocache_code = true;
|
||||||
}
|
}
|
||||||
$compiler->parent_compiler->mergedSubTemplatesCode[ $tpl->compiled->unifunc ] = $compiled_code;
|
$compiler->parent_compiler->mergedSubTemplatesCode[ $tpl->compiled->unifunc ] = $compiled_code;
|
||||||
|
@@ -42,7 +42,7 @@ class Smarty_Internal_Compile_Include_Php extends Smarty_Internal_CompileBase
|
|||||||
/**
|
/**
|
||||||
* Compiles code for the {include_php} tag
|
* Compiles code for the {include_php} tag
|
||||||
*
|
*
|
||||||
* @param array $args array with attributes from parser
|
* @param array $args array with attributes from parser
|
||||||
* @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
|
* @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
@@ -56,7 +56,10 @@ class Smarty_Internal_Compile_Include_Php extends Smarty_Internal_CompileBase
|
|||||||
}
|
}
|
||||||
// check and get attributes
|
// check and get attributes
|
||||||
$_attr = $this->getAttributes($compiler, $args);
|
$_attr = $this->getAttributes($compiler, $args);
|
||||||
/** @var Smarty_Internal_Template $_smarty_tpl
|
/**
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @var Smarty_Internal_Template $_smarty_tpl
|
||||||
* used in evaluated code
|
* used in evaluated code
|
||||||
*/
|
*/
|
||||||
$_smarty_tpl = $compiler->template;
|
$_smarty_tpl = $compiler->template;
|
||||||
|
@@ -41,7 +41,7 @@ class Smarty_Internal_Compile_Insert extends Smarty_Internal_CompileBase
|
|||||||
/**
|
/**
|
||||||
* Compiles code for the {insert} tag
|
* Compiles code for the {insert} tag
|
||||||
*
|
*
|
||||||
* @param array $args array with attributes from parser
|
* @param array $args array with attributes from parser
|
||||||
* @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
|
* @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
|
||||||
*
|
*
|
||||||
* @return string compiled code
|
* @return string compiled code
|
||||||
@@ -104,11 +104,13 @@ class Smarty_Internal_Compile_Insert extends Smarty_Internal_CompileBase
|
|||||||
}
|
}
|
||||||
// code for script file loading
|
// code for script file loading
|
||||||
$_output .= "require_once '{$_filepath}' ;";
|
$_output .= "require_once '{$_filepath}' ;";
|
||||||
require_once $_filepath;
|
include_once $_filepath;
|
||||||
if (!is_callable($_function)) {
|
if (!is_callable($_function)) {
|
||||||
$compiler->trigger_template_error(" {insert} function '{$_function}' is not callable in script file '{$_script}'",
|
$compiler->trigger_template_error(
|
||||||
null,
|
" {insert} function '{$_function}' is not callable in script file '{$_script}'",
|
||||||
true);
|
null,
|
||||||
|
true
|
||||||
|
);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$_filepath = 'null';
|
$_filepath = 'null';
|
||||||
@@ -117,9 +119,11 @@ class Smarty_Internal_Compile_Insert extends Smarty_Internal_CompileBase
|
|||||||
if (!is_callable($_function)) {
|
if (!is_callable($_function)) {
|
||||||
// try plugin
|
// try plugin
|
||||||
if (!$_function = $compiler->getPlugin($_name, 'insert')) {
|
if (!$_function = $compiler->getPlugin($_name, 'insert')) {
|
||||||
$compiler->trigger_template_error("{insert} no function or plugin found for '{$_name}'",
|
$compiler->trigger_template_error(
|
||||||
null,
|
"{insert} no function or plugin found for '{$_name}'",
|
||||||
true);
|
null,
|
||||||
|
true
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -16,11 +16,11 @@
|
|||||||
*/
|
*/
|
||||||
class Smarty_Internal_Compile_Ldelim extends Smarty_Internal_CompileBase
|
class Smarty_Internal_Compile_Ldelim extends Smarty_Internal_CompileBase
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Compiles code for the {ldelim} tag
|
* Compiles code for the {ldelim} tag
|
||||||
* This tag does output the left delimiter
|
* This tag does output the left delimiter
|
||||||
*
|
*
|
||||||
* @param array $args array with attributes from parser
|
* @param array $args array with attributes from parser
|
||||||
* @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
|
* @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
|
||||||
*
|
*
|
||||||
* @return string compiled code
|
* @return string compiled code
|
||||||
|
@@ -41,11 +41,11 @@ class Smarty_Internal_Compile_Make_Nocache extends Smarty_Internal_CompileBase
|
|||||||
/**
|
/**
|
||||||
* Compiles code for the {make_nocache} tag
|
* Compiles code for the {make_nocache} tag
|
||||||
*
|
*
|
||||||
* @param array $args array with attributes from parser
|
* @param array $args array with attributes from parser
|
||||||
* @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
|
* @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
|
||||||
*
|
*
|
||||||
* @return string compiled code
|
* @return string compiled code
|
||||||
*/
|
*/
|
||||||
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler)
|
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler)
|
||||||
{
|
{
|
||||||
// check and get attributes
|
// check and get attributes
|
||||||
|
@@ -27,7 +27,7 @@ class Smarty_Internal_Compile_Nocache extends Smarty_Internal_CompileBase
|
|||||||
* Compiles code for the {nocache} tag
|
* Compiles code for the {nocache} tag
|
||||||
* This tag does not generate compiled output. It only sets a compiler flag.
|
* This tag does not generate compiled output. It only sets a compiler flag.
|
||||||
*
|
*
|
||||||
* @param array $args array with attributes from parser
|
* @param array $args array with attributes from parser
|
||||||
* @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
|
* @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
|
||||||
*
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
@@ -57,7 +57,7 @@ class Smarty_Internal_Compile_Nocacheclose extends Smarty_Internal_CompileBase
|
|||||||
* Compiles code for the {/nocache} tag
|
* Compiles code for the {/nocache} tag
|
||||||
* This tag does not generate compiled output. It only sets a compiler flag.
|
* This tag does not generate compiled output. It only sets a compiler flag.
|
||||||
*
|
*
|
||||||
* @param array $args array with attributes from parser
|
* @param array $args array with attributes from parser
|
||||||
* @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
|
* @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
|
||||||
*
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
|
@@ -29,4 +29,4 @@ class Smarty_Internal_Compile_Parent extends Smarty_Internal_Compile_Child
|
|||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
public $blockType = 'Parent';
|
public $blockType = 'Parent';
|
||||||
}
|
}
|
||||||
|
@@ -34,11 +34,11 @@ class Smarty_Internal_Compile_Private_Block_Plugin extends Smarty_Internal_Compi
|
|||||||
/**
|
/**
|
||||||
* Compiles code for the execution of block plugin
|
* Compiles code for the execution of block plugin
|
||||||
*
|
*
|
||||||
* @param array $args array with attributes from parser
|
* @param array $args array with attributes from parser
|
||||||
* @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
|
* @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
|
||||||
* @param array $parameter array with compilation parameter
|
* @param array $parameter array with compilation parameter
|
||||||
* @param string $tag name of block plugin
|
* @param string $tag name of block plugin
|
||||||
* @param string $function PHP function name
|
* @param string $function PHP function name
|
||||||
*
|
*
|
||||||
* @return string compiled code
|
* @return string compiled code
|
||||||
* @throws \SmartyCompilerException
|
* @throws \SmartyCompilerException
|
||||||
@@ -84,9 +84,11 @@ class Smarty_Internal_Compile_Private_Block_Plugin extends Smarty_Internal_Compi
|
|||||||
$mod_content2 = "\$_block_content{$this->nesting}";
|
$mod_content2 = "\$_block_content{$this->nesting}";
|
||||||
$mod_content = "\$_block_content{$this->nesting} = ob_get_clean();\n";
|
$mod_content = "\$_block_content{$this->nesting} = ob_get_clean();\n";
|
||||||
$mod_pre = "ob_start();\n";
|
$mod_pre = "ob_start();\n";
|
||||||
$mod_post = 'echo ' . $compiler->compileTag('private_modifier', array(),
|
$mod_post = 'echo ' . $compiler->compileTag(
|
||||||
array('modifierlist' => $parameter[ 'modifier_list' ],
|
'private_modifier', array(),
|
||||||
'value' => 'ob_get_clean()')) . ";\n";
|
array('modifierlist' => $parameter[ 'modifier_list' ],
|
||||||
|
'value' => 'ob_get_clean()')
|
||||||
|
) . ";\n";
|
||||||
}
|
}
|
||||||
$output = "<?php {$mod_content}\$_block_repeat=false;\n{$mod_pre}echo {$callback}({$_params}, {$mod_content2}, \$_smarty_tpl, \$_block_repeat);\n{$mod_post}}\n";
|
$output = "<?php {$mod_content}\$_block_repeat=false;\n{$mod_pre}echo {$callback}({$_params}, {$mod_content2}, \$_smarty_tpl, \$_block_repeat);\n{$mod_post}}\n";
|
||||||
$output .= 'array_pop($_smarty_tpl->smarty->_cache[\'_tag_stack\']);?>';
|
$output .= 'array_pop($_smarty_tpl->smarty->_cache[\'_tag_stack\']);?>';
|
||||||
@@ -98,9 +100,9 @@ class Smarty_Internal_Compile_Private_Block_Plugin extends Smarty_Internal_Compi
|
|||||||
* Setup callback and parameter array
|
* Setup callback and parameter array
|
||||||
*
|
*
|
||||||
* @param \Smarty_Internal_TemplateCompilerBase $compiler
|
* @param \Smarty_Internal_TemplateCompilerBase $compiler
|
||||||
* @param array $_attr attributes
|
* @param array $_attr attributes
|
||||||
* @param string $tag
|
* @param string $tag
|
||||||
* @param string $function
|
* @param string $function
|
||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
|
@@ -74,7 +74,7 @@ class Smarty_Internal_Compile_Private_ForeachSection extends Smarty_Internal_Com
|
|||||||
/**
|
/**
|
||||||
* Scan sources for used tag attributes
|
* Scan sources for used tag attributes
|
||||||
*
|
*
|
||||||
* @param array $attributes
|
* @param array $attributes
|
||||||
* @param \Smarty_Internal_TemplateCompilerBase $compiler
|
* @param \Smarty_Internal_TemplateCompilerBase $compiler
|
||||||
*
|
*
|
||||||
* @throws \SmartyException
|
* @throws \SmartyException
|
||||||
@@ -178,11 +178,13 @@ class Smarty_Internal_Compile_Private_ForeachSection extends Smarty_Internal_Com
|
|||||||
$_content = $nextCompiler->template->source->getContent();
|
$_content = $nextCompiler->template->source->getContent();
|
||||||
if ($_content !== '') {
|
if ($_content !== '') {
|
||||||
// run pre filter if required
|
// run pre filter if required
|
||||||
if ((isset($nextCompiler->smarty->autoload_filters[ 'pre' ]) ||
|
if ((isset($nextCompiler->smarty->autoload_filters[ 'pre' ])
|
||||||
isset($nextCompiler->smarty->registered_filters[ 'pre' ]))
|
|| isset($nextCompiler->smarty->registered_filters[ 'pre' ]))
|
||||||
) {
|
) {
|
||||||
$_content = $nextCompiler->smarty->ext->_filterHandler->runFilter('pre', $_content,
|
$_content = $nextCompiler->smarty->ext->_filterHandler->runFilter(
|
||||||
$nextCompiler->template);
|
'pre', $_content,
|
||||||
|
$nextCompiler->template
|
||||||
|
);
|
||||||
}
|
}
|
||||||
$this->matchProperty($_content);
|
$this->matchProperty($_content);
|
||||||
}
|
}
|
||||||
@@ -202,9 +204,9 @@ class Smarty_Internal_Compile_Private_ForeachSection extends Smarty_Internal_Com
|
|||||||
/**
|
/**
|
||||||
* Compiles code for the {$smarty.foreach.xxx} or {$smarty.section.xxx}tag
|
* Compiles code for the {$smarty.foreach.xxx} or {$smarty.section.xxx}tag
|
||||||
*
|
*
|
||||||
* @param array $args array with attributes from parser
|
* @param array $args array with attributes from parser
|
||||||
* @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
|
* @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
|
||||||
* @param array $parameter array with compilation parameter
|
* @param array $parameter array with compilation parameter
|
||||||
*
|
*
|
||||||
* @return string compiled code
|
* @return string compiled code
|
||||||
* @throws \SmartyCompilerException
|
* @throws \SmartyCompilerException
|
||||||
@@ -223,4 +225,4 @@ class Smarty_Internal_Compile_Private_ForeachSection extends Smarty_Internal_Com
|
|||||||
$tagVar = "'__smarty_{$tag}_{$name}'";
|
$tagVar = "'__smarty_{$tag}_{$name}'";
|
||||||
return "(isset(\$_smarty_tpl->tpl_vars[{$tagVar}]->value['{$property}']) ? \$_smarty_tpl->tpl_vars[{$tagVar}]->value['{$property}'] : null)";
|
return "(isset(\$_smarty_tpl->tpl_vars[{$tagVar}]->value['{$property}']) ? \$_smarty_tpl->tpl_vars[{$tagVar}]->value['{$property}'] : null)";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -35,11 +35,11 @@ class Smarty_Internal_Compile_Private_Function_Plugin extends Smarty_Internal_Co
|
|||||||
/**
|
/**
|
||||||
* Compiles code for the execution of function plugin
|
* Compiles code for the execution of function plugin
|
||||||
*
|
*
|
||||||
* @param array $args array with attributes from parser
|
* @param array $args array with attributes from parser
|
||||||
* @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
|
* @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
|
||||||
* @param array $parameter array with compilation parameter
|
* @param array $parameter array with compilation parameter
|
||||||
* @param string $tag name of function plugin
|
* @param string $tag name of function plugin
|
||||||
* @param string $function PHP function name
|
* @param string $function PHP function name
|
||||||
*
|
*
|
||||||
* @return string compiled code
|
* @return string compiled code
|
||||||
* @throws \SmartyCompilerException
|
* @throws \SmartyCompilerException
|
||||||
@@ -64,9 +64,11 @@ class Smarty_Internal_Compile_Private_Function_Plugin extends Smarty_Internal_Co
|
|||||||
// compile code
|
// compile code
|
||||||
$output = "{$function}({$_params},\$_smarty_tpl)";
|
$output = "{$function}({$_params},\$_smarty_tpl)";
|
||||||
if (!empty($parameter[ 'modifierlist' ])) {
|
if (!empty($parameter[ 'modifierlist' ])) {
|
||||||
$output = $compiler->compileTag('private_modifier', array(),
|
$output = $compiler->compileTag(
|
||||||
array('modifierlist' => $parameter[ 'modifierlist' ],
|
'private_modifier', array(),
|
||||||
'value' => $output));
|
array('modifierlist' => $parameter[ 'modifierlist' ],
|
||||||
|
'value' => $output)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
$output = "<?php echo {$output};?>\n";
|
$output = "<?php echo {$output};?>\n";
|
||||||
return $output;
|
return $output;
|
||||||
|
@@ -20,9 +20,9 @@ class Smarty_Internal_Compile_Private_Modifier extends Smarty_Internal_CompileBa
|
|||||||
/**
|
/**
|
||||||
* Compiles code for modifier execution
|
* Compiles code for modifier execution
|
||||||
*
|
*
|
||||||
* @param array $args array with attributes from parser
|
* @param array $args array with attributes from parser
|
||||||
* @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
|
* @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
|
||||||
* @param array $parameter array with compilation parameter
|
* @param array $parameter array with compilation parameter
|
||||||
*
|
*
|
||||||
* @return string compiled code
|
* @return string compiled code
|
||||||
* @throws \SmartyCompilerException
|
* @throws \SmartyCompilerException
|
||||||
@@ -47,99 +47,103 @@ class Smarty_Internal_Compile_Private_Modifier extends Smarty_Internal_CompileBa
|
|||||||
}
|
}
|
||||||
foreach ($modifier_types as $type) {
|
foreach ($modifier_types as $type) {
|
||||||
switch ($type) {
|
switch ($type) {
|
||||||
case 1:
|
case 1:
|
||||||
// registered modifier
|
// registered modifier
|
||||||
if (isset($compiler->smarty->registered_plugins[ Smarty::PLUGIN_MODIFIER ][ $modifier ])) {
|
if (isset($compiler->smarty->registered_plugins[ Smarty::PLUGIN_MODIFIER ][ $modifier ])) {
|
||||||
if (is_callable($compiler->smarty->registered_plugins[ Smarty::PLUGIN_MODIFIER ][ $modifier ][ 0 ])) {
|
if (is_callable($compiler->smarty->registered_plugins[ Smarty::PLUGIN_MODIFIER ][ $modifier ][ 0 ])) {
|
||||||
$output =
|
|
||||||
sprintf('call_user_func_array($_smarty_tpl->registered_plugins[ \'%s\' ][ %s ][ 0 ], array( %s ))',
|
|
||||||
Smarty::PLUGIN_MODIFIER, var_export($modifier, true), $params);
|
|
||||||
$compiler->known_modifier_type[ $modifier ] = $type;
|
|
||||||
break 2;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
// registered modifier compiler
|
|
||||||
if (isset($compiler->smarty->registered_plugins[ Smarty::PLUGIN_MODIFIERCOMPILER ][ $modifier ][ 0 ])) {
|
|
||||||
$output =
|
$output =
|
||||||
call_user_func($compiler->smarty->registered_plugins[ Smarty::PLUGIN_MODIFIERCOMPILER ][ $modifier ][ 0 ],
|
sprintf(
|
||||||
$single_modifier, $compiler->smarty);
|
'call_user_func_array($_smarty_tpl->registered_plugins[ \'%s\' ][ %s ][ 0 ], array( %s ))',
|
||||||
|
Smarty::PLUGIN_MODIFIER, var_export($modifier, true), $params
|
||||||
|
);
|
||||||
$compiler->known_modifier_type[ $modifier ] = $type;
|
$compiler->known_modifier_type[ $modifier ] = $type;
|
||||||
break 2;
|
break 2;
|
||||||
}
|
}
|
||||||
break;
|
}
|
||||||
case 3:
|
break;
|
||||||
// modifiercompiler plugin
|
case 2:
|
||||||
if ($compiler->smarty->loadPlugin('smarty_modifiercompiler_' . $modifier)) {
|
// registered modifier compiler
|
||||||
// check if modifier allowed
|
if (isset($compiler->smarty->registered_plugins[ Smarty::PLUGIN_MODIFIERCOMPILER ][ $modifier ][ 0 ])) {
|
||||||
if (!is_object($compiler->smarty->security_policy) ||
|
$output =
|
||||||
$compiler->smarty->security_policy->isTrustedModifier($modifier, $compiler)
|
call_user_func(
|
||||||
) {
|
$compiler->smarty->registered_plugins[ Smarty::PLUGIN_MODIFIERCOMPILER ][ $modifier ][ 0 ],
|
||||||
$plugin = 'smarty_modifiercompiler_' . $modifier;
|
$single_modifier, $compiler->smarty
|
||||||
$output = $plugin($single_modifier, $compiler);
|
);
|
||||||
}
|
$compiler->known_modifier_type[ $modifier ] = $type;
|
||||||
$compiler->known_modifier_type[ $modifier ] = $type;
|
break 2;
|
||||||
break 2;
|
}
|
||||||
}
|
break;
|
||||||
break;
|
case 3:
|
||||||
case 4:
|
// modifiercompiler plugin
|
||||||
// modifier plugin
|
if ($compiler->smarty->loadPlugin('smarty_modifiercompiler_' . $modifier)) {
|
||||||
if ($function = $compiler->getPlugin($modifier, Smarty::PLUGIN_MODIFIER)) {
|
// check if modifier allowed
|
||||||
// check if modifier allowed
|
if (!is_object($compiler->smarty->security_policy)
|
||||||
if (!is_object($compiler->smarty->security_policy) ||
|
|| $compiler->smarty->security_policy->isTrustedModifier($modifier, $compiler)
|
||||||
$compiler->smarty->security_policy->isTrustedModifier($modifier, $compiler)
|
|
||||||
) {
|
|
||||||
$output = "{$function}({$params})";
|
|
||||||
}
|
|
||||||
$compiler->known_modifier_type[ $modifier ] = $type;
|
|
||||||
break 2;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 5:
|
|
||||||
// PHP function
|
|
||||||
if (is_callable($modifier)) {
|
|
||||||
// check if modifier allowed
|
|
||||||
if (!is_object($compiler->smarty->security_policy) ||
|
|
||||||
$compiler->smarty->security_policy->isTrustedPhpModifier($modifier, $compiler)
|
|
||||||
) {
|
|
||||||
$output = "{$modifier}({$params})";
|
|
||||||
}
|
|
||||||
$compiler->known_modifier_type[ $modifier ] = $type;
|
|
||||||
break 2;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 6:
|
|
||||||
// default plugin handler
|
|
||||||
if (isset($compiler->default_handler_plugins[ Smarty::PLUGIN_MODIFIER ][ $modifier ]) ||
|
|
||||||
(is_callable($compiler->smarty->default_plugin_handler_func) &&
|
|
||||||
$compiler->getPluginFromDefaultHandler($modifier, Smarty::PLUGIN_MODIFIER))
|
|
||||||
) {
|
) {
|
||||||
$function = $compiler->default_handler_plugins[ Smarty::PLUGIN_MODIFIER ][ $modifier ][ 0 ];
|
$plugin = 'smarty_modifiercompiler_' . $modifier;
|
||||||
// check if modifier allowed
|
$output = $plugin($single_modifier, $compiler);
|
||||||
if (!is_object($compiler->smarty->security_policy) ||
|
}
|
||||||
$compiler->smarty->security_policy->isTrustedModifier($modifier, $compiler)
|
$compiler->known_modifier_type[ $modifier ] = $type;
|
||||||
) {
|
break 2;
|
||||||
if (!is_array($function)) {
|
}
|
||||||
$output = "{$function}({$params})";
|
break;
|
||||||
|
case 4:
|
||||||
|
// modifier plugin
|
||||||
|
if ($function = $compiler->getPlugin($modifier, Smarty::PLUGIN_MODIFIER)) {
|
||||||
|
// check if modifier allowed
|
||||||
|
if (!is_object($compiler->smarty->security_policy)
|
||||||
|
|| $compiler->smarty->security_policy->isTrustedModifier($modifier, $compiler)
|
||||||
|
) {
|
||||||
|
$output = "{$function}({$params})";
|
||||||
|
}
|
||||||
|
$compiler->known_modifier_type[ $modifier ] = $type;
|
||||||
|
break 2;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 5:
|
||||||
|
// PHP function
|
||||||
|
if (is_callable($modifier)) {
|
||||||
|
// check if modifier allowed
|
||||||
|
if (!is_object($compiler->smarty->security_policy)
|
||||||
|
|| $compiler->smarty->security_policy->isTrustedPhpModifier($modifier, $compiler)
|
||||||
|
) {
|
||||||
|
$output = "{$modifier}({$params})";
|
||||||
|
}
|
||||||
|
$compiler->known_modifier_type[ $modifier ] = $type;
|
||||||
|
break 2;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 6:
|
||||||
|
// default plugin handler
|
||||||
|
if (isset($compiler->default_handler_plugins[ Smarty::PLUGIN_MODIFIER ][ $modifier ])
|
||||||
|
|| (is_callable($compiler->smarty->default_plugin_handler_func)
|
||||||
|
&& $compiler->getPluginFromDefaultHandler($modifier, Smarty::PLUGIN_MODIFIER))
|
||||||
|
) {
|
||||||
|
$function = $compiler->default_handler_plugins[ Smarty::PLUGIN_MODIFIER ][ $modifier ][ 0 ];
|
||||||
|
// check if modifier allowed
|
||||||
|
if (!is_object($compiler->smarty->security_policy)
|
||||||
|
|| $compiler->smarty->security_policy->isTrustedModifier($modifier, $compiler)
|
||||||
|
) {
|
||||||
|
if (!is_array($function)) {
|
||||||
|
$output = "{$function}({$params})";
|
||||||
|
} else {
|
||||||
|
if (is_object($function[ 0 ])) {
|
||||||
|
$output = $function[ 0 ] . '->'. $function[ 1 ] . '(' . $params . ')';
|
||||||
} else {
|
} else {
|
||||||
if (is_object($function[ 0 ])) {
|
$output = $function[ 0 ] . '::' . $function[ 1 ] . '(' . $params . ')';
|
||||||
$output = $function[ 0 ] . '->'. $function[ 1 ] . '(' . $params . ')';
|
|
||||||
} else {
|
|
||||||
$output = $function[ 0 ] . '::' . $function[ 1 ] . '(' . $params . ')';
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (isset($compiler->required_plugins[ 'nocache' ][ $modifier ][ Smarty::PLUGIN_MODIFIER ][ 'file' ]) ||
|
|
||||||
isset($compiler->required_plugins[ 'compiled' ][ $modifier ][ Smarty::PLUGIN_MODIFIER ][ 'file' ])
|
|
||||||
) {
|
|
||||||
// was a plugin
|
|
||||||
$compiler->known_modifier_type[ $modifier ] = 4;
|
|
||||||
} else {
|
|
||||||
$compiler->known_modifier_type[ $modifier ] = $type;
|
|
||||||
}
|
|
||||||
break 2;
|
|
||||||
}
|
}
|
||||||
|
if (isset($compiler->required_plugins[ 'nocache' ][ $modifier ][ Smarty::PLUGIN_MODIFIER ][ 'file' ])
|
||||||
|
|| isset($compiler->required_plugins[ 'compiled' ][ $modifier ][ Smarty::PLUGIN_MODIFIER ][ 'file' ])
|
||||||
|
) {
|
||||||
|
// was a plugin
|
||||||
|
$compiler->known_modifier_type[ $modifier ] = 4;
|
||||||
|
} else {
|
||||||
|
$compiler->known_modifier_type[ $modifier ] = $type;
|
||||||
|
}
|
||||||
|
break 2;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!isset($compiler->known_modifier_type[ $modifier ])) {
|
if (!isset($compiler->known_modifier_type[ $modifier ])) {
|
||||||
@@ -149,4 +153,4 @@ class Smarty_Internal_Compile_Private_Modifier extends Smarty_Internal_CompileBa
|
|||||||
|
|
||||||
return $output;
|
return $output;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -20,9 +20,9 @@ class Smarty_Internal_Compile_Private_Object_Block_Function extends Smarty_Inter
|
|||||||
* Setup callback and parameter array
|
* Setup callback and parameter array
|
||||||
*
|
*
|
||||||
* @param \Smarty_Internal_TemplateCompilerBase $compiler
|
* @param \Smarty_Internal_TemplateCompilerBase $compiler
|
||||||
* @param array $_attr attributes
|
* @param array $_attr attributes
|
||||||
* @param string $tag
|
* @param string $tag
|
||||||
* @param string $method
|
* @param string $method
|
||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
|
@@ -27,11 +27,11 @@ class Smarty_Internal_Compile_Private_Object_Function extends Smarty_Internal_Co
|
|||||||
/**
|
/**
|
||||||
* Compiles code for the execution of function plugin
|
* Compiles code for the execution of function plugin
|
||||||
*
|
*
|
||||||
* @param array $args array with attributes from parser
|
* @param array $args array with attributes from parser
|
||||||
* @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
|
* @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
|
||||||
* @param array $parameter array with compilation parameter
|
* @param array $parameter array with compilation parameter
|
||||||
* @param string $tag name of function
|
* @param string $tag name of function
|
||||||
* @param string $method name of method to call
|
* @param string $method name of method to call
|
||||||
*
|
*
|
||||||
* @return string compiled code
|
* @return string compiled code
|
||||||
* @throws \SmartyCompilerException
|
* @throws \SmartyCompilerException
|
||||||
@@ -70,8 +70,10 @@ class Smarty_Internal_Compile_Private_Object_Function extends Smarty_Internal_Co
|
|||||||
$output = "\$_smarty_tpl->smarty->registered_objects['{$tag}'][0]->{$method}";
|
$output = "\$_smarty_tpl->smarty->registered_objects['{$tag}'][0]->{$method}";
|
||||||
}
|
}
|
||||||
if (!empty($parameter[ 'modifierlist' ])) {
|
if (!empty($parameter[ 'modifierlist' ])) {
|
||||||
$output = $compiler->compileTag('private_modifier', array(),
|
$output = $compiler->compileTag(
|
||||||
array('modifierlist' => $parameter[ 'modifierlist' ], 'value' => $output));
|
'private_modifier', array(),
|
||||||
|
array('modifierlist' => $parameter[ 'modifierlist' ], 'value' => $output)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
if (empty($_assign)) {
|
if (empty($_assign)) {
|
||||||
return "<?php echo {$output};?>\n";
|
return "<?php echo {$output};?>\n";
|
||||||
|
@@ -43,10 +43,16 @@ class Smarty_Internal_Compile_Private_Php extends Smarty_Internal_CompileBase
|
|||||||
if ($_attr[ 'type' ] === 'xml') {
|
if ($_attr[ 'type' ] === 'xml') {
|
||||||
$compiler->tag_nocache = true;
|
$compiler->tag_nocache = true;
|
||||||
$output = addcslashes($_attr[ 'code' ], "'\\");
|
$output = addcslashes($_attr[ 'code' ], "'\\");
|
||||||
$compiler->parser->current_buffer->append_subtree($compiler->parser,
|
$compiler->parser->current_buffer->append_subtree(
|
||||||
new Smarty_Internal_ParseTree_Tag($compiler->parser,
|
$compiler->parser,
|
||||||
$compiler->processNocacheCode("<?php echo '{$output}';?>",
|
new Smarty_Internal_ParseTree_Tag(
|
||||||
true)));
|
$compiler->parser,
|
||||||
|
$compiler->processNocacheCode(
|
||||||
|
"<?php echo '{$output}';?>",
|
||||||
|
true
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
if ($_attr[ 'type' ] !== 'tag') {
|
if ($_attr[ 'type' ] !== 'tag') {
|
||||||
@@ -54,23 +60,35 @@ class Smarty_Internal_Compile_Private_Php extends Smarty_Internal_CompileBase
|
|||||||
return '';
|
return '';
|
||||||
} elseif ($compiler->php_handling === Smarty::PHP_QUOTE) {
|
} elseif ($compiler->php_handling === Smarty::PHP_QUOTE) {
|
||||||
$output =
|
$output =
|
||||||
preg_replace_callback('#(<\?(?:php|=)?)|(<%)|(<script\s+language\s*=\s*["\']?\s*php\s*["\']?\s*>)|(\?>)|(%>)|(<\/script>)#i',
|
preg_replace_callback(
|
||||||
array($this, 'quote'), $_attr[ 'code' ]);
|
'#(<\?(?:php|=)?)|(<%)|(<script\s+language\s*=\s*["\']?\s*php\s*["\']?\s*>)|(\?>)|(%>)|(<\/script>)#i',
|
||||||
$compiler->parser->current_buffer->append_subtree($compiler->parser,
|
array($this, 'quote'), $_attr[ 'code' ]
|
||||||
new Smarty_Internal_ParseTree_Text($output));
|
);
|
||||||
|
$compiler->parser->current_buffer->append_subtree(
|
||||||
|
$compiler->parser,
|
||||||
|
new Smarty_Internal_ParseTree_Text($output)
|
||||||
|
);
|
||||||
return '';
|
return '';
|
||||||
} elseif ($compiler->php_handling === Smarty::PHP_PASSTHRU || $_attr[ 'type' ] === 'unmatched') {
|
} elseif ($compiler->php_handling === Smarty::PHP_PASSTHRU || $_attr[ 'type' ] === 'unmatched') {
|
||||||
$compiler->tag_nocache = true;
|
$compiler->tag_nocache = true;
|
||||||
$output = addcslashes($_attr[ 'code' ], "'\\");
|
$output = addcslashes($_attr[ 'code' ], "'\\");
|
||||||
$compiler->parser->current_buffer->append_subtree($compiler->parser,
|
$compiler->parser->current_buffer->append_subtree(
|
||||||
new Smarty_Internal_ParseTree_Tag($compiler->parser,
|
$compiler->parser,
|
||||||
$compiler->processNocacheCode("<?php echo '{$output}';?>",
|
new Smarty_Internal_ParseTree_Tag(
|
||||||
true)));
|
$compiler->parser,
|
||||||
|
$compiler->processNocacheCode(
|
||||||
|
"<?php echo '{$output}';?>",
|
||||||
|
true
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
return '';
|
return '';
|
||||||
} elseif ($compiler->php_handling === Smarty::PHP_ALLOW) {
|
} elseif ($compiler->php_handling === Smarty::PHP_ALLOW) {
|
||||||
if (!($compiler->smarty instanceof SmartyBC)) {
|
if (!($compiler->smarty instanceof SmartyBC)) {
|
||||||
$compiler->trigger_template_error('$smarty->php_handling PHP_ALLOW not allowed. Use SmartyBC to enable it',
|
$compiler->trigger_template_error(
|
||||||
null, true);
|
'$smarty->php_handling PHP_ALLOW not allowed. Use SmartyBC to enable it',
|
||||||
|
null, true
|
||||||
|
);
|
||||||
}
|
}
|
||||||
$compiler->has_code = true;
|
$compiler->has_code = true;
|
||||||
return $_attr[ 'code' ];
|
return $_attr[ 'code' ];
|
||||||
@@ -80,8 +98,10 @@ class Smarty_Internal_Compile_Private_Php extends Smarty_Internal_CompileBase
|
|||||||
} else {
|
} else {
|
||||||
$compiler->has_code = true;
|
$compiler->has_code = true;
|
||||||
if (!($compiler->smarty instanceof SmartyBC)) {
|
if (!($compiler->smarty instanceof SmartyBC)) {
|
||||||
$compiler->trigger_template_error('{php}{/php} tags not allowed. Use SmartyBC to enable them', null,
|
$compiler->trigger_template_error(
|
||||||
true);
|
'{php}{/php} tags not allowed. Use SmartyBC to enable them', null,
|
||||||
|
true
|
||||||
|
);
|
||||||
}
|
}
|
||||||
$ldel = preg_quote($compiler->smarty->left_delimiter, '#');
|
$ldel = preg_quote($compiler->smarty->left_delimiter, '#');
|
||||||
$rdel = preg_quote($compiler->smarty->right_delimiter, '#');
|
$rdel = preg_quote($compiler->smarty->right_delimiter, '#');
|
||||||
@@ -93,8 +113,10 @@ class Smarty_Internal_Compile_Private_Php extends Smarty_Internal_CompileBase
|
|||||||
$compiler->trigger_template_error("illegal value of option flag '{$match[2]}'", null, true);
|
$compiler->trigger_template_error("illegal value of option flag '{$match[2]}'", null, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return preg_replace(array("#^{$ldel}\\s*php\\s*(.)*?{$rdel}#", "#{$ldel}\\s*/\\s*php\\s*{$rdel}$#"),
|
return preg_replace(
|
||||||
array('<?php ', '?>'), $_attr[ 'code' ]);
|
array("#^{$ldel}\\s*php\\s*(.)*?{$rdel}#", "#{$ldel}\\s*/\\s*php\\s*{$rdel}$#"),
|
||||||
|
array('<?php ', '?>'), $_attr[ 'code' ]
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -148,8 +170,8 @@ class Smarty_Internal_Compile_Private_Php extends Smarty_Internal_CompileBase
|
|||||||
if ($lex->phpType === 'unmatched') {
|
if ($lex->phpType === 'unmatched') {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (($lex->phpType === 'php' || $lex->phpType === 'asp') &&
|
if (($lex->phpType === 'php' || $lex->phpType === 'asp')
|
||||||
($lex->compiler->php_handling === Smarty::PHP_PASSTHRU || $lex->compiler->php_handling === Smarty::PHP_QUOTE)
|
&& ($lex->compiler->php_handling === Smarty::PHP_PASSTHRU || $lex->compiler->php_handling === Smarty::PHP_QUOTE)
|
||||||
) {
|
) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -161,8 +183,11 @@ class Smarty_Internal_Compile_Private_Php extends Smarty_Internal_CompileBase
|
|||||||
$lex->compiler->trigger_template_error("missing closing tag '{$closeTag}'");
|
$lex->compiler->trigger_template_error("missing closing tag '{$closeTag}'");
|
||||||
}
|
}
|
||||||
while ($body) {
|
while ($body) {
|
||||||
if (preg_match('~([/][*])|([/][/][^\n]*)|(\'[^\'\\\\]*(?:\\.[^\'\\\\]*)*\')|("[^"\\\\]*(?:\\.[^"\\\\]*)*")~',
|
if (preg_match(
|
||||||
$lex->data, $match, PREG_OFFSET_CAPTURE, $start)) {
|
'~([/][*])|([/][/][^\n]*)|(\'[^\'\\\\]*(?:\\.[^\'\\\\]*)*\')|("[^"\\\\]*(?:\\.[^"\\\\]*)*")~',
|
||||||
|
$lex->data, $match, PREG_OFFSET_CAPTURE, $start
|
||||||
|
)
|
||||||
|
) {
|
||||||
$value = $match[ 0 ][ 0 ];
|
$value = $match[ 0 ][ 0 ];
|
||||||
$from = $pos = $match[ 0 ][ 1 ];
|
$from = $pos = $match[ 0 ][ 1 ];
|
||||||
if ($pos > $close) {
|
if ($pos > $close) {
|
||||||
@@ -178,8 +203,11 @@ class Smarty_Internal_Compile_Private_Php extends Smarty_Internal_CompileBase
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
while ($close > $pos && $close < $start) {
|
while ($close > $pos && $close < $start) {
|
||||||
if (preg_match('~' . preg_quote($closeTag, '~') . '~i', $lex->data, $match, PREG_OFFSET_CAPTURE,
|
if (preg_match(
|
||||||
$from)) {
|
'~' . preg_quote($closeTag, '~') . '~i', $lex->data, $match, PREG_OFFSET_CAPTURE,
|
||||||
|
$from
|
||||||
|
)
|
||||||
|
) {
|
||||||
$close = $match[ 0 ][ 1 ];
|
$close = $match[ 0 ][ 1 ];
|
||||||
$from = $close + strlen($match[ 0 ][ 0 ]);
|
$from = $close + strlen($match[ 0 ][ 0 ]);
|
||||||
} else {
|
} else {
|
||||||
|
@@ -49,9 +49,11 @@ class Smarty_Internal_Compile_Private_Print_Expression extends Smarty_Internal_C
|
|||||||
$output = $parameter[ 'value' ];
|
$output = $parameter[ 'value' ];
|
||||||
// tag modifier
|
// tag modifier
|
||||||
if (!empty($parameter[ 'modifierlist' ])) {
|
if (!empty($parameter[ 'modifierlist' ])) {
|
||||||
$output = $compiler->compileTag('private_modifier', array(),
|
$output = $compiler->compileTag(
|
||||||
array('modifierlist' => $parameter[ 'modifierlist' ],
|
'private_modifier', array(),
|
||||||
'value' => $output));
|
array('modifierlist' => $parameter[ 'modifierlist' ],
|
||||||
|
'value' => $output)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
if (isset($_attr[ 'assign' ])) {
|
if (isset($_attr[ 'assign' ])) {
|
||||||
// assign output to variable
|
// assign output to variable
|
||||||
@@ -64,8 +66,10 @@ class Smarty_Internal_Compile_Private_Print_Expression extends Smarty_Internal_C
|
|||||||
if (empty($compiler->default_modifier_list)) {
|
if (empty($compiler->default_modifier_list)) {
|
||||||
$modifierlist = array();
|
$modifierlist = array();
|
||||||
foreach ($compiler->smarty->default_modifiers as $key => $single_default_modifier) {
|
foreach ($compiler->smarty->default_modifiers as $key => $single_default_modifier) {
|
||||||
preg_match_all('/(\'[^\'\\\\]*(?:\\\\.[^\'\\\\]*)*\'|"[^"\\\\]*(?:\\\\.[^"\\\\]*)*"|:|[^:]+)/',
|
preg_match_all(
|
||||||
$single_default_modifier, $mod_array);
|
'/(\'[^\'\\\\]*(?:\\\\.[^\'\\\\]*)*\'|"[^"\\\\]*(?:\\\\.[^"\\\\]*)*"|:|[^:]+)/',
|
||||||
|
$single_default_modifier, $mod_array
|
||||||
|
);
|
||||||
for ($i = 0, $count = count($mod_array[ 0 ]); $i < $count; $i ++) {
|
for ($i = 0, $count = count($mod_array[ 0 ]); $i < $count; $i ++) {
|
||||||
if ($mod_array[ 0 ][ $i ] !== ':') {
|
if ($mod_array[ 0 ][ $i ] !== ':') {
|
||||||
$modifierlist[ $key ][] = $mod_array[ 0 ][ $i ];
|
$modifierlist[ $key ][] = $mod_array[ 0 ][ $i ];
|
||||||
@@ -74,9 +78,11 @@ class Smarty_Internal_Compile_Private_Print_Expression extends Smarty_Internal_C
|
|||||||
}
|
}
|
||||||
$compiler->default_modifier_list = $modifierlist;
|
$compiler->default_modifier_list = $modifierlist;
|
||||||
}
|
}
|
||||||
$output = $compiler->compileTag('private_modifier', array(),
|
$output = $compiler->compileTag(
|
||||||
array('modifierlist' => $compiler->default_modifier_list,
|
'private_modifier', array(),
|
||||||
'value' => $output));
|
array('modifierlist' => $compiler->default_modifier_list,
|
||||||
|
'value' => $output)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
// autoescape html
|
// autoescape html
|
||||||
if ($compiler->template->smarty->escape_html) {
|
if ($compiler->template->smarty->escape_html) {
|
||||||
@@ -110,13 +116,15 @@ class Smarty_Internal_Compile_Private_Print_Expression extends Smarty_Internal_C
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
foreach ($compiler->variable_filters as $filter) {
|
foreach ($compiler->variable_filters as $filter) {
|
||||||
if (count($filter) === 1 &&
|
if (count($filter) === 1
|
||||||
($result = $this->compile_variable_filter($compiler, $filter[ 0 ], $output)) !== false
|
&& ($result = $this->compile_variable_filter($compiler, $filter[ 0 ], $output)) !== false
|
||||||
) {
|
) {
|
||||||
$output = $result;
|
$output = $result;
|
||||||
} else {
|
} else {
|
||||||
$output = $compiler->compileTag('private_modifier', array(),
|
$output = $compiler->compileTag(
|
||||||
array('modifierlist' => array($filter), 'value' => $output));
|
'private_modifier', array(),
|
||||||
|
array('modifierlist' => array($filter), 'value' => $output)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -136,12 +144,12 @@ class Smarty_Internal_Compile_Private_Print_Expression extends Smarty_Internal_C
|
|||||||
*/
|
*/
|
||||||
private function compile_variable_filter(Smarty_Internal_TemplateCompilerBase $compiler, $name, $output)
|
private function compile_variable_filter(Smarty_Internal_TemplateCompilerBase $compiler, $name, $output)
|
||||||
{
|
{
|
||||||
$function= $compiler->getPlugin($name, 'variablefilter');
|
$function= $compiler->getPlugin($name, 'variablefilter');
|
||||||
if ($function) {
|
if ($function) {
|
||||||
return "{$function}({$output},\$_smarty_tpl)";
|
return "{$function}({$output},\$_smarty_tpl)";
|
||||||
} else {
|
} else {
|
||||||
// not found
|
// not found
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -20,9 +20,9 @@ class Smarty_Internal_Compile_Private_Registered_Block extends Smarty_Internal_C
|
|||||||
* Setup callback, parameter array and nocache mode
|
* Setup callback, parameter array and nocache mode
|
||||||
*
|
*
|
||||||
* @param \Smarty_Internal_TemplateCompilerBase $compiler
|
* @param \Smarty_Internal_TemplateCompilerBase $compiler
|
||||||
* @param array $_attr attributes
|
* @param array $_attr attributes
|
||||||
* @param string $tag
|
* @param string $tag
|
||||||
* @param null $function
|
* @param null $function
|
||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
|
@@ -27,10 +27,10 @@ class Smarty_Internal_Compile_Private_Registered_Function extends Smarty_Interna
|
|||||||
/**
|
/**
|
||||||
* Compiles code for the execution of a registered function
|
* Compiles code for the execution of a registered function
|
||||||
*
|
*
|
||||||
* @param array $args array with attributes from parser
|
* @param array $args array with attributes from parser
|
||||||
* @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
|
* @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
|
||||||
* @param array $parameter array with compilation parameter
|
* @param array $parameter array with compilation parameter
|
||||||
* @param string $tag name of function
|
* @param string $tag name of function
|
||||||
*
|
*
|
||||||
* @return string compiled code
|
* @return string compiled code
|
||||||
* @throws \SmartyCompilerException
|
* @throws \SmartyCompilerException
|
||||||
@@ -76,11 +76,13 @@ class Smarty_Internal_Compile_Private_Registered_Function extends Smarty_Interna
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!empty($parameter[ 'modifierlist' ])) {
|
if (!empty($parameter[ 'modifierlist' ])) {
|
||||||
$output = $compiler->compileTag('private_modifier', array(),
|
$output = $compiler->compileTag(
|
||||||
array('modifierlist' => $parameter[ 'modifierlist' ],
|
'private_modifier', array(),
|
||||||
'value' => $output));
|
array('modifierlist' => $parameter[ 'modifierlist' ],
|
||||||
|
'value' => $output)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
$output = "<?php echo {$output};?>\n";
|
$output = "<?php echo {$output};?>\n";
|
||||||
return $output;
|
return $output;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -19,9 +19,9 @@ class Smarty_Internal_Compile_Private_Special_Variable extends Smarty_Internal_C
|
|||||||
/**
|
/**
|
||||||
* Compiles code for the special $smarty variables
|
* Compiles code for the special $smarty variables
|
||||||
*
|
*
|
||||||
* @param array $args array with attributes from parser
|
* @param array $args array with attributes from parser
|
||||||
* @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
|
* @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
|
||||||
* @param $parameter
|
* @param $parameter
|
||||||
*
|
*
|
||||||
* @return string compiled code
|
* @return string compiled code
|
||||||
* @throws \SmartyCompilerException
|
* @throws \SmartyCompilerException
|
||||||
@@ -33,86 +33,86 @@ class Smarty_Internal_Compile_Private_Special_Variable extends Smarty_Internal_C
|
|||||||
if ($variable === false) {
|
if ($variable === false) {
|
||||||
$compiler->trigger_template_error("special \$Smarty variable name index can not be variable", null, true);
|
$compiler->trigger_template_error("special \$Smarty variable name index can not be variable", null, true);
|
||||||
}
|
}
|
||||||
if (!isset($compiler->smarty->security_policy) ||
|
if (!isset($compiler->smarty->security_policy)
|
||||||
$compiler->smarty->security_policy->isTrustedSpecialSmartyVar($variable, $compiler)
|
|| $compiler->smarty->security_policy->isTrustedSpecialSmartyVar($variable, $compiler)
|
||||||
) {
|
) {
|
||||||
switch ($variable) {
|
switch ($variable) {
|
||||||
case 'foreach':
|
case 'foreach':
|
||||||
case 'section':
|
case 'section':
|
||||||
if (!isset(Smarty_Internal_TemplateCompilerBase::$_tag_objects[ $variable ])) {
|
if (!isset(Smarty_Internal_TemplateCompilerBase::$_tag_objects[ $variable ])) {
|
||||||
$class = 'Smarty_Internal_Compile_' . ucfirst($variable);
|
$class = 'Smarty_Internal_Compile_' . ucfirst($variable);
|
||||||
Smarty_Internal_TemplateCompilerBase::$_tag_objects[ $variable ] = new $class;
|
Smarty_Internal_TemplateCompilerBase::$_tag_objects[ $variable ] = new $class;
|
||||||
}
|
}
|
||||||
return Smarty_Internal_TemplateCompilerBase::$_tag_objects[ $variable ]->compileSpecialVariable(array(), $compiler, $_index);
|
return Smarty_Internal_TemplateCompilerBase::$_tag_objects[ $variable ]->compileSpecialVariable(array(), $compiler, $_index);
|
||||||
case 'capture':
|
case 'capture':
|
||||||
if (class_exists('Smarty_Internal_Compile_Capture')) {
|
if (class_exists('Smarty_Internal_Compile_Capture')) {
|
||||||
return Smarty_Internal_Compile_Capture::compileSpecialVariable(array(), $compiler, $_index);
|
return Smarty_Internal_Compile_Capture::compileSpecialVariable(array(), $compiler, $_index);
|
||||||
}
|
}
|
||||||
return '';
|
return '';
|
||||||
case 'now':
|
case 'now':
|
||||||
return 'time()';
|
return 'time()';
|
||||||
case 'cookies':
|
case 'cookies':
|
||||||
if (isset($compiler->smarty->security_policy) &&
|
if (isset($compiler->smarty->security_policy)
|
||||||
!$compiler->smarty->security_policy->allow_super_globals
|
&& !$compiler->smarty->security_policy->allow_super_globals
|
||||||
) {
|
) {
|
||||||
$compiler->trigger_template_error("(secure mode) super globals not permitted");
|
$compiler->trigger_template_error("(secure mode) super globals not permitted");
|
||||||
break;
|
|
||||||
}
|
|
||||||
$compiled_ref = '$_COOKIE';
|
|
||||||
break;
|
break;
|
||||||
case 'get':
|
}
|
||||||
case 'post':
|
$compiled_ref = '$_COOKIE';
|
||||||
case 'env':
|
break;
|
||||||
case 'server':
|
case 'get':
|
||||||
case 'session':
|
case 'post':
|
||||||
case 'request':
|
case 'env':
|
||||||
if (isset($compiler->smarty->security_policy) &&
|
case 'server':
|
||||||
!$compiler->smarty->security_policy->allow_super_globals
|
case 'session':
|
||||||
) {
|
case 'request':
|
||||||
$compiler->trigger_template_error("(secure mode) super globals not permitted");
|
if (isset($compiler->smarty->security_policy)
|
||||||
break;
|
&& !$compiler->smarty->security_policy->allow_super_globals
|
||||||
}
|
) {
|
||||||
$compiled_ref = '$_' . strtoupper($variable);
|
$compiler->trigger_template_error("(secure mode) super globals not permitted");
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
$compiled_ref = '$_' . strtoupper($variable);
|
||||||
|
break;
|
||||||
|
|
||||||
case 'template':
|
case 'template':
|
||||||
return 'basename($_smarty_tpl->source->filepath)';
|
return 'basename($_smarty_tpl->source->filepath)';
|
||||||
|
|
||||||
case 'template_object':
|
case 'template_object':
|
||||||
return '$_smarty_tpl';
|
return '$_smarty_tpl';
|
||||||
|
|
||||||
case 'current_dir':
|
case 'current_dir':
|
||||||
return 'dirname($_smarty_tpl->source->filepath)';
|
return 'dirname($_smarty_tpl->source->filepath)';
|
||||||
|
|
||||||
case 'version':
|
case 'version':
|
||||||
return "Smarty::SMARTY_VERSION";
|
return "Smarty::SMARTY_VERSION";
|
||||||
|
|
||||||
case 'const':
|
case 'const':
|
||||||
if (isset($compiler->smarty->security_policy) &&
|
if (isset($compiler->smarty->security_policy)
|
||||||
!$compiler->smarty->security_policy->allow_constants
|
&& !$compiler->smarty->security_policy->allow_constants
|
||||||
) {
|
) {
|
||||||
$compiler->trigger_template_error("(secure mode) constants not permitted");
|
$compiler->trigger_template_error("(secure mode) constants not permitted");
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (strpos($_index[ 1 ], '$') === false && strpos($_index[ 1 ], '\'') === false) {
|
|
||||||
return "@constant('{$_index[1]}')";
|
|
||||||
} else {
|
|
||||||
return "@constant({$_index[1]})";
|
|
||||||
}
|
|
||||||
|
|
||||||
case 'config':
|
|
||||||
if (isset($_index[ 2 ])) {
|
|
||||||
return "(is_array(\$tmp = \$_smarty_tpl->smarty->ext->configload->_getConfigVariable(\$_smarty_tpl, $_index[1])) ? \$tmp[$_index[2]] : null)";
|
|
||||||
} else {
|
|
||||||
return "\$_smarty_tpl->smarty->ext->configload->_getConfigVariable(\$_smarty_tpl, $_index[1])";
|
|
||||||
}
|
|
||||||
case 'ldelim':
|
|
||||||
return "\$_smarty_tpl->smarty->left_delimiter";
|
|
||||||
case 'rdelim':
|
|
||||||
return "\$_smarty_tpl->smarty->right_delimiter";
|
|
||||||
default:
|
|
||||||
$compiler->trigger_template_error('$smarty.' . trim($_index[ 0 ], "'") . ' is not defined');
|
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
if (strpos($_index[ 1 ], '$') === false && strpos($_index[ 1 ], '\'') === false) {
|
||||||
|
return "@constant('{$_index[1]}')";
|
||||||
|
} else {
|
||||||
|
return "@constant({$_index[1]})";
|
||||||
|
}
|
||||||
|
|
||||||
|
case 'config':
|
||||||
|
if (isset($_index[ 2 ])) {
|
||||||
|
return "(is_array(\$tmp = \$_smarty_tpl->smarty->ext->configload->_getConfigVariable(\$_smarty_tpl, $_index[1])) ? \$tmp[$_index[2]] : null)";
|
||||||
|
} else {
|
||||||
|
return "\$_smarty_tpl->smarty->ext->configload->_getConfigVariable(\$_smarty_tpl, $_index[1])";
|
||||||
|
}
|
||||||
|
case 'ldelim':
|
||||||
|
return "\$_smarty_tpl->smarty->left_delimiter";
|
||||||
|
case 'rdelim':
|
||||||
|
return "\$_smarty_tpl->smarty->right_delimiter";
|
||||||
|
default:
|
||||||
|
$compiler->trigger_template_error('$smarty.' . trim($_index[ 0 ], "'") . ' is not defined');
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
if (isset($_index[ 1 ])) {
|
if (isset($_index[ 1 ])) {
|
||||||
array_shift($_index);
|
array_shift($_index);
|
||||||
|
@@ -20,7 +20,7 @@ class Smarty_Internal_Compile_Rdelim extends Smarty_Internal_Compile_Ldelim
|
|||||||
* Compiles code for the {rdelim} tag
|
* Compiles code for the {rdelim} tag
|
||||||
* This tag does output the right delimiter.
|
* This tag does output the right delimiter.
|
||||||
*
|
*
|
||||||
* @param array $args array with attributes from parser
|
* @param array $args array with attributes from parser
|
||||||
* @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
|
* @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
|
||||||
*
|
*
|
||||||
* @return string compiled code
|
* @return string compiled code
|
||||||
@@ -28,7 +28,7 @@ class Smarty_Internal_Compile_Rdelim extends Smarty_Internal_Compile_Ldelim
|
|||||||
*/
|
*/
|
||||||
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler)
|
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler)
|
||||||
{
|
{
|
||||||
parent::compile($args,$compiler);
|
parent::compile($args, $compiler);
|
||||||
return $compiler->smarty->right_delimiter;
|
return $compiler->smarty->right_delimiter;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -79,8 +79,8 @@ class Smarty_Internal_Compile_Section extends Smarty_Internal_Compile_Private_Fo
|
|||||||
/**
|
/**
|
||||||
* Compiles code for the {section} tag
|
* Compiles code for the {section} tag
|
||||||
*
|
*
|
||||||
* @param array $args array with attributes from parser
|
* @param array $args array with attributes from parser
|
||||||
* @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
|
* @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
|
||||||
*
|
*
|
||||||
* @return string compiled code
|
* @return string compiled code
|
||||||
* @throws \SmartyCompilerException
|
* @throws \SmartyCompilerException
|
||||||
@@ -132,50 +132,50 @@ class Smarty_Internal_Compile_Section extends Smarty_Internal_Compile_Private_Fo
|
|||||||
$output = "<?php\n";
|
$output = "<?php\n";
|
||||||
foreach ($_attr as $attr_name => $attr_value) {
|
foreach ($_attr as $attr_name => $attr_value) {
|
||||||
switch ($attr_name) {
|
switch ($attr_name) {
|
||||||
case 'loop':
|
case 'loop':
|
||||||
if (is_numeric($attr_value)) {
|
if (is_numeric($attr_value)) {
|
||||||
$v = (int) $attr_value;
|
$v = (int) $attr_value;
|
||||||
$t = 0;
|
$t = 0;
|
||||||
} else {
|
} else {
|
||||||
$v = "(is_array(@\$_loop=$attr_value) ? count(\$_loop) : max(0, (int) \$_loop))";
|
$v = "(is_array(@\$_loop=$attr_value) ? count(\$_loop) : max(0, (int) \$_loop))";
|
||||||
$t = 1;
|
$t = 1;
|
||||||
}
|
}
|
||||||
if ($t === 1) {
|
if ($t === 1) {
|
||||||
$initLocal[ 'loop' ] = $v;
|
$initLocal[ 'loop' ] = $v;
|
||||||
$v = "{$local}loop";
|
$v = "{$local}loop";
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'show':
|
case 'show':
|
||||||
if (is_bool($attr_value)) {
|
if (is_bool($attr_value)) {
|
||||||
$v = $attr_value ? 'true' : 'false';
|
$v = $attr_value ? 'true' : 'false';
|
||||||
$t = 0;
|
$t = 0;
|
||||||
} else {
|
} else {
|
||||||
$v = "(bool) $attr_value";
|
$v = "(bool) $attr_value";
|
||||||
$t = 3;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 'step':
|
|
||||||
if (is_numeric($attr_value)) {
|
|
||||||
$v = (int) $attr_value;
|
|
||||||
$v = ($v === 0) ? 1 : $v;
|
|
||||||
$t = 0;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
$initLocal[ 'step' ] = "((int)@$attr_value) === 0 ? 1 : (int)@$attr_value";
|
|
||||||
$v = "{$local}step";
|
|
||||||
$t = 2;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'max':
|
|
||||||
case 'start':
|
|
||||||
if (is_numeric($attr_value)) {
|
|
||||||
$v = (int) $attr_value;
|
|
||||||
$t = 0;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
$v = "(int)@$attr_value";
|
|
||||||
$t = 3;
|
$t = 3;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 'step':
|
||||||
|
if (is_numeric($attr_value)) {
|
||||||
|
$v = (int) $attr_value;
|
||||||
|
$v = ($v === 0) ? 1 : $v;
|
||||||
|
$t = 0;
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
$initLocal[ 'step' ] = "((int)@$attr_value) === 0 ? 1 : (int)@$attr_value";
|
||||||
|
$v = "{$local}step";
|
||||||
|
$t = 2;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'max':
|
||||||
|
case 'start':
|
||||||
|
if (is_numeric($attr_value)) {
|
||||||
|
$v = (int) $attr_value;
|
||||||
|
$t = 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
$v = "(int)@$attr_value";
|
||||||
|
$t = 3;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
if ($t === 3 && $compiler->getId($attr_value)) {
|
if ($t === 3 && $compiler->getId($attr_value)) {
|
||||||
$t = 1;
|
$t = 1;
|
||||||
@@ -264,8 +264,10 @@ class Smarty_Internal_Compile_Section extends Smarty_Internal_Compile_Private_Fo
|
|||||||
$start_code[ $i ] = '';
|
$start_code[ $i ] = '';
|
||||||
}
|
}
|
||||||
if ($propType[ 'start' ] === 0) {
|
if ($propType[ 'start' ] === 0) {
|
||||||
$start_code = array(max($propValue[ 'step' ] > 0 ? 0 : - 1,
|
$start_code = array(max(
|
||||||
$propValue[ 'start' ] + $propValue[ 'loop' ]));
|
$propValue[ 'step' ] > 0 ? 0 : - 1,
|
||||||
|
$propValue[ 'start' ] + $propValue[ 'loop' ]
|
||||||
|
));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for ($i = 1; $i <= 11; $i ++) {
|
for ($i = 1; $i <= 11; $i ++) {
|
||||||
@@ -273,8 +275,10 @@ class Smarty_Internal_Compile_Section extends Smarty_Internal_Compile_Private_Fo
|
|||||||
}
|
}
|
||||||
if ($propType[ 'start' ] === 0) {
|
if ($propType[ 'start' ] === 0) {
|
||||||
$start_code =
|
$start_code =
|
||||||
array(min($propValue[ 'step' ] > 0 ? $propValue[ 'loop' ] : $propValue[ 'loop' ] - 1,
|
array(min(
|
||||||
$propValue[ 'start' ]));
|
$propValue[ 'step' ] > 0 ? $propValue[ 'loop' ] : $propValue[ 'loop' ] - 1,
|
||||||
|
$propValue[ 'start' ]
|
||||||
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -295,8 +299,12 @@ class Smarty_Internal_Compile_Section extends Smarty_Internal_Compile_Private_Fo
|
|||||||
$propType[ 'start' ] + $propType[ 'loop' ] + $propType[ 'step' ] + $propType[ 'max' ];
|
$propType[ 'start' ] + $propType[ 'loop' ] + $propType[ 'step' ] + $propType[ 'max' ];
|
||||||
if ($propType[ 'total' ] === 0) {
|
if ($propType[ 'total' ] === 0) {
|
||||||
$propValue[ 'total' ] =
|
$propValue[ 'total' ] =
|
||||||
min(ceil(($propValue[ 'step' ] > 0 ? $propValue[ 'loop' ] - $propValue[ 'start' ] :
|
min(
|
||||||
(int) $propValue[ 'start' ] + 1) / abs($propValue[ 'step' ])), $propValue[ 'max' ]);
|
ceil(
|
||||||
|
($propValue[ 'step' ] > 0 ? $propValue[ 'loop' ] - $propValue[ 'start' ] :
|
||||||
|
(int) $propValue[ 'start' ] + 1) / abs($propValue[ 'step' ])
|
||||||
|
), $propValue[ 'max' ]
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
$total_code = array(1 => 'min(', 2 => 'ceil(', 3 => '(', 4 => "{$propValue['step']} > 0 ? ",
|
$total_code = array(1 => 'min(', 2 => 'ceil(', 3 => '(', 4 => "{$propValue['step']} > 0 ? ",
|
||||||
5 => $propValue[ 'loop' ], 6 => ' - ', 7 => $propValue[ 'start' ], 8 => ' : ',
|
5 => $propValue[ 'loop' ], 6 => ' - ', 7 => $propValue[ 'start' ], 8 => ' : ',
|
||||||
@@ -404,7 +412,7 @@ class Smarty_Internal_Compile_Sectionelse extends Smarty_Internal_CompileBase
|
|||||||
/**
|
/**
|
||||||
* Compiles code for the {sectionelse} tag
|
* Compiles code for the {sectionelse} tag
|
||||||
*
|
*
|
||||||
* @param array $args array with attributes from parser
|
* @param array $args array with attributes from parser
|
||||||
* @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
|
* @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
|
||||||
*
|
*
|
||||||
* @return string compiled code
|
* @return string compiled code
|
||||||
@@ -432,7 +440,7 @@ class Smarty_Internal_Compile_Sectionclose extends Smarty_Internal_CompileBase
|
|||||||
/**
|
/**
|
||||||
* Compiles code for the {/section} tag
|
* Compiles code for the {/section} tag
|
||||||
*
|
*
|
||||||
* @param array $args array with attributes from parser
|
* @param array $args array with attributes from parser
|
||||||
* @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
|
* @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
|
||||||
*
|
*
|
||||||
* @return string compiled code
|
* @return string compiled code
|
||||||
|
@@ -19,9 +19,9 @@ class Smarty_Internal_Compile_Setfilter extends Smarty_Internal_CompileBase
|
|||||||
/**
|
/**
|
||||||
* Compiles code for setfilter tag
|
* Compiles code for setfilter tag
|
||||||
*
|
*
|
||||||
* @param array $args array with attributes from parser
|
* @param array $args array with attributes from parser
|
||||||
* @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
|
* @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
|
||||||
* @param array $parameter array with compilation parameter
|
* @param array $parameter array with compilation parameter
|
||||||
*
|
*
|
||||||
* @return string compiled code
|
* @return string compiled code
|
||||||
*/
|
*/
|
||||||
@@ -48,7 +48,7 @@ class Smarty_Internal_Compile_Setfilterclose extends Smarty_Internal_CompileBase
|
|||||||
* Compiles code for the {/setfilter} tag
|
* Compiles code for the {/setfilter} tag
|
||||||
* This tag does not generate compiled output. It resets variable filter.
|
* This tag does not generate compiled output. It resets variable filter.
|
||||||
*
|
*
|
||||||
* @param array $args array with attributes from parser
|
* @param array $args array with attributes from parser
|
||||||
* @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
|
* @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
|
||||||
*
|
*
|
||||||
* @return string compiled code
|
* @return string compiled code
|
||||||
|
@@ -37,12 +37,14 @@ class Smarty_Internal_Compile_Shared_Inheritance extends Smarty_Internal_Compile
|
|||||||
public function registerInit(Smarty_Internal_TemplateCompilerBase $compiler, $initChildSequence = false)
|
public function registerInit(Smarty_Internal_TemplateCompilerBase $compiler, $initChildSequence = false)
|
||||||
{
|
{
|
||||||
if ($initChildSequence || !isset($compiler->_cache['inheritanceInit'])) {
|
if ($initChildSequence || !isset($compiler->_cache['inheritanceInit'])) {
|
||||||
$compiler->registerPostCompileCallback(array('Smarty_Internal_Compile_Shared_Inheritance', 'postCompile'),
|
$compiler->registerPostCompileCallback(
|
||||||
array($initChildSequence),
|
array('Smarty_Internal_Compile_Shared_Inheritance', 'postCompile'),
|
||||||
'inheritanceInit',
|
array($initChildSequence),
|
||||||
$initChildSequence);
|
'inheritanceInit',
|
||||||
|
$initChildSequence
|
||||||
|
);
|
||||||
|
|
||||||
$compiler->_cache['inheritanceInit'] = true;
|
$compiler->_cache['inheritanceInit'] = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -19,9 +19,9 @@ class Smarty_Internal_Compile_While extends Smarty_Internal_CompileBase
|
|||||||
/**
|
/**
|
||||||
* Compiles code for the {while} tag
|
* Compiles code for the {while} tag
|
||||||
*
|
*
|
||||||
* @param array $args array with attributes from parser
|
* @param array $args array with attributes from parser
|
||||||
* @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
|
* @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
|
||||||
* @param array $parameter array with compilation parameter
|
* @param array $parameter array with compilation parameter
|
||||||
*
|
*
|
||||||
* @return string compiled code
|
* @return string compiled code
|
||||||
* @throws \SmartyCompilerException
|
* @throws \SmartyCompilerException
|
||||||
@@ -56,8 +56,10 @@ class Smarty_Internal_Compile_While extends Smarty_Internal_CompileBase
|
|||||||
if (is_array($parameter[ 'if condition' ][ 'var' ])) {
|
if (is_array($parameter[ 'if condition' ][ 'var' ])) {
|
||||||
$assignAttr[][ 'var' ] = $parameter[ 'if condition' ][ 'var' ][ 'var' ];
|
$assignAttr[][ 'var' ] = $parameter[ 'if condition' ][ 'var' ][ 'var' ];
|
||||||
$_output = "<?php while ({$prefixVar} = {$parameter[ 'if condition' ][ 'value' ]}) {?>";
|
$_output = "<?php while ({$prefixVar} = {$parameter[ 'if condition' ][ 'value' ]}) {?>";
|
||||||
$_output .= $assignCompiler->compile($assignAttr, $compiler,
|
$_output .= $assignCompiler->compile(
|
||||||
array('smarty_internal_index' => $parameter[ 'if condition' ][ 'var' ][ 'smarty_internal_index' ]));
|
$assignAttr, $compiler,
|
||||||
|
array('smarty_internal_index' => $parameter[ 'if condition' ][ 'var' ][ 'smarty_internal_index' ])
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
$assignAttr[][ 'var' ] = $parameter[ 'if condition' ][ 'var' ];
|
$assignAttr[][ 'var' ] = $parameter[ 'if condition' ][ 'var' ];
|
||||||
$_output = "<?php while ({$prefixVar} = {$parameter[ 'if condition' ][ 'value' ]}) {?>";
|
$_output = "<?php while ({$prefixVar} = {$parameter[ 'if condition' ][ 'value' ]}) {?>";
|
||||||
@@ -82,7 +84,7 @@ class Smarty_Internal_Compile_Whileclose extends Smarty_Internal_CompileBase
|
|||||||
/**
|
/**
|
||||||
* Compiles code for the {/while} tag
|
* Compiles code for the {/while} tag
|
||||||
*
|
*
|
||||||
* @param array $args array with attributes from parser
|
* @param array $args array with attributes from parser
|
||||||
* @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
|
* @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
|
||||||
*
|
*
|
||||||
* @return string compiled code
|
* @return string compiled code
|
||||||
|
@@ -65,8 +65,8 @@ abstract class Smarty_Internal_CompileBase
|
|||||||
* the corresponding list. The keyword '_any' specifies that any attribute will be accepted
|
* the corresponding list. The keyword '_any' specifies that any attribute will be accepted
|
||||||
* as valid
|
* as valid
|
||||||
*
|
*
|
||||||
* @param object $compiler compiler object
|
* @param object $compiler compiler object
|
||||||
* @param array $attributes attributes applied to the tag
|
* @param array $attributes attributes applied to the tag
|
||||||
*
|
*
|
||||||
* @return array of mapped attributes for further processing
|
* @return array of mapped attributes for further processing
|
||||||
*/
|
*/
|
||||||
@@ -103,8 +103,10 @@ abstract class Smarty_Internal_CompileBase
|
|||||||
if (isset($this->optionMap[ $v ])) {
|
if (isset($this->optionMap[ $v ])) {
|
||||||
$_indexed_attr[ $k ] = $this->optionMap[ $v ];
|
$_indexed_attr[ $k ] = $this->optionMap[ $v ];
|
||||||
} else {
|
} else {
|
||||||
$compiler->trigger_template_error("illegal value '" . var_export($v, true) .
|
$compiler->trigger_template_error(
|
||||||
"' for option flag '{$k}'", null, true);
|
"illegal value '" . var_export($v, true) .
|
||||||
|
"' for option flag '{$k}'", null, true
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// must be named attribute
|
// must be named attribute
|
||||||
@@ -124,8 +126,12 @@ abstract class Smarty_Internal_CompileBase
|
|||||||
if ($this->optional_attributes !== array('_any')) {
|
if ($this->optional_attributes !== array('_any')) {
|
||||||
if (!isset($this->mapCache[ 'all' ])) {
|
if (!isset($this->mapCache[ 'all' ])) {
|
||||||
$this->mapCache[ 'all' ] =
|
$this->mapCache[ 'all' ] =
|
||||||
array_fill_keys(array_merge($this->required_attributes, $this->optional_attributes,
|
array_fill_keys(
|
||||||
$this->option_flags), true);
|
array_merge(
|
||||||
|
$this->required_attributes, $this->optional_attributes,
|
||||||
|
$this->option_flags
|
||||||
|
), true
|
||||||
|
);
|
||||||
}
|
}
|
||||||
foreach ($_indexed_attr as $key => $dummy) {
|
foreach ($_indexed_attr as $key => $dummy) {
|
||||||
if (!isset($this->mapCache[ 'all' ][ $key ]) && $key !== 0) {
|
if (!isset($this->mapCache[ 'all' ][ $key ]) && $key !== 0) {
|
||||||
@@ -162,8 +168,8 @@ abstract class Smarty_Internal_CompileBase
|
|||||||
* Pop closing tag
|
* Pop closing tag
|
||||||
* Raise an error if this stack-top doesn't match with expected opening tags
|
* Raise an error if this stack-top doesn't match with expected opening tags
|
||||||
*
|
*
|
||||||
* @param object $compiler compiler object
|
* @param object $compiler compiler object
|
||||||
* @param array|string $expectedTag the expected opening tag names
|
* @param array|string $expectedTag the expected opening tag names
|
||||||
*
|
*
|
||||||
* @return mixed any type the opening tag's name or saved data
|
* @return mixed any type the opening tag's name or saved data
|
||||||
*/
|
*/
|
||||||
|
@@ -114,9 +114,13 @@ class Smarty_Internal_Config_File_Compiler
|
|||||||
}
|
}
|
||||||
// init the lexer/parser to compile the config file
|
// init the lexer/parser to compile the config file
|
||||||
/* @var Smarty_Internal_ConfigFileLexer $this ->lex */
|
/* @var Smarty_Internal_ConfigFileLexer $this ->lex */
|
||||||
$this->lex = new $this->lexer_class(str_replace(array("\r\n",
|
$this->lex = new $this->lexer_class(
|
||||||
"\r"), "\n", $template->source->getContent()) . "\n",
|
str_replace(
|
||||||
$this);
|
array("\r\n",
|
||||||
|
"\r"), "\n", $template->source->getContent()
|
||||||
|
) . "\n",
|
||||||
|
$this
|
||||||
|
);
|
||||||
/* @var Smarty_Internal_ConfigFileParser $this ->parser */
|
/* @var Smarty_Internal_ConfigFileParser $this ->parser */
|
||||||
$this->parser = new $this->parser_class($this->lex, $this);
|
$this->parser = new $this->parser_class($this->lex, $this);
|
||||||
|
|
||||||
|
@@ -130,7 +130,7 @@ class Smarty_Internal_Configfilelexer
|
|||||||
/**
|
/**
|
||||||
* constructor
|
* constructor
|
||||||
*
|
*
|
||||||
* @param string $data template source
|
* @param string $data template source
|
||||||
* @param Smarty_Internal_Config_File_Compiler $compiler
|
* @param Smarty_Internal_Config_File_Compiler $compiler
|
||||||
*/
|
*/
|
||||||
function __construct($data, Smarty_Internal_Config_File_Compiler $compiler)
|
function __construct($data, Smarty_Internal_Config_File_Compiler $compiler)
|
||||||
@@ -166,39 +166,47 @@ class Smarty_Internal_Configfilelexer
|
|||||||
public function yypushstate($state)
|
public function yypushstate($state)
|
||||||
{
|
{
|
||||||
if ($this->yyTraceFILE) {
|
if ($this->yyTraceFILE) {
|
||||||
fprintf($this->yyTraceFILE,
|
fprintf(
|
||||||
"%sState push %s\n",
|
$this->yyTraceFILE,
|
||||||
$this->yyTracePrompt,
|
"%sState push %s\n",
|
||||||
isset($this->state_name[ $this->_yy_state ]) ? $this->state_name[ $this->_yy_state ] :
|
$this->yyTracePrompt,
|
||||||
$this->_yy_state);
|
isset($this->state_name[ $this->_yy_state ]) ? $this->state_name[ $this->_yy_state ] :
|
||||||
|
$this->_yy_state
|
||||||
|
);
|
||||||
}
|
}
|
||||||
array_push($this->_yy_stack, $this->_yy_state);
|
array_push($this->_yy_stack, $this->_yy_state);
|
||||||
$this->_yy_state = $state;
|
$this->_yy_state = $state;
|
||||||
if ($this->yyTraceFILE) {
|
if ($this->yyTraceFILE) {
|
||||||
fprintf($this->yyTraceFILE,
|
fprintf(
|
||||||
"%snew State %s\n",
|
$this->yyTraceFILE,
|
||||||
$this->yyTracePrompt,
|
"%snew State %s\n",
|
||||||
isset($this->state_name[ $this->_yy_state ]) ? $this->state_name[ $this->_yy_state ] :
|
$this->yyTracePrompt,
|
||||||
$this->_yy_state);
|
isset($this->state_name[ $this->_yy_state ]) ? $this->state_name[ $this->_yy_state ] :
|
||||||
|
$this->_yy_state
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function yypopstate()
|
public function yypopstate()
|
||||||
{
|
{
|
||||||
if ($this->yyTraceFILE) {
|
if ($this->yyTraceFILE) {
|
||||||
fprintf($this->yyTraceFILE,
|
fprintf(
|
||||||
"%sState pop %s\n",
|
$this->yyTraceFILE,
|
||||||
$this->yyTracePrompt,
|
"%sState pop %s\n",
|
||||||
isset($this->state_name[ $this->_yy_state ]) ? $this->state_name[ $this->_yy_state ] :
|
$this->yyTracePrompt,
|
||||||
$this->_yy_state);
|
isset($this->state_name[ $this->_yy_state ]) ? $this->state_name[ $this->_yy_state ] :
|
||||||
|
$this->_yy_state
|
||||||
|
);
|
||||||
}
|
}
|
||||||
$this->_yy_state = array_pop($this->_yy_stack);
|
$this->_yy_state = array_pop($this->_yy_stack);
|
||||||
if ($this->yyTraceFILE) {
|
if ($this->yyTraceFILE) {
|
||||||
fprintf($this->yyTraceFILE,
|
fprintf(
|
||||||
"%snew State %s\n",
|
$this->yyTraceFILE,
|
||||||
$this->yyTracePrompt,
|
"%snew State %s\n",
|
||||||
isset($this->state_name[ $this->_yy_state ]) ? $this->state_name[ $this->_yy_state ] :
|
$this->yyTracePrompt,
|
||||||
$this->_yy_state);
|
isset($this->state_name[ $this->_yy_state ]) ? $this->state_name[ $this->_yy_state ] :
|
||||||
|
$this->_yy_state
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -206,11 +214,13 @@ class Smarty_Internal_Configfilelexer
|
|||||||
{
|
{
|
||||||
$this->_yy_state = $state;
|
$this->_yy_state = $state;
|
||||||
if ($this->yyTraceFILE) {
|
if ($this->yyTraceFILE) {
|
||||||
fprintf($this->yyTraceFILE,
|
fprintf(
|
||||||
"%sState set %s\n",
|
$this->yyTraceFILE,
|
||||||
$this->yyTracePrompt,
|
"%sState set %s\n",
|
||||||
isset($this->state_name[ $this->_yy_state ]) ? $this->state_name[ $this->_yy_state ] :
|
$this->yyTracePrompt,
|
||||||
$this->_yy_state);
|
isset($this->state_name[ $this->_yy_state ]) ? $this->state_name[ $this->_yy_state ] :
|
||||||
|
$this->_yy_state
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -234,10 +244,14 @@ class Smarty_Internal_Configfilelexer
|
|||||||
$yymatches = array_filter($yymatches);
|
$yymatches = array_filter($yymatches);
|
||||||
}
|
}
|
||||||
if (empty($yymatches)) {
|
if (empty($yymatches)) {
|
||||||
throw new Exception('Error: lexing failed because a rule matched' .
|
throw new Exception(
|
||||||
' an empty string. Input "' . substr($this->data,
|
'Error: lexing failed because a rule matched' .
|
||||||
$this->counter,
|
' an empty string. Input "' . substr(
|
||||||
5) . '... state START');
|
$this->data,
|
||||||
|
$this->counter,
|
||||||
|
5
|
||||||
|
) . '... state START'
|
||||||
|
);
|
||||||
}
|
}
|
||||||
next($yymatches); // skip global match
|
next($yymatches); // skip global match
|
||||||
$this->token = key($yymatches); // token number
|
$this->token = key($yymatches); // token number
|
||||||
@@ -262,8 +276,10 @@ class Smarty_Internal_Configfilelexer
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
throw new Exception('Unexpected input at line' . $this->line .
|
throw new Exception(
|
||||||
': ' . $this->data[ $this->counter ]);
|
'Unexpected input at line' . $this->line .
|
||||||
|
': ' . $this->data[ $this->counter ]
|
||||||
|
);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
} while (true);
|
} while (true);
|
||||||
@@ -332,10 +348,14 @@ class Smarty_Internal_Configfilelexer
|
|||||||
$yymatches = array_filter($yymatches);
|
$yymatches = array_filter($yymatches);
|
||||||
}
|
}
|
||||||
if (empty($yymatches)) {
|
if (empty($yymatches)) {
|
||||||
throw new Exception('Error: lexing failed because a rule matched' .
|
throw new Exception(
|
||||||
' an empty string. Input "' . substr($this->data,
|
'Error: lexing failed because a rule matched' .
|
||||||
$this->counter,
|
' an empty string. Input "' . substr(
|
||||||
5) . '... state VALUE');
|
$this->data,
|
||||||
|
$this->counter,
|
||||||
|
5
|
||||||
|
) . '... state VALUE'
|
||||||
|
);
|
||||||
}
|
}
|
||||||
next($yymatches); // skip global match
|
next($yymatches); // skip global match
|
||||||
$this->token = key($yymatches); // token number
|
$this->token = key($yymatches); // token number
|
||||||
@@ -360,8 +380,10 @@ class Smarty_Internal_Configfilelexer
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
throw new Exception('Unexpected input at line' . $this->line .
|
throw new Exception(
|
||||||
': ' . $this->data[ $this->counter ]);
|
'Unexpected input at line' . $this->line .
|
||||||
|
': ' . $this->data[ $this->counter ]
|
||||||
|
);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
} while (true);
|
} while (true);
|
||||||
@@ -404,8 +426,9 @@ class Smarty_Internal_Configfilelexer
|
|||||||
|
|
||||||
function yy_r2_7()
|
function yy_r2_7()
|
||||||
{
|
{
|
||||||
if (!$this->configBooleanize ||
|
if (!$this->configBooleanize
|
||||||
!in_array(strtolower($this->value), array('true', 'false', 'on', 'off', 'yes', 'no'))) {
|
|| !in_array(strtolower($this->value), array('true', 'false', 'on', 'off', 'yes', 'no'))
|
||||||
|
) {
|
||||||
$this->yypopstate();
|
$this->yypopstate();
|
||||||
$this->yypushstate(self::NAKED_STRING_VALUE);
|
$this->yypushstate(self::NAKED_STRING_VALUE);
|
||||||
return true; //reprocess in new state
|
return true; //reprocess in new state
|
||||||
@@ -447,10 +470,14 @@ class Smarty_Internal_Configfilelexer
|
|||||||
$yymatches = array_filter($yymatches);
|
$yymatches = array_filter($yymatches);
|
||||||
}
|
}
|
||||||
if (empty($yymatches)) {
|
if (empty($yymatches)) {
|
||||||
throw new Exception('Error: lexing failed because a rule matched' .
|
throw new Exception(
|
||||||
' an empty string. Input "' . substr($this->data,
|
'Error: lexing failed because a rule matched' .
|
||||||
$this->counter,
|
' an empty string. Input "' . substr(
|
||||||
5) . '... state NAKED_STRING_VALUE');
|
$this->data,
|
||||||
|
$this->counter,
|
||||||
|
5
|
||||||
|
) . '... state NAKED_STRING_VALUE'
|
||||||
|
);
|
||||||
}
|
}
|
||||||
next($yymatches); // skip global match
|
next($yymatches); // skip global match
|
||||||
$this->token = key($yymatches); // token number
|
$this->token = key($yymatches); // token number
|
||||||
@@ -475,8 +502,10 @@ class Smarty_Internal_Configfilelexer
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
throw new Exception('Unexpected input at line' . $this->line .
|
throw new Exception(
|
||||||
': ' . $this->data[ $this->counter ]);
|
'Unexpected input at line' . $this->line .
|
||||||
|
': ' . $this->data[ $this->counter ]
|
||||||
|
);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
} while (true);
|
} while (true);
|
||||||
@@ -507,10 +536,14 @@ class Smarty_Internal_Configfilelexer
|
|||||||
$yymatches = array_filter($yymatches);
|
$yymatches = array_filter($yymatches);
|
||||||
}
|
}
|
||||||
if (empty($yymatches)) {
|
if (empty($yymatches)) {
|
||||||
throw new Exception('Error: lexing failed because a rule matched' .
|
throw new Exception(
|
||||||
' an empty string. Input "' . substr($this->data,
|
'Error: lexing failed because a rule matched' .
|
||||||
$this->counter,
|
' an empty string. Input "' . substr(
|
||||||
5) . '... state COMMENT');
|
$this->data,
|
||||||
|
$this->counter,
|
||||||
|
5
|
||||||
|
) . '... state COMMENT'
|
||||||
|
);
|
||||||
}
|
}
|
||||||
next($yymatches); // skip global match
|
next($yymatches); // skip global match
|
||||||
$this->token = key($yymatches); // token number
|
$this->token = key($yymatches); // token number
|
||||||
@@ -535,8 +568,10 @@ class Smarty_Internal_Configfilelexer
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
throw new Exception('Unexpected input at line' . $this->line .
|
throw new Exception(
|
||||||
': ' . $this->data[ $this->counter ]);
|
'Unexpected input at line' . $this->line .
|
||||||
|
': ' . $this->data[ $this->counter ]
|
||||||
|
);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
} while (true);
|
} while (true);
|
||||||
@@ -577,10 +612,14 @@ class Smarty_Internal_Configfilelexer
|
|||||||
$yymatches = array_filter($yymatches);
|
$yymatches = array_filter($yymatches);
|
||||||
}
|
}
|
||||||
if (empty($yymatches)) {
|
if (empty($yymatches)) {
|
||||||
throw new Exception('Error: lexing failed because a rule matched' .
|
throw new Exception(
|
||||||
' an empty string. Input "' . substr($this->data,
|
'Error: lexing failed because a rule matched' .
|
||||||
$this->counter,
|
' an empty string. Input "' . substr(
|
||||||
5) . '... state SECTION');
|
$this->data,
|
||||||
|
$this->counter,
|
||||||
|
5
|
||||||
|
) . '... state SECTION'
|
||||||
|
);
|
||||||
}
|
}
|
||||||
next($yymatches); // skip global match
|
next($yymatches); // skip global match
|
||||||
$this->token = key($yymatches); // token number
|
$this->token = key($yymatches); // token number
|
||||||
@@ -605,8 +644,10 @@ class Smarty_Internal_Configfilelexer
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
throw new Exception('Unexpected input at line' . $this->line .
|
throw new Exception(
|
||||||
': ' . $this->data[ $this->counter ]);
|
'Unexpected input at line' . $this->line .
|
||||||
|
': ' . $this->data[ $this->counter ]
|
||||||
|
);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
} while (true);
|
} while (true);
|
||||||
@@ -642,10 +683,14 @@ class Smarty_Internal_Configfilelexer
|
|||||||
$yymatches = array_filter($yymatches);
|
$yymatches = array_filter($yymatches);
|
||||||
}
|
}
|
||||||
if (empty($yymatches)) {
|
if (empty($yymatches)) {
|
||||||
throw new Exception('Error: lexing failed because a rule matched' .
|
throw new Exception(
|
||||||
' an empty string. Input "' . substr($this->data,
|
'Error: lexing failed because a rule matched' .
|
||||||
$this->counter,
|
' an empty string. Input "' . substr(
|
||||||
5) . '... state TRIPPLE');
|
$this->data,
|
||||||
|
$this->counter,
|
||||||
|
5
|
||||||
|
) . '... state TRIPPLE'
|
||||||
|
);
|
||||||
}
|
}
|
||||||
next($yymatches); // skip global match
|
next($yymatches); // skip global match
|
||||||
$this->token = key($yymatches); // token number
|
$this->token = key($yymatches); // token number
|
||||||
@@ -670,8 +715,10 @@ class Smarty_Internal_Configfilelexer
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
throw new Exception('Unexpected input at line' . $this->line .
|
throw new Exception(
|
||||||
': ' . $this->data[ $this->counter ]);
|
'Unexpected input at line' . $this->line .
|
||||||
|
': ' . $this->data[ $this->counter ]
|
||||||
|
);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
} while (true);
|
} while (true);
|
||||||
|
@@ -9,7 +9,7 @@ class TPC_yyStackEntry
|
|||||||
** is the value of the token */
|
** is the value of the token */
|
||||||
}
|
}
|
||||||
|
|
||||||
#line 12 "../smarty/lexer/smarty_internal_configfileparser.y"
|
// line 12 "../smarty/lexer/smarty_internal_configfileparser.y"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Smarty Internal Plugin Configfileparse
|
* Smarty Internal Plugin Configfileparse
|
||||||
@@ -23,7 +23,7 @@ class TPC_yyStackEntry
|
|||||||
*/
|
*/
|
||||||
class Smarty_Internal_Configfileparser
|
class Smarty_Internal_Configfileparser
|
||||||
{
|
{
|
||||||
#line 25 "../smarty/lexer/smarty_internal_configfileparser.y"
|
// line 25 "../smarty/lexer/smarty_internal_configfileparser.y"
|
||||||
const TPC_OPENB = 1;
|
const TPC_OPENB = 1;
|
||||||
const TPC_SECTION = 2;
|
const TPC_SECTION = 2;
|
||||||
const TPC_CLOSEB = 3;
|
const TPC_CLOSEB = 3;
|
||||||
@@ -287,8 +287,8 @@ class Smarty_Internal_Configfileparser
|
|||||||
public static function yy_destructor($yymajor, $yypminor)
|
public static function yy_destructor($yymajor, $yypminor)
|
||||||
{
|
{
|
||||||
switch ($yymajor) {
|
switch ($yymajor) {
|
||||||
default:
|
default:
|
||||||
break; /* If no destructor action specified: do nothing */
|
break; /* If no destructor action specified: do nothing */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -375,9 +375,11 @@ class Smarty_Internal_Configfileparser
|
|||||||
}
|
}
|
||||||
$yytos = array_pop($this->yystack);
|
$yytos = array_pop($this->yystack);
|
||||||
if ($this->yyTraceFILE && $this->yyidx >= 0) {
|
if ($this->yyTraceFILE && $this->yyidx >= 0) {
|
||||||
fwrite($this->yyTraceFILE,
|
fwrite(
|
||||||
$this->yyTracePrompt . 'Popping ' . $this->yyTokenName[ $yytos->major ] .
|
$this->yyTraceFILE,
|
||||||
"\n");
|
$this->yyTracePrompt . 'Popping ' . $this->yyTokenName[ $yytos->major ] .
|
||||||
|
"\n"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
$yymajor = $yytos->major;
|
$yymajor = $yytos->major;
|
||||||
self::yy_destructor($yymajor, $yytos->minor);
|
self::yy_destructor($yymajor, $yytos->minor);
|
||||||
@@ -429,7 +431,8 @@ class Smarty_Internal_Configfileparser
|
|||||||
$this->yyidx -= self::$yyRuleInfo[ $yyruleno ][ 1 ];
|
$this->yyidx -= self::$yyRuleInfo[ $yyruleno ][ 1 ];
|
||||||
$nextstate = $this->yy_find_reduce_action(
|
$nextstate = $this->yy_find_reduce_action(
|
||||||
$this->yystack[ $this->yyidx ]->stateno,
|
$this->yystack[ $this->yyidx ]->stateno,
|
||||||
self::$yyRuleInfo[ $yyruleno ][ 0 ]);
|
self::$yyRuleInfo[ $yyruleno ][ 0 ]
|
||||||
|
);
|
||||||
if (isset(self::$yyExpectedTokens[ $nextstate ])) {
|
if (isset(self::$yyExpectedTokens[ $nextstate ])) {
|
||||||
$expected = array_merge($expected, self::$yyExpectedTokens[ $nextstate ]);
|
$expected = array_merge($expected, self::$yyExpectedTokens[ $nextstate ]);
|
||||||
if (isset($res4[ $nextstate ][ $token ])) {
|
if (isset($res4[ $nextstate ][ $token ])) {
|
||||||
@@ -439,8 +442,8 @@ class Smarty_Internal_Configfileparser
|
|||||||
return array_unique($expected);
|
return array_unique($expected);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if ($res4[ $nextstate ][ $token ] =
|
if ($res4[ $nextstate ][ $token ] = in_array($token, self::$yyExpectedTokens[ $nextstate ], true)
|
||||||
in_array($token, self::$yyExpectedTokens[ $nextstate ], true)) {
|
) {
|
||||||
$this->yyidx = $yyidx;
|
$this->yyidx = $yyidx;
|
||||||
$this->yystack = $stack;
|
$this->yystack = $stack;
|
||||||
return array_unique($expected);
|
return array_unique($expected);
|
||||||
@@ -515,7 +518,8 @@ class Smarty_Internal_Configfileparser
|
|||||||
$this->yyidx -= self::$yyRuleInfo[ $yyruleno ][ 1 ];
|
$this->yyidx -= self::$yyRuleInfo[ $yyruleno ][ 1 ];
|
||||||
$nextstate = $this->yy_find_reduce_action(
|
$nextstate = $this->yy_find_reduce_action(
|
||||||
$this->yystack[ $this->yyidx ]->stateno,
|
$this->yystack[ $this->yyidx ]->stateno,
|
||||||
self::$yyRuleInfo[ $yyruleno ][ 0 ]);
|
self::$yyRuleInfo[ $yyruleno ][ 0 ]
|
||||||
|
);
|
||||||
if (isset($res2[ $nextstate ][ $token ])) {
|
if (isset($res2[ $nextstate ][ $token ])) {
|
||||||
if ($res2[ $nextstate ][ $token ]) {
|
if ($res2[ $nextstate ][ $token ]) {
|
||||||
$this->yyidx = $yyidx;
|
$this->yyidx = $yyidx;
|
||||||
@@ -523,10 +527,13 @@ class Smarty_Internal_Configfileparser
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if ($res2[ $nextstate ][ $token ] = (isset(self::$yyExpectedTokens[ $nextstate ]) &&
|
if ($res2[ $nextstate ][ $token ] = (isset(self::$yyExpectedTokens[ $nextstate ])
|
||||||
in_array($token,
|
&& in_array(
|
||||||
self::$yyExpectedTokens[ $nextstate ],
|
$token,
|
||||||
true))) {
|
self::$yyExpectedTokens[ $nextstate ],
|
||||||
|
true
|
||||||
|
))
|
||||||
|
) {
|
||||||
$this->yyidx = $yyidx;
|
$this->yyidx = $yyidx;
|
||||||
$this->yystack = $stack;
|
$this->yystack = $stack;
|
||||||
return true;
|
return true;
|
||||||
@@ -584,15 +591,19 @@ class Smarty_Internal_Configfileparser
|
|||||||
return self::YY_NO_ACTION;
|
return self::YY_NO_ACTION;
|
||||||
}
|
}
|
||||||
$i += $iLookAhead;
|
$i += $iLookAhead;
|
||||||
if ($i < 0 || $i >= self::YY_SZ_ACTTAB ||
|
if ($i < 0 || $i >= self::YY_SZ_ACTTAB
|
||||||
self::$yy_lookahead[ $i ] != $iLookAhead) {
|
|| self::$yy_lookahead[ $i ] != $iLookAhead
|
||||||
|
) {
|
||||||
if (count(self::$yyFallback) && $iLookAhead < count(self::$yyFallback)
|
if (count(self::$yyFallback) && $iLookAhead < count(self::$yyFallback)
|
||||||
&& ($iFallback = self::$yyFallback[ $iLookAhead ]) != 0) {
|
&& ($iFallback = self::$yyFallback[ $iLookAhead ]) != 0
|
||||||
|
) {
|
||||||
if ($this->yyTraceFILE) {
|
if ($this->yyTraceFILE) {
|
||||||
fwrite($this->yyTraceFILE,
|
fwrite(
|
||||||
$this->yyTracePrompt . 'FALLBACK ' .
|
$this->yyTraceFILE,
|
||||||
|
$this->yyTracePrompt . 'FALLBACK ' .
|
||||||
$this->yyTokenName[ $iLookAhead ] . ' => ' .
|
$this->yyTokenName[ $iLookAhead ] . ' => ' .
|
||||||
$this->yyTokenName[ $iFallback ] . "\n");
|
$this->yyTokenName[ $iFallback ] . "\n"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
return $this->yy_find_shift_action($iFallback);
|
return $this->yy_find_shift_action($iFallback);
|
||||||
}
|
}
|
||||||
@@ -616,8 +627,9 @@ class Smarty_Internal_Configfileparser
|
|||||||
return self::YY_NO_ACTION;
|
return self::YY_NO_ACTION;
|
||||||
}
|
}
|
||||||
$i += $iLookAhead;
|
$i += $iLookAhead;
|
||||||
if ($i < 0 || $i >= self::YY_SZ_ACTTAB ||
|
if ($i < 0 || $i >= self::YY_SZ_ACTTAB
|
||||||
self::$yy_lookahead[ $i ] != $iLookAhead) {
|
|| self::$yy_lookahead[ $i ] != $iLookAhead
|
||||||
|
) {
|
||||||
return self::$yy_default[ $stateno ];
|
return self::$yy_default[ $stateno ];
|
||||||
} else {
|
} else {
|
||||||
return self::$yy_action[ $i ];
|
return self::$yy_action[ $i ];
|
||||||
@@ -635,7 +647,7 @@ class Smarty_Internal_Configfileparser
|
|||||||
while ($this->yyidx >= 0) {
|
while ($this->yyidx >= 0) {
|
||||||
$this->yy_pop_parser_stack();
|
$this->yy_pop_parser_stack();
|
||||||
}
|
}
|
||||||
#line 239 "../smarty/lexer/smarty_internal_configfileparser.y"
|
// line 239 "../smarty/lexer/smarty_internal_configfileparser.y"
|
||||||
$this->internalError = true;
|
$this->internalError = true;
|
||||||
$this->compiler->trigger_config_file_error('Stack overflow in configfile parser');
|
$this->compiler->trigger_config_file_error('Stack overflow in configfile parser');
|
||||||
return;
|
return;
|
||||||
@@ -646,15 +658,19 @@ class Smarty_Internal_Configfileparser
|
|||||||
$yytos->minor = $yypMinor;
|
$yytos->minor = $yypMinor;
|
||||||
$this->yystack[] = $yytos;
|
$this->yystack[] = $yytos;
|
||||||
if ($this->yyTraceFILE && $this->yyidx > 0) {
|
if ($this->yyTraceFILE && $this->yyidx > 0) {
|
||||||
fprintf($this->yyTraceFILE,
|
fprintf(
|
||||||
"%sShift %d\n",
|
$this->yyTraceFILE,
|
||||||
$this->yyTracePrompt,
|
"%sShift %d\n",
|
||||||
$yyNewState);
|
$this->yyTracePrompt,
|
||||||
|
$yyNewState
|
||||||
|
);
|
||||||
fprintf($this->yyTraceFILE, "%sStack:", $this->yyTracePrompt);
|
fprintf($this->yyTraceFILE, "%sStack:", $this->yyTracePrompt);
|
||||||
for ($i = 1; $i <= $this->yyidx; $i++) {
|
for ($i = 1; $i <= $this->yyidx; $i++) {
|
||||||
fprintf($this->yyTraceFILE,
|
fprintf(
|
||||||
" %s",
|
$this->yyTraceFILE,
|
||||||
$this->yyTokenName[ $this->yystack[ $i ]->major ]);
|
" %s",
|
||||||
|
$this->yyTokenName[ $this->yystack[ $i ]->major ]
|
||||||
|
);
|
||||||
}
|
}
|
||||||
fwrite($this->yyTraceFILE, "\n");
|
fwrite($this->yyTraceFILE, "\n");
|
||||||
}
|
}
|
||||||
@@ -677,100 +693,105 @@ class Smarty_Internal_Configfileparser
|
|||||||
$this->_retvalue = null;
|
$this->_retvalue = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
#line 245 "../smarty/lexer/smarty_internal_configfileparser.y"
|
// line 245 "../smarty/lexer/smarty_internal_configfileparser.y"
|
||||||
function yy_r5()
|
function yy_r5()
|
||||||
{
|
{
|
||||||
if ($this->configReadHidden) {
|
if ($this->configReadHidden) {
|
||||||
$this->add_section_vars($this->yystack[ $this->yyidx + -3 ]->minor,
|
$this->add_section_vars(
|
||||||
$this->yystack[ $this->yyidx + 0 ]->minor);
|
$this->yystack[ $this->yyidx + -3 ]->minor,
|
||||||
|
$this->yystack[ $this->yyidx + 0 ]->minor
|
||||||
|
);
|
||||||
}
|
}
|
||||||
$this->_retvalue = null;
|
$this->_retvalue = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
#line 250 "../smarty/lexer/smarty_internal_configfileparser.y"
|
// line 250 "../smarty/lexer/smarty_internal_configfileparser.y"
|
||||||
function yy_r6()
|
function yy_r6()
|
||||||
{
|
{
|
||||||
$this->_retvalue = $this->yystack[ $this->yyidx + -1 ]->minor;
|
$this->_retvalue = $this->yystack[ $this->yyidx + -1 ]->minor;
|
||||||
}
|
}
|
||||||
|
|
||||||
#line 264 "../smarty/lexer/smarty_internal_configfileparser.y"
|
// line 264 "../smarty/lexer/smarty_internal_configfileparser.y"
|
||||||
function yy_r7()
|
function yy_r7()
|
||||||
{
|
{
|
||||||
$this->_retvalue =
|
$this->_retvalue =
|
||||||
array_merge($this->yystack[ $this->yyidx + -1 ]->minor, array($this->yystack[ $this->yyidx + 0 ]->minor));
|
array_merge($this->yystack[ $this->yyidx + -1 ]->minor, array($this->yystack[ $this->yyidx + 0 ]->minor));
|
||||||
}
|
}
|
||||||
|
|
||||||
#line 269 "../smarty/lexer/smarty_internal_configfileparser.y"
|
// line 269 "../smarty/lexer/smarty_internal_configfileparser.y"
|
||||||
function yy_r8()
|
function yy_r8()
|
||||||
{
|
{
|
||||||
$this->_retvalue = array();
|
$this->_retvalue = array();
|
||||||
}
|
}
|
||||||
|
|
||||||
#line 277 "../smarty/lexer/smarty_internal_configfileparser.y"
|
// line 277 "../smarty/lexer/smarty_internal_configfileparser.y"
|
||||||
function yy_r9()
|
function yy_r9()
|
||||||
{
|
{
|
||||||
$this->_retvalue = array('key' => $this->yystack[ $this->yyidx + -2 ]->minor,
|
$this->_retvalue = array('key' => $this->yystack[ $this->yyidx + -2 ]->minor,
|
||||||
'value' => $this->yystack[ $this->yyidx + 0 ]->minor);
|
'value' => $this->yystack[ $this->yyidx + 0 ]->minor);
|
||||||
}
|
}
|
||||||
|
|
||||||
#line 281 "../smarty/lexer/smarty_internal_configfileparser.y"
|
// line 281 "../smarty/lexer/smarty_internal_configfileparser.y"
|
||||||
function yy_r10()
|
function yy_r10()
|
||||||
{
|
{
|
||||||
$this->_retvalue = (float)$this->yystack[ $this->yyidx + 0 ]->minor;
|
$this->_retvalue = (float)$this->yystack[ $this->yyidx + 0 ]->minor;
|
||||||
}
|
}
|
||||||
|
|
||||||
#line 285 "../smarty/lexer/smarty_internal_configfileparser.y"
|
// line 285 "../smarty/lexer/smarty_internal_configfileparser.y"
|
||||||
function yy_r11()
|
function yy_r11()
|
||||||
{
|
{
|
||||||
$this->_retvalue = (int)$this->yystack[ $this->yyidx + 0 ]->minor;
|
$this->_retvalue = (int)$this->yystack[ $this->yyidx + 0 ]->minor;
|
||||||
}
|
}
|
||||||
|
|
||||||
#line 291 "../smarty/lexer/smarty_internal_configfileparser.y"
|
// line 291 "../smarty/lexer/smarty_internal_configfileparser.y"
|
||||||
function yy_r12()
|
function yy_r12()
|
||||||
{
|
{
|
||||||
$this->_retvalue = $this->parse_bool($this->yystack[ $this->yyidx + 0 ]->minor);
|
$this->_retvalue = $this->parse_bool($this->yystack[ $this->yyidx + 0 ]->minor);
|
||||||
}
|
}
|
||||||
|
|
||||||
#line 296 "../smarty/lexer/smarty_internal_configfileparser.y"
|
// line 296 "../smarty/lexer/smarty_internal_configfileparser.y"
|
||||||
function yy_r13()
|
function yy_r13()
|
||||||
{
|
{
|
||||||
$this->_retvalue = self::parse_single_quoted_string($this->yystack[ $this->yyidx + 0 ]->minor);
|
$this->_retvalue = self::parse_single_quoted_string($this->yystack[ $this->yyidx + 0 ]->minor);
|
||||||
}
|
}
|
||||||
|
|
||||||
#line 300 "../smarty/lexer/smarty_internal_configfileparser.y"
|
// line 300 "../smarty/lexer/smarty_internal_configfileparser.y"
|
||||||
function yy_r14()
|
function yy_r14()
|
||||||
{
|
{
|
||||||
$this->_retvalue = self::parse_double_quoted_string($this->yystack[ $this->yyidx + 0 ]->minor);
|
$this->_retvalue = self::parse_double_quoted_string($this->yystack[ $this->yyidx + 0 ]->minor);
|
||||||
}
|
}
|
||||||
|
|
||||||
#line 304 "../smarty/lexer/smarty_internal_configfileparser.y"
|
// line 304 "../smarty/lexer/smarty_internal_configfileparser.y"
|
||||||
function yy_r15()
|
function yy_r15()
|
||||||
{
|
{
|
||||||
$this->_retvalue = self::parse_tripple_double_quoted_string($this->yystack[ $this->yyidx + -1 ]->minor);
|
$this->_retvalue = self::parse_tripple_double_quoted_string($this->yystack[ $this->yyidx + -1 ]->minor);
|
||||||
}
|
}
|
||||||
|
|
||||||
#line 308 "../smarty/lexer/smarty_internal_configfileparser.y"
|
// line 308 "../smarty/lexer/smarty_internal_configfileparser.y"
|
||||||
function yy_r16()
|
function yy_r16()
|
||||||
{
|
{
|
||||||
$this->_retvalue = '';
|
$this->_retvalue = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
#line 312 "../smarty/lexer/smarty_internal_configfileparser.y"
|
// line 312 "../smarty/lexer/smarty_internal_configfileparser.y"
|
||||||
function yy_r17()
|
function yy_r17()
|
||||||
{
|
{
|
||||||
$this->_retvalue = $this->yystack[ $this->yyidx + 0 ]->minor;
|
$this->_retvalue = $this->yystack[ $this->yyidx + 0 ]->minor;
|
||||||
}
|
}
|
||||||
|
|
||||||
#line 316 "../smarty/lexer/smarty_internal_configfileparser.y"
|
// line 316 "../smarty/lexer/smarty_internal_configfileparser.y"
|
||||||
public function yy_reduce($yyruleno)
|
public function yy_reduce($yyruleno)
|
||||||
{
|
{
|
||||||
if ($this->yyTraceFILE && $yyruleno >= 0
|
if ($this->yyTraceFILE && $yyruleno >= 0
|
||||||
&& $yyruleno < count(self::$yyRuleName)) {
|
&& $yyruleno < count(self::$yyRuleName)
|
||||||
fprintf($this->yyTraceFILE,
|
) {
|
||||||
"%sReduce (%d) [%s].\n",
|
fprintf(
|
||||||
$this->yyTracePrompt,
|
$this->yyTraceFILE,
|
||||||
$yyruleno,
|
"%sReduce (%d) [%s].\n",
|
||||||
self::$yyRuleName[ $yyruleno ]);
|
$this->yyTracePrompt,
|
||||||
|
$yyruleno,
|
||||||
|
self::$yyRuleName[ $yyruleno ]
|
||||||
|
);
|
||||||
}
|
}
|
||||||
$this->_retvalue = $yy_lefthand_side = null;
|
$this->_retvalue = $yy_lefthand_side = null;
|
||||||
if (isset(self::$yyReduceMap[ $yyruleno ])) {
|
if (isset(self::$yyReduceMap[ $yyruleno ])) {
|
||||||
@@ -803,7 +824,7 @@ class Smarty_Internal_Configfileparser
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#line 320 "../smarty/lexer/smarty_internal_configfileparser.y"
|
// line 320 "../smarty/lexer/smarty_internal_configfileparser.y"
|
||||||
public function yy_parse_failed()
|
public function yy_parse_failed()
|
||||||
{
|
{
|
||||||
if ($this->yyTraceFILE) {
|
if ($this->yyTraceFILE) {
|
||||||
@@ -814,10 +835,10 @@ class Smarty_Internal_Configfileparser
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#line 324 "../smarty/lexer/smarty_internal_configfileparser.y"
|
// line 324 "../smarty/lexer/smarty_internal_configfileparser.y"
|
||||||
public function yy_syntax_error($yymajor, $TOKEN)
|
public function yy_syntax_error($yymajor, $TOKEN)
|
||||||
{
|
{
|
||||||
#line 232 "../smarty/lexer/smarty_internal_configfileparser.y"
|
// line 232 "../smarty/lexer/smarty_internal_configfileparser.y"
|
||||||
$this->internalError = true;
|
$this->internalError = true;
|
||||||
$this->yymajor = $yymajor;
|
$this->yymajor = $yymajor;
|
||||||
$this->compiler->trigger_config_file_error();
|
$this->compiler->trigger_config_file_error();
|
||||||
@@ -831,7 +852,7 @@ class Smarty_Internal_Configfileparser
|
|||||||
while ($this->yyidx >= 0) {
|
while ($this->yyidx >= 0) {
|
||||||
$this->yy_pop_parser_stack();
|
$this->yy_pop_parser_stack();
|
||||||
}
|
}
|
||||||
#line 225 "../smarty/lexer/smarty_internal_configfileparser.y"
|
// line 225 "../smarty/lexer/smarty_internal_configfileparser.y"
|
||||||
$this->successful = !$this->internalError;
|
$this->successful = !$this->internalError;
|
||||||
$this->internalError = false;
|
$this->internalError = false;
|
||||||
$this->retvalue = $this->_retvalue;
|
$this->retvalue = $this->_retvalue;
|
||||||
@@ -851,15 +872,18 @@ class Smarty_Internal_Configfileparser
|
|||||||
}
|
}
|
||||||
$yyendofinput = ($yymajor == 0);
|
$yyendofinput = ($yymajor == 0);
|
||||||
if ($this->yyTraceFILE) {
|
if ($this->yyTraceFILE) {
|
||||||
fprintf($this->yyTraceFILE,
|
fprintf(
|
||||||
"%sInput %s\n",
|
$this->yyTraceFILE,
|
||||||
$this->yyTracePrompt,
|
"%sInput %s\n",
|
||||||
$this->yyTokenName[ $yymajor ]);
|
$this->yyTracePrompt,
|
||||||
|
$this->yyTokenName[ $yymajor ]
|
||||||
|
);
|
||||||
}
|
}
|
||||||
do {
|
do {
|
||||||
$yyact = $this->yy_find_shift_action($yymajor);
|
$yyact = $this->yy_find_shift_action($yymajor);
|
||||||
if ($yymajor < self::YYERRORSYMBOL &&
|
if ($yymajor < self::YYERRORSYMBOL
|
||||||
!$this->yy_is_expected_token($yymajor)) {
|
&& !$this->yy_is_expected_token($yymajor)
|
||||||
|
) {
|
||||||
// force a syntax error
|
// force a syntax error
|
||||||
$yyact = self::YY_ERROR_ACTION;
|
$yyact = self::YY_ERROR_ACTION;
|
||||||
}
|
}
|
||||||
@@ -875,9 +899,11 @@ class Smarty_Internal_Configfileparser
|
|||||||
$this->yy_reduce($yyact - self::YYNSTATE);
|
$this->yy_reduce($yyact - self::YYNSTATE);
|
||||||
} else if ($yyact === self::YY_ERROR_ACTION) {
|
} else if ($yyact === self::YY_ERROR_ACTION) {
|
||||||
if ($this->yyTraceFILE) {
|
if ($this->yyTraceFILE) {
|
||||||
fprintf($this->yyTraceFILE,
|
fprintf(
|
||||||
"%sSyntax Error!\n",
|
$this->yyTraceFILE,
|
||||||
$this->yyTracePrompt);
|
"%sSyntax Error!\n",
|
||||||
|
$this->yyTracePrompt
|
||||||
|
);
|
||||||
}
|
}
|
||||||
if (self::YYERRORSYMBOL) {
|
if (self::YYERRORSYMBOL) {
|
||||||
if ($this->yyerrcnt < 0) {
|
if ($this->yyerrcnt < 0) {
|
||||||
@@ -886,10 +912,12 @@ class Smarty_Internal_Configfileparser
|
|||||||
$yymx = $this->yystack[ $this->yyidx ]->major;
|
$yymx = $this->yystack[ $this->yyidx ]->major;
|
||||||
if ($yymx === self::YYERRORSYMBOL || $yyerrorhit) {
|
if ($yymx === self::YYERRORSYMBOL || $yyerrorhit) {
|
||||||
if ($this->yyTraceFILE) {
|
if ($this->yyTraceFILE) {
|
||||||
fprintf($this->yyTraceFILE,
|
fprintf(
|
||||||
"%sDiscard input token %s\n",
|
$this->yyTraceFILE,
|
||||||
$this->yyTracePrompt,
|
"%sDiscard input token %s\n",
|
||||||
$this->yyTokenName[ $yymajor ]);
|
$this->yyTracePrompt,
|
||||||
|
$this->yyTokenName[ $yymajor ]
|
||||||
|
);
|
||||||
}
|
}
|
||||||
$this->yy_destructor($yymajor, $yytokenvalue);
|
$this->yy_destructor($yymajor, $yytokenvalue);
|
||||||
$yymajor = self::YYNOCODE;
|
$yymajor = self::YYNOCODE;
|
||||||
|
@@ -87,9 +87,9 @@ abstract class Smarty_Internal_Data
|
|||||||
/**
|
/**
|
||||||
* assigns a Smarty variable
|
* assigns a Smarty variable
|
||||||
*
|
*
|
||||||
* @param array|string $tpl_var the template variable name(s)
|
* @param array|string $tpl_var the template variable name(s)
|
||||||
* @param mixed $value the value to assign
|
* @param mixed $value the value to assign
|
||||||
* @param boolean $nocache if true any output of this variable will be not cached
|
* @param boolean $nocache if true any output of this variable will be not cached
|
||||||
*
|
*
|
||||||
* @return Smarty_Internal_Data current Smarty_Internal_Data (or Smarty or Smarty_Internal_Template) instance for
|
* @return Smarty_Internal_Data current Smarty_Internal_Data (or Smarty or Smarty_Internal_Template) instance for
|
||||||
* chaining
|
* chaining
|
||||||
@@ -103,7 +103,11 @@ abstract class Smarty_Internal_Data
|
|||||||
} else {
|
} else {
|
||||||
if ($tpl_var !== '') {
|
if ($tpl_var !== '') {
|
||||||
if ($this->_objType === 2) {
|
if ($this->_objType === 2) {
|
||||||
/** @var Smarty_Internal_Template $this */
|
/**
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @var Smarty_Internal_Template $this
|
||||||
|
*/
|
||||||
$this->_assignInScope($tpl_var, $value, $nocache);
|
$this->_assignInScope($tpl_var, $value, $nocache);
|
||||||
} else {
|
} else {
|
||||||
$this->tpl_vars[ $tpl_var ] = new Smarty_Variable($value, $nocache);
|
$this->tpl_vars[ $tpl_var ] = new Smarty_Variable($value, $nocache);
|
||||||
@@ -119,11 +123,11 @@ abstract class Smarty_Internal_Data
|
|||||||
* @api Smarty::append()
|
* @api Smarty::append()
|
||||||
* @link http://www.smarty.net/docs/en/api.append.tpl
|
* @link http://www.smarty.net/docs/en/api.append.tpl
|
||||||
*
|
*
|
||||||
* @param array|string $tpl_var the template variable name(s)
|
* @param array|string $tpl_var the template variable name(s)
|
||||||
* @param mixed $value the value to append
|
* @param mixed $value the value to append
|
||||||
* @param bool $merge flag if array elements shall be merged
|
* @param bool $merge flag if array elements shall be merged
|
||||||
* @param bool $nocache if true any output of this variable will
|
* @param bool $nocache if true any output of this variable will
|
||||||
* be not cached
|
* be not cached
|
||||||
*
|
*
|
||||||
* @return \Smarty_Internal_Data|\Smarty_Internal_Template|\Smarty
|
* @return \Smarty_Internal_Data|\Smarty_Internal_Template|\Smarty
|
||||||
*/
|
*/
|
||||||
@@ -135,9 +139,9 @@ abstract class Smarty_Internal_Data
|
|||||||
/**
|
/**
|
||||||
* assigns a global Smarty variable
|
* assigns a global Smarty variable
|
||||||
*
|
*
|
||||||
* @param string $varName the global variable name
|
* @param string $varName the global variable name
|
||||||
* @param mixed $value the value to assign
|
* @param mixed $value the value to assign
|
||||||
* @param boolean $nocache if true any output of this variable will be not cached
|
* @param boolean $nocache if true any output of this variable will be not cached
|
||||||
*
|
*
|
||||||
* @return \Smarty_Internal_Data|\Smarty_Internal_Template|\Smarty
|
* @return \Smarty_Internal_Data|\Smarty_Internal_Template|\Smarty
|
||||||
*/
|
*/
|
||||||
@@ -149,9 +153,9 @@ abstract class Smarty_Internal_Data
|
|||||||
/**
|
/**
|
||||||
* appends values to template variables by reference
|
* appends values to template variables by reference
|
||||||
*
|
*
|
||||||
* @param string $tpl_var the template variable name
|
* @param string $tpl_var the template variable name
|
||||||
* @param mixed &$value the referenced value to append
|
* @param mixed &$value the referenced value to append
|
||||||
* @param boolean $merge flag if array elements shall be merged
|
* @param boolean $merge flag if array elements shall be merged
|
||||||
*
|
*
|
||||||
* @return \Smarty_Internal_Data|\Smarty_Internal_Template|\Smarty
|
* @return \Smarty_Internal_Data|\Smarty_Internal_Template|\Smarty
|
||||||
*/
|
*/
|
||||||
@@ -163,9 +167,9 @@ abstract class Smarty_Internal_Data
|
|||||||
/**
|
/**
|
||||||
* assigns values to template variables by reference
|
* assigns values to template variables by reference
|
||||||
*
|
*
|
||||||
* @param string $tpl_var the template variable name
|
* @param string $tpl_var the template variable name
|
||||||
* @param $value
|
* @param $value
|
||||||
* @param boolean $nocache if true any output of this variable will be not cached
|
* @param boolean $nocache if true any output of this variable will be not cached
|
||||||
*
|
*
|
||||||
* @return \Smarty_Internal_Data|\Smarty_Internal_Template|\Smarty
|
* @return \Smarty_Internal_Data|\Smarty_Internal_Template|\Smarty
|
||||||
*/
|
*/
|
||||||
@@ -180,9 +184,9 @@ abstract class Smarty_Internal_Data
|
|||||||
* @api Smarty::getTemplateVars()
|
* @api Smarty::getTemplateVars()
|
||||||
* @link http://www.smarty.net/docs/en/api.get.template.vars.tpl
|
* @link http://www.smarty.net/docs/en/api.get.template.vars.tpl
|
||||||
*
|
*
|
||||||
* @param string $varName variable name or null
|
* @param string $varName variable name or null
|
||||||
* @param \Smarty_Internal_Data|\Smarty_Internal_Template|\Smarty $_ptr optional pointer to data object
|
* @param \Smarty_Internal_Data|\Smarty_Internal_Template|\Smarty $_ptr optional pointer to data object
|
||||||
* @param bool $searchParents include parent templates?
|
* @param bool $searchParents include parent templates?
|
||||||
*
|
*
|
||||||
* @return mixed variable value or or array of variables
|
* @return mixed variable value or or array of variables
|
||||||
*/
|
*/
|
||||||
@@ -194,17 +198,17 @@ abstract class Smarty_Internal_Data
|
|||||||
/**
|
/**
|
||||||
* gets the object of a Smarty variable
|
* gets the object of a Smarty variable
|
||||||
*
|
*
|
||||||
* @param string $variable the name of the Smarty variable
|
* @param string $variable the name of the Smarty variable
|
||||||
* @param Smarty_Internal_Data $_ptr optional pointer to data object
|
* @param Smarty_Internal_Data $_ptr optional pointer to data object
|
||||||
* @param boolean $searchParents search also in parent data
|
* @param boolean $searchParents search also in parent data
|
||||||
* @param bool $error_enable
|
* @param bool $error_enable
|
||||||
*
|
*
|
||||||
* @return Smarty_Variable|Smarty_Undefined_Variable the object of the variable
|
* @return Smarty_Variable|Smarty_Undefined_Variable the object of the variable
|
||||||
* @deprecated since 3.1.28 please use Smarty_Internal_Data::getTemplateVars() instead.
|
* @deprecated since 3.1.28 please use Smarty_Internal_Data::getTemplateVars() instead.
|
||||||
*/
|
*/
|
||||||
public function getVariable($variable = null, Smarty_Internal_Data $_ptr = null, $searchParents = true,
|
public function getVariable($variable = null, Smarty_Internal_Data $_ptr = null, $searchParents = true,
|
||||||
$error_enable = true)
|
$error_enable = true
|
||||||
{
|
) {
|
||||||
return $this->ext->getTemplateVars->_getVariable($this, $variable, $_ptr, $searchParents, $error_enable);
|
return $this->ext->getTemplateVars->_getVariable($this, $variable, $_ptr, $searchParents, $error_enable);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -191,7 +191,7 @@ class Smarty_Internal_Debug extends Smarty_Internal_Data
|
|||||||
/**
|
/**
|
||||||
* Opens a window for the Smarty Debugging Console and display the data
|
* Opens a window for the Smarty Debugging Console and display the data
|
||||||
*
|
*
|
||||||
* @param Smarty_Internal_Template|Smarty $obj object to debug
|
* @param Smarty_Internal_Template|Smarty $obj object to debug
|
||||||
* @param bool $full
|
* @param bool $full
|
||||||
*
|
*
|
||||||
* @throws \Exception
|
* @throws \Exception
|
||||||
@@ -264,7 +264,7 @@ class Smarty_Internal_Debug extends Smarty_Internal_Data
|
|||||||
/**
|
/**
|
||||||
* Recursively gets variables from all template/data scopes
|
* Recursively gets variables from all template/data scopes
|
||||||
*
|
*
|
||||||
* @param Smarty_Internal_Template|Smarty_Data $obj object to debug
|
* @param Smarty_Internal_Template|Smarty_Data $obj object to debug
|
||||||
*
|
*
|
||||||
* @return StdClass
|
* @return StdClass
|
||||||
*/
|
*/
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user