- update for PHP 5.4 compatibility

- reformat source to PSR-2 standard
This commit is contained in:
Uwe.Tews@googlemail.com
2013-07-14 22:15:45 +00:00
parent f99e6a83ce
commit 00ccae8857
126 changed files with 5232 additions and 5186 deletions

View File

@@ -1,6 +1,8 @@
===== trunk ===== ===== trunk =====
14.7.2013 14.7.2013
- bugfix increase of internal maximum parser stacksize to allow more complex tag code {forum topic 24426} - bugfix increase of internal maximum parser stacksize to allow more complex tag code {forum topic 24426}
- update for PHP 5.4 compatibility
- reformat source to PSR-2 standard
12.7.2013 12.7.2013
- bugfix Do not remove '//' from file path at normalization (Issue 142) - bugfix Do not remove '//' from file path at normalization (Issue 142)

View File

@@ -5,12 +5,10 @@
* @package Example-application * @package Example-application
*/ */
require('../libs/Smarty.class.php'); require '../libs/Smarty.class.php';
$smarty = new Smarty; $smarty = new Smarty;
//$smarty->force_compile = true; //$smarty->force_compile = true;
$smarty->debugging = true; $smarty->debugging = true;
$smarty->caching = true; $smarty->caching = true;
@@ -30,4 +28,3 @@ $smarty->assign("option_output", array("New York","Nebraska","Kansas","Iowa","Ok
$smarty->assign("option_selected", "NE"); $smarty->assign("option_selected", "NE");
$smarty->display('index.tpl'); $smarty->display('index.tpl');
?>

View File

@@ -9,8 +9,8 @@
* @package CacheResource-examples * @package CacheResource-examples
* @author Uwe Tews * @author Uwe Tews
*/ */
class Smarty_CacheResource_Apc extends Smarty_CacheResource_KeyValueStore { class Smarty_CacheResource_Apc extends Smarty_CacheResource_KeyValueStore
{
public function __construct() public function __construct()
{ {
// test if APC is present // test if APC is present
@@ -33,6 +33,7 @@ class Smarty_CacheResource_Apc extends Smarty_CacheResource_KeyValueStore {
foreach ($res as $k => $v) { foreach ($res as $k => $v) {
$_res[$k] = $v; $_res[$k] = $v;
} }
return $_res; return $_res;
} }
@@ -48,6 +49,7 @@ class Smarty_CacheResource_Apc extends Smarty_CacheResource_KeyValueStore {
foreach ($keys as $k => $v) { foreach ($keys as $k => $v) {
apc_store($k, $v, $expire); apc_store($k, $v, $expire);
} }
return true; return true;
} }
@@ -62,6 +64,7 @@ class Smarty_CacheResource_Apc extends Smarty_CacheResource_KeyValueStore {
foreach ($keys as $k) { foreach ($keys as $k) {
apc_delete($k); apc_delete($k);
} }
return true; return true;
} }

View File

@@ -12,7 +12,8 @@
* @package CacheResource-examples * @package CacheResource-examples
* @author Rodney Rehm * @author Rodney Rehm
*/ */
class Smarty_CacheResource_Memcache extends Smarty_CacheResource_KeyValueStore { class Smarty_CacheResource_Memcache extends Smarty_CacheResource_KeyValueStore
{
/** /**
* memcache instance * memcache instance
* @var Memcache * @var Memcache
@@ -45,6 +46,7 @@ class Smarty_CacheResource_Memcache extends Smarty_CacheResource_KeyValueStore {
foreach ($res as $k => $v) { foreach ($res as $k => $v) {
$_res[$lookup[$k]] = $v; $_res[$lookup[$k]] = $v;
} }
return $_res; return $_res;
} }
@@ -61,6 +63,7 @@ class Smarty_CacheResource_Memcache extends Smarty_CacheResource_KeyValueStore {
$k = sha1($k); $k = sha1($k);
$this->memcache->set($k, $v, 0, $expire); $this->memcache->set($k, $v, 0, $expire);
} }
return true; return true;
} }
@@ -76,6 +79,7 @@ class Smarty_CacheResource_Memcache extends Smarty_CacheResource_KeyValueStore {
$k = sha1($k); $k = sha1($k);
$this->memcache->delete($k); $this->memcache->delete($k);
} }
return true; return true;
} }

View File

@@ -24,14 +24,16 @@
* @package CacheResource-examples * @package CacheResource-examples
* @author Rodney Rehm * @author Rodney Rehm
*/ */
class Smarty_CacheResource_Mysql extends Smarty_CacheResource_Custom { class Smarty_CacheResource_Mysql extends Smarty_CacheResource_Custom
{
// PDO instance // PDO instance
protected $db; protected $db;
protected $fetch; protected $fetch;
protected $fetchTimestamp; protected $fetchTimestamp;
protected $save; protected $save;
public function __construct() { public function __construct()
{
try { try {
$this->db = new PDO("mysql:dbname=test;host=127.0.0.1", "smarty", "smarty"); $this->db = new PDO("mysql:dbname=test;host=127.0.0.1", "smarty", "smarty");
} catch (PDOException $e) { } catch (PDOException $e) {
@@ -83,6 +85,7 @@ class Smarty_CacheResource_Mysql extends Smarty_CacheResource_Custom {
$this->fetchTimestamp->execute(array('id' => $id)); $this->fetchTimestamp->execute(array('id' => $id));
$mtime = strtotime($this->fetchTimestamp->fetchColumn()); $mtime = strtotime($this->fetchTimestamp->fetchColumn());
$this->fetchTimestamp->closeCursor(); $this->fetchTimestamp->closeCursor();
return $mtime; return $mtime;
} }
@@ -106,6 +109,7 @@ class Smarty_CacheResource_Mysql extends Smarty_CacheResource_Custom {
'compile_id' => $compile_id, 'compile_id' => $compile_id,
'content' => $content, 'content' => $content,
)); ));
return !!$this->save->rowCount(); return !!$this->save->rowCount();
} }
@@ -124,6 +128,7 @@ class Smarty_CacheResource_Mysql extends Smarty_CacheResource_Custom {
if ($name === null && $cache_id === null && $compile_id === null && $exp_time === null) { if ($name === null && $cache_id === null && $compile_id === null && $exp_time === null) {
// returning the number of deleted caches would require a second query to count them // returning the number of deleted caches would require a second query to count them
$query = $this->db->query('TRUNCATE TABLE output_cache'); $query = $this->db->query('TRUNCATE TABLE output_cache');
return -1; return -1;
} }
// build the filter // build the filter
@@ -147,6 +152,7 @@ class Smarty_CacheResource_Mysql extends Smarty_CacheResource_Custom {
} }
// run delete query // run delete query
$query = $this->db->query('DELETE FROM output_cache WHERE ' . join(' AND ', $where)); $query = $this->db->query('DELETE FROM output_cache WHERE ' . join(' AND ', $where));
return $query->rowCount(); return $query->rowCount();
} }
} }

View File

@@ -9,8 +9,8 @@
* @package Resource-examples * @package Resource-examples
* @author Rodney Rehm * @author Rodney Rehm
*/ */
class Smarty_Resource_Extendsall extends Smarty_Internal_Resource_Extends { 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
* *
@@ -31,13 +31,13 @@ class Smarty_Resource_Extendsall extends Smarty_Internal_Resource_Extends {
} }
$sources[$s->uid] = $s; $sources[$s->uid] = $s;
$uid .= $s->filepath; $uid .= $s->filepath;
} } catch (SmartyException $e) {}
catch (SmartyException $e) {}
} }
if (!$sources) { if (!$sources) {
$source->exists = false; $source->exists = false;
$source->template = $_template; $source->template = $_template;
return; return;
} }
@@ -56,5 +56,3 @@ class Smarty_Resource_Extendsall extends Smarty_Internal_Resource_Extends {
$source->template = $_template; $source->template = $_template;
} }
} }
?>

View File

@@ -20,7 +20,8 @@
* @package Resource-examples * @package Resource-examples
* @author Rodney Rehm * @author Rodney Rehm
*/ */
class Smarty_Resource_Mysql extends Smarty_Resource_Custom { class Smarty_Resource_Mysql extends Smarty_Resource_Custom
{
// PDO instance // PDO instance
protected $db; protected $db;
// prepared fetch() statement // prepared fetch() statement
@@ -28,7 +29,8 @@ class Smarty_Resource_Mysql extends Smarty_Resource_Custom {
// prepared fetchTimestamp() statement // prepared fetchTimestamp() statement
protected $mtime; protected $mtime;
public function __construct() { public function __construct()
{
try { try {
$this->db = new PDO("mysql:dbname=test;host=127.0.0.1", "smarty", "smarty"); $this->db = new PDO("mysql:dbname=test;host=127.0.0.1", "smarty", "smarty");
} catch (PDOException $e) { } catch (PDOException $e) {
@@ -67,10 +69,12 @@ class Smarty_Resource_Mysql extends Smarty_Resource_Custom {
* @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
*/ */
protected function fetchTimestamp($name) { protected function fetchTimestamp($name)
{
$this->mtime->execute(array('name' => $name)); $this->mtime->execute(array('name' => $name));
$mtime = $this->mtime->fetchColumn(); $mtime = $this->mtime->fetchColumn();
$this->mtime->closeCursor(); $this->mtime->closeCursor();
return strtotime($mtime); return strtotime($mtime);
} }
} }

View File

@@ -23,13 +23,15 @@
* @package Resource-examples * @package Resource-examples
* @author Rodney Rehm * @author Rodney Rehm
*/ */
class Smarty_Resource_Mysqls extends Smarty_Resource_Custom { class Smarty_Resource_Mysqls extends Smarty_Resource_Custom
{
// PDO instance // PDO instance
protected $db; protected $db;
// prepared fetch() statement // prepared fetch() statement
protected $fetch; protected $fetch;
public function __construct() { public function __construct()
{
try { try {
$this->db = new PDO("mysql:dbname=test;host=127.0.0.1", "smarty", "smarty"); $this->db = new PDO("mysql:dbname=test;host=127.0.0.1", "smarty", "smarty");
} catch (PDOException $e) { } catch (PDOException $e) {

View File

@@ -104,8 +104,8 @@ include_once SMARTY_SYSPLUGINS_DIR.'smarty_internal_cacheresource_file.php';
* This is the main Smarty class * This is the main Smarty class
* @package Smarty * @package Smarty
*/ */
class Smarty extends Smarty_Internal_TemplateBase { class Smarty extends Smarty_Internal_TemplateBase
{
/**#@+ /**#@+
* constant definitions * constant definitions
*/ */
@@ -167,38 +167,38 @@ class Smarty extends Smarty_Internal_TemplateBase {
/** /**
* assigned global tpl vars * assigned global tpl vars
*/ */
public static $global_tpl_vars = array(); static $global_tpl_vars = array();
/** /**
* error handler returned by set_error_hanlder() in Smarty::muteExpectedErrors() * error handler returned by set_error_hanlder() in Smarty::muteExpectedErrors()
*/ */
public static $_previous_error_handler = null; static $_previous_error_handler = null;
/** /**
* contains directories outside of SMARTY_DIR that are to be muted by muteExpectedErrors() * contains directories outside of SMARTY_DIR that are to be muted by muteExpectedErrors()
*/ */
public static $_muted_directories = array(); static $_muted_directories = array();
/** /**
* Flag denoting if Multibyte String functions are available * Flag denoting if Multibyte String functions are available
*/ */
public static $_MBSTRING = SMARTY_MBSTRING; static $_MBSTRING = SMARTY_MBSTRING;
/** /**
* The character set to adhere to (e.g. "UTF-8") * The character set to adhere to (e.g. "UTF-8")
*/ */
public static $_CHARSET = SMARTY_RESOURCE_CHAR_SET; static $_CHARSET = SMARTY_RESOURCE_CHAR_SET;
/** /**
* The date format to be used internally * The date format to be used internally
* (accepts date() and strftime()) * (accepts date() and strftime())
*/ */
public static $_DATE_FORMAT = SMARTY_RESOURCE_DATE_FORMAT; static $_DATE_FORMAT = SMARTY_RESOURCE_DATE_FORMAT;
/** /**
* Flag denoting if PCRE should run in UTF-8 mode * Flag denoting if PCRE should run in UTF-8 mode
*/ */
public static $_UTF8_MODIFIER = 'u'; static $_UTF8_MODIFIER = 'u';
/** /**
* Flag denoting if operating system is windows * Flag denoting if operating system is windows
*/ */
public static $_IS_WINDOWS = false; static $_IS_WINDOWS = false;
/**#@+ /**#@+
* variables * variables
@@ -564,7 +564,7 @@ class Smarty extends Smarty_Internal_TemplateBase {
* global internal smarty vars * global internal smarty vars
* @var array * @var array
*/ */
public static $_smarty_vars = array(); static $_smarty_vars = array();
/** /**
* start time for execution time calculation * start time for execution time calculation
* @var int * @var int
@@ -633,7 +633,6 @@ class Smarty extends Smarty_Internal_TemplateBase {
} }
} }
/** /**
* Class destructor * Class destructor
*/ */
@@ -650,7 +649,6 @@ class Smarty extends Smarty_Internal_TemplateBase {
$this->smarty = $this; $this->smarty = $this;
} }
/** /**
* <<magic>> Generic getter. * <<magic>> Generic getter.
* *
@@ -717,6 +715,7 @@ class Smarty extends Smarty_Internal_TemplateBase {
// check if it does exists // check if it does exists
$result = $tpl->source->exists; $result = $tpl->source->exists;
$this->template_objects = $save; $this->template_objects = $save;
return $result; return $result;
} }
@@ -740,6 +739,7 @@ class Smarty extends Smarty_Internal_TemplateBase {
foreach (self::$global_tpl_vars AS $key => $var) { foreach (self::$global_tpl_vars AS $key => $var) {
$_result[$key] = $var->value; $_result[$key] = $var->value;
} }
return $_result; return $_result;
} }
} }
@@ -751,11 +751,12 @@ class Smarty extends Smarty_Internal_TemplateBase {
* @param string $type resource type * @param string $type resource type
* @return integer number of cache files deleted * @return integer number of cache files deleted
*/ */
function clearAllCache($exp_time = null, $type = null) public function clearAllCache($exp_time = null, $type = null)
{ {
// load cache resource and call clearAll // load cache resource and call clearAll
$_cache_resource = Smarty_CacheResource::load($this, $type); $_cache_resource = Smarty_CacheResource::load($this, $type);
Smarty_CacheResource::invalidLoadedCache($this); Smarty_CacheResource::invalidLoadedCache($this);
return $_cache_resource->clearAll($this, $exp_time); return $_cache_resource->clearAll($this, $exp_time);
} }
@@ -774,6 +775,7 @@ class Smarty extends Smarty_Internal_TemplateBase {
// load cache resource and call clear // load cache resource and call clear
$_cache_resource = Smarty_CacheResource::load($this, $type); $_cache_resource = Smarty_CacheResource::load($this, $type);
Smarty_CacheResource::invalidLoadedCache($this); Smarty_CacheResource::invalidLoadedCache($this);
return $_cache_resource->clear($this, $template_name, $cache_id, $compile_id, $exp_time); return $_cache_resource->clear($this, $template_name, $cache_id, $compile_id, $exp_time);
} }
@@ -788,6 +790,7 @@ class Smarty extends Smarty_Internal_TemplateBase {
{ {
if ($security_class instanceof Smarty_Security) { if ($security_class instanceof Smarty_Security) {
$this->security_policy = $security_class; $this->security_policy = $security_class;
return $this; return $this;
} elseif (is_object($security_class)) { } elseif (is_object($security_class)) {
throw new SmartyException("Class '" . get_class($security_class) . "' must extend Smarty_Security."); throw new SmartyException("Class '" . get_class($security_class) . "' must extend Smarty_Security.");
@@ -831,6 +834,7 @@ class Smarty extends Smarty_Internal_TemplateBase {
} }
$this->joined_template_dir = join(DIRECTORY_SEPARATOR, $this->template_dir); $this->joined_template_dir = join(DIRECTORY_SEPARATOR, $this->template_dir);
return $this; return $this;
} }
@@ -865,6 +869,7 @@ class Smarty extends Smarty_Internal_TemplateBase {
$this->template_dir[] = rtrim($template_dir, '/\\') . DS; $this->template_dir[] = rtrim($template_dir, '/\\') . DS;
} }
$this->joined_template_dir = join(DIRECTORY_SEPARATOR, $this->template_dir); $this->joined_template_dir = join(DIRECTORY_SEPARATOR, $this->template_dir);
return $this; return $this;
} }
@@ -897,6 +902,7 @@ class Smarty extends Smarty_Internal_TemplateBase {
} }
$this->joined_config_dir = join(DIRECTORY_SEPARATOR, $this->config_dir); $this->joined_config_dir = join(DIRECTORY_SEPARATOR, $this->config_dir);
return $this; return $this;
} }
@@ -931,6 +937,7 @@ class Smarty extends Smarty_Internal_TemplateBase {
} }
$this->joined_config_dir = join(DIRECTORY_SEPARATOR, $this->config_dir); $this->joined_config_dir = join(DIRECTORY_SEPARATOR, $this->config_dir);
return $this; return $this;
} }
@@ -993,6 +1000,7 @@ class Smarty extends Smarty_Internal_TemplateBase {
} }
$this->plugins_dir = array_unique($this->plugins_dir); $this->plugins_dir = array_unique($this->plugins_dir);
return $this; return $this;
} }
@@ -1018,6 +1026,7 @@ class Smarty extends Smarty_Internal_TemplateBase {
if (!isset(Smarty::$_muted_directories[$this->compile_dir])) { if (!isset(Smarty::$_muted_directories[$this->compile_dir])) {
Smarty::$_muted_directories[$this->compile_dir] = null; Smarty::$_muted_directories[$this->compile_dir] = null;
} }
return $this; return $this;
} }
@@ -1043,6 +1052,7 @@ class Smarty extends Smarty_Internal_TemplateBase {
if (!isset(Smarty::$_muted_directories[$this->cache_dir])) { if (!isset(Smarty::$_muted_directories[$this->cache_dir])) {
Smarty::$_muted_directories[$this->cache_dir] = null; Smarty::$_muted_directories[$this->cache_dir] = null;
} }
return $this; return $this;
} }
@@ -1065,6 +1075,7 @@ class Smarty extends Smarty_Internal_TemplateBase {
public function setDefaultModifiers($modifiers) public function setDefaultModifiers($modifiers)
{ {
$this->default_modifiers = (array) $modifiers; $this->default_modifiers = (array) $modifiers;
return $this; return $this;
} }
@@ -1247,6 +1258,7 @@ class Smarty extends Smarty_Internal_TemplateBase {
$tpl->tpl_vars[$_key] = new Smarty_variable($_val); $tpl->tpl_vars[$_key] = new Smarty_variable($_val);
} }
} }
return $tpl; return $tpl;
} }
@@ -1272,6 +1284,7 @@ class Smarty extends Smarty_Internal_TemplateBase {
// count($_name_parts) < 3 === !isset($_name_parts[2]) // count($_name_parts) < 3 === !isset($_name_parts[2])
if (!isset($_name_parts[2]) || strtolower($_name_parts[0]) !== 'smarty') { if (!isset($_name_parts[2]) || strtolower($_name_parts[0]) !== 'smarty') {
throw new SmartyException("plugin {$plugin_name} is not a valid name format"); throw new SmartyException("plugin {$plugin_name} is not a valid name format");
return false; return false;
} }
// if type is "internal", get plugin from sysplugins // if type is "internal", get plugin from sysplugins
@@ -1279,6 +1292,7 @@ class Smarty extends Smarty_Internal_TemplateBase {
$file = SMARTY_SYSPLUGINS_DIR . strtolower($plugin_name) . '.php'; $file = SMARTY_SYSPLUGINS_DIR . strtolower($plugin_name) . '.php';
if (file_exists($file)) { if (file_exists($file)) {
require_once($file); require_once($file);
return $file; return $file;
} else { } else {
return false; return false;
@@ -1298,6 +1312,7 @@ class Smarty extends Smarty_Internal_TemplateBase {
foreach ($names as $file) { foreach ($names as $file) {
if (file_exists($file)) { if (file_exists($file)) {
require_once($file); require_once($file);
return $file; return $file;
} }
if ($this->use_include_path && !preg_match('/^([\/\\\\]|[a-zA-Z]:[\/\\\\])/', $_plugin_dir)) { if ($this->use_include_path && !preg_match('/^([\/\\\\]|[a-zA-Z]:[\/\\\\])/', $_plugin_dir)) {
@@ -1310,6 +1325,7 @@ class Smarty extends Smarty_Internal_TemplateBase {
if ($file !== false) { if ($file !== false) {
require_once($file); require_once($file);
return $file; return $file;
} }
} }
@@ -1390,7 +1406,7 @@ class Smarty extends Smarty_Internal_TemplateBase {
* @param integer $errno Error level * @param integer $errno Error level
* @return boolean * @return boolean
*/ */
public static function mutingErrorHandler($errno, $errstr, $errfile, $errline, $errcontext) static function mutingErrorHandler($errno, $errstr, $errfile, $errline, $errcontext)
{ {
$_is_muted_directory = false; $_is_muted_directory = false;
@@ -1442,7 +1458,7 @@ class Smarty extends Smarty_Internal_TemplateBase {
* *
* @return void * @return void
*/ */
public static function muteExpectedErrors() static function muteExpectedErrors()
{ {
/* /*
error muting is done because some people implemented custom error_handlers using error muting is done because some people implemented custom error_handlers using
@@ -1474,7 +1490,7 @@ class Smarty extends Smarty_Internal_TemplateBase {
* *
* @return void * @return void
*/ */
public static function unmuteExpectedErrors() static function unmuteExpectedErrors()
{ {
restore_error_handler(); restore_error_handler();
} }
@@ -1492,9 +1508,11 @@ if (Smarty::$_CHARSET !== 'UTF-8') {
* Smarty exception class * Smarty exception class
* @package Smarty * @package Smarty
*/ */
class SmartyException extends Exception { class SmartyException extends Exception
public static $escape = true; {
public function __construct($message) { static $escape = true;
public function __construct($message)
{
$this->message = self::$escape ? htmlentities($message) : $message; $this->message = self::$escape ? htmlentities($message) : $message;
} }
} }
@@ -1503,7 +1521,8 @@ class SmartyException extends Exception {
* Smarty compiler exception class * Smarty compiler exception class
* @package Smarty * @package Smarty
*/ */
class SmartyCompilerException extends SmartyException { class SmartyCompilerException extends SmartyException
{
} }
/** /**
@@ -1529,5 +1548,3 @@ function smartyAutoload($class)
include SMARTY_SYSPLUGINS_DIR . $_class . '.php'; include SMARTY_SYSPLUGINS_DIR . $_class . '.php';
} }
} }
?>

View File

@@ -39,8 +39,8 @@ require(dirname(__FILE__) . '/Smarty.class.php');
* *
* @package Smarty * @package Smarty
*/ */
class SmartyBC extends Smarty { class SmartyBC extends Smarty
{
/** /**
* Smarty 2 BC * Smarty 2 BC
* @var string * @var string
@@ -454,7 +454,6 @@ class SmartyBC extends Smarty {
function smarty_php_tag($params, $content, $template, &$repeat) function smarty_php_tag($params, $content, $template, &$repeat)
{ {
eval($content); eval($content);
return ''; return '';
} }
?>

View File

@@ -78,7 +78,6 @@ function smarty_block_textformat($params, $content, $template, &$repeat)
$_paragraphs = preg_split('![\r\n]{2}!', $content); $_paragraphs = preg_split('![\r\n]{2}!', $content);
$_output = ''; $_output = '';
foreach ($_paragraphs as &$_paragraph) { foreach ($_paragraphs as &$_paragraph) {
if (!$_paragraph) { if (!$_paragraph) {
continue; continue;
@@ -109,5 +108,3 @@ function smarty_block_textformat($params, $content, $template, &$repeat)
return $_output; return $_output;
} }
} }
?>

View File

@@ -74,5 +74,3 @@ function smarty_function_counter($params, $template)
return $retval; return $retval;
} }
?>

View File

@@ -55,6 +55,7 @@ function smarty_function_cycle($params, $template)
if (!isset($params['values'])) { if (!isset($params['values'])) {
if (!isset($cycle_vars[$name]['values'])) { if (!isset($cycle_vars[$name]['values'])) {
trigger_error("cycle: missing 'values' parameter"); trigger_error("cycle: missing 'values' parameter");
return; return;
} }
} else { } else {
@@ -102,5 +103,3 @@ function smarty_function_cycle($params, $template)
return $retval; return $retval;
} }
?>

View File

@@ -24,6 +24,7 @@ function smarty_function_fetch($params, $template)
{ {
if (empty($params['file'])) { if (empty($params['file'])) {
trigger_error("[plugin] fetch parameter 'file' cannot be empty",E_USER_NOTICE); trigger_error("[plugin] fetch parameter 'file' cannot be empty",E_USER_NOTICE);
return; return;
} }
@@ -101,6 +102,7 @@ function smarty_function_fetch($params, $template)
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; return;
} else { } else {
$extra_headers[] = $param_value; $extra_headers[] = $param_value;
@@ -117,6 +119,7 @@ function smarty_function_fetch($params, $template)
$proxy_port = (int) $param_value; $proxy_port = (int) $param_value;
} else { } else {
trigger_error("[plugin] invalid value for attribute '".$param_key."'",E_USER_NOTICE); trigger_error("[plugin] invalid value for attribute '".$param_key."'",E_USER_NOTICE);
return; return;
} }
break; break;
@@ -135,11 +138,13 @@ function smarty_function_fetch($params, $template)
$timeout = (int) $param_value; $timeout = (int) $param_value;
} else { } else {
trigger_error("[plugin] invalid value for attribute '".$param_key."'",E_USER_NOTICE); trigger_error("[plugin] invalid value for attribute '".$param_key."'",E_USER_NOTICE);
return; return;
} }
break; break;
default: default:
trigger_error("[plugin] unrecognized attribute '".$param_key."'",E_USER_NOTICE); trigger_error("[plugin] unrecognized attribute '".$param_key."'",E_USER_NOTICE);
return; return;
} }
} }
@@ -152,6 +157,7 @@ function smarty_function_fetch($params, $template)
if (!$fp) { if (!$fp) {
trigger_error("[plugin] unable to fetch: $errstr ($errno)",E_USER_NOTICE); trigger_error("[plugin] unable to fetch: $errstr ($errno)",E_USER_NOTICE);
return; return;
} else { } else {
if ($_is_proxy) { if ($_is_proxy) {
@@ -195,6 +201,7 @@ function smarty_function_fetch($params, $template)
} }
} else { } else {
trigger_error("[plugin fetch] unable to parse URL, check syntax",E_USER_NOTICE); trigger_error("[plugin fetch] unable to parse URL, check syntax",E_USER_NOTICE);
return; return;
} }
} else { } else {
@@ -210,5 +217,3 @@ function smarty_function_fetch($params, $template)
return $content; return $content;
} }
} }
?>

View File

@@ -167,7 +167,8 @@ function smarty_function_html_checkboxes($params, $template)
} }
function smarty_function_html_checkboxes_output($name, $value, $output, $selected, $extra, $separator, $labels, $label_ids, $escape=true) { function smarty_function_html_checkboxes_output($name, $value, $output, $selected, $extra, $separator, $labels, $label_ids, $escape=true)
{
$_output = ''; $_output = '';
if (is_object($value)) { if (is_object($value)) {
@@ -175,6 +176,7 @@ function smarty_function_html_checkboxes_output($name, $value, $output, $selecte
$value = (string) $value->__toString(); $value = (string) $value->__toString();
} else { } else {
trigger_error("html_options: value is an object of class '". get_class($value) ."' without __toString() method", E_USER_NOTICE); trigger_error("html_options: value is an object of class '". get_class($value) ."' without __toString() method", E_USER_NOTICE);
return ''; return '';
} }
} else { } else {
@@ -186,6 +188,7 @@ function smarty_function_html_checkboxes_output($name, $value, $output, $selecte
$output = (string) $output->__toString(); $output = (string) $output->__toString();
} else { } else {
trigger_error("html_options: output is an object of class '". get_class($output) ."' without __toString() method", E_USER_NOTICE); trigger_error("html_options: output is an object of class '". get_class($output) ."' without __toString() method", E_USER_NOTICE);
return ''; return '';
} }
} else { } else {
@@ -227,7 +230,6 @@ function smarty_function_html_checkboxes_output($name, $value, $output, $selecte
} }
$_output .= $separator; $_output .= $separator;
return $_output; return $_output;
} }
?>

View File

@@ -84,6 +84,7 @@ function smarty_function_html_image($params, $template)
if (empty($file)) { if (empty($file)) {
trigger_error("html_image: missing 'file' parameter", E_USER_NOTICE); trigger_error("html_image: missing 'file' parameter", E_USER_NOTICE);
return; return;
} }
@@ -122,12 +123,15 @@ function smarty_function_html_image($params, $template)
if (!$_image_data = @getimagesize($_image_path)) { if (!$_image_data = @getimagesize($_image_path)) {
if (!file_exists($_image_path)) { if (!file_exists($_image_path)) {
trigger_error("html_image: unable to find '$_image_path'", E_USER_NOTICE); trigger_error("html_image: unable to find '$_image_path'", E_USER_NOTICE);
return; return;
} elseif (!is_readable($_image_path)) { } elseif (!is_readable($_image_path)) {
trigger_error("html_image: unable to read '$_image_path'", E_USER_NOTICE); trigger_error("html_image: unable to read '$_image_path'", E_USER_NOTICE);
return; return;
} else { } else {
trigger_error("html_image: '$_image_path' is not a valid image file", E_USER_NOTICE); trigger_error("html_image: '$_image_path' is not a valid image file", E_USER_NOTICE);
return; return;
} }
} }
@@ -155,5 +159,3 @@ function smarty_function_html_image($params, $template)
return $prefix . '<img src="' . $path_prefix . $file . '" alt="' . $alt . '" width="' . $width . '" height="' . $height . '"' . $extra . ' />' . $suffix; return $prefix . '<img src="' . $path_prefix . $file . '" alt="' . $alt . '" width="' . $width . '" height="' . $height . '"' . $extra . ' />' . $suffix;
} }
?>

View File

@@ -120,6 +120,7 @@ function smarty_function_html_options($params, $template)
if (!isset($options) && !isset($values)) { if (!isset($options) && !isset($values)) {
/* raise error here? */ /* raise error here? */
return ''; return '';
} }
@@ -165,6 +166,7 @@ function smarty_function_html_options_optoutput($key, $value, $selected, $id, $c
$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) ."' without __toString() method", E_USER_NOTICE); trigger_error("html_options: value is an object of class '". get_class($value) ."' without __toString() method", E_USER_NOTICE);
return ''; return '';
} }
} else { } else {
@@ -177,6 +179,7 @@ function smarty_function_html_options_optoutput($key, $value, $selected, $id, $c
$_html_result = smarty_function_html_options_optgroup($key, $value, $selected, !empty($id) ? ($id.'-'.$idx) : null, $class, $_idx); $_html_result = smarty_function_html_options_optgroup($key, $value, $selected, !empty($id) ? ($id.'-'.$idx) : null, $class, $_idx);
$idx++; $idx++;
} }
return $_html_result; return $_html_result;
} }
@@ -187,7 +190,6 @@ function smarty_function_html_options_optgroup($key, $values, $selected, $id, $c
$optgroup_html .= smarty_function_html_options_optoutput($key, $value, $selected, $id, $class, $idx); $optgroup_html .= smarty_function_html_options_optoutput($key, $value, $selected, $id, $class, $idx);
} }
$optgroup_html .= "</optgroup>\n"; $optgroup_html .= "</optgroup>\n";
return $optgroup_html; return $optgroup_html;
} }
?>

View File

@@ -131,6 +131,7 @@ function smarty_function_html_radios($params, $template)
if (!isset($options) && !isset($values)) { if (!isset($options) && !isset($values)) {
/* raise error here? */ /* raise error here? */
return ''; return '';
} }
@@ -163,6 +164,7 @@ function smarty_function_html_radios_output($name, $value, $output, $selected, $
$value = (string) $value->__toString(); $value = (string) $value->__toString();
} else { } else {
trigger_error("html_options: value is an object of class '". get_class($value) ."' without __toString() method", E_USER_NOTICE); trigger_error("html_options: value is an object of class '". get_class($value) ."' without __toString() method", E_USER_NOTICE);
return ''; return '';
} }
} else { } else {
@@ -174,6 +176,7 @@ function smarty_function_html_radios_output($name, $value, $output, $selected, $
$output = (string) $output->__toString(); $output = (string) $output->__toString();
} else { } else {
trigger_error("html_options: output is an object of class '". get_class($output) ."' without __toString() method", E_USER_NOTICE); trigger_error("html_options: output is an object of class '". get_class($output) ."' without __toString() method", E_USER_NOTICE);
return ''; return '';
} }
} else { } else {
@@ -211,7 +214,6 @@ function smarty_function_html_radios_output($name, $value, $output, $selected, $
} }
$_output .= $separator; $_output .= $separator;
return $_output; return $_output;
} }
?>

View File

@@ -388,7 +388,6 @@ function smarty_function_html_select_date($params, $template)
break; break;
} }
} }
return $_html; return $_html;
} }
?>

View File

@@ -362,5 +362,3 @@ function smarty_function_html_select_time($params, $template)
return $_html; return $_html;
} }
?>

View File

@@ -64,6 +64,7 @@ function smarty_function_html_table($params, $template)
if (!isset($params['loop'])) { if (!isset($params['loop'])) {
trigger_error("html_table: missing 'loop' parameter",E_USER_WARNING); trigger_error("html_table: missing 'loop' parameter",E_USER_WARNING);
return; return;
} }
@@ -173,5 +174,3 @@ function smarty_function_html_table_cycle($name, $var, $no)
return ($ret) ? ' ' . $ret : ''; return ($ret) ? ' ' . $ret : '';
} }
?>

View File

@@ -55,6 +55,7 @@ function smarty_function_mailto($params, $template)
if (empty($params['address'])) { if (empty($params['address'])) {
trigger_error("mailto: missing 'address' parameter",E_USER_WARNING); trigger_error("mailto: missing 'address' parameter",E_USER_WARNING);
return; return;
} else { } else {
$address = $params['address']; $address = $params['address'];
@@ -95,6 +96,7 @@ function smarty_function_mailto($params, $template)
$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", E_USER_WARNING); trigger_error("mailto: 'encode' parameter must be none, javascript, javascript_charcode or hex", E_USER_WARNING);
return; return;
} }
// FIXME: (rodneyrehm) document.write() excues me what? 1998 has passed! // FIXME: (rodneyrehm) document.write() excues me what? 1998 has passed!
@@ -126,6 +128,7 @@ function smarty_function_mailto($params, $template)
preg_match('!^(.*)(\?.*)$!', $address, $match); preg_match('!^(.*)(\?.*)$!', $address, $match);
if (!empty($match[2])) { if (!empty($match[2])) {
trigger_error("mailto: hex encoding does not work with extra attributes. Try javascript.",E_USER_WARNING); trigger_error("mailto: hex encoding does not work with extra attributes. Try javascript.",E_USER_WARNING);
return; return;
} }
$address_encode = ''; $address_encode = '';
@@ -142,11 +145,10 @@ function smarty_function_mailto($params, $template)
} }
$mailto = "&#109;&#97;&#105;&#108;&#116;&#111;&#58;"; $mailto = "&#109;&#97;&#105;&#108;&#116;&#111;&#58;";
return '<a href="' . $mailto . $address_encode . '" ' . $extra . '>' . $text_encode . '</a>'; return '<a href="' . $mailto . $address_encode . '" ' . $extra . '>' . $text_encode . '</a>';
} else { } else {
// no encoding // no encoding
return '<a href="mailto:' . $address . '" ' . $extra . '>' . $text . '</a>'; return '<a href="mailto:' . $address . '" ' . $extra . '>' . $text . '</a>';
} }
} }
?>

View File

@@ -31,6 +31,7 @@ function smarty_function_math($params, $template)
// be sure equation parameter is present // be sure equation parameter is present
if (empty($params['equation'])) { if (empty($params['equation'])) {
trigger_error("math: missing equation parameter",E_USER_WARNING); trigger_error("math: missing equation parameter",E_USER_WARNING);
return; return;
} }
@@ -39,6 +40,7 @@ function smarty_function_math($params, $template)
// make sure parenthesis are balanced // make sure parenthesis are balanced
if (substr_count($equation,"(") != substr_count($equation,")")) { if (substr_count($equation,"(") != substr_count($equation,")")) {
trigger_error("math: unbalanced parenthesis",E_USER_WARNING); trigger_error("math: unbalanced parenthesis",E_USER_WARNING);
return; return;
} }
@@ -48,6 +50,7 @@ function smarty_function_math($params, $template)
foreach ($match[1] as $curr_var) { foreach ($match[1] as $curr_var) {
if ($curr_var && !isset($params[$curr_var]) && !isset($_allowed_funcs[$curr_var])) { if ($curr_var && !isset($params[$curr_var]) && !isset($_allowed_funcs[$curr_var])) {
trigger_error("math: function call $curr_var not allowed",E_USER_WARNING); trigger_error("math: function call $curr_var not allowed",E_USER_WARNING);
return; return;
} }
} }
@@ -57,10 +60,12 @@ function smarty_function_math($params, $template)
// make sure value is not empty // make sure value is not empty
if (strlen($val)==0) { if (strlen($val)==0) {
trigger_error("math: parameter $key is empty",E_USER_WARNING); trigger_error("math: parameter $key is empty",E_USER_WARNING);
return; return;
} }
if (!is_numeric($val)) { if (!is_numeric($val)) {
trigger_error("math: parameter $key: is not numeric",E_USER_WARNING); trigger_error("math: parameter $key: is not numeric",E_USER_WARNING);
return; return;
} }
$equation = preg_replace("/\b$key\b/", " \$params['$key'] ", $equation); $equation = preg_replace("/\b$key\b/", " \$params['$key'] ", $equation);
@@ -83,5 +88,3 @@ function smarty_function_math($params, $template)
} }
} }
} }
?>

View File

@@ -41,6 +41,7 @@ function smarty_modifier_capitalize($string, $uc_digits = false, $lc_rest = fals
} }
} }
$upper_string = preg_replace_callback("!((^|\s)['\"])(\w)!" . Smarty::$_UTF8_MODIFIER, create_function ('$matches', 'return stripslashes($matches[1]).mb_convert_case(stripslashes($matches[3]),MB_CASE_UPPER, "' . addslashes(Smarty::$_CHARSET) . '");'), $upper_string); $upper_string = preg_replace_callback("!((^|\s)['\"])(\w)!" . Smarty::$_UTF8_MODIFIER, create_function ('$matches', 'return stripslashes($matches[1]).mb_convert_case(stripslashes($matches[3]),MB_CASE_UPPER, "' . addslashes(Smarty::$_CHARSET) . '");'), $upper_string);
return $upper_string; return $upper_string;
} }
@@ -59,7 +60,6 @@ function smarty_modifier_capitalize($string, $uc_digits = false, $lc_rest = fals
} }
} }
$upper_string = preg_replace_callback("!((^|\s)['\"])(\w)!" . Smarty::$_UTF8_MODIFIER, create_function ('$matches', 'return stripslashes($matches[1]).ucfirst(stripslashes($matches[3]));'), $upper_string); $upper_string = preg_replace_callback("!((^|\s)['\"])(\w)!" . Smarty::$_UTF8_MODIFIER, create_function ('$matches', 'return stripslashes($matches[1]).ucfirst(stripslashes($matches[3]));'), $upper_string);
return $upper_string; return $upper_string;
} }
?>

View File

@@ -56,10 +56,9 @@ function smarty_modifier_date_format($string, $format=null, $default_date='', $f
} }
$format = str_replace($_win_from, $_win_to, $format); $format = str_replace($_win_from, $_win_to, $format);
} }
return strftime($format, $timestamp); return strftime($format, $timestamp);
} else { } else {
return date($format, $timestamp); return date($format, $timestamp);
} }
} }
?>

View File

@@ -101,5 +101,3 @@ function smarty_modifier_debug_print_var ($var, $depth = 0, $length = 40)
return $results; return $results;
} }
?>

View File

@@ -46,6 +46,7 @@ function smarty_modifier_escape($string, $esc_type = 'html', $char_set = null, $
$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%%%', '%%%SMARTY_END%%%'), array('&', ';'), $string); $string = str_replace(array('%%%SMARTY_START%%%', '%%%SMARTY_END%%%'), array('&', ';'), $string);
return $string; return $string;
} }
} }
@@ -65,6 +66,7 @@ function smarty_modifier_escape($string, $esc_type = 'html', $char_set = null, $
$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%%%', '%%%SMARTY_END%%%'), array('&', ';'), $string); $string = str_replace(array('%%%SMARTY_START%%%', '%%%SMARTY_END%%%'), array('&', ';'), $string);
return $string; return $string;
} }
} }
@@ -83,6 +85,7 @@ function smarty_modifier_escape($string, $esc_type = 'html', $char_set = null, $
$string = preg_replace('!&(#?\w+);!', '%%%SMARTY_START%%%\\1%%%SMARTY_END%%%', $string); $string = preg_replace('!&(#?\w+);!', '%%%SMARTY_START%%%\\1%%%SMARTY_END%%%', $string);
$string = htmlentities($string, ENT_QUOTES, $char_set); $string = htmlentities($string, ENT_QUOTES, $char_set);
$string = str_replace(array('%%%SMARTY_START%%%', '%%%SMARTY_END%%%'), array('&', ';'), $string); $string = str_replace(array('%%%SMARTY_START%%%', '%%%SMARTY_END%%%'), array('&', ';'), $string);
return $string; return $string;
} }
} }
@@ -105,6 +108,7 @@ function smarty_modifier_escape($string, $esc_type = 'html', $char_set = null, $
for ($x = 0; $x < $_length; $x++) { for ($x = 0; $x < $_length; $x++) {
$return .= '%' . bin2hex($string[$x]); $return .= '%' . bin2hex($string[$x]);
} }
return $return; return $return;
case 'hexentity': case 'hexentity':
@@ -115,6 +119,7 @@ function smarty_modifier_escape($string, $esc_type = 'html', $char_set = null, $
foreach (smarty_mb_to_unicode($string, Smarty::$_CHARSET) as $unicode) { foreach (smarty_mb_to_unicode($string, Smarty::$_CHARSET) as $unicode) {
$return .= '&#x' . strtoupper(dechex($unicode)) . ';'; $return .= '&#x' . strtoupper(dechex($unicode)) . ';';
} }
return $return; return $return;
} }
// no MBString fallback // no MBString fallback
@@ -122,6 +127,7 @@ function smarty_modifier_escape($string, $esc_type = 'html', $char_set = null, $
for ($x = 0; $x < $_length; $x++) { for ($x = 0; $x < $_length; $x++) {
$return .= '&#x' . bin2hex($string[$x]) . ';'; $return .= '&#x' . bin2hex($string[$x]) . ';';
} }
return $return; return $return;
case 'decentity': case 'decentity':
@@ -132,6 +138,7 @@ function smarty_modifier_escape($string, $esc_type = 'html', $char_set = null, $
foreach (smarty_mb_to_unicode($string, Smarty::$_CHARSET) as $unicode) { foreach (smarty_mb_to_unicode($string, Smarty::$_CHARSET) as $unicode) {
$return .= '&#' . $unicode . ';'; $return .= '&#' . $unicode . ';';
} }
return $return; return $return;
} }
// no MBString fallback // no MBString fallback
@@ -139,6 +146,7 @@ function smarty_modifier_escape($string, $esc_type = 'html', $char_set = null, $
for ($x = 0; $x < $_length; $x++) { for ($x = 0; $x < $_length; $x++) {
$return .= '&#' . ord($string[$x]) . ';'; $return .= '&#' . ord($string[$x]) . ';';
} }
return $return; return $return;
case 'javascript': case 'javascript':
@@ -148,6 +156,7 @@ function smarty_modifier_escape($string, $esc_type = 'html', $char_set = null, $
case 'mail': case 'mail':
if (Smarty::$_MBSTRING) { if (Smarty::$_MBSTRING) {
require_once(SMARTY_PLUGINS_DIR . 'shared.mb_str_replace.php'); require_once(SMARTY_PLUGINS_DIR . 'shared.mb_str_replace.php');
return smarty_mb_str_replace(array('@', '.'), array(' [AT] ', ' [DOT] '), $string); return smarty_mb_str_replace(array('@', '.'), array(' [AT] ', ' [DOT] '), $string);
} }
// no MBString fallback // no MBString fallback
@@ -165,6 +174,7 @@ function smarty_modifier_escape($string, $esc_type = 'html', $char_set = null, $
$return .= chr($unicode); $return .= chr($unicode);
} }
} }
return $return; return $return;
} }
@@ -178,11 +188,10 @@ function smarty_modifier_escape($string, $esc_type = 'html', $char_set = null, $
$return .= substr($string, $_i, 1); $return .= substr($string, $_i, 1);
} }
} }
return $return; return $return;
default: default:
return $string; return $string;
} }
} }
?>

View File

@@ -30,6 +30,7 @@ function smarty_modifier_regex_replace($string, $search, $replace)
} else { } else {
$search = _smarty_regex_replace_check($search); $search = _smarty_regex_replace_check($search);
} }
return preg_replace($search, $replace, $string); return preg_replace($search, $replace, $string);
} }
@@ -49,7 +50,6 @@ function _smarty_regex_replace_check($search)
if (preg_match('!([a-zA-Z\s]+)$!s', $search, $match) && (strpos($match[1], 'e') !== false)) { if (preg_match('!([a-zA-Z\s]+)$!s', $search, $match) && (strpos($match[1], 'e') !== false)) {
$search = substr($search, 0, -strlen($match[1])) . preg_replace('![e\s]+!', '', $match[1]); $search = substr($search, 0, -strlen($match[1])) . preg_replace('![e\s]+!', '', $match[1]);
} }
return $search; return $search;
} }
?>

View File

@@ -24,10 +24,9 @@ function smarty_modifier_replace($string, $search, $replace)
{ {
if (Smarty::$_MBSTRING) { if (Smarty::$_MBSTRING) {
require_once(SMARTY_PLUGINS_DIR . 'shared.mb_str_replace.php'); require_once(SMARTY_PLUGINS_DIR . 'shared.mb_str_replace.php');
return smarty_mb_str_replace($search, $replace, $string); return smarty_mb_str_replace($search, $replace, $string);
} }
return str_replace($search, $replace, $string); return str_replace($search, $replace, $string);
} }
?>

View File

@@ -23,5 +23,3 @@ function smarty_modifier_spacify($string, $spacify_char = ' ')
// well… what about charsets besides latin and UTF-8? // well… what about charsets besides latin and UTF-8?
return implode($spacify_char, preg_split('//' . Smarty::$_UTF8_MODIFIER, $string, -1, PREG_SPLIT_NO_EMPTY)); return implode($spacify_char, preg_split('//' . Smarty::$_UTF8_MODIFIER, $string, -1, PREG_SPLIT_NO_EMPTY));
} }
?>

View File

@@ -24,7 +24,8 @@
* @param boolean $middle truncate in the middle of text * @param boolean $middle truncate in the middle of text
* @return string truncated string * @return string truncated string
*/ */
function smarty_modifier_truncate($string, $length = 80, $etc = '...', $break_words = false, $middle = false) { function smarty_modifier_truncate($string, $length = 80, $etc = '...', $break_words = false, $middle = false)
{
if ($length == 0) if ($length == 0)
return ''; return '';
@@ -37,8 +38,10 @@ function smarty_modifier_truncate($string, $length = 80, $etc = '...', $break_wo
if (!$middle) { if (!$middle) {
return mb_substr($string, 0, $length, Smarty::$_CHARSET) . $etc; return mb_substr($string, 0, $length, Smarty::$_CHARSET) . $etc;
} }
return mb_substr($string, 0, $length / 2, Smarty::$_CHARSET) . $etc . mb_substr($string, - $length / 2, $length, Smarty::$_CHARSET); return mb_substr($string, 0, $length / 2, Smarty::$_CHARSET) . $etc . mb_substr($string, - $length / 2, $length, Smarty::$_CHARSET);
} }
return $string; return $string;
} }
@@ -51,9 +54,9 @@ function smarty_modifier_truncate($string, $length = 80, $etc = '...', $break_wo
if (!$middle) { if (!$middle) {
return substr($string, 0, $length) . $etc; return substr($string, 0, $length) . $etc;
} }
return substr($string, 0, $length / 2) . $etc . substr($string, - $length / 2); return substr($string, 0, $length / 2) . $etc . substr($string, - $length / 2);
} }
return $string; return $string;
} }
?>

View File

@@ -26,5 +26,3 @@ function smarty_modifiercompiler_cat($params, $compiler)
{ {
return '('.implode(').(', $params).')'; return '('.implode(').(', $params).')';
} }
?>

View File

@@ -29,5 +29,3 @@ function smarty_modifiercompiler_count_characters($params, $compiler)
// no MBString fallback // no MBString fallback
return 'strlen(' . $params[0] . ')'; return 'strlen(' . $params[0] . ')';
} }
?>

View File

@@ -24,5 +24,3 @@ function smarty_modifiercompiler_count_paragraphs($params, $compiler)
// count \r or \n characters // count \r or \n characters
return '(preg_match_all(\'#[\r\n]+#\', ' . $params[0] . ', $tmp)+1)'; return '(preg_match_all(\'#[\r\n]+#\', ' . $params[0] . ', $tmp)+1)';
} }
?>

View File

@@ -24,5 +24,3 @@ function smarty_modifiercompiler_count_sentences($params, $compiler)
// find periods, question marks, exclamation marks with a word before but not after. // find periods, question marks, exclamation marks with a word before but not after.
return 'preg_match_all("#\w[\.\?\!](\W|$)#S' . Smarty::$_UTF8_MODIFIER . '", ' . $params[0] . ', $tmp)'; return 'preg_match_all("#\w[\.\?\!](\W|$)#S' . Smarty::$_UTF8_MODIFIER . '", ' . $params[0] . ', $tmp)';
} }
?>

View File

@@ -28,5 +28,3 @@ function smarty_modifiercompiler_count_words($params, $compiler)
// no MBString fallback // no MBString fallback
return 'str_word_count(' . $params[0] . ')'; return 'str_word_count(' . $params[0] . ')';
} }
?>

View File

@@ -29,7 +29,6 @@ function smarty_modifiercompiler_default ($params, $compiler)
foreach ($params as $param) { foreach ($params as $param) {
$output = '(($tmp = @' . $output . ')===null||$tmp===\'\' ? ' . $param . ' : $tmp)'; $output = '(($tmp = @' . $output . ')===null||$tmp===\'\' ? ' . $param . ' : $tmp)';
} }
return $output; return $output;
} }
?>

View File

@@ -119,7 +119,6 @@ function smarty_modifiercompiler_escape($params, $compiler)
$compiler->template->required_plugins['compiled']['escape']['modifier']['file'] = SMARTY_PLUGINS_DIR .'modifier.escape.php'; $compiler->template->required_plugins['compiled']['escape']['modifier']['file'] = SMARTY_PLUGINS_DIR .'modifier.escape.php';
$compiler->template->required_plugins['compiled']['escape']['modifier']['function'] = 'smarty_modifier_escape'; $compiler->template->required_plugins['compiled']['escape']['modifier']['function'] = 'smarty_modifier_escape';
} }
return 'smarty_modifier_escape(' . join( ', ', $params ) . ')'; return 'smarty_modifier_escape(' . join( ', ', $params ) . ')';
} }
?>

View File

@@ -30,5 +30,3 @@ function smarty_modifiercompiler_from_charset($params, $compiler)
return 'mb_convert_encoding(' . $params[0] . ', "' . addslashes(Smarty::$_CHARSET) . '", ' . $params[1] . ')'; return 'mb_convert_encoding(' . $params[0] . ', "' . addslashes(Smarty::$_CHARSET) . '", ' . $params[1] . ')';
} }
?>

View File

@@ -26,7 +26,6 @@ function smarty_modifiercompiler_indent($params, $compiler)
if (!isset($params[2])) { if (!isset($params[2])) {
$params[2] = "' '"; $params[2] = "' '";
} }
return 'preg_replace(\'!^!m\',str_repeat(' . $params[2] . ',' . $params[1] . '),' . $params[0] . ')'; return 'preg_replace(\'!^!m\',str_repeat(' . $params[2] . ',' . $params[1] . '),' . $params[0] . ')';
} }
?>

View File

@@ -27,5 +27,3 @@ function smarty_modifiercompiler_lower($params, $compiler)
// no MBString fallback // no MBString fallback
return 'strtolower(' . $params[0] . ')'; return 'strtolower(' . $params[0] . ')';
} }
?>

View File

@@ -21,5 +21,3 @@ function smarty_modifiercompiler_noprint($params, $compiler)
{ {
return "''"; return "''";
} }
?>

View File

@@ -22,5 +22,3 @@ function smarty_modifiercompiler_string_format($params, $compiler)
{ {
return 'sprintf(' . $params[1] . ',' . $params[0] . ')'; return 'sprintf(' . $params[1] . ',' . $params[0] . ')';
} }
?>

View File

@@ -27,7 +27,6 @@ function smarty_modifiercompiler_strip($params, $compiler)
if (!isset($params[1])) { if (!isset($params[1])) {
$params[1] = "' '"; $params[1] = "' '";
} }
return "preg_replace('!\s+!" . Smarty::$_UTF8_MODIFIER . "', {$params[1]},{$params[0]})"; return "preg_replace('!\s+!" . Smarty::$_UTF8_MODIFIER . "', {$params[1]},{$params[0]})";
} }
?>

View File

@@ -30,5 +30,3 @@ function smarty_modifiercompiler_to_charset($params, $compiler)
return 'mb_convert_encoding(' . $params[0] . ', ' . $params[1] . ', "' . addslashes(Smarty::$_CHARSET) . '")'; return 'mb_convert_encoding(' . $params[0] . ', ' . $params[1] . ', "' . addslashes(Smarty::$_CHARSET) . '")';
} }
?>

View File

@@ -47,5 +47,3 @@ function smarty_modifiercompiler_unescape($params, $compiler)
return $params[0]; return $params[0];
} }
} }
?>

View File

@@ -26,5 +26,3 @@ function smarty_modifiercompiler_upper($params, $compiler)
// no MBString fallback // no MBString fallback
return 'strtoupper(' . $params[0] . ')'; return 'strtoupper(' . $params[0] . ')';
} }
?>

View File

@@ -40,7 +40,6 @@ function smarty_modifiercompiler_wordwrap($params, $compiler)
} }
$function = 'smarty_mb_wordwrap'; $function = 'smarty_mb_wordwrap';
} }
return $function . '(' . $params[0] . ',' . $params[1] . ',' . $params[2] . ',' . $params[3] . ')'; return $function . '(' . $params[0] . ',' . $params[1] . ',' . $params[2] . ',' . $params[3] . ')';
} }
?>

View File

@@ -88,5 +88,3 @@ function smarty_outputfilter_trimwhitespace($source, Smarty_Internal_Template $s
return $source; return $source;
} }
?>

View File

@@ -23,6 +23,7 @@ if (version_compare(PHP_VERSION, '5.2.3', '>=')) {
if (!is_array($string)) { if (!is_array($string)) {
$string = htmlspecialchars($string, ENT_COMPAT, Smarty::$_CHARSET, false); $string = htmlspecialchars($string, ENT_COMPAT, Smarty::$_CHARSET, false);
} }
return $string; return $string;
} }
} else { } else {
@@ -44,8 +45,7 @@ if (version_compare(PHP_VERSION, '5.2.3', '>=')) {
$string = htmlspecialchars($string); $string = htmlspecialchars($string);
$string = str_replace(array('%%%SMARTY_START%%%', '%%%SMARTY_END%%%'), array('&', ';'), $string); $string = str_replace(array('%%%SMARTY_START%%%', '%%%SMARTY_END%%%'), array('&', ';'), $string);
} }
return $string; return $string;
} }
} }
?>

View File

@@ -29,5 +29,6 @@ function smarty_literal_compiler_param($params, $index, $default=null)
$t = null; $t = null;
eval("\$t = " . $params[$index] . ";"); eval("\$t = " . $params[$index] . ";");
return $t; return $t;
} }

View File

@@ -35,8 +35,7 @@ function smarty_make_timestamp($string)
// strtotime() was not able to parse $string, use "now": // strtotime() was not able to parse $string, use "now":
return time(); return time();
} }
return $time; return $time;
} }
} }
?>

View File

@@ -48,8 +48,8 @@ if (!function_exists('smarty_mb_str_replace')) {
$count = count($parts) - 1; $count = count($parts) - 1;
$subject = implode($replace, $parts); $subject = implode($replace, $parts);
} }
return $subject; return $subject;
} }
} }
?>

View File

@@ -15,12 +15,14 @@
* @return array sequence of unicodes * @return array sequence of unicodes
* @author Rodney Rehm * @author Rodney Rehm
*/ */
function smarty_mb_to_unicode($string, $encoding=null) { function smarty_mb_to_unicode($string, $encoding=null)
{
if ($encoding) { if ($encoding) {
$expanded = mb_convert_encoding($string, "UTF-32BE", $encoding); $expanded = mb_convert_encoding($string, "UTF-32BE", $encoding);
} else { } else {
$expanded = mb_convert_encoding($string, "UTF-32BE"); $expanded = mb_convert_encoding($string, "UTF-32BE");
} }
return unpack("N*", $expanded); return unpack("N*", $expanded);
} }
@@ -33,7 +35,8 @@ function smarty_mb_to_unicode($string, $encoding=null) {
* @return string unicode as character sequence in given $encoding * @return string unicode as character sequence in given $encoding
* @author Rodney Rehm * @author Rodney Rehm
*/ */
function smarty_mb_from_unicode($unicode, $encoding=null) { function smarty_mb_from_unicode($unicode, $encoding=null)
{
$t = ''; $t = '';
if (!$encoding) { if (!$encoding) {
$encoding = mb_internal_encoding(); $encoding = mb_internal_encoding();
@@ -42,7 +45,6 @@ function smarty_mb_from_unicode($unicode, $encoding=null) {
$character = pack("N*", $utf32be); $character = pack("N*", $utf32be);
$t .= mb_convert_encoding($character, $encoding, "UTF-32BE"); $t .= mb_convert_encoding($character, $encoding, "UTF-32BE");
} }
return $t; return $t;
} }
?>

View File

@@ -80,4 +80,3 @@ if(!function_exists('smarty_mb_wordwrap')) {
} }
} }
?>

View File

@@ -17,5 +17,3 @@ function smarty_variablefilter_htmlspecialchars($source, $smarty)
{ {
return htmlspecialchars($source, ENT_QUOTES, Smarty::$_CHARSET); return htmlspecialchars($source, ENT_QUOTES, Smarty::$_CHARSET);
} }
?>

View File

@@ -13,7 +13,8 @@
* @subpackage Cacher * @subpackage Cacher
* @author Rodney Rehm * @author Rodney Rehm
*/ */
abstract class Smarty_CacheResource { abstract class Smarty_CacheResource
{
/** /**
* cache for Smarty_CacheResource instances * cache for Smarty_CacheResource instances
* @var array * @var array
@@ -35,7 +36,7 @@ abstract class Smarty_CacheResource {
* @param Smarty_Internal_Template $_template template object * @param Smarty_Internal_Template $_template template object
* @return void * @return void
*/ */
public abstract function populate(Smarty_Template_Cached $cached, Smarty_Internal_Template $_template); abstract public function populate(Smarty_Template_Cached $cached, Smarty_Internal_Template $_template);
/** /**
* populate Cached Object with timestamp and exists from Resource * populate Cached Object with timestamp and exists from Resource
@@ -43,7 +44,7 @@ abstract class Smarty_CacheResource {
* @param Smarty_Template_Cached $source cached object * @param Smarty_Template_Cached $source cached object
* @return void * @return void
*/ */
public abstract function populateTimestamp(Smarty_Template_Cached $cached); abstract public function populateTimestamp(Smarty_Template_Cached $cached);
/** /**
* Read the cached template and process header * Read the cached template and process header
@@ -52,7 +53,7 @@ abstract class Smarty_CacheResource {
* @param Smarty_Template_Cached $cached cached object * @param Smarty_Template_Cached $cached cached object
* @return booelan true or false if the cached content does not exist * @return booelan true or false if the cached content does not exist
*/ */
public abstract function process(Smarty_Internal_Template $_template, Smarty_Template_Cached $cached=null); abstract public function process(Smarty_Internal_Template $_template, Smarty_Template_Cached $cached=null);
/** /**
* Write the rendered template output to cache * Write the rendered template output to cache
@@ -61,7 +62,7 @@ abstract class Smarty_CacheResource {
* @param string $content content to cache * @param string $content content to cache
* @return boolean success * @return boolean success
*/ */
public abstract function writeCachedContent(Smarty_Internal_Template $_template, $content); abstract public function writeCachedContent(Smarty_Internal_Template $_template, $content);
/** /**
* Return cached content * Return cached content
@@ -74,8 +75,10 @@ abstract class Smarty_CacheResource {
if ($_template->cached->handler->process($_template)) { if ($_template->cached->handler->process($_template)) {
ob_start(); ob_start();
$_template->properties['unifunc']($_template); $_template->properties['unifunc']($_template);
return ob_get_clean(); return ob_get_clean();
} }
return null; return null;
} }
@@ -86,7 +89,7 @@ abstract class Smarty_CacheResource {
* @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
*/ */
public abstract function clearAll(Smarty $smarty, $exp_time=null); abstract public function clearAll(Smarty $smarty, $exp_time=null);
/** /**
* Empty cache for a specific template * Empty cache for a specific template
@@ -98,8 +101,7 @@ abstract class Smarty_CacheResource {
* @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
*/ */
public abstract function clear(Smarty $smarty, $resource_name, $cache_id, $compile_id, $exp_time); abstract public function clear(Smarty $smarty, $resource_name, $cache_id, $compile_id, $exp_time);
public function locked(Smarty $smarty, Smarty_Template_Cached $cached) public function locked(Smarty $smarty, Smarty_Template_Cached $cached)
{ {
@@ -114,6 +116,7 @@ abstract class Smarty_CacheResource {
} }
sleep(1); sleep(1);
} }
return $hadLock; return $hadLock;
} }
@@ -135,7 +138,6 @@ abstract class Smarty_CacheResource {
return true; return true;
} }
/** /**
* Load Cache Resource Handler * Load Cache Resource Handler
* *
@@ -165,6 +167,7 @@ abstract class Smarty_CacheResource {
$cache_resource_class = 'Smarty_Internal_CacheResource_' . ucfirst($type); $cache_resource_class = 'Smarty_Internal_CacheResource_' . ucfirst($type);
self::$resources[$type] = new $cache_resource_class(); self::$resources[$type] = new $cache_resource_class();
} }
return $smarty->_cacheresource_handlers[$type] = self::$resources[$type]; return $smarty->_cacheresource_handlers[$type] = self::$resources[$type];
} }
// try plugins dir // try plugins dir
@@ -173,6 +176,7 @@ abstract class Smarty_CacheResource {
if (!isset(self::$resources[$type])) { if (!isset(self::$resources[$type])) {
self::$resources[$type] = new $cache_resource_class(); self::$resources[$type] = new $cache_resource_class();
} }
return $smarty->_cacheresource_handlers[$type] = self::$resources[$type]; return $smarty->_cacheresource_handlers[$type] = self::$resources[$type];
} }
// give up // give up
@@ -204,7 +208,8 @@ abstract class Smarty_CacheResource {
* @subpackage TemplateResources * @subpackage TemplateResources
* @author Rodney Rehm * @author Rodney Rehm
*/ */
class Smarty_Template_Cached { class Smarty_Template_Cached
{
/** /**
* Source Filepath * Source Filepath
* @var string * @var string
@@ -300,6 +305,7 @@ class Smarty_Template_Cached {
// //
if (!($_template->caching == Smarty::CACHING_LIFETIME_CURRENT || $_template->caching == Smarty::CACHING_LIFETIME_SAVED) || $_template->source->recompiled) { if (!($_template->caching == Smarty::CACHING_LIFETIME_CURRENT || $_template->caching == Smarty::CACHING_LIFETIME_SAVED) || $_template->source->recompiled) {
$handler->populate($this, $_template); $handler->populate($this, $_template);
return; return;
} }
while (true) { while (true) {
@@ -347,6 +353,7 @@ class Smarty_Template_Cached {
} }
if (!$this->valid && $_template->smarty->cache_locking) { if (!$this->valid && $_template->smarty->cache_locking) {
$this->handler->acquireLock($_template->smarty, $this); $this->handler->acquireLock($_template->smarty, $this);
return; return;
} else { } else {
return; return;
@@ -371,11 +378,12 @@ class Smarty_Template_Cached {
if ($_template->smarty->cache_locking) { if ($_template->smarty->cache_locking) {
$this->handler->releaseLock($_template->smarty, $this); $this->handler->releaseLock($_template->smarty, $this);
} }
return true; return true;
} }
} }
return false; return false;
} }
} }
?>

View File

@@ -13,8 +13,8 @@
* @subpackage Cacher * @subpackage Cacher
* @author Rodney Rehm * @author Rodney Rehm
*/ */
abstract class Smarty_CacheResource_Custom extends Smarty_CacheResource { 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
* *
@@ -26,7 +26,7 @@ abstract class Smarty_CacheResource_Custom extends Smarty_CacheResource {
* @param integer $mtime cache modification timestamp (epoch) * @param integer $mtime cache modification timestamp (epoch)
* @return void * @return void
*/ */
protected abstract function fetch($id, $name, $cache_id, $compile_id, &$content, &$mtime); abstract protected function fetch($id, $name, $cache_id, $compile_id, &$content, &$mtime);
/** /**
* Fetch cached content's modification timestamp from data source * Fetch cached content's modification timestamp from data source
@@ -56,7 +56,7 @@ abstract class Smarty_CacheResource_Custom extends Smarty_CacheResource {
* @param string $content content to cache * @param string $content content to cache
* @return boolean success * @return boolean success
*/ */
protected abstract function save($id, $name, $cache_id, $compile_id, $exp_time, $content); abstract protected function save($id, $name, $cache_id, $compile_id, $exp_time, $content);
/** /**
* Delete content from cache * Delete content from cache
@@ -67,7 +67,7 @@ abstract class Smarty_CacheResource_Custom extends Smarty_CacheResource {
* @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
*/ */
protected abstract function delete($name, $cache_id, $compile_id, $exp_time); abstract protected function delete($name, $cache_id, $compile_id, $exp_time);
/** /**
* populate Cached Object with meta data from Resource * populate Cached Object with meta data from Resource
@@ -97,6 +97,7 @@ abstract class Smarty_CacheResource_Custom extends Smarty_CacheResource {
if ($mtime !== null) { if ($mtime !== null) {
$cached->timestamp = $mtime; $cached->timestamp = $mtime;
$cached->exists = !!$cached->timestamp; $cached->exists = !!$cached->timestamp;
return; return;
} }
$timestamp = null; $timestamp = null;
@@ -132,8 +133,10 @@ abstract class Smarty_CacheResource_Custom extends Smarty_CacheResource {
if (isset($content)) { if (isset($content)) {
$_smarty_tpl = $_template; $_smarty_tpl = $_template;
eval("?>" . $content); eval("?>" . $content);
return true; return true;
} }
return false; return false;
} }
@@ -166,6 +169,7 @@ abstract class Smarty_CacheResource_Custom extends Smarty_CacheResource {
public function clearAll(Smarty $smarty, $exp_time=null) public function clearAll(Smarty $smarty, $exp_time=null)
{ {
$this->cache = array(); $this->cache = array();
return $this->delete(null, null, null, $exp_time); return $this->delete(null, null, null, $exp_time);
} }
@@ -182,6 +186,7 @@ abstract class Smarty_CacheResource_Custom extends Smarty_CacheResource {
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)
{ {
$this->cache = array(); $this->cache = array();
return $this->delete($resource_name, $cache_id, $compile_id, $exp_time); return $this->delete($resource_name, $cache_id, $compile_id, $exp_time);
} }
@@ -234,4 +239,3 @@ abstract class Smarty_CacheResource_Custom extends Smarty_CacheResource {
$this->delete($name, null, null, null); $this->delete($name, null, null, null);
} }
} }
?>

View File

@@ -31,8 +31,8 @@
* @subpackage Cacher * @subpackage Cacher
* @author Rodney Rehm * @author Rodney Rehm
*/ */
abstract class Smarty_CacheResource_KeyValueStore extends Smarty_CacheResource { abstract class Smarty_CacheResource_KeyValueStore extends Smarty_CacheResource
{
/** /**
* cache for contents * cache for contents
* @var array * @var array
@@ -99,8 +99,10 @@ abstract class Smarty_CacheResource_KeyValueStore extends Smarty_CacheResource {
if (isset($content)) { if (isset($content)) {
$_smarty_tpl = $_template; $_smarty_tpl = $_template;
eval("?>" . $content); eval("?>" . $content);
return true; return true;
} }
return false; return false;
} }
@@ -114,6 +116,7 @@ abstract class Smarty_CacheResource_KeyValueStore extends Smarty_CacheResource {
public function writeCachedContent(Smarty_Internal_Template $_template, $content) public function writeCachedContent(Smarty_Internal_Template $_template, $content)
{ {
$this->addMetaTimestamp($content); $this->addMetaTimestamp($content);
return $this->write(array($_template->cached->filepath => $content), $_template->properties['cache_lifetime']); return $this->write(array($_template->cached->filepath => $content), $_template->properties['cache_lifetime']);
} }
@@ -133,6 +136,7 @@ abstract class Smarty_CacheResource_KeyValueStore extends Smarty_CacheResource {
if (!$this->purge()) { if (!$this->purge()) {
$this->invalidate(null); $this->invalidate(null);
} }
return -1; return -1;
} }
@@ -157,6 +161,7 @@ abstract class Smarty_CacheResource_KeyValueStore extends Smarty_CacheResource {
$cid = $uid . '#' . $this->sanitize($resource_name) . '#' . $this->sanitize($cache_id) . '#' . $this->sanitize($compile_id); $cid = $uid . '#' . $this->sanitize($resource_name) . '#' . $this->sanitize($cache_id) . '#' . $this->sanitize($compile_id);
$this->delete(array($cid)); $this->delete(array($cid));
$this->invalidate($cid, $resource_name, $cache_id, $compile_id, $uid); $this->invalidate($cid, $resource_name, $cache_id, $compile_id, $uid);
return -1; return -1;
} }
/** /**
@@ -188,6 +193,7 @@ abstract class Smarty_CacheResource_KeyValueStore extends Smarty_CacheResource {
} }
unset($smarty->template_objects[$_templateId]); unset($smarty->template_objects[$_templateId]);
} }
return $uid; return $uid;
} }
@@ -204,6 +210,7 @@ abstract class Smarty_CacheResource_KeyValueStore extends Smarty_CacheResource {
if (!$string) { if (!$string) {
return null; return null;
} }
return preg_replace('#[^\w\|]+#S', '_', $string); return preg_replace('#[^\w\|]+#S', '_', $string);
} }
@@ -261,6 +268,7 @@ abstract class Smarty_CacheResource_KeyValueStore extends Smarty_CacheResource {
$s = unpack("N", substr($content, 0, 4)); $s = unpack("N", substr($content, 0, 4));
$m = unpack("N", substr($content, 4, 4)); $m = unpack("N", substr($content, 4, 4));
$content = substr($content, 8); $content = substr($content, 8);
return $s[1] + ($m[1] / 100000000); return $s[1] + ($m[1] / 100000000);
} }
@@ -328,6 +336,7 @@ abstract class Smarty_CacheResource_KeyValueStore extends Smarty_CacheResource {
} }
// make sure we're dealing with floats // make sure we're dealing with floats
$values = array_map('floatval', $values); $values = array_map('floatval', $values);
return max($values); return max($values);
} }
@@ -380,6 +389,7 @@ abstract class Smarty_CacheResource_KeyValueStore extends Smarty_CacheResource {
// skip past delimiter position // skip past delimiter position
$i++; $i++;
} }
return $t; return $t;
} }
@@ -394,6 +404,7 @@ abstract class Smarty_CacheResource_KeyValueStore extends Smarty_CacheResource {
{ {
$key = 'LOCK#' . $cached->filepath; $key = 'LOCK#' . $cached->filepath;
$data = $this->read(array($key)); $data = $this->read(array($key));
return $data && time() - $data[$key] < $smarty->locking_timeout; return $data && time() - $data[$key] < $smarty->locking_timeout;
} }
@@ -429,7 +440,7 @@ abstract class Smarty_CacheResource_KeyValueStore extends Smarty_CacheResource {
* @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
*/ */
protected abstract function read(array $keys); abstract protected function read(array $keys);
/** /**
* Save values for a set of keys to cache * Save values for a set of keys to cache
@@ -438,7 +449,7 @@ abstract class Smarty_CacheResource_KeyValueStore extends Smarty_CacheResource {
* @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
*/ */
protected abstract function write(array $keys, $expire=null); abstract protected function write(array $keys, $expire=null);
/** /**
* Remove values from cache * Remove values from cache
@@ -446,7 +457,7 @@ abstract class Smarty_CacheResource_KeyValueStore extends Smarty_CacheResource {
* @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
*/ */
protected abstract function delete(array $keys); abstract protected function delete(array $keys);
/** /**
* Remove *all* values from cache * Remove *all* values from cache
@@ -459,5 +470,3 @@ abstract class Smarty_CacheResource_KeyValueStore extends Smarty_CacheResource {
} }
} }
?>

View File

@@ -19,8 +19,8 @@
* @property int $timestamp * @property int $timestamp
* @property bool $exists * @property bool $exists
*/ */
class Smarty_Config_Source extends Smarty_Template_Source { class Smarty_Config_Source extends Smarty_Template_Source
{
/** /**
* create Config Object container * create Config Object container
* *
@@ -80,6 +80,7 @@ class Smarty_Config_Source extends Smarty_Template_Source {
case 'timestamp': case 'timestamp':
case 'exists': case 'exists':
$this->handler->populateTimestamp($this); $this->handler->populateTimestamp($this);
return $this->$property_name; return $this->$property_name;
case 'content': case 'content':
@@ -91,5 +92,3 @@ class Smarty_Config_Source extends Smarty_Template_Source {
} }
} }
?>

View File

@@ -16,8 +16,8 @@
* @package Smarty * @package Smarty
* @subpackage Cacher * @subpackage Cacher
*/ */
class Smarty_Internal_CacheResource_File extends Smarty_CacheResource { class Smarty_Internal_CacheResource_File extends Smarty_CacheResource
{
/** /**
* populate Cached Object with meta data from Resource * populate Cached Object with meta data from Resource
* *
@@ -87,6 +87,7 @@
public function process(Smarty_Internal_Template $_template, Smarty_Template_Cached $cached=null) public function process(Smarty_Internal_Template $_template, Smarty_Template_Cached $cached=null)
{ {
$_smarty_tpl = $_template; $_smarty_tpl = $_template;
return @include $_template->cached->filepath; return @include $_template->cached->filepath;
} }
@@ -106,6 +107,7 @@
return true; return true;
} }
} }
return false; return false;
} }
@@ -226,6 +228,7 @@
} }
} }
} }
return $_count; return $_count;
} }
@@ -244,6 +247,7 @@
clearstatcache(); clearstatcache();
} }
$t = @filemtime($cached->lock_id); $t = @filemtime($cached->lock_id);
return $t && (time() - $t < $smarty->locking_timeout); return $t && (time() - $t < $smarty->locking_timeout);
} }
@@ -271,5 +275,3 @@
@unlink($cached->lock_id); @unlink($cached->lock_id);
} }
} }
?>

View File

@@ -15,8 +15,8 @@
* @package Smarty * @package Smarty
* @subpackage Compiler * @subpackage Compiler
*/ */
class Smarty_Internal_Compile_Append extends Smarty_Internal_Compile_Assign { class Smarty_Internal_Compile_Append extends Smarty_Internal_Compile_Assign
{
/** /**
* Compiles code for the {append} tag * Compiles code for the {append} tag
* *
@@ -49,5 +49,3 @@ class Smarty_Internal_Compile_Append extends Smarty_Internal_Compile_Assign {
} }
} }
?>

View File

@@ -15,8 +15,8 @@
* @package Smarty * @package Smarty
* @subpackage Compiler * @subpackage Compiler
*/ */
class Smarty_Internal_Compile_Assign extends Smarty_Internal_CompileBase { class Smarty_Internal_Compile_Assign extends Smarty_Internal_CompileBase
{
/** /**
* Compiles code for the {assign} tag * Compiles code for the {assign} tag
* *
@@ -80,9 +80,8 @@ class Smarty_Internal_Compile_Assign extends Smarty_Internal_CompileBase {
$output .= "\nSmarty::\$global_tpl_vars[$_attr[var]] = clone \$_smarty_tpl->tpl_vars[$_attr[var]];"; $output .= "\nSmarty::\$global_tpl_vars[$_attr[var]] = clone \$_smarty_tpl->tpl_vars[$_attr[var]];";
} }
$output .= '?>'; $output .= '?>';
return $output; return $output;
} }
} }
?>

View File

@@ -16,8 +16,8 @@
* @package Smarty * @package Smarty
* @subpackage Compiler * @subpackage Compiler
*/ */
class Smarty_Internal_Compile_Block extends Smarty_Internal_CompileBase { class Smarty_Internal_Compile_Block extends Smarty_Internal_CompileBase
{
/** /**
* Attribute definition: Overwrites base class. * Attribute definition: Overwrites base class.
* *
@@ -49,7 +49,8 @@ class Smarty_Internal_Compile_Block extends Smarty_Internal_CompileBase {
* @param object $compiler compiler object * @param object $compiler compiler object
* @return boolean true * @return boolean true
*/ */
public function compile($args, $compiler) { public function compile($args, $compiler)
{
// check and get attributes // check and get attributes
$_attr = $this->getAttributes($compiler, $args); $_attr = $this->getAttributes($compiler, $args);
$save = array($_attr, $compiler->parser->current_buffer, $compiler->nocache, $compiler->smarty->merge_compiled_includes, $compiler->merged_templates, $compiler->smarty->merged_templates_func, $compiler->template->properties, $compiler->template->has_nocache_code); $save = array($_attr, $compiler->parser->current_buffer, $compiler->nocache, $compiler->smarty->merge_compiled_includes, $compiler->merged_templates, $compiler->smarty->merged_templates_func, $compiler->template->properties, $compiler->template->has_nocache_code);
@@ -64,6 +65,7 @@ class Smarty_Internal_Compile_Block extends Smarty_Internal_CompileBase {
$compiler->parser->current_buffer = new _smarty_template_buffer($compiler->parser); $compiler->parser->current_buffer = new _smarty_template_buffer($compiler->parser);
$compiler->has_code = false; $compiler->has_code = false;
return true; return true;
} }
@@ -75,7 +77,8 @@ class Smarty_Internal_Compile_Block extends Smarty_Internal_CompileBase {
* @param object $template template object * @param object $template template object
* @param string $filepath filepath of template source * @param string $filepath filepath of template source
*/ */
public static function saveBlockData($block_content, $block_tag, $template, $filepath) { static function saveBlockData($block_content, $block_tag, $template, $filepath)
{
$_rdl = preg_quote($template->smarty->right_delimiter); $_rdl = preg_quote($template->smarty->right_delimiter);
$_ldl = preg_quote($template->smarty->left_delimiter); $_ldl = preg_quote($template->smarty->left_delimiter);
if (!$template->smarty->auto_literal) { if (!$template->smarty->auto_literal) {
@@ -157,7 +160,8 @@ class Smarty_Internal_Compile_Block extends Smarty_Internal_CompileBase {
* @param string $_name optional name of child block * @param string $_name optional name of child block
* @return string compiled code of schild block * @return string compiled code of schild block
*/ */
public static function compileChildBlock($compiler, $_name = null) { static function compileChildBlock($compiler, $_name = null)
{
$_output = ''; $_output = '';
// if called by {$smarty.block.child} we must search the name of enclosing {block} // if called by {$smarty.block.child} we must search the name of enclosing {block}
if ($_name == null) { if ($_name == null) {
@@ -222,6 +226,7 @@ class Smarty_Internal_Compile_Block extends Smarty_Internal_CompileBase {
} }
} }
unset($_tpl); unset($_tpl);
return $_output; return $_output;
} }
@@ -233,8 +238,8 @@ class Smarty_Internal_Compile_Block extends Smarty_Internal_CompileBase {
* @package Smarty * @package Smarty
* @subpackage Compiler * @subpackage Compiler
*/ */
class Smarty_Internal_Compile_Blockclose extends Smarty_Internal_CompileBase { class Smarty_Internal_Compile_Blockclose extends Smarty_Internal_CompileBase
{
/** /**
* Compiles code for the {/block} tag * Compiles code for the {/block} tag
* *
@@ -242,7 +247,8 @@ class Smarty_Internal_Compile_Blockclose extends Smarty_Internal_CompileBase {
* @param object $compiler compiler object * @param object $compiler compiler object
* @return string compiled code * @return string compiled code
*/ */
public function compile($args, $compiler) { public function compile($args, $compiler)
{
$compiler->has_code = true; $compiler->has_code = true;
// check and get attributes // check and get attributes
$_attr = $this->getAttributes($compiler, $args); $_attr = $this->getAttributes($compiler, $args);
@@ -275,9 +281,8 @@ class Smarty_Internal_Compile_Blockclose extends Smarty_Internal_CompileBase {
$compiler->inheritance = false; $compiler->inheritance = false;
// $_output content has already nocache code processed // $_output content has already nocache code processed
$compiler->suppressNocacheProcessing = true; $compiler->suppressNocacheProcessing = true;
return $_output; return $_output;
} }
} }
?>

View File

@@ -14,8 +14,8 @@
* @package Smarty * @package Smarty
* @subpackage Compiler * @subpackage Compiler
*/ */
class Smarty_Internal_Compile_Break extends Smarty_Internal_CompileBase { class Smarty_Internal_Compile_Break extends Smarty_Internal_CompileBase
{
/** /**
* Attribute definition: Overwrites base class. * Attribute definition: Overwrites base class.
* *
@@ -69,9 +69,8 @@ class Smarty_Internal_Compile_Break extends Smarty_Internal_CompileBase {
$compiler->trigger_template_error("cannot break {$_levels} level(s)", $compiler->lex->taglineno); $compiler->trigger_template_error("cannot break {$_levels} level(s)", $compiler->lex->taglineno);
} }
$compiler->has_code = true; $compiler->has_code = true;
return "<?php break {$_levels}?>"; return "<?php break {$_levels}?>";
} }
} }
?>

View File

@@ -15,8 +15,8 @@
* @package Smarty * @package Smarty
* @subpackage Compiler * @subpackage Compiler
*/ */
class Smarty_Internal_Compile_Call extends Smarty_Internal_CompileBase { class Smarty_Internal_Compile_Call extends Smarty_Internal_CompileBase
{
/** /**
* Attribute definition: Overwrites base class. * Attribute definition: Overwrites base class.
* *
@@ -122,9 +122,8 @@ class Smarty_Internal_Compile_Call extends Smarty_Internal_CompileBase {
$_output = "<?php {$call_function}(\$_smarty_tpl,{$_params});?>\n"; $_output = "<?php {$call_function}(\$_smarty_tpl,{$_params});?>\n";
} }
} }
return $_output; return $_output;
} }
} }
?>

View File

@@ -15,8 +15,8 @@
* @package Smarty * @package Smarty
* @subpackage Compiler * @subpackage Compiler
*/ */
class Smarty_Internal_Compile_Capture extends Smarty_Internal_CompileBase { class Smarty_Internal_Compile_Capture extends Smarty_Internal_CompileBase
{
/** /**
* Attribute definition: Overwrites base class. * Attribute definition: Overwrites base class.
* *
@@ -64,8 +64,8 @@ class Smarty_Internal_Compile_Capture extends Smarty_Internal_CompileBase {
* @package Smarty * @package Smarty
* @subpackage Compiler * @subpackage Compiler
*/ */
class Smarty_Internal_Compile_CaptureClose extends Smarty_Internal_CompileBase { class Smarty_Internal_Compile_CaptureClose extends Smarty_Internal_CompileBase
{
/** /**
* Compiles code for the {/capture} tag * Compiles code for the {/capture} tag
* *
@@ -90,9 +90,8 @@ class Smarty_Internal_Compile_CaptureClose extends Smarty_Internal_CompileBase {
$_output .= " if (isset( \$_capture_append)) \$_smarty_tpl->append( \$_capture_append, ob_get_contents());\n"; $_output .= " if (isset( \$_capture_append)) \$_smarty_tpl->append( \$_capture_append, ob_get_contents());\n";
$_output .= " Smarty::\$_smarty_vars['capture'][\$_capture_buffer]=ob_get_clean();\n"; $_output .= " Smarty::\$_smarty_vars['capture'][\$_capture_buffer]=ob_get_clean();\n";
$_output .= "} else \$_smarty_tpl->capture_error();?>"; $_output .= "} else \$_smarty_tpl->capture_error();?>";
return $_output; return $_output;
} }
} }
?>

View File

@@ -15,8 +15,8 @@
* @package Smarty * @package Smarty
* @subpackage Compiler * @subpackage Compiler
*/ */
class Smarty_Internal_Compile_Config_Load extends Smarty_Internal_CompileBase { class Smarty_Internal_Compile_Config_Load extends Smarty_Internal_CompileBase
{
/** /**
* Attribute definition: Overwrites base class. * Attribute definition: Overwrites base class.
* *
@@ -56,7 +56,6 @@ class Smarty_Internal_Compile_Config_Load extends Smarty_Internal_CompileBase {
$compiler->trigger_template_error('nocache option not allowed', $compiler->lex->taglineno); $compiler->trigger_template_error('nocache option not allowed', $compiler->lex->taglineno);
} }
// save posible attributes // save posible attributes
$conf_file = $_attr['file']; $conf_file = $_attr['file'];
if (isset($_attr['section'])) { if (isset($_attr['section'])) {
@@ -77,9 +76,8 @@ class Smarty_Internal_Compile_Config_Load extends Smarty_Internal_CompileBase {
// create config object // create config object
$_output = "<?php \$_config = new Smarty_Internal_Config($conf_file, \$_smarty_tpl->smarty, \$_smarty_tpl);"; $_output = "<?php \$_config = new Smarty_Internal_Config($conf_file, \$_smarty_tpl->smarty, \$_smarty_tpl);";
$_output .= "\$_config->loadConfigVars($section, '$scope'); ?>"; $_output .= "\$_config->loadConfigVars($section, '$scope'); ?>";
return $_output; return $_output;
} }
} }
?>

View File

@@ -15,8 +15,8 @@
* @package Smarty * @package Smarty
* @subpackage Compiler * @subpackage Compiler
*/ */
class Smarty_Internal_Compile_Continue extends Smarty_Internal_CompileBase { class Smarty_Internal_Compile_Continue extends Smarty_Internal_CompileBase
{
/** /**
* Attribute definition: Overwrites base class. * Attribute definition: Overwrites base class.
* *
@@ -70,9 +70,8 @@ class Smarty_Internal_Compile_Continue extends Smarty_Internal_CompileBase {
$compiler->trigger_template_error("cannot continue {$_levels} level(s)", $compiler->lex->taglineno); $compiler->trigger_template_error("cannot continue {$_levels} level(s)", $compiler->lex->taglineno);
} }
$compiler->has_code = true; $compiler->has_code = true;
return "<?php continue {$_levels}?>"; return "<?php continue {$_levels}?>";
} }
} }
?>

View File

@@ -16,8 +16,8 @@
* @package Smarty * @package Smarty
* @subpackage Compiler * @subpackage Compiler
*/ */
class Smarty_Internal_Compile_Debug extends Smarty_Internal_CompileBase { class Smarty_Internal_Compile_Debug extends Smarty_Internal_CompileBase
{
/** /**
* Compiles code for the {debug} tag * Compiles code for the {debug} tag
* *
@@ -35,9 +35,8 @@ class Smarty_Internal_Compile_Debug extends Smarty_Internal_CompileBase {
// display debug template // display debug template
$_output = "<?php \$_smarty_tpl->smarty->loadPlugin('Smarty_Internal_Debug'); Smarty_Internal_Debug::display_debug(\$_smarty_tpl); ?>"; $_output = "<?php \$_smarty_tpl->smarty->loadPlugin('Smarty_Internal_Debug'); Smarty_Internal_Debug::display_debug(\$_smarty_tpl); ?>";
return $_output; return $_output;
} }
} }
?>

View File

@@ -15,8 +15,8 @@
* @package Smarty * @package Smarty
* @subpackage Compiler * @subpackage Compiler
*/ */
class Smarty_Internal_Compile_Eval extends Smarty_Internal_CompileBase { class Smarty_Internal_Compile_Eval extends Smarty_Internal_CompileBase
{
/** /**
* Attribute definition: Overwrites base class. * Attribute definition: Overwrites base class.
* *
@@ -65,9 +65,8 @@ class Smarty_Internal_Compile_Eval extends Smarty_Internal_CompileBase {
} else { } else {
$_output .= "echo \$_template->fetch();"; $_output .= "echo \$_template->fetch();";
} }
return "<?php $_output ?>"; return "<?php $_output ?>";
} }
} }
?>

View File

@@ -16,8 +16,8 @@
* @package Smarty * @package Smarty
* @subpackage Compiler * @subpackage Compiler
*/ */
class Smarty_Internal_Compile_Extends extends Smarty_Internal_CompileBase { class Smarty_Internal_Compile_Extends extends Smarty_Internal_CompileBase
{
/** /**
* Attribute definition: Overwrites base class. * Attribute definition: Overwrites base class.
* *
@@ -125,9 +125,8 @@ class Smarty_Internal_Compile_Extends extends Smarty_Internal_CompileBase {
} }
$compiler->template->source->filepath = $_template->source->filepath; $compiler->template->source->filepath = $_template->source->filepath;
$compiler->abort_and_recompile = true; $compiler->abort_and_recompile = true;
return ''; return '';
} }
} }
?>

View File

@@ -15,8 +15,8 @@
* @package Smarty * @package Smarty
* @subpackage Compiler * @subpackage Compiler
*/ */
class Smarty_Internal_Compile_For extends Smarty_Internal_CompileBase { class Smarty_Internal_Compile_For extends Smarty_Internal_CompileBase
{
/** /**
* Compiles code for the {for} tag * Compiles code for the {for} tag
* *
@@ -90,8 +90,8 @@ class Smarty_Internal_Compile_For extends Smarty_Internal_CompileBase {
* @package Smarty * @package Smarty
* @subpackage Compiler * @subpackage Compiler
*/ */
class Smarty_Internal_Compile_Forelse extends Smarty_Internal_CompileBase { class Smarty_Internal_Compile_Forelse extends Smarty_Internal_CompileBase
{
/** /**
* Compiles code for the {forelse} tag * Compiles code for the {forelse} tag
* *
@@ -107,6 +107,7 @@ class Smarty_Internal_Compile_Forelse extends Smarty_Internal_CompileBase {
list($openTag, $nocache) = $this->closeTag($compiler, array('for')); list($openTag, $nocache) = $this->closeTag($compiler, array('for'));
$this->openTag($compiler, 'forelse', array('forelse', $nocache)); $this->openTag($compiler, 'forelse', array('forelse', $nocache));
return "<?php }} else { ?>"; return "<?php }} else { ?>";
} }
@@ -118,8 +119,8 @@ class Smarty_Internal_Compile_Forelse extends Smarty_Internal_CompileBase {
* @package Smarty * @package Smarty
* @subpackage Compiler * @subpackage Compiler
*/ */
class Smarty_Internal_Compile_Forclose extends Smarty_Internal_CompileBase { class Smarty_Internal_Compile_Forclose extends Smarty_Internal_CompileBase
{
/** /**
* Compiles code for the {/for} tag * Compiles code for the {/for} tag
* *
@@ -147,5 +148,3 @@ class Smarty_Internal_Compile_Forclose extends Smarty_Internal_CompileBase {
} }
} }
?>

View File

@@ -15,7 +15,8 @@
* @package Smarty * @package Smarty
* @subpackage Compiler * @subpackage Compiler
*/ */
class Smarty_Internal_Compile_Foreach extends Smarty_Internal_CompileBase { class Smarty_Internal_Compile_Foreach extends Smarty_Internal_CompileBase
{
/** /**
* Attribute definition: Overwrites base class. * Attribute definition: Overwrites base class.
* *
@@ -173,8 +174,8 @@ class Smarty_Internal_Compile_Foreach extends Smarty_Internal_CompileBase {
* @package Smarty * @package Smarty
* @subpackage Compiler * @subpackage Compiler
*/ */
class Smarty_Internal_Compile_Foreachelse extends Smarty_Internal_CompileBase { class Smarty_Internal_Compile_Foreachelse extends Smarty_Internal_CompileBase
{
/** /**
* Compiles code for the {foreachelse} tag * Compiles code for the {foreachelse} tag
* *
@@ -202,8 +203,8 @@ class Smarty_Internal_Compile_Foreachelse extends Smarty_Internal_CompileBase {
* @package Smarty * @package Smarty
* @subpackage Compiler * @subpackage Compiler
*/ */
class Smarty_Internal_Compile_Foreachclose extends Smarty_Internal_CompileBase { class Smarty_Internal_Compile_Foreachclose extends Smarty_Internal_CompileBase
{
/** /**
* Compiles code for the {/foreach} tag * Compiles code for the {/foreach} tag
* *
@@ -227,5 +228,3 @@ class Smarty_Internal_Compile_Foreachclose extends Smarty_Internal_CompileBase {
} }
} }
?>

View File

@@ -15,8 +15,8 @@
* @package Smarty * @package Smarty
* @subpackage Compiler * @subpackage Compiler
*/ */
class Smarty_Internal_Compile_Function extends Smarty_Internal_CompileBase { class Smarty_Internal_Compile_Function extends Smarty_Internal_CompileBase
{
/** /**
* Attribute definition: Overwrites base class. * Attribute definition: Overwrites base class.
* *
@@ -86,6 +86,7 @@ class Smarty_Internal_Compile_Function extends Smarty_Internal_CompileBase {
$compiler->template->has_nocache_code = false; $compiler->template->has_nocache_code = false;
$compiler->has_code = false; $compiler->has_code = false;
$compiler->template->properties['function'][$_name]['compiled'] = ''; $compiler->template->properties['function'][$_name]['compiled'] = '';
return true; return true;
} }
@@ -97,8 +98,8 @@ class Smarty_Internal_Compile_Function extends Smarty_Internal_CompileBase {
* @package Smarty * @package Smarty
* @subpackage Compiler * @subpackage Compiler
*/ */
class Smarty_Internal_Compile_Functionclose extends Smarty_Internal_CompileBase { class Smarty_Internal_Compile_Functionclose extends Smarty_Internal_CompileBase
{
/** /**
* Compiles code for the {/function} tag * Compiles code for the {/function} tag
* *
@@ -158,9 +159,8 @@ foreach (Smarty::\$global_tpl_vars as \$key => \$value) if(!isset(\$_smarty_tpl-
$compiler->parser->current_buffer = $saved_data[1]; $compiler->parser->current_buffer = $saved_data[1];
$compiler->template->has_nocache_code = $compiler->template->has_nocache_code | $saved_data[2]; $compiler->template->has_nocache_code = $compiler->template->has_nocache_code | $saved_data[2];
$compiler->template->required_plugins = $saved_data[3]; $compiler->template->required_plugins = $saved_data[3];
return $output; return $output;
} }
} }
?>

View File

@@ -15,8 +15,8 @@
* @package Smarty * @package Smarty
* @subpackage Compiler * @subpackage Compiler
*/ */
class Smarty_Internal_Compile_If extends Smarty_Internal_CompileBase { class Smarty_Internal_Compile_If extends Smarty_Internal_CompileBase
{
/** /**
* Compiles code for the {if} tag * Compiles code for the {if} tag
* *
@@ -56,6 +56,7 @@ class Smarty_Internal_Compile_If extends Smarty_Internal_CompileBase {
$_output = "<?php if (!isset(\$_smarty_tpl->tpl_vars[".$parameter['if condition']['var']."])) \$_smarty_tpl->tpl_vars[".$parameter['if condition']['var']."] = new Smarty_Variable(null{$_nocache});"; $_output = "<?php if (!isset(\$_smarty_tpl->tpl_vars[".$parameter['if condition']['var']."])) \$_smarty_tpl->tpl_vars[".$parameter['if condition']['var']."] = new Smarty_Variable(null{$_nocache});";
$_output .= "if (\$_smarty_tpl->tpl_vars[".$parameter['if condition']['var']."]->value = ".$parameter['if condition']['value'].") {?>"; $_output .= "if (\$_smarty_tpl->tpl_vars[".$parameter['if condition']['var']."]->value = ".$parameter['if condition']['value'].") {?>";
} }
return $_output; return $_output;
} else { } else {
return "<?php if ({$parameter['if condition']}) {?>"; return "<?php if ({$parameter['if condition']}) {?>";
@@ -70,8 +71,8 @@ class Smarty_Internal_Compile_If extends Smarty_Internal_CompileBase {
* @package Smarty * @package Smarty
* @subpackage Compiler * @subpackage Compiler
*/ */
class Smarty_Internal_Compile_Else extends Smarty_Internal_CompileBase { class Smarty_Internal_Compile_Else extends Smarty_Internal_CompileBase
{
/** /**
* Compiles code for the {else} tag * Compiles code for the {else} tag
* *
@@ -96,8 +97,8 @@ class Smarty_Internal_Compile_Else extends Smarty_Internal_CompileBase {
* @package Smarty * @package Smarty
* @subpackage Compiler * @subpackage Compiler
*/ */
class Smarty_Internal_Compile_Elseif extends Smarty_Internal_CompileBase { class Smarty_Internal_Compile_Elseif extends Smarty_Internal_CompileBase
{
/** /**
* Compiles code for the {elseif} tag * Compiles code for the {elseif} tag
* *
@@ -144,9 +145,11 @@ class Smarty_Internal_Compile_Elseif extends Smarty_Internal_CompileBase {
$_output = "<?php } else { if (!isset(\$_smarty_tpl->tpl_vars[" . $parameter['if condition']['var'] . "])) \$_smarty_tpl->tpl_vars[" . $parameter['if condition']['var'] . "] = new Smarty_Variable(null{$_nocache});"; $_output = "<?php } else { if (!isset(\$_smarty_tpl->tpl_vars[" . $parameter['if condition']['var'] . "])) \$_smarty_tpl->tpl_vars[" . $parameter['if condition']['var'] . "] = new Smarty_Variable(null{$_nocache});";
$_output .= "if (\$_smarty_tpl->tpl_vars[" . $parameter['if condition']['var'] . "]->value = " . $parameter['if condition']['value'] . ") {?>"; $_output .= "if (\$_smarty_tpl->tpl_vars[" . $parameter['if condition']['var'] . "]->value = " . $parameter['if condition']['value'] . ") {?>";
} }
return $_output; return $_output;
} else { } else {
$this->openTag($compiler, 'elseif', array($nesting, $compiler->tag_nocache)); $this->openTag($compiler, 'elseif', array($nesting, $compiler->tag_nocache));
return "<?php } elseif ({$parameter['if condition']}) {?>"; return "<?php } elseif ({$parameter['if condition']}) {?>";
} }
} else { } else {
@@ -163,6 +166,7 @@ class Smarty_Internal_Compile_Elseif extends Smarty_Internal_CompileBase {
$_output = "<?php } else {?>{$tmp}<?php if (!isset(\$_smarty_tpl->tpl_vars[" . $parameter['if condition']['var'] . "])) \$_smarty_tpl->tpl_vars[" . $parameter['if condition']['var'] . "] = new Smarty_Variable(null{$_nocache});"; $_output = "<?php } else {?>{$tmp}<?php if (!isset(\$_smarty_tpl->tpl_vars[" . $parameter['if condition']['var'] . "])) \$_smarty_tpl->tpl_vars[" . $parameter['if condition']['var'] . "] = new Smarty_Variable(null{$_nocache});";
$_output .= "if (\$_smarty_tpl->tpl_vars[" . $parameter['if condition']['var'] . "]->value = " . $parameter['if condition']['value'] . ") {?>"; $_output .= "if (\$_smarty_tpl->tpl_vars[" . $parameter['if condition']['var'] . "]->value = " . $parameter['if condition']['value'] . ") {?>";
} }
return $_output; return $_output;
} else { } else {
return "<?php } else {?>{$tmp}<?php if ({$parameter['if condition']}) {?>"; return "<?php } else {?>{$tmp}<?php if ({$parameter['if condition']}) {?>";
@@ -178,8 +182,8 @@ class Smarty_Internal_Compile_Elseif extends Smarty_Internal_CompileBase {
* @package Smarty * @package Smarty
* @subpackage Compiler * @subpackage Compiler
*/ */
class Smarty_Internal_Compile_Ifclose extends Smarty_Internal_CompileBase { class Smarty_Internal_Compile_Ifclose extends Smarty_Internal_CompileBase
{
/** /**
* Compiles code for the {/if} tag * Compiles code for the {/if} tag
* *
@@ -199,9 +203,8 @@ class Smarty_Internal_Compile_Ifclose extends Smarty_Internal_CompileBase {
for ($i = 0; $i < $nesting; $i++) { for ($i = 0; $i < $nesting; $i++) {
$tmp .= '}'; $tmp .= '}';
} }
return "<?php {$tmp}?>"; return "<?php {$tmp}?>";
} }
} }
?>

View File

@@ -15,8 +15,8 @@
* @package Smarty * @package Smarty
* @subpackage Compiler * @subpackage Compiler
*/ */
class Smarty_Internal_Compile_Include extends Smarty_Internal_CompileBase { class Smarty_Internal_Compile_Include extends Smarty_Internal_CompileBase
{
/** /**
* caching mode to create nocache code but no cache file * caching mode to create nocache code but no cache file
*/ */
@@ -198,6 +198,7 @@ class Smarty_Internal_Compile_Include extends Smarty_Internal_CompileBase {
$_output .= " \$_smarty_tpl->tpl_vars[$_assign] = new Smarty_variable(ob_get_clean());"; $_output .= " \$_smarty_tpl->tpl_vars[$_assign] = new Smarty_variable(ob_get_clean());";
} }
$_output .= "/* End of included template \"" . $tpl_name . "\" */?>"; $_output .= "/* End of included template \"" . $tpl_name . "\" */?>";
return $_output; return $_output;
} }
@@ -207,9 +208,8 @@ class Smarty_Internal_Compile_Include extends Smarty_Internal_CompileBase {
} else { } else {
$_output = "<?php echo \$_smarty_tpl->getSubTemplate ($include_file, $_cache_id, $_compile_id, $_caching, $_cache_lifetime, $_vars, $_parent_scope);?>\n"; $_output = "<?php echo \$_smarty_tpl->getSubTemplate ($include_file, $_cache_id, $_compile_id, $_caching, $_cache_lifetime, $_vars, $_parent_scope);?>\n";
} }
return $_output; return $_output;
} }
} }
?>

View File

@@ -15,8 +15,8 @@
* @package Smarty * @package Smarty
* @subpackage Compiler * @subpackage Compiler
*/ */
class Smarty_Internal_Compile_Include_Php extends Smarty_Internal_CompileBase { class Smarty_Internal_Compile_Include_Php extends Smarty_Internal_CompileBase
{
/** /**
* Attribute definition: Overwrites base class. * Attribute definition: Overwrites base class.
* *
@@ -104,5 +104,3 @@ class Smarty_Internal_Compile_Include_Php extends Smarty_Internal_CompileBase {
} }
} }
?>

View File

@@ -16,8 +16,8 @@
* @package Smarty * @package Smarty
* @subpackage Compiler * @subpackage Compiler
*/ */
class Smarty_Internal_Compile_Insert extends Smarty_Internal_CompileBase { class Smarty_Internal_Compile_Insert extends Smarty_Internal_CompileBase
{
/** /**
* Attribute definition: Overwrites base class. * Attribute definition: Overwrites base class.
* *
@@ -134,9 +134,8 @@ class Smarty_Internal_Compile_Insert extends Smarty_Internal_CompileBase {
$_output .= "echo {$_function}({$_params},\$_smarty_tpl);?>"; $_output .= "echo {$_function}({$_params},\$_smarty_tpl);?>";
} }
} }
return $_output; return $_output;
} }
} }
?>

View File

@@ -15,8 +15,8 @@
* @package Smarty * @package Smarty
* @subpackage Compiler * @subpackage Compiler
*/ */
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
* *
@@ -33,9 +33,8 @@ class Smarty_Internal_Compile_Ldelim extends Smarty_Internal_CompileBase {
} }
// this tag does not return compiled code // this tag does not return compiled code
$compiler->has_code = true; $compiler->has_code = true;
return $compiler->smarty->left_delimiter; return $compiler->smarty->left_delimiter;
} }
} }
?>

View File

@@ -15,8 +15,8 @@
* @package Smarty * @package Smarty
* @subpackage Compiler * @subpackage Compiler
*/ */
class Smarty_Internal_Compile_Nocache extends Smarty_Internal_CompileBase { class Smarty_Internal_Compile_Nocache extends Smarty_Internal_CompileBase
{
/** /**
* Compiles code for the {nocache} tag * Compiles code for the {nocache} tag
* *
@@ -36,6 +36,7 @@ class Smarty_Internal_Compile_Nocache extends Smarty_Internal_CompileBase {
$compiler->nocache = true; $compiler->nocache = true;
// this tag does not return compiled code // this tag does not return compiled code
$compiler->has_code = false; $compiler->has_code = false;
return true; return true;
} }
@@ -47,8 +48,8 @@ class Smarty_Internal_Compile_Nocache extends Smarty_Internal_CompileBase {
* @package Smarty * @package Smarty
* @subpackage Compiler * @subpackage Compiler
*/ */
class Smarty_Internal_Compile_Nocacheclose extends Smarty_Internal_CompileBase { class Smarty_Internal_Compile_Nocacheclose extends Smarty_Internal_CompileBase
{
/** /**
* Compiles code for the {/nocache} tag * Compiles code for the {/nocache} tag
* *
@@ -65,9 +66,8 @@ class Smarty_Internal_Compile_Nocacheclose extends Smarty_Internal_CompileBase {
$compiler->nocache = false; $compiler->nocache = false;
// this tag does not return compiled code // this tag does not return compiled code
$compiler->has_code = false; $compiler->has_code = false;
return true; return true;
} }
} }
?>

View File

@@ -15,8 +15,8 @@
* @package Smarty * @package Smarty
* @subpackage Compiler * @subpackage Compiler
*/ */
class Smarty_Internal_Compile_Private_Block_Plugin extends Smarty_Internal_CompileBase { class Smarty_Internal_Compile_Private_Block_Plugin extends Smarty_Internal_CompileBase
{
/** /**
* Attribute definition: Overwrites base class. * Attribute definition: Overwrites base class.
* *
@@ -79,9 +79,8 @@ class Smarty_Internal_Compile_Private_Block_Plugin extends Smarty_Internal_Compi
} }
$output = "<?php \$_block_content = ob_get_clean(); \$_block_repeat=false;".$mod_pre." echo {$function}({$_params}, \$_block_content, \$_smarty_tpl, \$_block_repeat); ".$mod_post." } array_pop(\$_smarty_tpl->smarty->_tag_stack);?>"; $output = "<?php \$_block_content = ob_get_clean(); \$_block_repeat=false;".$mod_pre." echo {$function}({$_params}, \$_block_content, \$_smarty_tpl, \$_block_repeat); ".$mod_post." } array_pop(\$_smarty_tpl->smarty->_tag_stack);?>";
} }
return $output . "\n"; return $output . "\n";
} }
} }
?>

View File

@@ -15,8 +15,8 @@
* @package Smarty * @package Smarty
* @subpackage Compiler * @subpackage Compiler
*/ */
class Smarty_Internal_Compile_Private_Function_Plugin extends Smarty_Internal_CompileBase { class Smarty_Internal_Compile_Private_Function_Plugin extends Smarty_Internal_CompileBase
{
/** /**
* Attribute definition: Overwrites base class. * Attribute definition: Overwrites base class.
* *
@@ -65,9 +65,8 @@ class Smarty_Internal_Compile_Private_Function_Plugin extends Smarty_Internal_Co
$_params = 'array(' . implode(",", $_paramsArray) . ')'; $_params = 'array(' . implode(",", $_paramsArray) . ')';
// compile code // compile code
$output = "<?php echo {$function}({$_params},\$_smarty_tpl);?>\n"; $output = "<?php echo {$function}({$_params},\$_smarty_tpl);?>\n";
return $output; return $output;
} }
} }
?>

View File

@@ -16,8 +16,8 @@
* @package Smarty * @package Smarty
* @subpackage Compiler * @subpackage Compiler
*/ */
class Smarty_Internal_Compile_Private_Modifier extends Smarty_Internal_CompileBase { class Smarty_Internal_Compile_Private_Modifier extends Smarty_Internal_CompileBase
{
/** /**
* Compiles code for modifier execution * Compiles code for modifier execution
* *
@@ -26,7 +26,8 @@ class Smarty_Internal_Compile_Private_Modifier extends Smarty_Internal_CompileBa
* @param array $parameter array with compilation parameter * @param array $parameter array with compilation parameter
* @return string compiled code * @return string compiled code
*/ */
public function compile($args, $compiler, $parameter) { public function compile($args, $compiler, $parameter)
{
// check and get attributes // check and get attributes
$_attr = $this->getAttributes($compiler, $args); $_attr = $this->getAttributes($compiler, $args);
$output = $parameter['value']; $output = $parameter['value'];
@@ -132,9 +133,8 @@ class Smarty_Internal_Compile_Private_Modifier extends Smarty_Internal_CompileBa
$compiler->trigger_template_error("unknown modifier \"" . $modifier . "\"", $compiler->lex->taglineno); $compiler->trigger_template_error("unknown modifier \"" . $modifier . "\"", $compiler->lex->taglineno);
} }
} }
return $output; return $output;
} }
} }
?>

View File

@@ -15,8 +15,8 @@
* @package Smarty * @package Smarty
* @subpackage Compiler * @subpackage Compiler
*/ */
class Smarty_Internal_Compile_Private_Object_Block_Function extends Smarty_Internal_CompileBase { class Smarty_Internal_Compile_Private_Object_Block_Function extends Smarty_Internal_CompileBase
{
/** /**
* Attribute definition: Overwrites base class. * Attribute definition: Overwrites base class.
* *
@@ -80,9 +80,8 @@ class Smarty_Internal_Compile_Private_Object_Block_Function extends Smarty_Inter
} }
$output = "<?php \$_block_content = ob_get_contents(); ob_end_clean(); \$_block_repeat=false;" . $mod_pre . " echo \$_smarty_tpl->smarty->registered_objects['{$base_tag}'][0]->{$method}({$_params}, \$_block_content, \$_smarty_tpl, \$_block_repeat); " . $mod_post . " } array_pop(\$_smarty_tpl->smarty->_tag_stack);?>"; $output = "<?php \$_block_content = ob_get_contents(); ob_end_clean(); \$_block_repeat=false;" . $mod_pre . " echo \$_smarty_tpl->smarty->registered_objects['{$base_tag}'][0]->{$method}({$_params}, \$_block_content, \$_smarty_tpl, \$_block_repeat); " . $mod_post . " } array_pop(\$_smarty_tpl->smarty->_tag_stack);?>";
} }
return $output . "\n"; return $output . "\n";
} }
} }
?>

View File

@@ -15,8 +15,8 @@
* @package Smarty * @package Smarty
* @subpackage Compiler * @subpackage Compiler
*/ */
class Smarty_Internal_Compile_Private_Object_Function extends Smarty_Internal_CompileBase { class Smarty_Internal_Compile_Private_Object_Function extends Smarty_Internal_CompileBase
{
/** /**
* Attribute definition: Overwrites base class. * Attribute definition: Overwrites base class.
* *
@@ -71,9 +71,8 @@ class Smarty_Internal_Compile_Private_Object_Function extends Smarty_Internal_Co
} else { } else {
$output = "<?php \$_smarty_tpl->assign({$_assign},{$return});?>\n"; $output = "<?php \$_smarty_tpl->assign({$_assign},{$return});?>\n";
} }
return $output; return $output;
} }
} }
?>

View File

@@ -15,8 +15,8 @@
* @package Smarty * @package Smarty
* @subpackage Compiler * @subpackage Compiler
*/ */
class Smarty_Internal_Compile_Private_Print_Expression extends Smarty_Internal_CompileBase { class Smarty_Internal_Compile_Private_Print_Expression extends Smarty_Internal_CompileBase
{
/** /**
* Attribute definition: Overwrites base class. * Attribute definition: Overwrites base class.
* *
@@ -123,6 +123,7 @@ class Smarty_Internal_Compile_Private_Print_Expression extends Smarty_Internal_C
$compiler->has_output = true; $compiler->has_output = true;
$output = "<?php echo {$output};?>"; $output = "<?php echo {$output};?>";
} }
return $output; return $output;
} }
@@ -148,9 +149,8 @@ class Smarty_Internal_Compile_Private_Print_Expression extends Smarty_Internal_C
// not found // not found
return false; return false;
} }
return "{$plugin_name}({$output},\$_smarty_tpl)"; return "{$plugin_name}({$output},\$_smarty_tpl)";
} }
} }
?>

View File

@@ -15,8 +15,8 @@
* @package Smarty * @package Smarty
* @subpackage Compiler * @subpackage Compiler
*/ */
class Smarty_Internal_Compile_Private_Registered_Block extends Smarty_Internal_CompileBase { class Smarty_Internal_Compile_Private_Registered_Block extends Smarty_Internal_CompileBase
{
/** /**
* Attribute definition: Overwrites base class. * Attribute definition: Overwrites base class.
* *
@@ -105,9 +105,8 @@ class Smarty_Internal_Compile_Private_Registered_Block extends Smarty_Internal_C
$output = "<?php \$_block_content = ob_get_clean(); \$_block_repeat=false;".$mod_pre." echo {$function[0]}::{$function[1]}({$_params}, \$_block_content, \$_smarty_tpl, \$_block_repeat); ".$mod_post."} array_pop(\$_smarty_tpl->smarty->_tag_stack);?>"; $output = "<?php \$_block_content = ob_get_clean(); \$_block_repeat=false;".$mod_pre." echo {$function[0]}::{$function[1]}({$_params}, \$_block_content, \$_smarty_tpl, \$_block_repeat); ".$mod_post."} array_pop(\$_smarty_tpl->smarty->_tag_stack);?>";
} }
} }
return $output . "\n"; return $output . "\n";
} }
} }
?>

View File

@@ -15,8 +15,8 @@
* @package Smarty * @package Smarty
* @subpackage Compiler * @subpackage Compiler
*/ */
class Smarty_Internal_Compile_Private_Registered_Function extends Smarty_Internal_CompileBase { class Smarty_Internal_Compile_Private_Registered_Function extends Smarty_Internal_CompileBase
{
/** /**
* Attribute definition: Overwrites base class. * Attribute definition: Overwrites base class.
* *
@@ -73,9 +73,8 @@ class Smarty_Internal_Compile_Private_Registered_Function extends Smarty_Interna
} else { } else {
$output = "<?php echo {$function[0]}::{$function[1]}({$_params},\$_smarty_tpl);?>\n"; $output = "<?php echo {$function[0]}::{$function[1]}({$_params},\$_smarty_tpl);?>\n";
} }
return $output; return $output;
} }
} }
?>

View File

@@ -15,8 +15,8 @@
* @package Smarty * @package Smarty
* @subpackage Compiler * @subpackage Compiler
*/ */
class Smarty_Internal_Compile_Private_Special_Variable extends Smarty_Internal_CompileBase { class Smarty_Internal_Compile_Private_Special_Variable extends Smarty_Internal_CompileBase
{
/** /**
* Compiles code for the speical $smarty variables * Compiles code for the speical $smarty variables
* *
@@ -70,6 +70,7 @@ class Smarty_Internal_Compile_Private_Special_Variable extends Smarty_Internal_C
case 'version': case 'version':
$_version = Smarty::SMARTY_VERSION; $_version = Smarty::SMARTY_VERSION;
return "'$_version'"; return "'$_version'";
case 'const': case 'const':
@@ -77,6 +78,7 @@ class Smarty_Internal_Compile_Private_Special_Variable extends Smarty_Internal_C
$compiler->trigger_template_error("(secure mode) constants not permitted"); $compiler->trigger_template_error("(secure mode) constants not permitted");
break; break;
} }
return "@constant({$_index[1]})"; return "@constant({$_index[1]})";
case 'config': case 'config':
@@ -87,10 +89,12 @@ class Smarty_Internal_Compile_Private_Special_Variable extends Smarty_Internal_C
} }
case 'ldelim': case 'ldelim':
$_ldelim = $compiler->smarty->left_delimiter; $_ldelim = $compiler->smarty->left_delimiter;
return "'$_ldelim'"; return "'$_ldelim'";
case 'rdelim': case 'rdelim':
$_rdelim = $compiler->smarty->right_delimiter; $_rdelim = $compiler->smarty->right_delimiter;
return "'$_rdelim'"; return "'$_rdelim'";
default: default:
@@ -103,9 +107,8 @@ class Smarty_Internal_Compile_Private_Special_Variable extends Smarty_Internal_C
$compiled_ref = $compiled_ref . "[$_ind]"; $compiled_ref = $compiled_ref . "[$_ind]";
} }
} }
return $compiled_ref; return $compiled_ref;
} }
} }
?>

View File

@@ -14,8 +14,8 @@
* @package Smarty * @package Smarty
* @subpackage Compiler * @subpackage Compiler
*/ */
class Smarty_Internal_Compile_Rdelim extends Smarty_Internal_CompileBase { class Smarty_Internal_Compile_Rdelim extends Smarty_Internal_CompileBase
{
/** /**
* Compiles code for the {rdelim} tag * Compiles code for the {rdelim} tag
* *
@@ -33,9 +33,8 @@ class Smarty_Internal_Compile_Rdelim extends Smarty_Internal_CompileBase {
} }
// this tag does not return compiled code // this tag does not return compiled code
$compiler->has_code = true; $compiler->has_code = true;
return $compiler->smarty->right_delimiter; return $compiler->smarty->right_delimiter;
} }
} }
?>

View File

@@ -15,8 +15,8 @@
* @package Smarty * @package Smarty
* @subpackage Compiler * @subpackage Compiler
*/ */
class Smarty_Internal_Compile_Section extends Smarty_Internal_CompileBase { class Smarty_Internal_Compile_Section extends Smarty_Internal_CompileBase
{
/** /**
* Attribute definition: Overwrites base class. * Attribute definition: Overwrites base class.
* *
@@ -131,6 +131,7 @@ class Smarty_Internal_Compile_Section extends Smarty_Internal_CompileBase {
$output .= "{$section_props}['last'] = ({$section_props}['iteration'] == {$section_props}['total']);\n"; $output .= "{$section_props}['last'] = ({$section_props}['iteration'] == {$section_props}['total']);\n";
$output .= "?>"; $output .= "?>";
return $output; return $output;
} }
@@ -142,8 +143,8 @@ class Smarty_Internal_Compile_Section extends Smarty_Internal_CompileBase {
* @package Smarty * @package Smarty
* @subpackage Compiler * @subpackage Compiler
*/ */
class Smarty_Internal_Compile_Sectionelse extends Smarty_Internal_CompileBase { class Smarty_Internal_Compile_Sectionelse extends Smarty_Internal_CompileBase
{
/** /**
* Compiles code for the {sectionelse} tag * Compiles code for the {sectionelse} tag
* *
@@ -170,8 +171,8 @@ class Smarty_Internal_Compile_Sectionelse extends Smarty_Internal_CompileBase {
* @package Smarty * @package Smarty
* @subpackage Compiler * @subpackage Compiler
*/ */
class Smarty_Internal_Compile_Sectionclose extends Smarty_Internal_CompileBase { class Smarty_Internal_Compile_Sectionclose extends Smarty_Internal_CompileBase
{
/** /**
* Compiles code for the {/section} tag * Compiles code for the {/section} tag
* *
@@ -199,5 +200,3 @@ class Smarty_Internal_Compile_Sectionclose extends Smarty_Internal_CompileBase {
} }
} }
?>

View File

@@ -15,8 +15,8 @@
* @package Smarty * @package Smarty
* @subpackage Compiler * @subpackage Compiler
*/ */
class Smarty_Internal_Compile_Setfilter extends Smarty_Internal_CompileBase { class Smarty_Internal_Compile_Setfilter extends Smarty_Internal_CompileBase
{
/** /**
* Compiles code for setfilter tag * Compiles code for setfilter tag
* *
@@ -31,6 +31,7 @@ class Smarty_Internal_Compile_Setfilter extends Smarty_Internal_CompileBase {
$compiler->template->variable_filters = $parameter['modifier_list']; $compiler->template->variable_filters = $parameter['modifier_list'];
// this tag does not return compiled code // this tag does not return compiled code
$compiler->has_code = false; $compiler->has_code = false;
return true; return true;
} }
@@ -42,8 +43,8 @@ class Smarty_Internal_Compile_Setfilter extends Smarty_Internal_CompileBase {
* @package Smarty * @package Smarty
* @subpackage Compiler * @subpackage Compiler
*/ */
class Smarty_Internal_Compile_Setfilterclose extends Smarty_Internal_CompileBase { class Smarty_Internal_Compile_Setfilterclose extends Smarty_Internal_CompileBase
{
/** /**
* Compiles code for the {/setfilter} tag * Compiles code for the {/setfilter} tag
* *
@@ -64,9 +65,8 @@ class Smarty_Internal_Compile_Setfilterclose extends Smarty_Internal_CompileBase
} }
// this tag does not return compiled code // this tag does not return compiled code
$compiler->has_code = false; $compiler->has_code = false;
return true; return true;
} }
} }
?>

View File

@@ -15,8 +15,8 @@
* @package Smarty * @package Smarty
* @subpackage Compiler * @subpackage Compiler
*/ */
class Smarty_Internal_Compile_While extends Smarty_Internal_CompileBase { class Smarty_Internal_Compile_While extends Smarty_Internal_CompileBase
{
/** /**
* Compiles code for the {while} tag * Compiles code for the {while} tag
* *
@@ -56,6 +56,7 @@ class Smarty_Internal_Compile_While extends Smarty_Internal_CompileBase {
$_output = "<?php if (!isset(\$_smarty_tpl->tpl_vars[" . $parameter['if condition']['var'] . "])) \$_smarty_tpl->tpl_vars[" . $parameter['if condition']['var'] . "] = new Smarty_Variable(null{$_nocache});"; $_output = "<?php if (!isset(\$_smarty_tpl->tpl_vars[" . $parameter['if condition']['var'] . "])) \$_smarty_tpl->tpl_vars[" . $parameter['if condition']['var'] . "] = new Smarty_Variable(null{$_nocache});";
$_output .= "while (\$_smarty_tpl->tpl_vars[" . $parameter['if condition']['var'] . "]->value = " . $parameter['if condition']['value'] . ") {?>"; $_output .= "while (\$_smarty_tpl->tpl_vars[" . $parameter['if condition']['var'] . "]->value = " . $parameter['if condition']['value'] . ") {?>";
} }
return $_output; return $_output;
} else { } else {
return "<?php while ({$parameter['if condition']}) {?>"; return "<?php while ({$parameter['if condition']}) {?>";
@@ -70,8 +71,8 @@ class Smarty_Internal_Compile_While extends Smarty_Internal_CompileBase {
* @package Smarty * @package Smarty
* @subpackage Compiler * @subpackage Compiler
*/ */
class Smarty_Internal_Compile_Whileclose extends Smarty_Internal_CompileBase { class Smarty_Internal_Compile_Whileclose extends Smarty_Internal_CompileBase
{
/** /**
* Compiles code for the {/while} tag * Compiles code for the {/while} tag
* *
@@ -86,9 +87,8 @@ class Smarty_Internal_Compile_Whileclose extends Smarty_Internal_CompileBase {
$compiler->tag_nocache = true; $compiler->tag_nocache = true;
} }
$compiler->nocache = $this->closeTag($compiler, array('while')); $compiler->nocache = $this->closeTag($compiler, array('while'));
return "<?php }?>"; return "<?php }?>";
} }
} }
?>

View File

@@ -13,8 +13,8 @@
* @package Smarty * @package Smarty
* @subpackage Compiler * @subpackage Compiler
*/ */
abstract class Smarty_Internal_CompileBase { abstract class Smarty_Internal_CompileBase
{
/** /**
* Array of names of required attribute required by tag * Array of names of required attribute required by tag
* *
@@ -164,13 +164,13 @@ abstract class Smarty_Internal_CompileBase {
} }
// wrong nesting of tags // wrong nesting of tags
$compiler->trigger_template_error("unclosed {" . $_openTag . "} tag"); $compiler->trigger_template_error("unclosed {" . $_openTag . "} tag");
return; return;
} }
// wrong nesting of tags // wrong nesting of tags
$compiler->trigger_template_error("unexpected closing tag", $compiler->lex->taglineno); $compiler->trigger_template_error("unexpected closing tag", $compiler->lex->taglineno);
return; return;
} }
} }
?>

View File

@@ -19,8 +19,8 @@
* @property Smarty_Config_Compiled $compiled * @property Smarty_Config_Compiled $compiled
* @ignore * @ignore
*/ */
class Smarty_Internal_Config { class Smarty_Internal_Config
{
/** /**
* Samrty instance * Samrty instance
* *
@@ -117,6 +117,7 @@ class Smarty_Internal_Config {
$_filepath = $_compile_id . $_compile_dir_sep . $_filepath; $_filepath = $_compile_id . $_compile_dir_sep . $_filepath;
} }
$_compile_dir = $this->smarty->getCompileDir(); $_compile_dir = $this->smarty->getCompileDir();
return $_compile_dir . $_filepath . '.' . basename($this->source->name) . '.config' . '.php'; return $_compile_dir . $_filepath . '.' . basename($this->source->name) . '.config' . '.php';
} }
@@ -163,6 +164,7 @@ class Smarty_Internal_Config {
$this->compiled_config = file_get_contents($this->getCompiledFilepath()); $this->compiled_config = file_get_contents($this->getCompiledFilepath());
} }
} }
return $this->compiled_config; return $this->compiled_config;
} }
@@ -267,6 +269,7 @@ class Smarty_Internal_Config {
case 'source': case 'source':
case 'compiled': case 'compiled':
$this->$property_name = $value; $this->$property_name = $value;
return; return;
} }
@@ -287,10 +290,12 @@ class Smarty_Internal_Config {
throw new SmartyException("Unable to parse resource name \"{$this->config_resource}\""); throw new SmartyException("Unable to parse resource name \"{$this->config_resource}\"");
} }
$this->source = Smarty_Resource::config($this); $this->source = Smarty_Resource::config($this);
return $this->source; return $this->source;
case 'compiled': case 'compiled':
$this->compiled = $this->source->getCompiled($this); $this->compiled = $this->source->getCompiled($this);
return $this->compiled; return $this->compiled;
} }
@@ -298,5 +303,3 @@ class Smarty_Internal_Config {
} }
} }
?>

View File

@@ -16,8 +16,8 @@
* @package Smarty * @package Smarty
* @subpackage Config * @subpackage Config
*/ */
class Smarty_Internal_Config_File_Compiler { class Smarty_Internal_Config_File_Compiler
{
/** /**
* Lexer object * Lexer object
* *
@@ -140,5 +140,3 @@ class Smarty_Internal_Config_File_Compiler {
} }
} }
?>

View File

@@ -33,7 +33,7 @@ class Smarty_Internal_Configfilelexer
$this->smarty = $smarty; $this->smarty = $smarty;
$this->mbstring_overload = ini_get('mbstring.func_overload') & 2; $this->mbstring_overload = ini_get('mbstring.func_overload') & 2;
} }
public static function &instance($new_instance = null) static function &instance($new_instance = null)
{ {
static $instance = null; static $instance = null;
if (isset($new_instance) && is_object($new_instance)) if (isset($new_instance) && is_object($new_instance))

View File

@@ -102,7 +102,7 @@ class Smarty_Internal_Configfileparser#line 79 "smarty_internal_configfileparser
$this->smarty = $compiler->smarty; $this->smarty = $compiler->smarty;
$this->compiler = $compiler; $this->compiler = $compiler;
} }
public static function &instance($new_instance = null) static function &instance($new_instance = null)
{ {
static $instance = null; static $instance = null;
if (isset($new_instance) && is_object($new_instance)) if (isset($new_instance) && is_object($new_instance))
@@ -219,7 +219,7 @@ static public $yy_action = array(
/* 20 */ 15, 17, 23, 18, 27, 26, 4, 5, 6, 32, /* 20 */ 15, 17, 23, 18, 27, 26, 4, 5, 6, 32,
/* 30 */ 2, 11, 28, 22, 16, 9, 7, 10, /* 30 */ 2, 11, 28, 22, 16, 9, 7, 10,
); );
public static $yy_lookahead = array( static $yy_lookahead = array(
/* 0 */ 7, 8, 9, 10, 11, 12, 5, 27, 15, 16, /* 0 */ 7, 8, 9, 10, 11, 12, 5, 27, 15, 16,
/* 10 */ 20, 21, 23, 23, 17, 18, 13, 14, 17, 18, /* 10 */ 20, 21, 23, 23, 17, 18, 13, 14, 17, 18,
/* 20 */ 15, 2, 17, 4, 25, 26, 6, 3, 3, 14, /* 20 */ 15, 2, 17, 4, 25, 26, 6, 3, 3, 14,
@@ -227,17 +227,17 @@ static public $yy_action = array(
); );
const YY_SHIFT_USE_DFLT = -8; const YY_SHIFT_USE_DFLT = -8;
const YY_SHIFT_MAX = 19; const YY_SHIFT_MAX = 19;
public static $yy_shift_ofst = array( static $yy_shift_ofst = array(
/* 0 */ -8, 1, 1, 1, -7, -3, -3, 30, -8, -8, /* 0 */ -8, 1, 1, 1, -7, -3, -3, 30, -8, -8,
/* 10 */ -8, 19, 5, 3, 15, 16, 24, 25, 32, 20, /* 10 */ -8, 19, 5, 3, 15, 16, 24, 25, 32, 20,
); );
const YY_REDUCE_USE_DFLT = -21; const YY_REDUCE_USE_DFLT = -21;
const YY_REDUCE_MAX = 10; const YY_REDUCE_MAX = 10;
public static $yy_reduce_ofst = array( static $yy_reduce_ofst = array(
/* 0 */ -10, -1, -1, -1, -20, 10, 12, 8, 14, 7, /* 0 */ -10, -1, -1, -1, -20, 10, 12, 8, 14, 7,
/* 10 */ -11, /* 10 */ -11,
); );
public static $yyExpectedTokens = array( static $yyExpectedTokens = array(
/* 0 */ array(), /* 0 */ array(),
/* 1 */ array(5, 17, 18, ), /* 1 */ array(5, 17, 18, ),
/* 2 */ array(5, 17, 18, ), /* 2 */ array(5, 17, 18, ),
@@ -275,7 +275,7 @@ static public $yy_action = array(
/* 34 */ array(), /* 34 */ array(),
/* 35 */ array(), /* 35 */ array(),
); );
public static $yy_default = array( static $yy_default = array(
/* 0 */ 44, 37, 41, 40, 58, 58, 58, 36, 39, 44, /* 0 */ 44, 37, 41, 40, 58, 58, 58, 36, 39, 44,
/* 10 */ 44, 58, 58, 58, 58, 58, 58, 58, 58, 58, /* 10 */ 44, 58, 58, 58, 58, 58, 58, 58, 58, 58,
/* 20 */ 55, 54, 57, 56, 50, 45, 43, 42, 38, 46, /* 20 */ 55, 54, 57, 56, 50, 45, 43, 42, 38, 46,
@@ -288,9 +288,9 @@ static public $yy_action = array(
const YYERRORSYMBOL = 19; const YYERRORSYMBOL = 19;
const YYERRSYMDT = 'yy0'; const YYERRSYMDT = 'yy0';
const YYFALLBACK = 0; const YYFALLBACK = 0;
public static $yyFallback = array( static $yyFallback = array(
); );
public static function Trace($TraceFILE, $zTracePrompt) static function Trace($TraceFILE, $zTracePrompt)
{ {
if (!$TraceFILE) { if (!$TraceFILE) {
$zTracePrompt = 0; $zTracePrompt = 0;
@@ -301,14 +301,14 @@ static public $yy_action = array(
self::$yyTracePrompt = $zTracePrompt; self::$yyTracePrompt = $zTracePrompt;
} }
public static function PrintTrace() static function PrintTrace()
{ {
self::$yyTraceFILE = fopen('php://output', 'w'); self::$yyTraceFILE = fopen('php://output', 'w');
self::$yyTracePrompt = '<br>'; self::$yyTracePrompt = '<br>';
} }
public static $yyTraceFILE; static $yyTraceFILE;
public static $yyTracePrompt; static $yyTracePrompt;
public $yyidx; /* Index of top element in stack */ public $yyidx; /* Index of top element in stack */
public $yyerrcnt; /* Shifts left before out of the error */ public $yyerrcnt; /* Shifts left before out of the error */
public $yystack = array(); /* The parser's stack */ public $yystack = array(); /* The parser's stack */
@@ -323,7 +323,7 @@ static public $yy_action = array(
'section', 'newline', 'var', 'value', 'section', 'newline', 'var', 'value',
); );
public static $yyRuleName = array( static $yyRuleName = array(
/* 0 */ "start ::= global_vars sections", /* 0 */ "start ::= global_vars sections",
/* 1 */ "global_vars ::= var_list", /* 1 */ "global_vars ::= var_list",
/* 2 */ "sections ::= sections section", /* 2 */ "sections ::= sections section",
@@ -360,7 +360,7 @@ static public $yy_action = array(
} }
} }
public static function yy_destructor($yymajor, $yypminor) static function yy_destructor($yymajor, $yypminor)
{ {
switch ($yymajor) { switch ($yymajor) {
default: break; /* If no destructor action specified: do nothing */ default: break; /* If no destructor action specified: do nothing */
@@ -633,7 +633,7 @@ static public $yy_action = array(
} }
} }
public static $yyRuleInfo = array( static $yyRuleInfo = array(
array( 'lhs' => 20, 'rhs' => 2 ), array( 'lhs' => 20, 'rhs' => 2 ),
array( 'lhs' => 21, 'rhs' => 1 ), array( 'lhs' => 21, 'rhs' => 1 ),
array( 'lhs' => 22, 'rhs' => 2 ), array( 'lhs' => 22, 'rhs' => 2 ),
@@ -658,7 +658,7 @@ static public $yy_action = array(
array( 'lhs' => 25, 'rhs' => 3 ), array( 'lhs' => 25, 'rhs' => 3 ),
); );
public static $yyReduceMap = array( static $yyReduceMap = array(
0 => 0, 0 => 0,
2 => 0, 2 => 0,
3 => 0, 3 => 0,
@@ -830,8 +830,7 @@ static public $yy_action = array(
{ {
if (self::$yyTraceFILE) { if (self::$yyTraceFILE) {
fprintf(self::$yyTraceFILE, "%sFail!\n", self::$yyTracePrompt); fprintf(self::$yyTraceFILE, "%sFail!\n", self::$yyTracePrompt);
} } while ($this->yyidx >= 0) {
while ($this->yyidx >= 0) {
$this->yy_pop_parser_stack(); $this->yy_pop_parser_stack();
} }
} }

View File

@@ -15,8 +15,8 @@
* @package Smarty * @package Smarty
* @subpackage Template * @subpackage Template
*/ */
class Smarty_Internal_Data { class Smarty_Internal_Data
{
/** /**
* name of class used for templates * name of class used for templates
* *
@@ -238,6 +238,7 @@ class Smarty_Internal_Data {
} }
} }
} }
return $_result; return $_result;
} }
} }
@@ -268,6 +269,7 @@ class Smarty_Internal_Data {
public function clearAllAssign() public function clearAllAssign()
{ {
$this->tpl_vars = array(); $this->tpl_vars = array();
return $this; return $this;
} }
@@ -283,6 +285,7 @@ class Smarty_Internal_Data {
// load Config class // load Config class
$config = new Smarty_Internal_Config($config_file, $this->smarty, $this); $config = new Smarty_Internal_Config($config_file, $this->smarty, $this);
$config->loadConfigVars($sections); $config->loadConfigVars($sections);
return $this; return $this;
} }
@@ -318,6 +321,7 @@ class Smarty_Internal_Data {
// force a notice // force a notice
$x = $$variable; $x = $$variable;
} }
return new Undefined_Smarty_Variable; return new Undefined_Smarty_Variable;
} }
@@ -342,6 +346,7 @@ class Smarty_Internal_Data {
// force a notice // force a notice
$x = $$variable; $x = $$variable;
} }
return null; return null;
} }
@@ -360,6 +365,7 @@ class Smarty_Internal_Data {
$_result .= $current_line; $_result .= $current_line;
} }
fclose($fp); fclose($fp);
return $_result; return $_result;
} }
@@ -415,6 +421,7 @@ class Smarty_Internal_Data {
} else { } else {
$this->config_vars = array(); $this->config_vars = array();
} }
return $this; return $this;
} }
@@ -428,8 +435,8 @@ class Smarty_Internal_Data {
* @package Smarty * @package Smarty
* @subpackage Template * @subpackage Template
*/ */
class Smarty_Data extends Smarty_Internal_Data { class Smarty_Data extends Smarty_Internal_Data
{
/** /**
* Smarty object * Smarty object
* *
@@ -469,8 +476,8 @@ class Smarty_Data extends Smarty_Internal_Data {
* @package Smarty * @package Smarty
* @subpackage Template * @subpackage Template
*/ */
class Smarty_Variable { class Smarty_Variable
{
/** /**
* template variable * template variable
* *
@@ -524,8 +531,8 @@ class Smarty_Variable {
* @package Smarty * @package Smarty
* @subpackage Template * @subpackage Template
*/ */
class Undefined_Smarty_Variable { class Undefined_Smarty_Variable
{
/** /**
* Returns FALSE for 'nocache' and NULL otherwise. * Returns FALSE for 'nocache' and NULL otherwise.
* *
@@ -552,5 +559,3 @@ class Undefined_Smarty_Variable {
} }
} }
?>

Some files were not shown because too many files have changed in this diff Show More