upgrade to smarty 3.1.7
This commit is contained in:
parent
7e0d7a61d9
commit
d0889cbd3d
@ -1,4 +1,4 @@
|
||||
Smarty 3.1.6
|
||||
Smarty 3.1.7
|
||||
|
||||
Author: Monte Ohrt <monte at ohrt dot com >
|
||||
Author: Uwe Tews
|
||||
|
@ -1,4 +1,29 @@
|
||||
===== Smarty-3.1.6 =====
|
||||
===== Smarty-3.1.7 =====
|
||||
18.12.2011
|
||||
- bugfix strings ending with " in multiline strings of config files failed to compile (isse #67)
|
||||
- added chaining to Smarty_Internal_Templatebase
|
||||
- changed unloadFilter() to not return a boolean in favor of chaining and API conformity
|
||||
- bugfix unregisterObject() raised notice when object to unregister did not exist
|
||||
- changed internals to use Smarty::$_MBSTRING ($_CHARSET, $_DATE_FORMAT) for better unit testing
|
||||
- added Smarty::$_UTF8_MODIFIER for proper PCRE charset handling (Forum Topic 20452)
|
||||
- added Smarty_Security::isTrustedUri() and Smarty_Security::$trusted_uri to validate
|
||||
remote resource calls through {fetch} and {html_image} (Forum Topic 20627)
|
||||
|
||||
17.12.2011
|
||||
- improvement of compiling speed by new handling of plain text blocks in the lexer/parser (issue #68)
|
||||
|
||||
16.12.2011
|
||||
- bugfix the source exits flag and timestamp was not setup when template was in php include path (issue #69)
|
||||
|
||||
9.12.2011
|
||||
- bugfix {capture} tags around recursive {include} calls did throw exception (Forum Topic 20549)
|
||||
- bugfix $auto_literal = false did not work with { block} tags in child templates (Forum Topic 20581)
|
||||
- bugfix template inheritance: do not include code of {include} in overloaded {block} into compiled
|
||||
parent template (Issue #66}
|
||||
- bugfix template inheritance: {$smarty.block.child} in nested child {block} tags did not return expected
|
||||
result (Forum Topic 20564)
|
||||
|
||||
===== Smarty-3.1.6 =====
|
||||
30.11.2011
|
||||
- bugfix is_cache() for individual cached subtemplates with $smarty->caching = CACHING_OFF did produce
|
||||
an exception (Forum Topic 20531)
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -84,13 +84,13 @@ function smarty_block_textformat($params, $content, $template, &$repeat)
|
||||
continue;
|
||||
}
|
||||
// convert mult. spaces & special chars to single space
|
||||
$_paragraph = preg_replace(array('!\s+!u', '!(^\s+)|(\s+$)!u'), array(' ', ''), $_paragraph);
|
||||
$_paragraph = preg_replace(array('!\s+!' . Smarty::$_UTF8_MODIFIER, '!(^\s+)|(\s+$)!' . Smarty::$_UTF8_MODIFIER), array(' ', ''), $_paragraph);
|
||||
// indent first line
|
||||
if ($indent_first > 0) {
|
||||
$_paragraph = str_repeat($indent_char, $indent_first) . $_paragraph;
|
||||
}
|
||||
// wordwrap sentences
|
||||
if (SMARTY_MBSTRING /* ^phpunit */&&empty($_SERVER['SMARTY_PHPUNIT_DISABLE_MBSTRING'])/* phpunit$ */) {
|
||||
if (Smarty::$_MBSTRING) {
|
||||
require_once(SMARTY_PLUGINS_DIR . 'shared.mb_wordwrap.php');
|
||||
$_paragraph = smarty_mb_wordwrap($_paragraph, $wrap - $indent, $wrap_char, $wrap_cut);
|
||||
} else {
|
||||
|
@ -26,188 +26,186 @@ function smarty_function_fetch($params, $template)
|
||||
trigger_error("[plugin] fetch parameter 'file' cannot be empty",E_USER_NOTICE);
|
||||
return;
|
||||
}
|
||||
|
||||
// strip file protocol
|
||||
if (stripos($params['file'], 'file://') === 0) {
|
||||
$params['file'] = substr($params['file'], 7);
|
||||
}
|
||||
|
||||
$protocol = strpos($params['file'], '://');
|
||||
if ($protocol !== false) {
|
||||
$protocol = strtolower(substr($params['file'], 0, $protocol));
|
||||
}
|
||||
|
||||
if (isset($template->smarty->security_policy)) {
|
||||
if ($protocol) {
|
||||
// remote resource (or php stream, …)
|
||||
if(!$template->smarty->security_policy->isTrustedUri($params['file'])) {
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
// local file
|
||||
if(!$template->smarty->security_policy->isTrustedResourceDir($params['file'])) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$content = '';
|
||||
if (isset($template->smarty->security_policy) && !preg_match('!^(http|ftp)://!i', $params['file'])) {
|
||||
if(!$template->smarty->security_policy->isTrustedResourceDir($params['file'])) {
|
||||
return;
|
||||
}
|
||||
|
||||
// fetch the file
|
||||
if($fp = @fopen($params['file'],'r')) {
|
||||
while(!feof($fp)) {
|
||||
$content .= fgets ($fp,4096);
|
||||
if ($protocol == 'http') {
|
||||
// http fetch
|
||||
if($uri_parts = parse_url($params['file'])) {
|
||||
// set defaults
|
||||
$host = $server_name = $uri_parts['host'];
|
||||
$timeout = 30;
|
||||
$accept = "image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*";
|
||||
$agent = "Smarty Template Engine ". Smarty::SMARTY_VERSION;
|
||||
$referer = "";
|
||||
$uri = !empty($uri_parts['path']) ? $uri_parts['path'] : '/';
|
||||
$uri .= !empty($uri_parts['query']) ? '?' . $uri_parts['query'] : '';
|
||||
$_is_proxy = false;
|
||||
if(empty($uri_parts['port'])) {
|
||||
$port = 80;
|
||||
} else {
|
||||
$port = $uri_parts['port'];
|
||||
}
|
||||
if(!empty($uri_parts['user'])) {
|
||||
$user = $uri_parts['user'];
|
||||
}
|
||||
if(!empty($uri_parts['pass'])) {
|
||||
$pass = $uri_parts['pass'];
|
||||
}
|
||||
// loop through parameters, setup headers
|
||||
foreach($params as $param_key => $param_value) {
|
||||
switch($param_key) {
|
||||
case "file":
|
||||
case "assign":
|
||||
case "assign_headers":
|
||||
break;
|
||||
case "user":
|
||||
if(!empty($param_value)) {
|
||||
$user = $param_value;
|
||||
}
|
||||
break;
|
||||
case "pass":
|
||||
if(!empty($param_value)) {
|
||||
$pass = $param_value;
|
||||
}
|
||||
break;
|
||||
case "accept":
|
||||
if(!empty($param_value)) {
|
||||
$accept = $param_value;
|
||||
}
|
||||
break;
|
||||
case "header":
|
||||
if(!empty($param_value)) {
|
||||
if(!preg_match('![\w\d-]+: .+!',$param_value)) {
|
||||
trigger_error("[plugin] invalid header format '".$param_value."'",E_USER_NOTICE);
|
||||
return;
|
||||
} else {
|
||||
$extra_headers[] = $param_value;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case "proxy_host":
|
||||
if(!empty($param_value)) {
|
||||
$proxy_host = $param_value;
|
||||
}
|
||||
break;
|
||||
case "proxy_port":
|
||||
if(!preg_match('!\D!', $param_value)) {
|
||||
$proxy_port = (int) $param_value;
|
||||
} else {
|
||||
trigger_error("[plugin] invalid value for attribute '".$param_key."'",E_USER_NOTICE);
|
||||
return;
|
||||
}
|
||||
break;
|
||||
case "agent":
|
||||
if(!empty($param_value)) {
|
||||
$agent = $param_value;
|
||||
}
|
||||
break;
|
||||
case "referer":
|
||||
if(!empty($param_value)) {
|
||||
$referer = $param_value;
|
||||
}
|
||||
break;
|
||||
case "timeout":
|
||||
if(!preg_match('!\D!', $param_value)) {
|
||||
$timeout = (int) $param_value;
|
||||
} else {
|
||||
trigger_error("[plugin] invalid value for attribute '".$param_key."'",E_USER_NOTICE);
|
||||
return;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
trigger_error("[plugin] unrecognized attribute '".$param_key."'",E_USER_NOTICE);
|
||||
return;
|
||||
}
|
||||
}
|
||||
if(!empty($proxy_host) && !empty($proxy_port)) {
|
||||
$_is_proxy = true;
|
||||
$fp = fsockopen($proxy_host,$proxy_port,$errno,$errstr,$timeout);
|
||||
} else {
|
||||
$fp = fsockopen($server_name,$port,$errno,$errstr,$timeout);
|
||||
}
|
||||
|
||||
if(!$fp) {
|
||||
trigger_error("[plugin] unable to fetch: $errstr ($errno)",E_USER_NOTICE);
|
||||
return;
|
||||
} else {
|
||||
if($_is_proxy) {
|
||||
fputs($fp, 'GET ' . $params['file'] . " HTTP/1.0\r\n");
|
||||
} else {
|
||||
fputs($fp, "GET $uri HTTP/1.0\r\n");
|
||||
}
|
||||
if(!empty($host)) {
|
||||
fputs($fp, "Host: $host\r\n");
|
||||
}
|
||||
if(!empty($accept)) {
|
||||
fputs($fp, "Accept: $accept\r\n");
|
||||
}
|
||||
if(!empty($agent)) {
|
||||
fputs($fp, "User-Agent: $agent\r\n");
|
||||
}
|
||||
if(!empty($referer)) {
|
||||
fputs($fp, "Referer: $referer\r\n");
|
||||
}
|
||||
if(isset($extra_headers) && is_array($extra_headers)) {
|
||||
foreach($extra_headers as $curr_header) {
|
||||
fputs($fp, $curr_header."\r\n");
|
||||
}
|
||||
}
|
||||
if(!empty($user) && !empty($pass)) {
|
||||
fputs($fp, "Authorization: BASIC ".base64_encode("$user:$pass")."\r\n");
|
||||
}
|
||||
|
||||
fputs($fp, "\r\n");
|
||||
while(!feof($fp)) {
|
||||
$content .= fgets($fp,4096);
|
||||
}
|
||||
fclose($fp);
|
||||
$csplit = preg_split("!\r\n\r\n!",$content,2);
|
||||
|
||||
$content = $csplit[1];
|
||||
|
||||
if(!empty($params['assign_headers'])) {
|
||||
$template->assign($params['assign_headers'],preg_split("!\r\n!",$csplit[0]));
|
||||
}
|
||||
}
|
||||
fclose($fp);
|
||||
} else {
|
||||
trigger_error('[plugin] fetch cannot read file \'' . $params['file'] . '\'',E_USER_NOTICE);
|
||||
trigger_error("[plugin fetch] unable to parse URL, check syntax",E_USER_NOTICE);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
// not a local file
|
||||
if(preg_match('!^http://!i',$params['file'])) {
|
||||
// http fetch
|
||||
if($uri_parts = parse_url($params['file'])) {
|
||||
// set defaults
|
||||
$host = $server_name = $uri_parts['host'];
|
||||
$timeout = 30;
|
||||
$accept = "image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*";
|
||||
$agent = "Smarty Template Engine ". Smarty::SMARTY_VERSION;
|
||||
$referer = "";
|
||||
$uri = !empty($uri_parts['path']) ? $uri_parts['path'] : '/';
|
||||
$uri .= !empty($uri_parts['query']) ? '?' . $uri_parts['query'] : '';
|
||||
$_is_proxy = false;
|
||||
if(empty($uri_parts['port'])) {
|
||||
$port = 80;
|
||||
} else {
|
||||
$port = $uri_parts['port'];
|
||||
}
|
||||
if(!empty($uri_parts['user'])) {
|
||||
$user = $uri_parts['user'];
|
||||
}
|
||||
if(!empty($uri_parts['pass'])) {
|
||||
$pass = $uri_parts['pass'];
|
||||
}
|
||||
// loop through parameters, setup headers
|
||||
foreach($params as $param_key => $param_value) {
|
||||
switch($param_key) {
|
||||
case "file":
|
||||
case "assign":
|
||||
case "assign_headers":
|
||||
break;
|
||||
case "user":
|
||||
if(!empty($param_value)) {
|
||||
$user = $param_value;
|
||||
}
|
||||
break;
|
||||
case "pass":
|
||||
if(!empty($param_value)) {
|
||||
$pass = $param_value;
|
||||
}
|
||||
break;
|
||||
case "accept":
|
||||
if(!empty($param_value)) {
|
||||
$accept = $param_value;
|
||||
}
|
||||
break;
|
||||
case "header":
|
||||
if(!empty($param_value)) {
|
||||
if(!preg_match('![\w\d-]+: .+!',$param_value)) {
|
||||
trigger_error("[plugin] invalid header format '".$param_value."'",E_USER_NOTICE);
|
||||
return;
|
||||
} else {
|
||||
$extra_headers[] = $param_value;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case "proxy_host":
|
||||
if(!empty($param_value)) {
|
||||
$proxy_host = $param_value;
|
||||
}
|
||||
break;
|
||||
case "proxy_port":
|
||||
if(!preg_match('!\D!', $param_value)) {
|
||||
$proxy_port = (int) $param_value;
|
||||
} else {
|
||||
trigger_error("[plugin] invalid value for attribute '".$param_key."'",E_USER_NOTICE);
|
||||
return;
|
||||
}
|
||||
break;
|
||||
case "agent":
|
||||
if(!empty($param_value)) {
|
||||
$agent = $param_value;
|
||||
}
|
||||
break;
|
||||
case "referer":
|
||||
if(!empty($param_value)) {
|
||||
$referer = $param_value;
|
||||
}
|
||||
break;
|
||||
case "timeout":
|
||||
if(!preg_match('!\D!', $param_value)) {
|
||||
$timeout = (int) $param_value;
|
||||
} else {
|
||||
trigger_error("[plugin] invalid value for attribute '".$param_key."'",E_USER_NOTICE);
|
||||
return;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
trigger_error("[plugin] unrecognized attribute '".$param_key."'",E_USER_NOTICE);
|
||||
return;
|
||||
}
|
||||
}
|
||||
if(!empty($proxy_host) && !empty($proxy_port)) {
|
||||
$_is_proxy = true;
|
||||
$fp = fsockopen($proxy_host,$proxy_port,$errno,$errstr,$timeout);
|
||||
} else {
|
||||
$fp = fsockopen($server_name,$port,$errno,$errstr,$timeout);
|
||||
}
|
||||
|
||||
if(!$fp) {
|
||||
trigger_error("[plugin] unable to fetch: $errstr ($errno)",E_USER_NOTICE);
|
||||
return;
|
||||
} else {
|
||||
if($_is_proxy) {
|
||||
fputs($fp, 'GET ' . $params['file'] . " HTTP/1.0\r\n");
|
||||
} else {
|
||||
fputs($fp, "GET $uri HTTP/1.0\r\n");
|
||||
}
|
||||
if(!empty($host)) {
|
||||
fputs($fp, "Host: $host\r\n");
|
||||
}
|
||||
if(!empty($accept)) {
|
||||
fputs($fp, "Accept: $accept\r\n");
|
||||
}
|
||||
if(!empty($agent)) {
|
||||
fputs($fp, "User-Agent: $agent\r\n");
|
||||
}
|
||||
if(!empty($referer)) {
|
||||
fputs($fp, "Referer: $referer\r\n");
|
||||
}
|
||||
if(isset($extra_headers) && is_array($extra_headers)) {
|
||||
foreach($extra_headers as $curr_header) {
|
||||
fputs($fp, $curr_header."\r\n");
|
||||
}
|
||||
}
|
||||
if(!empty($user) && !empty($pass)) {
|
||||
fputs($fp, "Authorization: BASIC ".base64_encode("$user:$pass")."\r\n");
|
||||
}
|
||||
|
||||
fputs($fp, "\r\n");
|
||||
while(!feof($fp)) {
|
||||
$content .= fgets($fp,4096);
|
||||
}
|
||||
fclose($fp);
|
||||
$csplit = preg_split("!\r\n\r\n!",$content,2);
|
||||
|
||||
$content = $csplit[1];
|
||||
|
||||
if(!empty($params['assign_headers'])) {
|
||||
$template->assign($params['assign_headers'],preg_split("!\r\n!",$csplit[0]));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
trigger_error("[plugin fetch] unable to parse URL, check syntax",E_USER_NOTICE);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
// ftp fetch
|
||||
if($fp = @fopen($params['file'],'r')) {
|
||||
while(!feof($fp)) {
|
||||
$content .= fgets ($fp,4096);
|
||||
}
|
||||
fclose($fp);
|
||||
} else {
|
||||
trigger_error('[plugin] fetch cannot read file \'' . $params['file'] .'\'',E_USER_NOTICE);
|
||||
return;
|
||||
}
|
||||
$content = @file_get_contents($params['file']);
|
||||
if ($content === false) {
|
||||
throw new SmartyException("{fetch} cannot read resource '" . $params['file'] ."'");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
if (!empty($params['assign'])) {
|
||||
$template->assign($params['assign'],$content);
|
||||
$template->assign($params['assign'], $content);
|
||||
} else {
|
||||
return $content;
|
||||
}
|
||||
|
@ -177,7 +177,7 @@ function smarty_function_html_checkboxes_output($name, $value, $output, $selecte
|
||||
|
||||
if ($labels) {
|
||||
if ($label_ids) {
|
||||
$_id = smarty_function_escape_special_chars(preg_replace('![^\w\-\.]!u', '_', $name . '_' . $value));
|
||||
$_id = smarty_function_escape_special_chars(preg_replace('![^\w\-\.]!' . Smarty::$_UTF8_MODIFIER, '_', $name . '_' . $value));
|
||||
$_output .= '<label for="' . $_id . '">';
|
||||
} else {
|
||||
$_output .= '<label>';
|
||||
|
@ -46,8 +46,7 @@ function smarty_function_html_image($params, $template)
|
||||
$prefix = '';
|
||||
$suffix = '';
|
||||
$path_prefix = '';
|
||||
$server_vars = $_SERVER;
|
||||
$basedir = isset($server_vars['DOCUMENT_ROOT']) ? $server_vars['DOCUMENT_ROOT'] : '';
|
||||
$basedir = isset($_SERVER['DOCUMENT_ROOT']) ? $_SERVER['DOCUMENT_ROOT'] : '';
|
||||
foreach($params as $_key => $_val) {
|
||||
switch ($_key) {
|
||||
case 'file':
|
||||
@ -88,13 +87,38 @@ function smarty_function_html_image($params, $template)
|
||||
return;
|
||||
}
|
||||
|
||||
if (substr($file, 0, 1) == '/') {
|
||||
if ($file[0] == '/') {
|
||||
$_image_path = $basedir . $file;
|
||||
} else {
|
||||
$_image_path = $file;
|
||||
}
|
||||
}
|
||||
|
||||
// strip file protocol
|
||||
if (stripos($params['file'], 'file://') === 0) {
|
||||
$params['file'] = substr($params['file'], 7);
|
||||
}
|
||||
|
||||
$protocol = strpos($params['file'], '://');
|
||||
if ($protocol !== false) {
|
||||
$protocol = strtolower(substr($params['file'], 0, $protocol));
|
||||
}
|
||||
|
||||
if (isset($template->smarty->security_policy)) {
|
||||
if ($protocol) {
|
||||
// remote resource (or php stream, …)
|
||||
if(!$template->smarty->security_policy->isTrustedUri($params['file'])) {
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
// local file
|
||||
if(!$template->smarty->security_policy->isTrustedResourceDir($params['file'])) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!isset($params['width']) || !isset($params['height'])) {
|
||||
// FIXME: (rodneyrehm) getimagesize() loads the complete file off a remote resource, use custom [jpg,png,gif]header reader!
|
||||
if (!$_image_data = @getimagesize($_image_path)) {
|
||||
if (!file_exists($_image_path)) {
|
||||
trigger_error("html_image: unable to find '$_image_path'", E_USER_NOTICE);
|
||||
@ -106,12 +130,7 @@ function smarty_function_html_image($params, $template)
|
||||
trigger_error("html_image: '$_image_path' is not a valid image file", E_USER_NOTICE);
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (isset($template->smarty->security_policy)) {
|
||||
if (!$template->smarty->security_policy->isTrustedResourceDir($_image_path)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!isset($params['width'])) {
|
||||
$width = $_image_data[0];
|
||||
@ -122,7 +141,9 @@ function smarty_function_html_image($params, $template)
|
||||
}
|
||||
|
||||
if (isset($params['dpi'])) {
|
||||
if (strstr($server_vars['HTTP_USER_AGENT'], 'Mac')) {
|
||||
if (strstr($_SERVER['HTTP_USER_AGENT'], 'Mac')) {
|
||||
// FIXME: (rodneyrehm) wrong dpi assumption
|
||||
// don't know who thought this up… even if it was true in 1998, it's definitely wrong in 2011.
|
||||
$dpi_default = 72;
|
||||
} else {
|
||||
$dpi_default = 96;
|
||||
|
@ -165,7 +165,7 @@ function smarty_function_html_radios_output($name, $value, $output, $selected, $
|
||||
|
||||
if ($labels) {
|
||||
if ($label_ids) {
|
||||
$_id = smarty_function_escape_special_chars(preg_replace('![^\w\-\.]!u', '_', $name . '_' . $value));
|
||||
$_id = smarty_function_escape_special_chars(preg_replace('![^\w\-\.]!' . Smarty::$_UTF8_MODIFIER, '_', $name . '_' . $value));
|
||||
$_output .= '<label for="' . $_id . '">';
|
||||
} else {
|
||||
$_output .= '<label>';
|
||||
|
@ -130,7 +130,7 @@ function smarty_function_mailto($params, $template)
|
||||
}
|
||||
$address_encode = '';
|
||||
for ($x = 0, $_length = strlen($address); $x < $_length; $x++) {
|
||||
if (preg_match('!\w!u', $address[$x])) {
|
||||
if (preg_match('!\w!' . Smarty::$_UTF8_MODIFIER, $address[$x])) {
|
||||
$address_encode .= '%' . bin2hex($address[$x]);
|
||||
} else {
|
||||
$address_encode .= $address[$x];
|
||||
|
@ -24,23 +24,23 @@
|
||||
*/
|
||||
function smarty_modifier_capitalize($string, $uc_digits = false, $lc_rest = false)
|
||||
{
|
||||
if (SMARTY_MBSTRING /* ^phpunit */&&empty($_SERVER['SMARTY_PHPUNIT_DISABLE_MBSTRING'])/* phpunit$ */) {
|
||||
if (Smarty::$_MBSTRING) {
|
||||
if ($lc_rest) {
|
||||
// uppercase (including hyphenated words)
|
||||
$upper_string = mb_convert_case( $string, MB_CASE_TITLE, SMARTY_RESOURCE_CHAR_SET );
|
||||
$upper_string = mb_convert_case( $string, MB_CASE_TITLE, Smarty::$_CHARSET );
|
||||
} else {
|
||||
// uppercase word breaks
|
||||
$upper_string = preg_replace("!(^|[^\p{L}'])([\p{Ll}])!ueS", "stripslashes('\\1').mb_convert_case(stripslashes('\\2'),MB_CASE_UPPER, SMARTY_RESOURCE_CHAR_SET)", $string);
|
||||
$upper_string = preg_replace("!(^|[^\p{L}'])([\p{Ll}])!eS" . Smarty::$_UTF8_MODIFIER, "stripslashes('\\1').mb_convert_case(stripslashes('\\2'),MB_CASE_UPPER, '" . addslashes(Smarty::$_CHARSET) . "')", $string);
|
||||
}
|
||||
// check uc_digits case
|
||||
if (!$uc_digits) {
|
||||
if (preg_match_all("!\b([\p{L}]*[\p{N}]+[\p{L}]*)\b!u", $string, $matches, PREG_OFFSET_CAPTURE)) {
|
||||
if (preg_match_all("!\b([\p{L}]*[\p{N}]+[\p{L}]*)\b!" . Smarty::$_UTF8_MODIFIER, $string, $matches, PREG_OFFSET_CAPTURE)) {
|
||||
foreach($matches[1] as $match) {
|
||||
$upper_string = substr_replace($upper_string, mb_strtolower($match[0], SMARTY_RESOURCE_CHAR_SET), $match[1], strlen($match[0]));
|
||||
$upper_string = substr_replace($upper_string, mb_strtolower($match[0], Smarty::$_CHARSET), $match[1], strlen($match[0]));
|
||||
}
|
||||
}
|
||||
}
|
||||
$upper_string = preg_replace("!((^|\s)['\"])(\w)!ue", "stripslashes('\\1').mb_convert_case(stripslashes('\\3'),MB_CASE_UPPER, SMARTY_RESOURCE_CHAR_SET)", $upper_string);
|
||||
$upper_string = preg_replace("!((^|\s)['\"])(\w)!e" . Smarty::$_UTF8_MODIFIER, "stripslashes('\\1').mb_convert_case(stripslashes('\\3'),MB_CASE_UPPER, '" . addslashes(Smarty::$_CHARSET) . "')", $upper_string);
|
||||
return $upper_string;
|
||||
}
|
||||
|
||||
@ -49,16 +49,16 @@ function smarty_modifier_capitalize($string, $uc_digits = false, $lc_rest = fals
|
||||
$string = strtolower($string);
|
||||
}
|
||||
// uppercase (including hyphenated words)
|
||||
$upper_string = preg_replace("!(^|[^\p{L}'])([\p{Ll}])!ueS", "stripslashes('\\1').ucfirst(stripslashes('\\2'))", $string);
|
||||
$upper_string = preg_replace("!(^|[^\p{L}'])([\p{Ll}])!eS" . Smarty::$_UTF8_MODIFIER, "stripslashes('\\1').ucfirst(stripslashes('\\2'))", $string);
|
||||
// check uc_digits case
|
||||
if (!$uc_digits) {
|
||||
if (preg_match_all("!\b([\p{L}]*[\p{N}]+[\p{L}]*)\b!u", $string, $matches, PREG_OFFSET_CAPTURE)) {
|
||||
if (preg_match_all("!\b([\p{L}]*[\p{N}]+[\p{L}]*)\b!" . Smarty::$_UTF8_MODIFIER, $string, $matches, PREG_OFFSET_CAPTURE)) {
|
||||
foreach($matches[1] as $match) {
|
||||
$upper_string = substr_replace($upper_string, strtolower($match[0]), $match[1], strlen($match[0]));
|
||||
}
|
||||
}
|
||||
}
|
||||
$upper_string = preg_replace("!((^|\s)['\"])(\w)!ue", "stripslashes('\\1').strtoupper(stripslashes('\\3'))", $upper_string);
|
||||
$upper_string = preg_replace("!((^|\s)['\"])(\w)!e" . Smarty::$_UTF8_MODIFIER, "stripslashes('\\1').strtoupper(stripslashes('\\3'))", $upper_string);
|
||||
return $upper_string;
|
||||
}
|
||||
|
||||
|
@ -26,8 +26,11 @@
|
||||
* @return string |void
|
||||
* @uses smarty_make_timestamp()
|
||||
*/
|
||||
function smarty_modifier_date_format($string, $format = SMARTY_RESOURCE_DATE_FORMAT, $default_date = '',$formatter='auto')
|
||||
function smarty_modifier_date_format($string, $format=null, $default_date='', $formatter='auto')
|
||||
{
|
||||
if ($format === null) {
|
||||
$format = Smarty::$_DATE_FORMAT;
|
||||
}
|
||||
/**
|
||||
* Include the {@link shared.make_timestamp.php} plugin
|
||||
*/
|
||||
|
@ -70,9 +70,9 @@ function smarty_modifier_debug_print_var ($var, $depth = 0, $length = 40)
|
||||
|
||||
case 'string' :
|
||||
$results = strtr($var, $_replace);
|
||||
if (SMARTY_MBSTRING /* ^phpunit */&&empty($_SERVER['SMARTY_PHPUNIT_DISABLE_MBSTRING'])/* phpunit$ */) {
|
||||
if (mb_strlen($var, SMARTY_RESOURCE_CHAR_SET) > $length) {
|
||||
$results = mb_substr($var, 0, $length - 3, SMARTY_RESOURCE_CHAR_SET) . '...';
|
||||
if (Smarty::$_MBSTRING) {
|
||||
if (mb_strlen($var, Smarty::$_CHARSET) > $length) {
|
||||
$results = mb_substr($var, 0, $length - 3, Smarty::$_CHARSET) . '...';
|
||||
}
|
||||
} else {
|
||||
if (isset($var[$length])) {
|
||||
@ -86,9 +86,9 @@ function smarty_modifier_debug_print_var ($var, $depth = 0, $length = 40)
|
||||
case 'unknown type' :
|
||||
default :
|
||||
$results = strtr((string) $var, $_replace);
|
||||
if (SMARTY_MBSTRING /* ^phpunit */&&empty($_SERVER['SMARTY_PHPUNIT_DISABLE_MBSTRING'])/* phpunit$ */) {
|
||||
if (mb_strlen($results, SMARTY_RESOURCE_CHAR_SET) > $length) {
|
||||
$results = mb_substr($results, 0, $length - 3, SMARTY_RESOURCE_CHAR_SET) . '...';
|
||||
if (Smarty::$_MBSTRING) {
|
||||
if (mb_strlen($results, Smarty::$_CHARSET) > $length) {
|
||||
$results = mb_substr($results, 0, $length - 3, Smarty::$_CHARSET) . '...';
|
||||
}
|
||||
} else {
|
||||
if (strlen($results) > $length) {
|
||||
|
@ -24,7 +24,7 @@
|
||||
function smarty_modifier_escape($string, $esc_type = 'html', $char_set = null, $double_encode = true)
|
||||
{
|
||||
if (!$char_set) {
|
||||
$char_set = SMARTY_RESOURCE_CHAR_SET;
|
||||
$char_set = Smarty::$_CHARSET;
|
||||
}
|
||||
|
||||
switch ($esc_type) {
|
||||
@ -32,7 +32,7 @@ function smarty_modifier_escape($string, $esc_type = 'html', $char_set = null, $
|
||||
return htmlspecialchars($string, ENT_QUOTES, $char_set, $double_encode);
|
||||
|
||||
case 'htmlall':
|
||||
if (SMARTY_MBSTRING /* ^phpunit */ && empty($_SERVER['SMARTY_PHPUNIT_DISABLE_MBSTRING'])/* phpunit$ */) {
|
||||
if (Smarty::$_MBSTRING) {
|
||||
// mb_convert_encoding ignores htmlspecialchars()
|
||||
$string = htmlspecialchars($string, ENT_QUOTES, $char_set, $double_encode);
|
||||
// htmlentities() won't convert everything, so use mb_convert_encoding
|
||||
@ -64,10 +64,10 @@ function smarty_modifier_escape($string, $esc_type = 'html', $char_set = null, $
|
||||
|
||||
case 'hexentity':
|
||||
$return = '';
|
||||
if (SMARTY_MBSTRING /* ^phpunit */ && empty($_SERVER['SMARTY_PHPUNIT_DISABLE_MBSTRING'])/* phpunit$ */) {
|
||||
if (Smarty::$_MBSTRING) {
|
||||
require_once(SMARTY_PLUGINS_DIR . 'shared.mb_unicode.php');
|
||||
$return = '';
|
||||
foreach (smarty_mb_to_unicode($string, SMARTY_RESOURCE_CHAR_SET) as $unicode) {
|
||||
foreach (smarty_mb_to_unicode($string, Smarty::$_CHARSET) as $unicode) {
|
||||
$return .= '&#x' . strtoupper(dechex($unicode)) . ';';
|
||||
}
|
||||
return $return;
|
||||
@ -81,10 +81,10 @@ function smarty_modifier_escape($string, $esc_type = 'html', $char_set = null, $
|
||||
|
||||
case 'decentity':
|
||||
$return = '';
|
||||
if (SMARTY_MBSTRING /* ^phpunit */ && empty($_SERVER['SMARTY_PHPUNIT_DISABLE_MBSTRING'])/* phpunit$ */) {
|
||||
if (Smarty::$_MBSTRING) {
|
||||
require_once(SMARTY_PLUGINS_DIR . 'shared.mb_unicode.php');
|
||||
$return = '';
|
||||
foreach (smarty_mb_to_unicode($string, SMARTY_RESOURCE_CHAR_SET) as $unicode) {
|
||||
foreach (smarty_mb_to_unicode($string, Smarty::$_CHARSET) as $unicode) {
|
||||
$return .= '&#' . $unicode . ';';
|
||||
}
|
||||
return $return;
|
||||
@ -101,7 +101,7 @@ function smarty_modifier_escape($string, $esc_type = 'html', $char_set = null, $
|
||||
return strtr($string, array('\\' => '\\\\', "'" => "\\'", '"' => '\\"', "\r" => '\\r', "\n" => '\\n', '</' => '<\/'));
|
||||
|
||||
case 'mail':
|
||||
if (SMARTY_MBSTRING /* ^phpunit */ && empty($_SERVER['SMARTY_PHPUNIT_DISABLE_MBSTRING'])/* phpunit$ */) {
|
||||
if (Smarty::$_MBSTRING) {
|
||||
require_once(SMARTY_PLUGINS_DIR . 'shared.mb_str_replace.php');
|
||||
return smarty_mb_str_replace(array('@', '.'), array(' [AT] ', ' [DOT] '), $string);
|
||||
}
|
||||
@ -111,9 +111,9 @@ function smarty_modifier_escape($string, $esc_type = 'html', $char_set = null, $
|
||||
case 'nonstd':
|
||||
// escape non-standard chars, such as ms document quotes
|
||||
$return = '';
|
||||
if (SMARTY_MBSTRING /* ^phpunit */ && empty($_SERVER['SMARTY_PHPUNIT_DISABLE_MBSTRING'])/* phpunit$ */) {
|
||||
if (Smarty::$_MBSTRING) {
|
||||
require_once(SMARTY_PLUGINS_DIR . 'shared.mb_unicode.php');
|
||||
foreach (smarty_mb_to_unicode($string, SMARTY_RESOURCE_CHAR_SET) as $unicode) {
|
||||
foreach (smarty_mb_to_unicode($string, Smarty::$_CHARSET) as $unicode) {
|
||||
if ($unicode >= 126) {
|
||||
$return .= '&#' . $unicode . ';';
|
||||
} else {
|
||||
|
@ -22,7 +22,7 @@
|
||||
*/
|
||||
function smarty_modifier_replace($string, $search, $replace)
|
||||
{
|
||||
if (SMARTY_MBSTRING /* ^phpunit */&&empty($_SERVER['SMARTY_PHPUNIT_DISABLE_MBSTRING'])/* phpunit$ */) {
|
||||
if (Smarty::$_MBSTRING) {
|
||||
require_once(SMARTY_PLUGINS_DIR . 'shared.mb_str_replace.php');
|
||||
return smarty_mb_str_replace($search, $replace, $string);
|
||||
}
|
||||
|
@ -21,7 +21,7 @@
|
||||
function smarty_modifier_spacify($string, $spacify_char = ' ')
|
||||
{
|
||||
// well… what about charsets besides latin and UTF-8?
|
||||
return implode($spacify_char, preg_split('//u', $string, -1, PREG_SPLIT_NO_EMPTY));
|
||||
return implode($spacify_char, preg_split('//' . Smarty::$_UTF8_MODIFIER, $string, -1, PREG_SPLIT_NO_EMPTY));
|
||||
}
|
||||
|
||||
?>
|
@ -28,16 +28,16 @@ function smarty_modifier_truncate($string, $length = 80, $etc = '...', $break_wo
|
||||
if ($length == 0)
|
||||
return '';
|
||||
|
||||
if (SMARTY_MBSTRING /* ^phpunit */&&empty($_SERVER['SMARTY_PHPUNIT_DISABLE_MBSTRING'])/* phpunit$ */) {
|
||||
if (mb_strlen($string, SMARTY_RESOURCE_CHAR_SET) > $length) {
|
||||
$length -= min($length, mb_strlen($etc, SMARTY_RESOURCE_CHAR_SET));
|
||||
if (Smarty::$_MBSTRING) {
|
||||
if (mb_strlen($string, Smarty::$_CHARSET) > $length) {
|
||||
$length -= min($length, mb_strlen($etc, Smarty::$_CHARSET));
|
||||
if (!$break_words && !$middle) {
|
||||
$string = preg_replace('/\s+?(\S+)?$/u', '', mb_substr($string, 0, $length + 1, SMARTY_RESOURCE_CHAR_SET));
|
||||
$string = preg_replace('/\s+?(\S+)?$/' . Smarty::$_UTF8_MODIFIER, '', mb_substr($string, 0, $length + 1, Smarty::$_CHARSET));
|
||||
}
|
||||
if (!$middle) {
|
||||
return mb_substr($string, 0, $length, SMARTY_RESOURCE_CHAR_SET) . $etc;
|
||||
return mb_substr($string, 0, $length, Smarty::$_CHARSET) . $etc;
|
||||
}
|
||||
return mb_substr($string, 0, $length / 2, SMARTY_RESOURCE_CHAR_SET) . $etc . mb_substr($string, - $length / 2, $length, SMARTY_RESOURCE_CHAR_SET);
|
||||
return mb_substr($string, 0, $length / 2, Smarty::$_CHARSET) . $etc . mb_substr($string, - $length / 2, $length, Smarty::$_CHARSET);
|
||||
}
|
||||
return $string;
|
||||
}
|
||||
|
@ -21,10 +21,10 @@
|
||||
function smarty_modifiercompiler_count_characters($params, $compiler)
|
||||
{
|
||||
if (!isset($params[1]) || $params[1] != 'true') {
|
||||
return 'preg_match_all(\'/[^\s]/u\',' . $params[0] . ', $tmp)';
|
||||
return 'preg_match_all(\'/[^\s]/' . Smarty::$_UTF8_MODIFIER . '\',' . $params[0] . ', $tmp)';
|
||||
}
|
||||
if (SMARTY_MBSTRING /* ^phpunit */&&empty($_SERVER['SMARTY_PHPUNIT_DISABLE_MBSTRING'])/* phpunit$ */) {
|
||||
return 'mb_strlen(' . $params[0] . ', SMARTY_RESOURCE_CHAR_SET)';
|
||||
if (Smarty::$_MBSTRING) {
|
||||
return 'mb_strlen(' . $params[0] . ', \'' . addslashes(Smarty::$_CHARSET) . '\')';
|
||||
}
|
||||
// no MBString fallback
|
||||
return 'strlen(' . $params[0] . ')';
|
||||
|
@ -22,7 +22,7 @@
|
||||
function smarty_modifiercompiler_count_sentences($params, $compiler)
|
||||
{
|
||||
// find periods, question marks, exclamation marks with a word before but not after.
|
||||
return 'preg_match_all("#\w[\.\?\!](\W|$)#uS", ' . $params[0] . ', $tmp)';
|
||||
return 'preg_match_all("#\w[\.\?\!](\W|$)#S' . Smarty::$_UTF8_MODIFIER . '", ' . $params[0] . ', $tmp)';
|
||||
}
|
||||
|
||||
?>
|
@ -20,10 +20,10 @@
|
||||
*/
|
||||
function smarty_modifiercompiler_count_words($params, $compiler)
|
||||
{
|
||||
if (SMARTY_MBSTRING /* ^phpunit */&&empty($_SERVER['SMARTY_PHPUNIT_DISABLE_MBSTRING'])/* phpunit$ */) {
|
||||
// return 'preg_match_all(\'#[\w\pL]+#u\', ' . $params[0] . ', $tmp)';
|
||||
if (Smarty::$_MBSTRING) {
|
||||
// return 'preg_match_all(\'#[\w\pL]+#' . Smarty::$_UTF8_MODIFIER . '\', ' . $params[0] . ', $tmp)';
|
||||
// expression taken from http://de.php.net/manual/en/function.str-word-count.php#85592
|
||||
return 'preg_match_all(\'/\p{L}[\p{L}\p{Mn}\p{Pd}\\\'\x{2019}]*/u\', ' . $params[0] . ', $tmp)';
|
||||
return 'preg_match_all(\'/\p{L}[\p{L}\p{Mn}\p{Pd}\\\'\x{2019}]*/' . Smarty::$_UTF8_MODIFIER . '\', ' . $params[0] . ', $tmp)';
|
||||
}
|
||||
// no MBString fallback
|
||||
return 'str_word_count(' . $params[0] . ')';
|
||||
|
@ -27,11 +27,11 @@ function smarty_modifiercompiler_escape($params, $compiler)
|
||||
{
|
||||
try {
|
||||
$esc_type = smarty_literal_compiler_param($params, 1, 'html');
|
||||
$char_set = smarty_literal_compiler_param($params, 2, SMARTY_RESOURCE_CHAR_SET);
|
||||
$char_set = smarty_literal_compiler_param($params, 2, Smarty::$_CHARSET);
|
||||
$double_encode = smarty_literal_compiler_param($params, 3, true);
|
||||
|
||||
if (!$char_set) {
|
||||
$char_set = SMARTY_RESOURCE_CHAR_SET;
|
||||
$char_set = Smarty::$_CHARSET;
|
||||
}
|
||||
|
||||
switch ($esc_type) {
|
||||
@ -42,7 +42,7 @@ function smarty_modifiercompiler_escape($params, $compiler)
|
||||
. var_export($double_encode, true) . ')';
|
||||
|
||||
case 'htmlall':
|
||||
if (SMARTY_MBSTRING /* ^phpunit */&&empty($_SERVER['SMARTY_PHPUNIT_DISABLE_MBSTRING'])/* phpunit$ */) {
|
||||
if (Smarty::$_MBSTRING) {
|
||||
return 'mb_convert_encoding(htmlspecialchars('
|
||||
. $params[0] .', ENT_QUOTES, '
|
||||
. var_export($char_set, true) . ', '
|
||||
|
@ -19,7 +19,7 @@
|
||||
*/
|
||||
function smarty_modifiercompiler_from_charset($params, $compiler)
|
||||
{
|
||||
if (!SMARTY_MBSTRING /* ^phpunit */&&empty($_SERVER['SMARTY_PHPUNIT_DISABLE_MBSTRING'])/* phpunit$ */) {
|
||||
if (!Smarty::$_MBSTRING) {
|
||||
// FIXME: (rodneyrehm) shouldn't this throw an error?
|
||||
return $params[0];
|
||||
}
|
||||
@ -28,7 +28,7 @@ function smarty_modifiercompiler_from_charset($params, $compiler)
|
||||
$params[1] = '"ISO-8859-1"';
|
||||
}
|
||||
|
||||
return 'mb_convert_encoding(' . $params[0] . ', SMARTY_RESOURCE_CHAR_SET, ' . $params[1] . ')';
|
||||
return 'mb_convert_encoding(' . $params[0] . ', "' . addslashes(Smarty::$_CHARSET) . '", ' . $params[1] . ')';
|
||||
}
|
||||
|
||||
?>
|
@ -21,8 +21,8 @@
|
||||
|
||||
function smarty_modifiercompiler_lower($params, $compiler)
|
||||
{
|
||||
if (SMARTY_MBSTRING /* ^phpunit */&&empty($_SERVER['SMARTY_PHPUNIT_DISABLE_MBSTRING'])/* phpunit$ */) {
|
||||
return 'mb_strtolower(' . $params[0] . ',SMARTY_RESOURCE_CHAR_SET)' ;
|
||||
if (Smarty::$_MBSTRING) {
|
||||
return 'mb_strtolower(' . $params[0] . ', \'' . addslashes(Smarty::$_CHARSET) . '\')' ;
|
||||
}
|
||||
// no MBString fallback
|
||||
return 'strtolower(' . $params[0] . ')';
|
||||
|
@ -27,7 +27,7 @@ function smarty_modifiercompiler_strip($params, $compiler)
|
||||
if (!isset($params[1])) {
|
||||
$params[1] = "' '";
|
||||
}
|
||||
return "preg_replace('!\s+!u', {$params[1]},{$params[0]})";
|
||||
return "preg_replace('!\s+!" . Smarty::$_UTF8_MODIFIER . "', {$params[1]},{$params[0]})";
|
||||
}
|
||||
|
||||
?>
|
@ -19,7 +19,7 @@
|
||||
*/
|
||||
function smarty_modifiercompiler_to_charset($params, $compiler)
|
||||
{
|
||||
if (!SMARTY_MBSTRING /* ^phpunit */&&empty($_SERVER['SMARTY_PHPUNIT_DISABLE_MBSTRING'])/* phpunit$ */) {
|
||||
if (!Smarty::$_MBSTRING) {
|
||||
// FIXME: (rodneyrehm) shouldn't this throw an error?
|
||||
return $params[0];
|
||||
}
|
||||
@ -28,7 +28,7 @@ function smarty_modifiercompiler_to_charset($params, $compiler)
|
||||
$params[1] = '"ISO-8859-1"';
|
||||
}
|
||||
|
||||
return 'mb_convert_encoding(' . $params[0] . ', ' . $params[1] . ', SMARTY_RESOURCE_CHAR_SET)';
|
||||
return 'mb_convert_encoding(' . $params[0] . ', ' . $params[1] . ', "' . addslashes(Smarty::$_CHARSET) . '")';
|
||||
}
|
||||
|
||||
?>
|
@ -23,7 +23,7 @@ function smarty_modifiercompiler_unescape($params, $compiler)
|
||||
$params[1] = 'html';
|
||||
}
|
||||
if (!isset($params[2])) {
|
||||
$params[2] = "SMARTY_RESOURCE_CHAR_SET";
|
||||
$params[2] = '\'' . addslashes(Smarty::$_CHARSET) . '\'';
|
||||
} else {
|
||||
$params[2] = "'" . $params[2] . "'";
|
||||
}
|
||||
@ -32,7 +32,7 @@ function smarty_modifiercompiler_unescape($params, $compiler)
|
||||
case 'entity':
|
||||
return 'mb_convert_encoding(' . $params[0] . ', ' . $params[2] . ', \'HTML-ENTITIES\')';
|
||||
case 'htmlall':
|
||||
if (SMARTY_MBSTRING /* ^phpunit */&&empty($_SERVER['SMARTY_PHPUNIT_DISABLE_MBSTRING'])/* phpunit$ */) {
|
||||
if (Smarty::$_MBSTRING) {
|
||||
return 'mb_convert_encoding(' . $params[0] . ', ' . $params[2] . ', \'HTML-ENTITIES\')';
|
||||
}
|
||||
return 'html_entity_decode(' . $params[0] . ', ENT_QUOTES, ' . $params[2] . ')';
|
||||
|
@ -20,8 +20,8 @@
|
||||
*/
|
||||
function smarty_modifiercompiler_upper($params, $compiler)
|
||||
{
|
||||
if (SMARTY_MBSTRING /* ^phpunit */&&empty($_SERVER['SMARTY_PHPUNIT_DISABLE_MBSTRING'])/* phpunit$ */) {
|
||||
return 'mb_strtoupper(' . $params[0] . ',SMARTY_RESOURCE_CHAR_SET)' ;
|
||||
if (Smarty::$_MBSTRING) {
|
||||
return 'mb_strtoupper(' . $params[0] . ', \'' . addslashes(Smarty::$_CHARSET) . '\')' ;
|
||||
}
|
||||
// no MBString fallback
|
||||
return 'strtoupper(' . $params[0] . ')';
|
||||
|
@ -30,7 +30,7 @@ function smarty_modifiercompiler_wordwrap($params, $compiler)
|
||||
$params[3] = 'false';
|
||||
}
|
||||
$function = 'wordwrap';
|
||||
if (SMARTY_MBSTRING /* ^phpunit */&&empty($_SERVER['SMARTY_PHPUNIT_DISABLE_MBSTRING'])/* phpunit$ */) {
|
||||
if (Smarty::$_MBSTRING) {
|
||||
if ($compiler->tag_nocache | $compiler->nocache) {
|
||||
$compiler->template->required_plugins['nocache']['wordwrap']['modifier']['file'] = SMARTY_PLUGINS_DIR .'shared.mb_wordwrap.php';
|
||||
$compiler->template->required_plugins['nocache']['wordwrap']['modifier']['function'] = 'smarty_mb_wordwrap';
|
||||
|
@ -21,7 +21,7 @@ if (version_compare(PHP_VERSION, '5.2.3', '>=')) {
|
||||
function smarty_function_escape_special_chars($string)
|
||||
{
|
||||
if (!is_array($string)) {
|
||||
$string = htmlspecialchars($string, ENT_COMPAT, SMARTY_RESOURCE_CHAR_SET, false);
|
||||
$string = htmlspecialchars($string, ENT_COMPAT, Smarty::$_CHARSET, false);
|
||||
}
|
||||
return $string;
|
||||
}
|
||||
|
@ -22,36 +22,36 @@ if(!function_exists('smarty_mb_wordwrap')) {
|
||||
function smarty_mb_wordwrap($str, $width=75, $break="\n", $cut=false)
|
||||
{
|
||||
// break words into tokens using white space as a delimiter
|
||||
$tokens = preg_split('!(\s)!uS', $str, -1, PREG_SPLIT_NO_EMPTY + PREG_SPLIT_DELIM_CAPTURE);
|
||||
$tokens = preg_split('!(\s)!S' . Smarty::$_UTF8_MODIFIER, $str, -1, PREG_SPLIT_NO_EMPTY + PREG_SPLIT_DELIM_CAPTURE);
|
||||
$length = 0;
|
||||
$t = '';
|
||||
$_previous = false;
|
||||
|
||||
foreach ($tokens as $_token) {
|
||||
$token_length = mb_strlen($_token, SMARTY_RESOURCE_CHAR_SET);
|
||||
$token_length = mb_strlen($_token, Smarty::$_CHARSET);
|
||||
$_tokens = array($_token);
|
||||
if ($token_length > $width) {
|
||||
// remove last space
|
||||
$t = mb_substr($t, 0, -1, SMARTY_RESOURCE_CHAR_SET);
|
||||
$t = mb_substr($t, 0, -1, Smarty::$_CHARSET);
|
||||
$_previous = false;
|
||||
$length = 0;
|
||||
|
||||
if ($cut) {
|
||||
$_tokens = preg_split('!(.{' . $width . '})!uS', $_token, -1, PREG_SPLIT_NO_EMPTY + PREG_SPLIT_DELIM_CAPTURE);
|
||||
$_tokens = preg_split('!(.{' . $width . '})!S' . Smarty::$_UTF8_MODIFIER, $_token, -1, PREG_SPLIT_NO_EMPTY + PREG_SPLIT_DELIM_CAPTURE);
|
||||
// broken words go on a new line
|
||||
$t .= $break;
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($_tokens as $token) {
|
||||
$_space = !!preg_match('!^\s$!uS', $token);
|
||||
$token_length = mb_strlen($token, SMARTY_RESOURCE_CHAR_SET);
|
||||
$_space = !!preg_match('!^\s$!S' . Smarty::$_UTF8_MODIFIER, $token);
|
||||
$token_length = mb_strlen($token, Smarty::$_CHARSET);
|
||||
$length += $token_length;
|
||||
|
||||
if ($length > $width) {
|
||||
// remove space before inserted break
|
||||
if ($_previous && $token_length < $width) {
|
||||
$t = mb_substr($t, 0, -1, SMARTY_RESOURCE_CHAR_SET);
|
||||
$t = mb_substr($t, 0, -1, Smarty::$_CHARSET);
|
||||
}
|
||||
|
||||
// add the break before the token
|
||||
|
@ -15,7 +15,7 @@
|
||||
*/
|
||||
function smarty_variablefilter_htmlspecialchars($source, $smarty)
|
||||
{
|
||||
return htmlspecialchars($source, ENT_QUOTES, SMARTY_RESOURCE_CHAR_SET);
|
||||
return htmlspecialchars($source, ENT_QUOTES, Smarty::$_CHARSET);
|
||||
}
|
||||
|
||||
?>
|
@ -1,56 +1,56 @@
|
||||
<?php
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Block
|
||||
*
|
||||
* Compiles the {block}{/block} tags
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
* Smarty Internal Plugin Compile Block
|
||||
*
|
||||
* Compiles the {block}{/block} tags
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Block Class
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
*/
|
||||
* Smarty Internal Plugin Compile Block Class
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
*/
|
||||
class Smarty_Internal_Compile_Block extends Smarty_Internal_CompileBase {
|
||||
|
||||
/**
|
||||
* Attribute definition: Overwrites base class.
|
||||
*
|
||||
* @var array
|
||||
* @see Smarty_Internal_CompileBase
|
||||
*/
|
||||
* Attribute definition: Overwrites base class.
|
||||
*
|
||||
* @var array
|
||||
* @see Smarty_Internal_CompileBase
|
||||
*/
|
||||
public $required_attributes = array('name');
|
||||
/**
|
||||
* Attribute definition: Overwrites base class.
|
||||
*
|
||||
* @var array
|
||||
* @see Smarty_Internal_CompileBase
|
||||
*/
|
||||
* Attribute definition: Overwrites base class.
|
||||
*
|
||||
* @var array
|
||||
* @see Smarty_Internal_CompileBase
|
||||
*/
|
||||
public $shorttag_order = array('name', 'hide');
|
||||
/**
|
||||
* Attribute definition: Overwrites base class.
|
||||
*
|
||||
* @var array
|
||||
* @see Smarty_Internal_CompileBase
|
||||
*/
|
||||
* Attribute definition: Overwrites base class.
|
||||
*
|
||||
* @var array
|
||||
* @see Smarty_Internal_CompileBase
|
||||
*/
|
||||
public $optional_attributes = array('hide');
|
||||
|
||||
/**
|
||||
* Compiles code for the {block} tag
|
||||
*
|
||||
* @param array $args array with attributes from parser
|
||||
* @param object $compiler compiler object
|
||||
* @return boolean true
|
||||
*/
|
||||
* Compiles code for the {block} tag
|
||||
*
|
||||
* @param array $args array with attributes from parser
|
||||
* @param object $compiler compiler object
|
||||
* @return boolean true
|
||||
*/
|
||||
public function compile($args, $compiler)
|
||||
{
|
||||
// check and get attributes
|
||||
$_attr = $this->getAttributes($compiler, $args);
|
||||
$save = array($_attr, $compiler->parser->current_buffer, $compiler->nocache, $compiler->smarty->merge_compiled_includes);
|
||||
$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);
|
||||
$this->openTag($compiler, 'block', $save);
|
||||
if ($_attr['nocache'] == true) {
|
||||
$compiler->nocache = true;
|
||||
@ -66,33 +66,54 @@ class Smarty_Internal_Compile_Block extends Smarty_Internal_CompileBase {
|
||||
}
|
||||
|
||||
/**
|
||||
* Save or replace child block source by block name during parsing
|
||||
*
|
||||
* @param string $block_content block source content
|
||||
* @param string $block_tag opening block tag
|
||||
* @param object $template template object
|
||||
* @param string $filepath filepath of template source
|
||||
*/
|
||||
* Save or replace child block source by block name during parsing
|
||||
*
|
||||
* @param string $block_content block source content
|
||||
* @param string $block_tag opening block tag
|
||||
* @param object $template template object
|
||||
* @param string $filepath filepath of template source
|
||||
*/
|
||||
public static function saveBlockData($block_content, $block_tag, $template, $filepath)
|
||||
{
|
||||
$_rdl = preg_quote($template->smarty->right_delimiter);
|
||||
$_ldl = preg_quote($template->smarty->left_delimiter);
|
||||
|
||||
if (0 == preg_match("!({$_ldl}block\s+)(name=)?(\w+|'.*'|\".*\")(\s*?)?((append|prepend|nocache)?(\s*)?(hide)?)?(\s*{$_rdl})!", $block_tag, $_match)) {
|
||||
if ($template->smarty->auto_literal) {
|
||||
$al = '\s*';
|
||||
} else {
|
||||
$al = '';
|
||||
}
|
||||
if (0 == preg_match("!({$_ldl}{$al}block\s+)(name=)?(\w+|'.*'|\".*\")(\s*?)?((append|prepend|nocache)?(\s*)?(hide)?)?(\s*{$_rdl})!", $block_tag, $_match)) {
|
||||
$error_text = 'Syntax Error in template "' . $template->source->filepath . '" "' . htmlspecialchars($block_tag) . '" illegal options';
|
||||
throw new SmartyCompilerException($error_text);
|
||||
} else {
|
||||
$_name = trim($_match[3], '\'"');
|
||||
if ($_match[8] != 'hide' || isset($template->block_data[$_name])) { // replace {$smarty.block.child}
|
||||
if (strpos($block_content, $template->smarty->left_delimiter . '$smarty.block.child' . $template->smarty->right_delimiter) !== false) {
|
||||
// do we have {$smart.block.child} in nested {block} tags?
|
||||
if (0 != preg_match_all("!({$_ldl}{$al}block\s+)(name=)?(\w+|'.*'|\".*\")([\s\S]*?{$_rdl})([\s\S]*?)({$_ldl}{$al}\\\$smarty\.block\.child{$_rdl})([\s\S]*?{$_ldl}{$al}/block{$_rdl})!", $block_content, $_match2)) {
|
||||
foreach($_match2[3] as $name) {
|
||||
// get it's replacement
|
||||
$_name2 = trim($name, '\'"');
|
||||
if (isset($template->block_data[$_name2])) {
|
||||
$replacement = $template->block_data[$_name2]['source'];
|
||||
} else {
|
||||
$replacement = '';
|
||||
}
|
||||
// replace {$smarty.block.child} tag
|
||||
$search = array("%({$_ldl}{$al}block[\s\S]*?{$name}[\s\S]*?{$_rdl})([\s\S]*?)({$_ldl}{$al}\\\$smarty\.block\.child{$_rdl})([\s\S]*?{$_ldl}{$al}/block{$_rdl})%","/§§§child§§§/");
|
||||
$replace = array('\2§§§child§§§', $replacement);
|
||||
$block_content = preg_replace($search, $replace , $block_content);
|
||||
}
|
||||
}
|
||||
// do we have not nested {$smart.block.child}
|
||||
if (0 != preg_match("/({$_ldl}{$al}\\\$smarty\.block\.child{$_rdl})/", $block_content, $_match2)) {
|
||||
// get child replacement for this block
|
||||
if (isset($template->block_data[$_name])) {
|
||||
$block_content = str_replace($template->smarty->left_delimiter . '$smarty.block.child' . $template->smarty->right_delimiter,
|
||||
$template->block_data[$_name]['source'], $block_content);
|
||||
$replacement = $template->block_data[$_name]['source'];
|
||||
unset($template->block_data[$_name]);
|
||||
} else {
|
||||
$block_content = str_replace($template->smarty->left_delimiter . '$smarty.block.child' . $template->smarty->right_delimiter,
|
||||
'', $block_content);
|
||||
$replacement = '';
|
||||
}
|
||||
$block_content = preg_replace("/({$_ldl}{$al}\\\$smarty\.block\.child{$_rdl})/", $replacement, $block_content);
|
||||
}
|
||||
if (isset($template->block_data[$_name])) {
|
||||
if (strpos($template->block_data[$_name]['source'], '%%%%SMARTY_PARENT%%%%') !== false) {
|
||||
@ -119,12 +140,12 @@ class Smarty_Internal_Compile_Block extends Smarty_Internal_CompileBase {
|
||||
}
|
||||
|
||||
/**
|
||||
* Compile saved child block source
|
||||
*
|
||||
* @param object $compiler compiler object
|
||||
* @param string $_name optional name of child block
|
||||
* @return string compiled code of schild block
|
||||
*/
|
||||
* Compile saved child block source
|
||||
*
|
||||
* @param object $compiler compiler object
|
||||
* @param string $_name optional name of child block
|
||||
* @return string compiled code of schild block
|
||||
*/
|
||||
public static function compileChildBlock($compiler, $_name = null)
|
||||
{
|
||||
$_output = '';
|
||||
@ -191,20 +212,20 @@ class Smarty_Internal_Compile_Block extends Smarty_Internal_CompileBase {
|
||||
}
|
||||
|
||||
/**
|
||||
* Smarty Internal Plugin Compile BlockClose Class
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
* Smarty Internal Plugin Compile BlockClose Class
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
*/
|
||||
class Smarty_Internal_Compile_Blockclose extends Smarty_Internal_CompileBase {
|
||||
|
||||
/**
|
||||
* Compiles code for the {/block} tag
|
||||
*
|
||||
* @param array $args array with attributes from parser
|
||||
* @param object $compiler compiler object
|
||||
* @return string compiled code
|
||||
*/
|
||||
* Compiles code for the {/block} tag
|
||||
*
|
||||
* @param array $args array with attributes from parser
|
||||
* @param object $compiler compiler object
|
||||
* @return string compiled code
|
||||
*/
|
||||
public function compile($args, $compiler)
|
||||
{
|
||||
$compiler->has_code = true;
|
||||
@ -213,6 +234,11 @@ class Smarty_Internal_Compile_Blockclose extends Smarty_Internal_CompileBase {
|
||||
$saved_data = $this->closeTag($compiler, array('block'));
|
||||
$_name = trim($saved_data[0]['name'], "\"'");
|
||||
if (isset($compiler->template->block_data[$_name]) && !isset($compiler->template->block_data[$_name]['compiled'])) {
|
||||
// restore to status before {block} tag as new subtemplate code of parent {block} is not needed
|
||||
$compiler->merged_templates = $saved_data[4];
|
||||
$compiler->smarty->merged_templates_func = $saved_data[5];
|
||||
$compiler->template->properties = $saved_data[6];
|
||||
$compiler->template->has_nocache_code = $saved_data[7];
|
||||
$_output = Smarty_Internal_Compile_Block::compileChildBlock($compiler, $_name);
|
||||
} else {
|
||||
if (isset($saved_data[0]['hide']) && !isset($compiler->template->block_data[$_name]['source'])) {
|
||||
|
@ -48,10 +48,10 @@ class Smarty_Internal_Compile_Capture extends Smarty_Internal_CompileBase {
|
||||
$assign = isset($_attr['assign']) ? $_attr['assign'] : 'null';
|
||||
$append = isset($_attr['append']) ? $_attr['append'] : 'null';
|
||||
|
||||
$compiler->_capture_stack[] = array($buffer, $assign, $append, $compiler->nocache);
|
||||
$compiler->_capture_stack[0][] = array($buffer, $assign, $append, $compiler->nocache);
|
||||
// maybe nocache because of nocache variables
|
||||
$compiler->nocache = $compiler->nocache | $compiler->tag_nocache;
|
||||
$_output = "<?php \$_smarty_tpl->_capture_stack[] = array($buffer, $assign, $append); ob_start(); ?>";
|
||||
$_output = "<?php \$_smarty_tpl->_capture_stack[0][] = array($buffer, $assign, $append); ob_start(); ?>";
|
||||
|
||||
return $_output;
|
||||
}
|
||||
@ -82,9 +82,9 @@ class Smarty_Internal_Compile_CaptureClose extends Smarty_Internal_CompileBase {
|
||||
$compiler->tag_nocache = true;
|
||||
}
|
||||
|
||||
list($buffer, $assign, $append, $compiler->nocache) = array_pop($compiler->_capture_stack);
|
||||
list($buffer, $assign, $append, $compiler->nocache) = array_pop($compiler->_capture_stack[0]);
|
||||
|
||||
$_output = "<?php list(\$_capture_buffer, \$_capture_assign, \$_capture_append) = array_pop(\$_smarty_tpl->_capture_stack);\n";
|
||||
$_output = "<?php list(\$_capture_buffer, \$_capture_assign, \$_capture_append) = array_pop(\$_smarty_tpl->_capture_stack[0]);\n";
|
||||
$_output .= "if (!empty(\$_capture_buffer)) {\n";
|
||||
$_output .= " if (isset(\$_capture_assign)) \$_smarty_tpl->assign(\$_capture_assign, ob_get_contents());\n";
|
||||
$_output .= " if (isset( \$_capture_append)) \$_smarty_tpl->append( \$_capture_append, ob_get_contents());\n";
|
||||
|
@ -83,7 +83,7 @@ class Smarty_Internal_Compile_Private_Print_Expression extends Smarty_Internal_C
|
||||
}
|
||||
// autoescape html
|
||||
if ($compiler->template->smarty->escape_html) {
|
||||
$output = "htmlspecialchars({$output}, ENT_QUOTES, SMARTY_RESOURCE_CHAR_SET)";
|
||||
$output = "htmlspecialchars({$output}, ENT_QUOTES, '" . addslashes(Smarty::$_CHARSET) . "')";
|
||||
}
|
||||
// loop over registerd filters
|
||||
if (!empty($compiler->template->smarty->registered_filters[Smarty::FILTER_VARIABLE])) {
|
||||
|
@ -81,11 +81,12 @@ class Smarty_Internal_Configfilelexer
|
||||
5 => 0,
|
||||
6 => 0,
|
||||
7 => 0,
|
||||
8 => 0,
|
||||
);
|
||||
if ($this->counter >= strlen($this->data)) {
|
||||
return false; // end of input
|
||||
}
|
||||
$yy_global_pattern = "/\G(#|;)|\G(\\[)|\G(\\])|\G(=)|\G([ \t\r]+)|\G(\n)|\G([0-9]*[a-zA-Z_]\\w*)/iS";
|
||||
$yy_global_pattern = "/\G(#|;)|\G(\\[)|\G(\\])|\G(=)|\G([ \t\r]+)|\G(\n)|\G([0-9]*[a-zA-Z_]\\w*)|\G([\S\s])/iS";
|
||||
|
||||
do {
|
||||
if ($this->mbstring_overload ? preg_match($yy_global_pattern, substr($this->data, $this->counter), $yymatches) : preg_match($yy_global_pattern,$this->data, $yymatches, null, $this->counter)) {
|
||||
@ -173,6 +174,11 @@ class Smarty_Internal_Configfilelexer
|
||||
|
||||
$this->token = Smarty_Internal_Configfileparser::TPC_ID;
|
||||
}
|
||||
function yy_r1_8($yy_subpatterns)
|
||||
{
|
||||
|
||||
$this->token = Smarty_Internal_Configfileparser::TPC_OTHER;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -528,12 +534,11 @@ class Smarty_Internal_Configfilelexer
|
||||
$tokenMap = array (
|
||||
1 => 0,
|
||||
2 => 0,
|
||||
3 => 2,
|
||||
);
|
||||
if ($this->counter >= strlen($this->data)) {
|
||||
return false; // end of input
|
||||
}
|
||||
$yy_global_pattern = "/\G(\"\"\"(?=[ \t\r]*[\n#;]))|\G([ \t\r]*\n)|\G(([\S\s]*?)(?=([ \t\r]*\n|\"\"\")))/iS";
|
||||
$yy_global_pattern = "/\G(\"\"\"(?=[ \t\r]*[\n#;]))|\G([\S\s])/iS";
|
||||
|
||||
do {
|
||||
if ($this->mbstring_overload ? preg_match($yy_global_pattern, substr($this->data, $this->counter), $yymatches) : preg_match($yy_global_pattern,$this->data, $yymatches, null, $this->counter)) {
|
||||
@ -593,12 +598,13 @@ class Smarty_Internal_Configfilelexer
|
||||
function yy_r6_2($yy_subpatterns)
|
||||
{
|
||||
|
||||
$this->token = Smarty_Internal_Configfileparser::TPC_TRIPPLE_CONTENT;
|
||||
}
|
||||
function yy_r6_3($yy_subpatterns)
|
||||
{
|
||||
|
||||
$this->token = Smarty_Internal_Configfileparser::TPC_TRIPPLE_CONTENT;
|
||||
$to = strlen($this->data);
|
||||
preg_match("/\"\"\"[ \t\r]*[\n#;]/",$this->data,$match,PREG_OFFSET_CAPTURE,$this->counter);
|
||||
if (isset($match[0][1])) {
|
||||
$to = $match[0][1];
|
||||
}
|
||||
$this->value = substr($this->data,$this->counter,$to-$this->counter);
|
||||
$this->token = Smarty_Internal_Configfileparser::TPC_TRIPPLE_TEXT;
|
||||
}
|
||||
|
||||
|
||||
|
@ -191,57 +191,58 @@ class Smarty_Internal_Configfileparser#line 79 "smarty_internal_configfileparser
|
||||
const TPC_SINGLE_QUOTED_STRING = 10;
|
||||
const TPC_DOUBLE_QUOTED_STRING = 11;
|
||||
const TPC_TRIPPLE_QUOTES = 12;
|
||||
const TPC_TRIPPLE_QUOTES_END = 13;
|
||||
const TPC_NAKED_STRING = 14;
|
||||
const TPC_TRIPPLE_CONTENT = 15;
|
||||
const TPC_NEWLINE = 16;
|
||||
const TPC_COMMENTSTART = 17;
|
||||
const YY_NO_ACTION = 61;
|
||||
const YY_ACCEPT_ACTION = 60;
|
||||
const YY_ERROR_ACTION = 59;
|
||||
const TPC_TRIPPLE_TEXT = 13;
|
||||
const TPC_TRIPPLE_QUOTES_END = 14;
|
||||
const TPC_NAKED_STRING = 15;
|
||||
const TPC_OTHER = 16;
|
||||
const TPC_NEWLINE = 17;
|
||||
const TPC_COMMENTSTART = 18;
|
||||
const YY_NO_ACTION = 60;
|
||||
const YY_ACCEPT_ACTION = 59;
|
||||
const YY_ERROR_ACTION = 58;
|
||||
|
||||
const YY_SZ_ACTTAB = 39;
|
||||
const YY_SZ_ACTTAB = 38;
|
||||
static public $yy_action = array(
|
||||
/* 0 */ 29, 30, 34, 33, 24, 7, 19, 21, 60, 9,
|
||||
/* 10 */ 16, 1, 20, 14, 15, 6, 23, 20, 14, 32,
|
||||
/* 20 */ 17, 31, 18, 27, 26, 2, 3, 5, 25, 22,
|
||||
/* 30 */ 35, 4, 13, 11, 10, 12, 53, 28, 8,
|
||||
/* 0 */ 29, 30, 34, 33, 24, 13, 19, 25, 35, 21,
|
||||
/* 10 */ 59, 8, 3, 1, 20, 12, 14, 31, 20, 12,
|
||||
/* 20 */ 15, 17, 23, 18, 27, 26, 4, 5, 6, 32,
|
||||
/* 30 */ 2, 11, 28, 22, 16, 9, 7, 10,
|
||||
);
|
||||
static public $yy_lookahead = array(
|
||||
/* 0 */ 7, 8, 9, 10, 11, 12, 5, 14, 19, 20,
|
||||
/* 10 */ 2, 22, 16, 17, 14, 3, 16, 16, 17, 13,
|
||||
/* 20 */ 2, 15, 4, 24, 25, 22, 22, 3, 26, 16,
|
||||
/* 30 */ 15, 6, 27, 24, 24, 1, 28, 23, 21,
|
||||
/* 0 */ 7, 8, 9, 10, 11, 12, 5, 27, 15, 16,
|
||||
/* 10 */ 20, 21, 23, 23, 17, 18, 13, 14, 17, 18,
|
||||
/* 20 */ 15, 2, 17, 4, 25, 26, 6, 3, 3, 14,
|
||||
/* 30 */ 23, 1, 24, 17, 2, 25, 22, 25,
|
||||
);
|
||||
const YY_SHIFT_USE_DFLT = -8;
|
||||
const YY_SHIFT_MAX = 19;
|
||||
static public $yy_shift_ofst = array(
|
||||
/* 0 */ -8, 1, 1, 1, -7, -4, -4, 15, 34, -8,
|
||||
/* 10 */ -8, -8, 18, 6, 0, 13, 24, 12, 8, 25,
|
||||
/* 0 */ -8, 1, 1, 1, -7, -3, -3, 30, -8, -8,
|
||||
/* 10 */ -8, 19, 5, 3, 15, 16, 24, 25, 32, 20,
|
||||
);
|
||||
const YY_REDUCE_USE_DFLT = -12;
|
||||
const YY_REDUCE_MAX = 11;
|
||||
const YY_REDUCE_USE_DFLT = -21;
|
||||
const YY_REDUCE_MAX = 10;
|
||||
static public $yy_reduce_ofst = array(
|
||||
/* 0 */ -11, -1, -1, -1, 2, 10, 9, 5, 14, 17,
|
||||
/* 10 */ 3, 4,
|
||||
/* 0 */ -10, -1, -1, -1, -20, 10, 12, 8, 14, 7,
|
||||
/* 10 */ -11,
|
||||
);
|
||||
static public $yyExpectedTokens = array(
|
||||
/* 0 */ array(),
|
||||
/* 1 */ array(5, 16, 17, ),
|
||||
/* 2 */ array(5, 16, 17, ),
|
||||
/* 3 */ array(5, 16, 17, ),
|
||||
/* 4 */ array(7, 8, 9, 10, 11, 12, 14, ),
|
||||
/* 5 */ array(16, 17, ),
|
||||
/* 6 */ array(16, 17, ),
|
||||
/* 7 */ array(15, ),
|
||||
/* 8 */ array(1, ),
|
||||
/* 1 */ array(5, 17, 18, ),
|
||||
/* 2 */ array(5, 17, 18, ),
|
||||
/* 3 */ array(5, 17, 18, ),
|
||||
/* 4 */ array(7, 8, 9, 10, 11, 12, 15, 16, ),
|
||||
/* 5 */ array(17, 18, ),
|
||||
/* 6 */ array(17, 18, ),
|
||||
/* 7 */ array(1, ),
|
||||
/* 8 */ array(),
|
||||
/* 9 */ array(),
|
||||
/* 10 */ array(),
|
||||
/* 11 */ array(),
|
||||
/* 12 */ array(2, 4, ),
|
||||
/* 13 */ array(13, 15, ),
|
||||
/* 14 */ array(14, 16, ),
|
||||
/* 15 */ array(16, ),
|
||||
/* 11 */ array(2, 4, ),
|
||||
/* 12 */ array(15, 17, ),
|
||||
/* 13 */ array(13, 14, ),
|
||||
/* 14 */ array(14, ),
|
||||
/* 15 */ array(17, ),
|
||||
/* 16 */ array(3, ),
|
||||
/* 17 */ array(3, ),
|
||||
/* 18 */ array(2, ),
|
||||
@ -264,16 +265,16 @@ static public $yy_action = array(
|
||||
/* 35 */ array(),
|
||||
);
|
||||
static public $yy_default = array(
|
||||
/* 0 */ 44, 37, 41, 40, 59, 59, 59, 55, 36, 39,
|
||||
/* 10 */ 44, 44, 59, 59, 59, 59, 59, 59, 59, 59,
|
||||
/* 20 */ 56, 52, 58, 57, 50, 45, 43, 42, 38, 46,
|
||||
/* 30 */ 47, 53, 51, 49, 48, 54,
|
||||
/* 0 */ 44, 37, 41, 40, 58, 58, 58, 36, 39, 44,
|
||||
/* 10 */ 44, 58, 58, 58, 58, 58, 58, 58, 58, 58,
|
||||
/* 20 */ 55, 54, 57, 56, 50, 45, 43, 42, 38, 46,
|
||||
/* 30 */ 47, 52, 51, 49, 48, 53,
|
||||
);
|
||||
const YYNOCODE = 29;
|
||||
const YYSTACKDEPTH = 100;
|
||||
const YYNSTATE = 36;
|
||||
const YYNRULE = 23;
|
||||
const YYERRORSYMBOL = 18;
|
||||
const YYNRULE = 22;
|
||||
const YYERRORSYMBOL = 19;
|
||||
const YYERRSYMDT = 'yy0';
|
||||
const YYFALLBACK = 0;
|
||||
static public $yyFallback = array(
|
||||
@ -305,10 +306,10 @@ static public $yy_action = array(
|
||||
'$', 'OPENB', 'SECTION', 'CLOSEB',
|
||||
'DOT', 'ID', 'EQUAL', 'FLOAT',
|
||||
'INT', 'BOOL', 'SINGLE_QUOTED_STRING', 'DOUBLE_QUOTED_STRING',
|
||||
'TRIPPLE_QUOTES', 'TRIPPLE_QUOTES_END', 'NAKED_STRING', 'TRIPPLE_CONTENT',
|
||||
'NEWLINE', 'COMMENTSTART', 'error', 'start',
|
||||
'global_vars', 'sections', 'var_list', 'section',
|
||||
'newline', 'var', 'value', 'tripple_content',
|
||||
'TRIPPLE_QUOTES', 'TRIPPLE_TEXT', 'TRIPPLE_QUOTES_END', 'NAKED_STRING',
|
||||
'OTHER', 'NEWLINE', 'COMMENTSTART', 'error',
|
||||
'start', 'global_vars', 'sections', 'var_list',
|
||||
'section', 'newline', 'var', 'value',
|
||||
);
|
||||
|
||||
static public $yyRuleName = array(
|
||||
@ -327,14 +328,13 @@ static public $yy_action = array(
|
||||
/* 12 */ "value ::= BOOL",
|
||||
/* 13 */ "value ::= SINGLE_QUOTED_STRING",
|
||||
/* 14 */ "value ::= DOUBLE_QUOTED_STRING",
|
||||
/* 15 */ "value ::= TRIPPLE_QUOTES tripple_content TRIPPLE_QUOTES_END",
|
||||
/* 16 */ "value ::= NAKED_STRING",
|
||||
/* 17 */ "tripple_content ::= tripple_content TRIPPLE_CONTENT",
|
||||
/* 18 */ "tripple_content ::= TRIPPLE_CONTENT",
|
||||
/* 19 */ "tripple_content ::=",
|
||||
/* 20 */ "newline ::= NEWLINE",
|
||||
/* 21 */ "newline ::= COMMENTSTART NEWLINE",
|
||||
/* 22 */ "newline ::= COMMENTSTART NAKED_STRING NEWLINE",
|
||||
/* 15 */ "value ::= TRIPPLE_QUOTES TRIPPLE_TEXT TRIPPLE_QUOTES_END",
|
||||
/* 16 */ "value ::= TRIPPLE_QUOTES TRIPPLE_QUOTES_END",
|
||||
/* 17 */ "value ::= NAKED_STRING",
|
||||
/* 18 */ "value ::= OTHER",
|
||||
/* 19 */ "newline ::= NEWLINE",
|
||||
/* 20 */ "newline ::= COMMENTSTART NEWLINE",
|
||||
/* 21 */ "newline ::= COMMENTSTART NAKED_STRING NEWLINE",
|
||||
);
|
||||
|
||||
function tokenName($tokenType)
|
||||
@ -615,38 +615,37 @@ static public $yy_action = array(
|
||||
}
|
||||
|
||||
static public $yyRuleInfo = array(
|
||||
array( 'lhs' => 19, 'rhs' => 2 ),
|
||||
array( 'lhs' => 20, 'rhs' => 1 ),
|
||||
array( 'lhs' => 21, 'rhs' => 2 ),
|
||||
array( 'lhs' => 21, 'rhs' => 0 ),
|
||||
array( 'lhs' => 23, 'rhs' => 5 ),
|
||||
array( 'lhs' => 23, 'rhs' => 6 ),
|
||||
array( 'lhs' => 22, 'rhs' => 2 ),
|
||||
array( 'lhs' => 20, 'rhs' => 2 ),
|
||||
array( 'lhs' => 21, 'rhs' => 1 ),
|
||||
array( 'lhs' => 22, 'rhs' => 2 ),
|
||||
array( 'lhs' => 22, 'rhs' => 0 ),
|
||||
array( 'lhs' => 25, 'rhs' => 3 ),
|
||||
array( 'lhs' => 26, 'rhs' => 1 ),
|
||||
array( 'lhs' => 26, 'rhs' => 1 ),
|
||||
array( 'lhs' => 26, 'rhs' => 1 ),
|
||||
array( 'lhs' => 26, 'rhs' => 1 ),
|
||||
array( 'lhs' => 26, 'rhs' => 1 ),
|
||||
array( 'lhs' => 24, 'rhs' => 5 ),
|
||||
array( 'lhs' => 24, 'rhs' => 6 ),
|
||||
array( 'lhs' => 23, 'rhs' => 2 ),
|
||||
array( 'lhs' => 23, 'rhs' => 2 ),
|
||||
array( 'lhs' => 23, 'rhs' => 0 ),
|
||||
array( 'lhs' => 26, 'rhs' => 3 ),
|
||||
array( 'lhs' => 26, 'rhs' => 1 ),
|
||||
array( 'lhs' => 27, 'rhs' => 1 ),
|
||||
array( 'lhs' => 27, 'rhs' => 1 ),
|
||||
array( 'lhs' => 27, 'rhs' => 1 ),
|
||||
array( 'lhs' => 27, 'rhs' => 1 ),
|
||||
array( 'lhs' => 27, 'rhs' => 1 ),
|
||||
array( 'lhs' => 27, 'rhs' => 3 ),
|
||||
array( 'lhs' => 27, 'rhs' => 2 ),
|
||||
array( 'lhs' => 27, 'rhs' => 1 ),
|
||||
array( 'lhs' => 27, 'rhs' => 0 ),
|
||||
array( 'lhs' => 24, 'rhs' => 1 ),
|
||||
array( 'lhs' => 24, 'rhs' => 2 ),
|
||||
array( 'lhs' => 24, 'rhs' => 3 ),
|
||||
array( 'lhs' => 27, 'rhs' => 1 ),
|
||||
array( 'lhs' => 25, 'rhs' => 1 ),
|
||||
array( 'lhs' => 25, 'rhs' => 2 ),
|
||||
array( 'lhs' => 25, 'rhs' => 3 ),
|
||||
);
|
||||
|
||||
static public $yyReduceMap = array(
|
||||
0 => 0,
|
||||
2 => 0,
|
||||
3 => 0,
|
||||
19 => 0,
|
||||
20 => 0,
|
||||
21 => 0,
|
||||
22 => 0,
|
||||
1 => 1,
|
||||
4 => 4,
|
||||
5 => 5,
|
||||
@ -661,26 +660,25 @@ static public $yy_action = array(
|
||||
14 => 14,
|
||||
15 => 15,
|
||||
16 => 16,
|
||||
18 => 16,
|
||||
17 => 17,
|
||||
19 => 19,
|
||||
18 => 17,
|
||||
);
|
||||
#line 131 "smarty_internal_configfileparser.y"
|
||||
function yy_r0(){
|
||||
$this->_retvalue = null;
|
||||
}
|
||||
#line 668 "smarty_internal_configfileparser.php"
|
||||
#line 666 "smarty_internal_configfileparser.php"
|
||||
#line 136 "smarty_internal_configfileparser.y"
|
||||
function yy_r1(){
|
||||
$this->add_global_vars($this->yystack[$this->yyidx + 0]->minor); $this->_retvalue = null;
|
||||
}
|
||||
#line 673 "smarty_internal_configfileparser.php"
|
||||
#line 671 "smarty_internal_configfileparser.php"
|
||||
#line 149 "smarty_internal_configfileparser.y"
|
||||
function yy_r4(){
|
||||
$this->add_section_vars($this->yystack[$this->yyidx + -3]->minor, $this->yystack[$this->yyidx + 0]->minor);
|
||||
$this->_retvalue = null;
|
||||
}
|
||||
#line 679 "smarty_internal_configfileparser.php"
|
||||
#line 677 "smarty_internal_configfileparser.php"
|
||||
#line 154 "smarty_internal_configfileparser.y"
|
||||
function yy_r5(){
|
||||
if ($this->smarty->config_read_hidden) {
|
||||
@ -688,72 +686,67 @@ static public $yy_action = array(
|
||||
}
|
||||
$this->_retvalue = null;
|
||||
}
|
||||
#line 687 "smarty_internal_configfileparser.php"
|
||||
#line 685 "smarty_internal_configfileparser.php"
|
||||
#line 162 "smarty_internal_configfileparser.y"
|
||||
function yy_r6(){
|
||||
$this->_retvalue = $this->yystack[$this->yyidx + -1]->minor;
|
||||
}
|
||||
#line 692 "smarty_internal_configfileparser.php"
|
||||
#line 690 "smarty_internal_configfileparser.php"
|
||||
#line 166 "smarty_internal_configfileparser.y"
|
||||
function yy_r7(){
|
||||
$this->_retvalue = array_merge($this->yystack[$this->yyidx + -1]->minor, Array($this->yystack[$this->yyidx + 0]->minor));
|
||||
}
|
||||
#line 697 "smarty_internal_configfileparser.php"
|
||||
#line 695 "smarty_internal_configfileparser.php"
|
||||
#line 170 "smarty_internal_configfileparser.y"
|
||||
function yy_r8(){
|
||||
$this->_retvalue = Array();
|
||||
}
|
||||
#line 702 "smarty_internal_configfileparser.php"
|
||||
#line 700 "smarty_internal_configfileparser.php"
|
||||
#line 176 "smarty_internal_configfileparser.y"
|
||||
function yy_r9(){
|
||||
$this->_retvalue = Array("key" => $this->yystack[$this->yyidx + -2]->minor, "value" => $this->yystack[$this->yyidx + 0]->minor);
|
||||
}
|
||||
#line 707 "smarty_internal_configfileparser.php"
|
||||
#line 705 "smarty_internal_configfileparser.php"
|
||||
#line 181 "smarty_internal_configfileparser.y"
|
||||
function yy_r10(){
|
||||
$this->_retvalue = (float) $this->yystack[$this->yyidx + 0]->minor;
|
||||
}
|
||||
#line 712 "smarty_internal_configfileparser.php"
|
||||
#line 710 "smarty_internal_configfileparser.php"
|
||||
#line 185 "smarty_internal_configfileparser.y"
|
||||
function yy_r11(){
|
||||
$this->_retvalue = (int) $this->yystack[$this->yyidx + 0]->minor;
|
||||
}
|
||||
#line 717 "smarty_internal_configfileparser.php"
|
||||
#line 715 "smarty_internal_configfileparser.php"
|
||||
#line 189 "smarty_internal_configfileparser.y"
|
||||
function yy_r12(){
|
||||
$this->_retvalue = $this->parse_bool($this->yystack[$this->yyidx + 0]->minor);
|
||||
}
|
||||
#line 722 "smarty_internal_configfileparser.php"
|
||||
#line 720 "smarty_internal_configfileparser.php"
|
||||
#line 193 "smarty_internal_configfileparser.y"
|
||||
function yy_r13(){
|
||||
$this->_retvalue = self::parse_single_quoted_string($this->yystack[$this->yyidx + 0]->minor);
|
||||
}
|
||||
#line 727 "smarty_internal_configfileparser.php"
|
||||
#line 725 "smarty_internal_configfileparser.php"
|
||||
#line 197 "smarty_internal_configfileparser.y"
|
||||
function yy_r14(){
|
||||
$this->_retvalue = self::parse_double_quoted_string($this->yystack[$this->yyidx + 0]->minor);
|
||||
}
|
||||
#line 732 "smarty_internal_configfileparser.php"
|
||||
#line 730 "smarty_internal_configfileparser.php"
|
||||
#line 201 "smarty_internal_configfileparser.y"
|
||||
function yy_r15(){
|
||||
$this->_retvalue = self::parse_tripple_double_quoted_string($this->yystack[$this->yyidx + -1]->minor);
|
||||
}
|
||||
#line 737 "smarty_internal_configfileparser.php"
|
||||
#line 735 "smarty_internal_configfileparser.php"
|
||||
#line 205 "smarty_internal_configfileparser.y"
|
||||
function yy_r16(){
|
||||
$this->_retvalue = $this->yystack[$this->yyidx + 0]->minor;
|
||||
}
|
||||
#line 742 "smarty_internal_configfileparser.php"
|
||||
#line 210 "smarty_internal_configfileparser.y"
|
||||
function yy_r17(){
|
||||
$this->_retvalue = $this->yystack[$this->yyidx + -1]->minor . $this->yystack[$this->yyidx + 0]->minor;
|
||||
}
|
||||
#line 747 "smarty_internal_configfileparser.php"
|
||||
#line 216 "smarty_internal_configfileparser.y"
|
||||
function yy_r19(){
|
||||
$this->_retvalue = '';
|
||||
}
|
||||
#line 752 "smarty_internal_configfileparser.php"
|
||||
#line 740 "smarty_internal_configfileparser.php"
|
||||
#line 209 "smarty_internal_configfileparser.y"
|
||||
function yy_r17(){
|
||||
$this->_retvalue = $this->yystack[$this->yyidx + 0]->minor;
|
||||
}
|
||||
#line 745 "smarty_internal_configfileparser.php"
|
||||
|
||||
private $_retvalue;
|
||||
|
||||
@ -815,7 +808,7 @@ static public $yy_action = array(
|
||||
$this->internalError = true;
|
||||
$this->yymajor = $yymajor;
|
||||
$this->compiler->trigger_config_file_error();
|
||||
#line 815 "smarty_internal_configfileparser.php"
|
||||
#line 808 "smarty_internal_configfileparser.php"
|
||||
}
|
||||
|
||||
function yy_accept()
|
||||
@ -832,7 +825,7 @@ static public $yy_action = array(
|
||||
$this->internalError = false;
|
||||
$this->retvalue = $this->_retvalue;
|
||||
//echo $this->retvalue."\n\n";
|
||||
#line 833 "smarty_internal_configfileparser.php"
|
||||
#line 826 "smarty_internal_configfileparser.php"
|
||||
}
|
||||
|
||||
function doParse($yymajor, $yytokenvalue)
|
||||
|
@ -97,7 +97,7 @@ class Smarty_Internal_Template extends Smarty_Internal_TemplateBase {
|
||||
* internal capture runtime stack
|
||||
* @var array
|
||||
*/
|
||||
public $_capture_stack = array();
|
||||
public $_capture_stack = array(0 => array());
|
||||
|
||||
/**
|
||||
* Create template data object
|
||||
|
@ -43,8 +43,8 @@ abstract class Smarty_Internal_TemplateBase extends Smarty_Internal_Data {
|
||||
}
|
||||
// create template object if necessary
|
||||
$_template = ($template instanceof $this->template_class)
|
||||
? $template
|
||||
: $this->smarty->createTemplate($template, $cache_id, $compile_id, $parent, false);
|
||||
? $template
|
||||
: $this->smarty->createTemplate($template, $cache_id, $compile_id, $parent, false);
|
||||
// if called by Smarty object make sure we use current caching status
|
||||
if ($this instanceof Smarty) {
|
||||
$_template->caching = $this->caching;
|
||||
@ -173,10 +173,16 @@ abstract class Smarty_Internal_TemplateBase extends Smarty_Internal_Data {
|
||||
if (empty($_template->properties['unifunc']) || !is_callable($_template->properties['unifunc'])) {
|
||||
throw new SmartyException("Invalid compiled template for '{$_template->template_resource}'");
|
||||
}
|
||||
array_unshift($_template->_capture_stack,array());
|
||||
//
|
||||
// render compiled template
|
||||
//
|
||||
$_template->properties['unifunc']($_template);
|
||||
if (isset($_template->_capture_stack[0])) {
|
||||
// any unclosed {capture} tags ?
|
||||
if (isset($_template->_capture_stack[0][0])) {
|
||||
$_template->capture_error();
|
||||
}
|
||||
array_shift($_template->_capture_stack);
|
||||
} catch (Exception $e) {
|
||||
ob_get_clean();
|
||||
throw $e;
|
||||
@ -268,10 +274,16 @@ abstract class Smarty_Internal_TemplateBase extends Smarty_Internal_Data {
|
||||
}
|
||||
try {
|
||||
ob_start();
|
||||
array_unshift($_template->_capture_stack,array());
|
||||
//
|
||||
// render cached template
|
||||
//
|
||||
$_template->properties['unifunc']($_template);
|
||||
if (isset($_template->_capture_stack[0])) {
|
||||
// any unclosed {capture} tags ?
|
||||
if (isset($_template->_capture_stack[0][0])) {
|
||||
$_template->capture_error();
|
||||
}
|
||||
array_shift($_template->_capture_stack);
|
||||
$_output = ob_get_clean();
|
||||
} catch (Exception $e) {
|
||||
ob_get_clean();
|
||||
@ -297,30 +309,30 @@ abstract class Smarty_Internal_TemplateBase extends Smarty_Internal_Data {
|
||||
case 'cgi': // php-cgi < 5.3
|
||||
case 'cgi-fcgi': // php-cgi >= 5.3
|
||||
case 'fpm-fcgi': // php-fpm >= 5.3.3
|
||||
header('Status: 304 Not Modified');
|
||||
break;
|
||||
header('Status: 304 Not Modified');
|
||||
break;
|
||||
|
||||
case 'cli':
|
||||
if (/* ^phpunit */!empty($_SERVER['SMARTY_PHPUNIT_DISABLE_HEADERS'])/* phpunit$ */) {
|
||||
$_SERVER['SMARTY_PHPUNIT_HEADERS'][] = '304 Not Modified';
|
||||
}
|
||||
break;
|
||||
if (/* ^phpunit */!empty($_SERVER['SMARTY_PHPUNIT_DISABLE_HEADERS'])/* phpunit$ */) {
|
||||
$_SERVER['SMARTY_PHPUNIT_HEADERS'][] = '304 Not Modified';
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
header('HTTP/1.1 304 Not Modified');
|
||||
break;
|
||||
header('HTTP/1.1 304 Not Modified');
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
switch (PHP_SAPI) {
|
||||
case 'cli':
|
||||
if (/* ^phpunit */!empty($_SERVER['SMARTY_PHPUNIT_DISABLE_HEADERS'])/* phpunit$ */) {
|
||||
$_SERVER['SMARTY_PHPUNIT_HEADERS'][] = 'Last-Modified: ' . gmdate('D, d M Y H:i:s', $_template->cached->timestamp) . ' GMT';
|
||||
}
|
||||
break;
|
||||
if (/* ^phpunit */!empty($_SERVER['SMARTY_PHPUNIT_DISABLE_HEADERS'])/* phpunit$ */) {
|
||||
$_SERVER['SMARTY_PHPUNIT_HEADERS'][] = 'Last-Modified: ' . gmdate('D, d M Y H:i:s', $_template->cached->timestamp) . ' GMT';
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
header('Last-Modified: ' . gmdate('D, d M Y H:i:s', $_template->cached->timestamp) . ' GMT');
|
||||
break;
|
||||
header('Last-Modified: ' . gmdate('D, d M Y H:i:s', $_template->cached->timestamp) . ' GMT');
|
||||
break;
|
||||
}
|
||||
echo $_output;
|
||||
}
|
||||
@ -405,6 +417,7 @@ abstract class Smarty_Internal_TemplateBase extends Smarty_Internal_Data {
|
||||
* @param callback $callback PHP callback to register
|
||||
* @param boolean $cacheable if true (default) this fuction is cachable
|
||||
* @param array $cache_attr caching attributes if any
|
||||
* @return Smarty_Internal_Templatebase current Smarty_Internal_Templatebase (or Smarty or Smarty_Internal_Template) instance for chaining
|
||||
* @throws SmartyException when the plugin tag is invalid
|
||||
*/
|
||||
public function registerPlugin($type, $tag, $callback, $cacheable = true, $cache_attr = null)
|
||||
@ -416,6 +429,8 @@ abstract class Smarty_Internal_TemplateBase extends Smarty_Internal_Data {
|
||||
} else {
|
||||
$this->smarty->registered_plugins[$type][$tag] = array($callback, (bool) $cacheable, (array) $cache_attr);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -423,12 +438,15 @@ abstract class Smarty_Internal_TemplateBase extends Smarty_Internal_Data {
|
||||
*
|
||||
* @param string $type of plugin
|
||||
* @param string $tag name of plugin
|
||||
* @return Smarty_Internal_Templatebase current Smarty_Internal_Templatebase (or Smarty or Smarty_Internal_Template) instance for chaining
|
||||
*/
|
||||
public function unregisterPlugin($type, $tag)
|
||||
{
|
||||
if (isset($this->smarty->registered_plugins[$type][$tag])) {
|
||||
unset($this->smarty->registered_plugins[$type][$tag]);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -436,22 +454,27 @@ abstract class Smarty_Internal_TemplateBase extends Smarty_Internal_Data {
|
||||
*
|
||||
* @param string $type name of resource type
|
||||
* @param Smarty_Resource|array $callback or instance of Smarty_Resource, or array of callbacks to handle resource (deprecated)
|
||||
* @return Smarty_Internal_Templatebase current Smarty_Internal_Templatebase (or Smarty or Smarty_Internal_Template) instance for chaining
|
||||
*/
|
||||
public function registerResource($type, $callback)
|
||||
{
|
||||
$this->smarty->registered_resources[$type] = $callback instanceof Smarty_Resource ? $callback : array($callback, false);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Unregisters a resource
|
||||
*
|
||||
* @param string $type name of resource type
|
||||
* @return Smarty_Internal_Templatebase current Smarty_Internal_Templatebase (or Smarty or Smarty_Internal_Template) instance for chaining
|
||||
*/
|
||||
public function unregisterResource($type)
|
||||
{
|
||||
if (isset($this->smarty->registered_resources[$type])) {
|
||||
unset($this->smarty->registered_resources[$type]);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -459,22 +482,27 @@ abstract class Smarty_Internal_TemplateBase extends Smarty_Internal_Data {
|
||||
*
|
||||
* @param string $type name of cache resource type
|
||||
* @param Smarty_CacheResource $callback instance of Smarty_CacheResource to handle output caching
|
||||
* @return Smarty_Internal_Templatebase current Smarty_Internal_Templatebase (or Smarty or Smarty_Internal_Template) instance for chaining
|
||||
*/
|
||||
public function registerCacheResource($type, Smarty_CacheResource $callback)
|
||||
{
|
||||
$this->smarty->registered_cache_resources[$type] = $callback;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Unregisters a cache resource
|
||||
*
|
||||
* @param string $type name of cache resource type
|
||||
* @return Smarty_Internal_Templatebase current Smarty_Internal_Templatebase (or Smarty or Smarty_Internal_Template) instance for chaining
|
||||
*/
|
||||
public function unregisterCacheResource($type)
|
||||
{
|
||||
if (isset($this->smarty->registered_cache_resources[$type])) {
|
||||
unset($this->smarty->registered_cache_resources[$type]);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -486,6 +514,7 @@ abstract class Smarty_Internal_TemplateBase extends Smarty_Internal_Data {
|
||||
* @param boolean $smarty_args smarty argument format, else traditional
|
||||
* @param array $block_methods list of block-methods
|
||||
* @param array $block_functs list of methods that are block format
|
||||
* @return Smarty_Internal_Templatebase current Smarty_Internal_Templatebase (or Smarty or Smarty_Internal_Template) instance for chaining
|
||||
* @throws SmartyException if any of the methods in $allowed or $block_methods are invalid
|
||||
*/
|
||||
public function registerObject($object_name, $object_impl, $allowed = array(), $smarty_args = true, $block_methods = array())
|
||||
@ -508,7 +537,8 @@ abstract class Smarty_Internal_TemplateBase extends Smarty_Internal_Data {
|
||||
}
|
||||
// register the object
|
||||
$this->smarty->registered_objects[$object_name] =
|
||||
array($object_impl, (array) $allowed, (boolean) $smarty_args, (array) $block_methods);
|
||||
array($object_impl, (array) $allowed, (boolean) $smarty_args, (array) $block_methods);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -533,12 +563,15 @@ abstract class Smarty_Internal_TemplateBase extends Smarty_Internal_Data {
|
||||
* unregister an object
|
||||
*
|
||||
* @param string $name object name
|
||||
* @throws SmartyException if no such object is found
|
||||
* @return Smarty_Internal_Templatebase current Smarty_Internal_Templatebase (or Smarty or Smarty_Internal_Template) instance for chaining
|
||||
*/
|
||||
public function unregisterObject($name)
|
||||
{
|
||||
unset($this->smarty->registered_objects[$name]);
|
||||
return;
|
||||
if (isset($this->smarty->registered_objects[$name])) {
|
||||
unset($this->smarty->registered_objects[$name]);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -546,6 +579,7 @@ abstract class Smarty_Internal_TemplateBase extends Smarty_Internal_Data {
|
||||
*
|
||||
* @param string $class name of template class
|
||||
* @param string $class_impl the referenced PHP class to register
|
||||
* @return Smarty_Internal_Templatebase current Smarty_Internal_Templatebase (or Smarty or Smarty_Internal_Template) instance for chaining
|
||||
* @throws SmartyException if $class_impl does not refer to an existing class
|
||||
*/
|
||||
public function registerClass($class_name, $class_impl)
|
||||
@ -556,12 +590,14 @@ abstract class Smarty_Internal_TemplateBase extends Smarty_Internal_Data {
|
||||
}
|
||||
// register the class
|
||||
$this->smarty->registered_classes[$class_name] = $class_impl;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a default plugin handler
|
||||
*
|
||||
* @param callable $callback class/method name
|
||||
* @return Smarty_Internal_Templatebase current Smarty_Internal_Templatebase (or Smarty or Smarty_Internal_Template) instance for chaining
|
||||
* @throws SmartyException if $callback is not callable
|
||||
*/
|
||||
public function registerDefaultPluginHandler($callback)
|
||||
@ -571,12 +607,15 @@ abstract class Smarty_Internal_TemplateBase extends Smarty_Internal_Data {
|
||||
} else {
|
||||
throw new SmartyException("Default plugin handler '$callback' not callable");
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a default template handler
|
||||
*
|
||||
* @param callable $callback class/method name
|
||||
* @return Smarty_Internal_Templatebase current Smarty_Internal_Templatebase (or Smarty or Smarty_Internal_Template) instance for chaining
|
||||
* @throws SmartyException if $callback is not callable
|
||||
*/
|
||||
public function registerDefaultTemplateHandler($callback)
|
||||
@ -586,12 +625,15 @@ abstract class Smarty_Internal_TemplateBase extends Smarty_Internal_Data {
|
||||
} else {
|
||||
throw new SmartyException("Default template handler '$callback' not callable");
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a default template handler
|
||||
*
|
||||
* @param callable $callback class/method name
|
||||
* @return Smarty_Internal_Templatebase current Smarty_Internal_Templatebase (or Smarty or Smarty_Internal_Template) instance for chaining
|
||||
* @throws SmartyException if $callback is not callable
|
||||
*/
|
||||
public function registerDefaultConfigHandler($callback)
|
||||
@ -601,6 +643,8 @@ abstract class Smarty_Internal_TemplateBase extends Smarty_Internal_Data {
|
||||
} else {
|
||||
throw new SmartyException("Default config handler '$callback' not callable");
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -608,10 +652,12 @@ abstract class Smarty_Internal_TemplateBase extends Smarty_Internal_Data {
|
||||
*
|
||||
* @param string $type filter type
|
||||
* @param callback $callback
|
||||
* @return Smarty_Internal_Templatebase current Smarty_Internal_Templatebase (or Smarty or Smarty_Internal_Template) instance for chaining
|
||||
*/
|
||||
public function registerFilter($type, $callback)
|
||||
{
|
||||
$this->smarty->registered_filters[$type][$this->_get_filter_name($callback)] = $callback;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -619,6 +665,7 @@ abstract class Smarty_Internal_TemplateBase extends Smarty_Internal_Data {
|
||||
*
|
||||
* @param string $type filter type
|
||||
* @param callback $callback
|
||||
* @return Smarty_Internal_Templatebase current Smarty_Internal_Templatebase (or Smarty or Smarty_Internal_Template) instance for chaining
|
||||
*/
|
||||
public function unregisterFilter($type, $callback)
|
||||
{
|
||||
@ -626,18 +673,21 @@ abstract class Smarty_Internal_TemplateBase extends Smarty_Internal_Data {
|
||||
if (isset($this->smarty->registered_filters[$type][$name])) {
|
||||
unset($this->smarty->registered_filters[$type][$name]);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return internal filter name
|
||||
*
|
||||
* @param callback $function_name
|
||||
* @return string internal filter name
|
||||
*/
|
||||
public function _get_filter_name($function_name)
|
||||
{
|
||||
if (is_array($function_name)) {
|
||||
$_class_name = (is_object($function_name[0]) ?
|
||||
get_class($function_name[0]) : $function_name[0]);
|
||||
get_class($function_name[0]) : $function_name[0]);
|
||||
return $_class_name . '_' . $function_name[1];
|
||||
} else {
|
||||
return $function_name;
|
||||
@ -649,7 +699,7 @@ abstract class Smarty_Internal_TemplateBase extends Smarty_Internal_Data {
|
||||
*
|
||||
* @param string $type filter type
|
||||
* @param string $name filter name
|
||||
* @return bool
|
||||
* @throws SmartyException if filter could not be loaded
|
||||
*/
|
||||
public function loadFilter($type, $name)
|
||||
{
|
||||
@ -665,7 +715,6 @@ abstract class Smarty_Internal_TemplateBase extends Smarty_Internal_Data {
|
||||
}
|
||||
}
|
||||
throw new SmartyException("{$type}filter \"{$name}\" not callable");
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -673,24 +722,23 @@ abstract class Smarty_Internal_TemplateBase extends Smarty_Internal_Data {
|
||||
*
|
||||
* @param string $type filter type
|
||||
* @param string $name filter name
|
||||
* @return bool
|
||||
* @return Smarty_Internal_Templatebase current Smarty_Internal_Templatebase (or Smarty or Smarty_Internal_Template) instance for chaining
|
||||
*/
|
||||
public function unloadFilter($type, $name)
|
||||
{
|
||||
$_filter_name = "smarty_{$type}filter_{$name}";
|
||||
if (isset($this->smarty->registered_filters[$type][$_filter_name])) {
|
||||
unset ($this->smarty->registered_filters[$type][$_filter_name]);
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* preg_replace callback to convert camelcase getter/setter to underscore property names
|
||||
*
|
||||
* @param string $match match string
|
||||
* @return string replacemant
|
||||
* @return string replacemant
|
||||
*/
|
||||
private function replaceCamelcase($match) {
|
||||
return "_" . strtolower($match[1]);
|
||||
@ -738,14 +786,14 @@ abstract class Smarty_Internal_TemplateBase extends Smarty_Internal_Data {
|
||||
}
|
||||
if ($_is_this) {
|
||||
if ($first3 == 'get')
|
||||
return $this->$property_name;
|
||||
return $this->$property_name;
|
||||
else
|
||||
return $this->$property_name = $args[0];
|
||||
return $this->$property_name = $args[0];
|
||||
} else if ($_is_this === false) {
|
||||
if ($first3 == 'get')
|
||||
return $this->smarty->$property_name;
|
||||
return $this->smarty->$property_name;
|
||||
else
|
||||
return $this->smarty->$property_name = $args[0];
|
||||
return $this->smarty->$property_name = $args[0];
|
||||
} else {
|
||||
throw new SmartyException("property '$property_name' does not exist.");
|
||||
return false;
|
||||
|
@ -20,7 +20,6 @@ class Smarty_Internal_Templatelexer
|
||||
public $line;
|
||||
public $taglineno;
|
||||
public $state = 1;
|
||||
public $strip = false;
|
||||
private $heredoc_id_stack = Array();
|
||||
public $smarty_token_names = array ( // Text for parser error messages
|
||||
'IDENTITY' => '===',
|
||||
@ -62,8 +61,7 @@ class Smarty_Internal_Templatelexer
|
||||
'ANDSYM' => '"&"',
|
||||
'QMARK' => '"?"',
|
||||
'ID' => 'identifier',
|
||||
'OTHER' => 'text',
|
||||
'LINEBREAK' => 'newline',
|
||||
'TEXT' => 'text',
|
||||
'FAKEPHPSTARTTAG' => 'Fake PHP start tag',
|
||||
'PHPSTARTTAG' => 'PHP start tag',
|
||||
'PHPENDTAG' => 'PHP end tag',
|
||||
@ -131,8 +129,8 @@ class Smarty_Internal_Templatelexer
|
||||
8 => 0,
|
||||
9 => 0,
|
||||
10 => 0,
|
||||
11 => 0,
|
||||
12 => 1,
|
||||
11 => 1,
|
||||
13 => 0,
|
||||
14 => 0,
|
||||
15 => 0,
|
||||
16 => 0,
|
||||
@ -143,14 +141,11 @@ class Smarty_Internal_Templatelexer
|
||||
21 => 0,
|
||||
22 => 0,
|
||||
23 => 0,
|
||||
24 => 2,
|
||||
27 => 0,
|
||||
28 => 0,
|
||||
);
|
||||
if ($this->counter >= strlen($this->data)) {
|
||||
return false; // end of input
|
||||
}
|
||||
$yy_global_pattern = "/\G(".$this->ldel."[$]smarty\\.block\\.child".$this->rdel.")|\G(\\{\\})|\G(".$this->ldel."\\*([\S\s]*?)\\*".$this->rdel.")|\G([\t ]*[\r\n]+[\t ]*)|\G(".$this->ldel."strip".$this->rdel.")|\G(".$this->ldel."\\s{1,}strip\\s{1,}".$this->rdel.")|\G(".$this->ldel."\/strip".$this->rdel.")|\G(".$this->ldel."\\s{1,}\/strip\\s{1,}".$this->rdel.")|\G(".$this->ldel."\\s*literal\\s*".$this->rdel.")|\G(".$this->ldel."\\s{1,}\/)|\G(".$this->ldel."\\s*(if|elseif|else if|while)\\s+)|\G(".$this->ldel."\\s*for\\s+)|\G(".$this->ldel."\\s*foreach(?![^\s]))|\G(".$this->ldel."\\s*setfilter\\s+)|\G(".$this->ldel."\\s{1,})|\G(".$this->ldel."\/)|\G(".$this->ldel.")|\G(<\\?(?:php\\w+|=|[a-zA-Z]+)?)|\G(\\?>)|\G(<%)|\G(%>)|\G(([\S\s]*?)(?=([\t ]*[\r\n]+[\t ]*|".$this->ldel."|<\\?|\\?>|<%|%>)))|\G([\S\s]+)|\G(.)/iS";
|
||||
$yy_global_pattern = "/\G(".$this->ldel."[$]smarty\\.block\\.child".$this->rdel.")|\G(\\{\\})|\G(".$this->ldel."\\*([\S\s]*?)\\*".$this->rdel.")|\G(".$this->ldel."strip".$this->rdel.")|\G(".$this->ldel."\\s{1,}strip\\s{1,}".$this->rdel.")|\G(".$this->ldel."\/strip".$this->rdel.")|\G(".$this->ldel."\\s{1,}\/strip\\s{1,}".$this->rdel.")|\G(".$this->ldel."\\s*literal\\s*".$this->rdel.")|\G(".$this->ldel."\\s{1,}\/)|\G(".$this->ldel."\\s*(if|elseif|else if|while)\\s+)|\G(".$this->ldel."\\s*for\\s+)|\G(".$this->ldel."\\s*foreach(?![^\s]))|\G(".$this->ldel."\\s*setfilter\\s+)|\G(".$this->ldel."\\s{1,})|\G(".$this->ldel."\/)|\G(".$this->ldel.")|\G(<\\?(?:php\\w+|=|[a-zA-Z]+)?)|\G(\\?>)|\G(<%)|\G(%>)|\G([\S\s])/iS";
|
||||
|
||||
do {
|
||||
if ($this->mbstring_overload ? preg_match($yy_global_pattern, substr($this->data, $this->counter), $yymatches) : preg_match($yy_global_pattern,$this->data, $yymatches, null, $this->counter)) {
|
||||
@ -208,7 +203,7 @@ class Smarty_Internal_Templatelexer
|
||||
function yy_r1_2($yy_subpatterns)
|
||||
{
|
||||
|
||||
$this->token = Smarty_Internal_Templateparser::TP_OTHER;
|
||||
$this->token = Smarty_Internal_Templateparser::TP_TEXT;
|
||||
}
|
||||
function yy_r1_3($yy_subpatterns)
|
||||
{
|
||||
@ -218,79 +213,77 @@ class Smarty_Internal_Templatelexer
|
||||
function yy_r1_5($yy_subpatterns)
|
||||
{
|
||||
|
||||
if ($this->strip) {
|
||||
return false;
|
||||
} else {
|
||||
$this->token = Smarty_Internal_Templateparser::TP_LINEBREAK;
|
||||
}
|
||||
$this->token = Smarty_Internal_Templateparser::TP_STRIPON;
|
||||
}
|
||||
function yy_r1_6($yy_subpatterns)
|
||||
{
|
||||
|
||||
$this->strip = true;
|
||||
return false;
|
||||
if ($this->smarty->auto_literal) {
|
||||
$this->token = Smarty_Internal_Templateparser::TP_TEXT;
|
||||
} else {
|
||||
$this->token = Smarty_Internal_Templateparser::TP_STRIPON;
|
||||
}
|
||||
}
|
||||
function yy_r1_7($yy_subpatterns)
|
||||
{
|
||||
|
||||
if ($this->smarty->auto_literal) {
|
||||
$this->token = Smarty_Internal_Templateparser::TP_OTHER;
|
||||
} else {
|
||||
$this->strip = true;
|
||||
return false;
|
||||
}
|
||||
$this->token = Smarty_Internal_Templateparser::TP_STRIPOFF;
|
||||
}
|
||||
function yy_r1_8($yy_subpatterns)
|
||||
{
|
||||
|
||||
$this->strip = false;
|
||||
return false;
|
||||
}
|
||||
function yy_r1_9($yy_subpatterns)
|
||||
{
|
||||
|
||||
if ($this->smarty->auto_literal) {
|
||||
$this->token = Smarty_Internal_Templateparser::TP_OTHER;
|
||||
$this->token = Smarty_Internal_Templateparser::TP_TEXT;
|
||||
} else {
|
||||
$this->strip = false;
|
||||
return false;
|
||||
$this->token = Smarty_Internal_Templateparser::TP_STRIPOFF;
|
||||
}
|
||||
}
|
||||
function yy_r1_10($yy_subpatterns)
|
||||
function yy_r1_9($yy_subpatterns)
|
||||
{
|
||||
|
||||
$this->token = Smarty_Internal_Templateparser::TP_LITERALSTART;
|
||||
$this->yypushstate(self::LITERAL);
|
||||
}
|
||||
function yy_r1_11($yy_subpatterns)
|
||||
function yy_r1_10($yy_subpatterns)
|
||||
{
|
||||
|
||||
if ($this->smarty->auto_literal) {
|
||||
$this->token = Smarty_Internal_Templateparser::TP_OTHER;
|
||||
$this->token = Smarty_Internal_Templateparser::TP_TEXT;
|
||||
} else {
|
||||
$this->token = Smarty_Internal_Templateparser::TP_LDELSLASH;
|
||||
$this->yypushstate(self::SMARTY);
|
||||
$this->taglineno = $this->line;
|
||||
}
|
||||
}
|
||||
function yy_r1_12($yy_subpatterns)
|
||||
function yy_r1_11($yy_subpatterns)
|
||||
{
|
||||
|
||||
if ($this->smarty->auto_literal && trim(substr($this->value,$this->ldel_length,1)) == '') {
|
||||
$this->token = Smarty_Internal_Templateparser::TP_OTHER;
|
||||
$this->token = Smarty_Internal_Templateparser::TP_TEXT;
|
||||
} else {
|
||||
$this->token = Smarty_Internal_Templateparser::TP_LDELIF;
|
||||
$this->yypushstate(self::SMARTY);
|
||||
$this->taglineno = $this->line;
|
||||
}
|
||||
}
|
||||
function yy_r1_13($yy_subpatterns)
|
||||
{
|
||||
|
||||
if ($this->smarty->auto_literal && trim(substr($this->value,$this->ldel_length,1)) == '') {
|
||||
$this->token = Smarty_Internal_Templateparser::TP_TEXT;
|
||||
} else {
|
||||
$this->token = Smarty_Internal_Templateparser::TP_LDELFOR;
|
||||
$this->yypushstate(self::SMARTY);
|
||||
$this->taglineno = $this->line;
|
||||
}
|
||||
}
|
||||
function yy_r1_14($yy_subpatterns)
|
||||
{
|
||||
|
||||
if ($this->smarty->auto_literal && trim(substr($this->value,$this->ldel_length,1)) == '') {
|
||||
$this->token = Smarty_Internal_Templateparser::TP_OTHER;
|
||||
$this->token = Smarty_Internal_Templateparser::TP_TEXT;
|
||||
} else {
|
||||
$this->token = Smarty_Internal_Templateparser::TP_LDELFOR;
|
||||
$this->token = Smarty_Internal_Templateparser::TP_LDELFOREACH;
|
||||
$this->yypushstate(self::SMARTY);
|
||||
$this->taglineno = $this->line;
|
||||
}
|
||||
@ -299,9 +292,9 @@ class Smarty_Internal_Templatelexer
|
||||
{
|
||||
|
||||
if ($this->smarty->auto_literal && trim(substr($this->value,$this->ldel_length,1)) == '') {
|
||||
$this->token = Smarty_Internal_Templateparser::TP_OTHER;
|
||||
$this->token = Smarty_Internal_Templateparser::TP_TEXT;
|
||||
} else {
|
||||
$this->token = Smarty_Internal_Templateparser::TP_LDELFOREACH;
|
||||
$this->token = Smarty_Internal_Templateparser::TP_LDELSETFILTER;
|
||||
$this->yypushstate(self::SMARTY);
|
||||
$this->taglineno = $this->line;
|
||||
}
|
||||
@ -309,10 +302,10 @@ class Smarty_Internal_Templatelexer
|
||||
function yy_r1_16($yy_subpatterns)
|
||||
{
|
||||
|
||||
if ($this->smarty->auto_literal && trim(substr($this->value,$this->ldel_length,1)) == '') {
|
||||
$this->token = Smarty_Internal_Templateparser::TP_OTHER;
|
||||
if ($this->smarty->auto_literal) {
|
||||
$this->token = Smarty_Internal_Templateparser::TP_TEXT;
|
||||
} else {
|
||||
$this->token = Smarty_Internal_Templateparser::TP_LDELSETFILTER;
|
||||
$this->token = Smarty_Internal_Templateparser::TP_LDEL;
|
||||
$this->yypushstate(self::SMARTY);
|
||||
$this->taglineno = $this->line;
|
||||
}
|
||||
@ -320,29 +313,18 @@ class Smarty_Internal_Templatelexer
|
||||
function yy_r1_17($yy_subpatterns)
|
||||
{
|
||||
|
||||
if ($this->smarty->auto_literal) {
|
||||
$this->token = Smarty_Internal_Templateparser::TP_OTHER;
|
||||
} else {
|
||||
$this->token = Smarty_Internal_Templateparser::TP_LDEL;
|
||||
$this->yypushstate(self::SMARTY);
|
||||
$this->taglineno = $this->line;
|
||||
}
|
||||
}
|
||||
function yy_r1_18($yy_subpatterns)
|
||||
{
|
||||
|
||||
$this->token = Smarty_Internal_Templateparser::TP_LDELSLASH;
|
||||
$this->yypushstate(self::SMARTY);
|
||||
$this->taglineno = $this->line;
|
||||
}
|
||||
function yy_r1_19($yy_subpatterns)
|
||||
function yy_r1_18($yy_subpatterns)
|
||||
{
|
||||
|
||||
$this->token = Smarty_Internal_Templateparser::TP_LDEL;
|
||||
$this->yypushstate(self::SMARTY);
|
||||
$this->taglineno = $this->line;
|
||||
}
|
||||
function yy_r1_20($yy_subpatterns)
|
||||
function yy_r1_19($yy_subpatterns)
|
||||
{
|
||||
|
||||
if (in_array($this->value, Array('<?', '<?=', '<?php'))) {
|
||||
@ -354,35 +336,31 @@ class Smarty_Internal_Templatelexer
|
||||
$this->value = substr($this->value, 0, 2);
|
||||
}
|
||||
}
|
||||
function yy_r1_21($yy_subpatterns)
|
||||
function yy_r1_20($yy_subpatterns)
|
||||
{
|
||||
|
||||
$this->token = Smarty_Internal_Templateparser::TP_PHPENDTAG;
|
||||
}
|
||||
function yy_r1_22($yy_subpatterns)
|
||||
function yy_r1_21($yy_subpatterns)
|
||||
{
|
||||
|
||||
$this->token = Smarty_Internal_Templateparser::TP_ASPSTARTTAG;
|
||||
}
|
||||
function yy_r1_23($yy_subpatterns)
|
||||
function yy_r1_22($yy_subpatterns)
|
||||
{
|
||||
|
||||
$this->token = Smarty_Internal_Templateparser::TP_ASPENDTAG;
|
||||
}
|
||||
function yy_r1_24($yy_subpatterns)
|
||||
function yy_r1_23($yy_subpatterns)
|
||||
{
|
||||
|
||||
$this->token = Smarty_Internal_Templateparser::TP_OTHER;
|
||||
}
|
||||
function yy_r1_27($yy_subpatterns)
|
||||
{
|
||||
|
||||
$this->token = Smarty_Internal_Templateparser::TP_OTHER;
|
||||
}
|
||||
function yy_r1_28($yy_subpatterns)
|
||||
{
|
||||
|
||||
$this->token = Smarty_Internal_Templateparser::TP_OTHER;
|
||||
$to = strlen($this->data);
|
||||
preg_match("/{$this->ldel}|<\?|\?>|<%|%>/",$this->data,$match,PREG_OFFSET_CAPTURE,$this->counter);
|
||||
if (isset($match[0][1])) {
|
||||
$to = $match[0][1];
|
||||
}
|
||||
$this->value = substr($this->data,$this->counter,$to-$this->counter);
|
||||
$this->token = Smarty_Internal_Templateparser::TP_TEXT;
|
||||
}
|
||||
|
||||
|
||||
@ -460,7 +438,7 @@ class Smarty_Internal_Templatelexer
|
||||
if ($this->counter >= strlen($this->data)) {
|
||||
return false; // end of input
|
||||
}
|
||||
$yy_global_pattern = "/\G('[^'\\\\]*(?:\\\\.[^'\\\\]*)*')|\G(".$this->ldel."\\s{1,}\/)|\G(".$this->ldel."\\s*(if|elseif|else if|while)\\s+)|\G(".$this->ldel."\\s*for\\s+)|\G(".$this->ldel."\\s*foreach(?![^\s]))|\G(".$this->ldel."\\s{1,})|\G(\\s{1,}".$this->rdel.")|\G(".$this->ldel."\/)|\G(".$this->ldel.")|\G(".$this->rdel.")|\G(\\s+is\\s+in\\s+)|\G(\\s+as\\s+)|\G(\\s+to\\s+)|\G(\\s+step\\s+)|\G(\\s+instanceof\\s+)|\G(\\s*===\\s*)|\G(\\s*!==\\s*)|\G(\\s*==\\s*|\\s+eq\\s+)|\G(\\s*!=\\s*|\\s*<>\\s*|\\s+(ne|neq)\\s+)|\G(\\s*>=\\s*|\\s+(ge|gte)\\s+)|\G(\\s*<=\\s*|\\s+(le|lte)\\s+)|\G(\\s*>\\s*|\\s+gt\\s+)|\G(\\s*<\\s*|\\s+lt\\s+)|\G(\\s+mod\\s+)|\G(!\\s*|not\\s+)|\G(\\s*&&\\s*|\\s*and\\s+)|\G(\\s*\\|\\|\\s*|\\s*or\\s+)|\G(\\s*xor\\s+)|\G(\\s+is\\s+odd\\s+by\\s+)|\G(\\s+is\\s+not\\s+odd\\s+by\\s+)|\G(\\s+is\\s+odd)|\G(\\s+is\\s+not\\s+odd)|\G(\\s+is\\s+even\\s+by\\s+)|\G(\\s+is\\s+not\\s+even\\s+by\\s+)|\G(\\s+is\\s+even)|\G(\\s+is\\s+not\\s+even)|\G(\\s+is\\s+div\\s+by\\s+)|\G(\\s+is\\s+not\\s+div\\s+by\\s+)|\G(\\((int(eger)?|bool(ean)?|float|double|real|string|binary|array|object)\\)\\s*)|\G(\\s*\\(\\s*)|\G(\\s*\\))|\G(\\[\\s*)|\G(\\s*\\])|\G(\\s*->\\s*)|\G(\\s*=>\\s*)|\G(\\s*=\\s*)|\G(\\+\\+|--)|\G(\\s*(\\+|-)\\s*)|\G(\\s*(\\*|\/|%)\\s*)|\G(\\$)|\G(\\s*;)|\G(::)|\G(\\s*:\\s*)|\G(@)|\G(#)|\G(\")|\G(`)|\G(\\|)|\G(\\.)|\G(\\s*,\\s*)|\G(\\s*&\\s*)|\G(\\s*\\?\\s*)|\G(0[xX][0-9a-fA-F]+)|\G([0-9]*[a-zA-Z_]\\w*)|\G(\\d+)|\G(\\s+)|\G(.)/iS";
|
||||
$yy_global_pattern = "/\G('[^'\\\\]*(?:\\\\.[^'\\\\]*)*')|\G(".$this->ldel."\\s{1,}\/)|\G(".$this->ldel."\\s*(if|elseif|else if|while)\\s+)|\G(".$this->ldel."\\s*for\\s+)|\G(".$this->ldel."\\s*foreach(?![^\s]))|\G(".$this->ldel."\\s{1,})|\G(\\s{1,}".$this->rdel.")|\G(".$this->ldel."\/)|\G(".$this->ldel.")|\G(".$this->rdel.")|\G(\\s+is\\s+in\\s+)|\G(\\s+as\\s+)|\G(\\s+to\\s+)|\G(\\s+step\\s+)|\G(\\s+instanceof\\s+)|\G(\\s*===\\s*)|\G(\\s*!==\\s*)|\G(\\s*==\\s*|\\s+eq\\s+)|\G(\\s*!=\\s*|\\s*<>\\s*|\\s+(ne|neq)\\s+)|\G(\\s*>=\\s*|\\s+(ge|gte)\\s+)|\G(\\s*<=\\s*|\\s+(le|lte)\\s+)|\G(\\s*>\\s*|\\s+gt\\s+)|\G(\\s*<\\s*|\\s+lt\\s+)|\G(\\s+mod\\s+)|\G(!\\s*|not\\s+)|\G(\\s*&&\\s*|\\s*and\\s+)|\G(\\s*\\|\\|\\s*|\\s*or\\s+)|\G(\\s*xor\\s+)|\G(\\s+is\\s+odd\\s+by\\s+)|\G(\\s+is\\s+not\\s+odd\\s+by\\s+)|\G(\\s+is\\s+odd)|\G(\\s+is\\s+not\\s+odd)|\G(\\s+is\\s+even\\s+by\\s+)|\G(\\s+is\\s+not\\s+even\\s+by\\s+)|\G(\\s+is\\s+even)|\G(\\s+is\\s+not\\s+even)|\G(\\s+is\\s+div\\s+by\\s+)|\G(\\s+is\\s+not\\s+div\\s+by\\s+)|\G(\\((int(eger)?|bool(ean)?|float|double|real|string|binary|array|object)\\)\\s*)|\G(\\s*\\(\\s*)|\G(\\s*\\))|\G(\\[\\s*)|\G(\\s*\\])|\G(\\s*->\\s*)|\G(\\s*=>\\s*)|\G(\\s*=\\s*)|\G(\\+\\+|--)|\G(\\s*(\\+|-)\\s*)|\G(\\s*(\\*|\/|%)\\s*)|\G(\\$)|\G(\\s*;)|\G(::)|\G(\\s*:\\s*)|\G(@)|\G(#)|\G(\")|\G(`)|\G(\\|)|\G(\\.)|\G(\\s*,\\s*)|\G(\\s*&\\s*)|\G(\\s*\\?\\s*)|\G(0[xX][0-9a-fA-F]+)|\G([0-9]*[a-zA-Z_]\\w*)|\G(\\d+)|\G(\\s+)|\G([\S\s])/iS";
|
||||
|
||||
do {
|
||||
if ($this->mbstring_overload ? preg_match($yy_global_pattern, substr($this->data, $this->counter), $yymatches) : preg_match($yy_global_pattern,$this->data, $yymatches, null, $this->counter)) {
|
||||
@ -519,7 +497,7 @@ class Smarty_Internal_Templatelexer
|
||||
{
|
||||
|
||||
if ($this->smarty->auto_literal) {
|
||||
$this->token = Smarty_Internal_Templateparser::TP_OTHER;
|
||||
$this->token = Smarty_Internal_Templateparser::TP_TEXT;
|
||||
} else {
|
||||
$this->token = Smarty_Internal_Templateparser::TP_LDELSLASH;
|
||||
$this->yypushstate(self::SMARTY);
|
||||
@ -530,7 +508,7 @@ class Smarty_Internal_Templatelexer
|
||||
{
|
||||
|
||||
if ($this->smarty->auto_literal && trim(substr($this->value,$this->ldel_length,1)) == '') {
|
||||
$this->token = Smarty_Internal_Templateparser::TP_OTHER;
|
||||
$this->token = Smarty_Internal_Templateparser::TP_TEXT;
|
||||
} else {
|
||||
$this->token = Smarty_Internal_Templateparser::TP_LDELIF;
|
||||
$this->yypushstate(self::SMARTY);
|
||||
@ -541,7 +519,7 @@ class Smarty_Internal_Templatelexer
|
||||
{
|
||||
|
||||
if ($this->smarty->auto_literal && trim(substr($this->value,$this->ldel_length,1)) == '') {
|
||||
$this->token = Smarty_Internal_Templateparser::TP_OTHER;
|
||||
$this->token = Smarty_Internal_Templateparser::TP_TEXT;
|
||||
} else {
|
||||
$this->token = Smarty_Internal_Templateparser::TP_LDELFOR;
|
||||
$this->yypushstate(self::SMARTY);
|
||||
@ -552,7 +530,7 @@ class Smarty_Internal_Templatelexer
|
||||
{
|
||||
|
||||
if ($this->smarty->auto_literal && trim(substr($this->value,$this->ldel_length,1)) == '') {
|
||||
$this->token = Smarty_Internal_Templateparser::TP_OTHER;
|
||||
$this->token = Smarty_Internal_Templateparser::TP_TEXT;
|
||||
} else {
|
||||
$this->token = Smarty_Internal_Templateparser::TP_LDELFOREACH;
|
||||
$this->yypushstate(self::SMARTY);
|
||||
@ -563,7 +541,7 @@ class Smarty_Internal_Templatelexer
|
||||
{
|
||||
|
||||
if ($this->smarty->auto_literal) {
|
||||
$this->token = Smarty_Internal_Templateparser::TP_OTHER;
|
||||
$this->token = Smarty_Internal_Templateparser::TP_TEXT;
|
||||
} else {
|
||||
$this->token = Smarty_Internal_Templateparser::TP_LDEL;
|
||||
$this->yypushstate(self::SMARTY);
|
||||
@ -881,7 +859,7 @@ class Smarty_Internal_Templatelexer
|
||||
function yy_r2_76($yy_subpatterns)
|
||||
{
|
||||
|
||||
$this->token = Smarty_Internal_Templateparser::TP_OTHER;
|
||||
$this->token = Smarty_Internal_Templateparser::TP_TEXT;
|
||||
}
|
||||
|
||||
|
||||
@ -896,13 +874,11 @@ class Smarty_Internal_Templatelexer
|
||||
5 => 0,
|
||||
6 => 0,
|
||||
7 => 0,
|
||||
8 => 2,
|
||||
11 => 0,
|
||||
);
|
||||
if ($this->counter >= strlen($this->data)) {
|
||||
return false; // end of input
|
||||
}
|
||||
$yy_global_pattern = "/\G(".$this->ldel."\\s*literal\\s*".$this->rdel.")|\G(".$this->ldel."\\s*\/literal\\s*".$this->rdel.")|\G([\t ]*[\r\n]+[\t ]*)|\G(<\\?(?:php\\w+|=|[a-zA-Z]+)?)|\G(\\?>)|\G(<%)|\G(%>)|\G(([\S\s]*?)(?=([\t ]*[\r\n]+[\t ]*|".$this->ldel."\/?literal".$this->rdel."|<\\?|<%)))|\G(.)/iS";
|
||||
$yy_global_pattern = "/\G(".$this->ldel."\\s*literal\\s*".$this->rdel.")|\G(".$this->ldel."\\s*\/literal\\s*".$this->rdel.")|\G(<\\?(?:php\\w+|=|[a-zA-Z]+)?)|\G(\\?>)|\G(<%)|\G(%>)|\G([\S\s])/iS";
|
||||
|
||||
do {
|
||||
if ($this->mbstring_overload ? preg_match($yy_global_pattern, substr($this->data, $this->counter), $yymatches) : preg_match($yy_global_pattern,$this->data, $yymatches, null, $this->counter)) {
|
||||
@ -967,11 +943,6 @@ class Smarty_Internal_Templatelexer
|
||||
function yy_r3_3($yy_subpatterns)
|
||||
{
|
||||
|
||||
$this->token = Smarty_Internal_Templateparser::TP_LITERAL;
|
||||
}
|
||||
function yy_r3_4($yy_subpatterns)
|
||||
{
|
||||
|
||||
if (in_array($this->value, Array('<?', '<?=', '<?php'))) {
|
||||
$this->token = Smarty_Internal_Templateparser::TP_PHPSTARTTAG;
|
||||
} else {
|
||||
@ -979,31 +950,35 @@ class Smarty_Internal_Templatelexer
|
||||
$this->value = substr($this->value, 0, 2);
|
||||
}
|
||||
}
|
||||
function yy_r3_5($yy_subpatterns)
|
||||
function yy_r3_4($yy_subpatterns)
|
||||
{
|
||||
|
||||
$this->token = Smarty_Internal_Templateparser::TP_PHPENDTAG;
|
||||
}
|
||||
function yy_r3_6($yy_subpatterns)
|
||||
function yy_r3_5($yy_subpatterns)
|
||||
{
|
||||
|
||||
$this->token = Smarty_Internal_Templateparser::TP_ASPSTARTTAG;
|
||||
}
|
||||
function yy_r3_7($yy_subpatterns)
|
||||
function yy_r3_6($yy_subpatterns)
|
||||
{
|
||||
|
||||
$this->token = Smarty_Internal_Templateparser::TP_ASPENDTAG;
|
||||
}
|
||||
function yy_r3_8($yy_subpatterns)
|
||||
function yy_r3_7($yy_subpatterns)
|
||||
{
|
||||
|
||||
$to = strlen($this->data);
|
||||
preg_match("/{$this->ldel}\/?literal{$this->rdel}|<\?|<%|\?>|%>/",$this->data,$match,PREG_OFFSET_CAPTURE,$this->counter);
|
||||
if (isset($match[0][1])) {
|
||||
$to = $match[0][1];
|
||||
} else {
|
||||
$this->compiler->trigger_template_error ("missing or misspelled literal closing tag");
|
||||
}
|
||||
|
||||
$this->value = substr($this->data,$this->counter,$to-$this->counter);
|
||||
$this->token = Smarty_Internal_Templateparser::TP_LITERAL;
|
||||
}
|
||||
function yy_r3_11($yy_subpatterns)
|
||||
{
|
||||
|
||||
$this->compiler->trigger_template_error ("missing or misspelled literal closing tag");
|
||||
}
|
||||
|
||||
|
||||
function yylex4()
|
||||
@ -1022,12 +997,11 @@ class Smarty_Internal_Templatelexer
|
||||
12 => 0,
|
||||
13 => 3,
|
||||
17 => 0,
|
||||
18 => 0,
|
||||
);
|
||||
if ($this->counter >= strlen($this->data)) {
|
||||
return false; // end of input
|
||||
}
|
||||
$yy_global_pattern = "/\G(".$this->ldel."\\s{1,}\/)|\G(".$this->ldel."\\s*(if|elseif|else if|while)\\s+)|\G(".$this->ldel."\\s*for\\s+)|\G(".$this->ldel."\\s*foreach(?![^\s]))|\G(".$this->ldel."\\s{1,})|\G(".$this->ldel."\/)|\G(".$this->ldel.")|\G(\")|\G(`\\$)|\G(\\$[0-9]*[a-zA-Z_]\\w*)|\G(\\$)|\G(([^\"\\\\]*?)((?:\\\\.[^\"\\\\]*?)*?)(?=(".$this->ldel."|\\$|`\\$|\")))|\G([\S\s]+)|\G(.)/iS";
|
||||
$yy_global_pattern = "/\G(".$this->ldel."\\s{1,}\/)|\G(".$this->ldel."\\s*(if|elseif|else if|while)\\s+)|\G(".$this->ldel."\\s*for\\s+)|\G(".$this->ldel."\\s*foreach(?![^\s]))|\G(".$this->ldel."\\s{1,})|\G(".$this->ldel."\/)|\G(".$this->ldel.")|\G(\")|\G(`\\$)|\G(\\$[0-9]*[a-zA-Z_]\\w*)|\G(\\$)|\G(([^\"\\\\]*?)((?:\\\\.[^\"\\\\]*?)*?)(?=(".$this->ldel."|\\$|`\\$|\")))|\G([\S\s])/iS";
|
||||
|
||||
do {
|
||||
if ($this->mbstring_overload ? preg_match($yy_global_pattern, substr($this->data, $this->counter), $yymatches) : preg_match($yy_global_pattern,$this->data, $yymatches, null, $this->counter)) {
|
||||
@ -1081,7 +1055,7 @@ class Smarty_Internal_Templatelexer
|
||||
{
|
||||
|
||||
if ($this->smarty->auto_literal) {
|
||||
$this->token = Smarty_Internal_Templateparser::TP_OTHER;
|
||||
$this->token = Smarty_Internal_Templateparser::TP_TEXT;
|
||||
} else {
|
||||
$this->token = Smarty_Internal_Templateparser::TP_LDELSLASH;
|
||||
$this->yypushstate(self::SMARTY);
|
||||
@ -1092,7 +1066,7 @@ class Smarty_Internal_Templatelexer
|
||||
{
|
||||
|
||||
if ($this->smarty->auto_literal && trim(substr($this->value,$this->ldel_length,1)) == '') {
|
||||
$this->token = Smarty_Internal_Templateparser::TP_OTHER;
|
||||
$this->token = Smarty_Internal_Templateparser::TP_TEXT;
|
||||
} else {
|
||||
$this->token = Smarty_Internal_Templateparser::TP_LDELIF;
|
||||
$this->yypushstate(self::SMARTY);
|
||||
@ -1103,7 +1077,7 @@ class Smarty_Internal_Templatelexer
|
||||
{
|
||||
|
||||
if ($this->smarty->auto_literal && trim(substr($this->value,$this->ldel_length,1)) == '') {
|
||||
$this->token = Smarty_Internal_Templateparser::TP_OTHER;
|
||||
$this->token = Smarty_Internal_Templateparser::TP_TEXT;
|
||||
} else {
|
||||
$this->token = Smarty_Internal_Templateparser::TP_LDELFOR;
|
||||
$this->yypushstate(self::SMARTY);
|
||||
@ -1114,7 +1088,7 @@ class Smarty_Internal_Templatelexer
|
||||
{
|
||||
|
||||
if ($this->smarty->auto_literal && trim(substr($this->value,$this->ldel_length,1)) == '') {
|
||||
$this->token = Smarty_Internal_Templateparser::TP_OTHER;
|
||||
$this->token = Smarty_Internal_Templateparser::TP_TEXT;
|
||||
} else {
|
||||
$this->token = Smarty_Internal_Templateparser::TP_LDELFOREACH;
|
||||
$this->yypushstate(self::SMARTY);
|
||||
@ -1125,7 +1099,7 @@ class Smarty_Internal_Templatelexer
|
||||
{
|
||||
|
||||
if ($this->smarty->auto_literal) {
|
||||
$this->token = Smarty_Internal_Templateparser::TP_OTHER;
|
||||
$this->token = Smarty_Internal_Templateparser::TP_TEXT;
|
||||
} else {
|
||||
$this->token = Smarty_Internal_Templateparser::TP_LDEL;
|
||||
$this->yypushstate(self::SMARTY);
|
||||
@ -1168,22 +1142,19 @@ class Smarty_Internal_Templatelexer
|
||||
function yy_r4_12($yy_subpatterns)
|
||||
{
|
||||
|
||||
$this->token = Smarty_Internal_Templateparser::TP_OTHER;
|
||||
$this->token = Smarty_Internal_Templateparser::TP_TEXT;
|
||||
}
|
||||
function yy_r4_13($yy_subpatterns)
|
||||
{
|
||||
|
||||
$this->token = Smarty_Internal_Templateparser::TP_OTHER;
|
||||
$this->token = Smarty_Internal_Templateparser::TP_TEXT;
|
||||
}
|
||||
function yy_r4_17($yy_subpatterns)
|
||||
{
|
||||
|
||||
$this->token = Smarty_Internal_Templateparser::TP_OTHER;
|
||||
}
|
||||
function yy_r4_18($yy_subpatterns)
|
||||
{
|
||||
|
||||
$this->token = Smarty_Internal_Templateparser::TP_OTHER;
|
||||
$to = strlen($this->data);
|
||||
$this->value = substr($this->data,$this->counter,$to-$this->counter);
|
||||
$this->token = Smarty_Internal_Templateparser::TP_TEXT;
|
||||
}
|
||||
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -90,8 +90,8 @@ abstract class Smarty_Resource {
|
||||
{
|
||||
// intentionally left blank
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* modify resource_name according to resource handlers specifications
|
||||
*
|
||||
@ -103,7 +103,7 @@ abstract class Smarty_Resource {
|
||||
{
|
||||
return get_class($this) . '#' . $smarty->joined_template_dir . '#' . $resource_name;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* populate Compiled Object with compiled filepath
|
||||
*
|
||||
@ -265,7 +265,9 @@ abstract class Smarty_Resource {
|
||||
if ($source->smarty->use_include_path && !preg_match('/^([\/\\\\]|[a-zA-Z]:[\/\\\\])/', $_directory)) {
|
||||
// try PHP include_path
|
||||
if (($_filepath = Smarty_Internal_Get_Include_Path::getIncludePath($_filepath)) !== false) {
|
||||
return $_filepath;
|
||||
if ($this->fileExists($source, $_filepath)) {
|
||||
return $_filepath;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -349,14 +351,14 @@ abstract class Smarty_Resource {
|
||||
// note registered to smarty is not kept unique!
|
||||
return $smarty->_resource_handlers[$type];
|
||||
}
|
||||
|
||||
|
||||
if (!isset(self::$resources['registered'])) {
|
||||
self::$resources['registered'] = new Smarty_Internal_Resource_Registered();
|
||||
}
|
||||
if (!isset($smarty->_resource_handlers[$type])) {
|
||||
$smarty->_resource_handlers[$type] = self::$resources['registered'];
|
||||
}
|
||||
|
||||
|
||||
return $smarty->_resource_handlers[$type];
|
||||
}
|
||||
|
||||
@ -375,7 +377,7 @@ abstract class Smarty_Resource {
|
||||
if (isset(self::$resources[$type])) {
|
||||
return $smarty->_resource_handlers[$type] = self::$resources[$type];
|
||||
}
|
||||
|
||||
|
||||
if (class_exists($_resource_class, false)) {
|
||||
self::$resources[$type] = new $_resource_class();
|
||||
return $smarty->_resource_handlers[$type] = self::$resources[$type];
|
||||
@ -410,7 +412,7 @@ abstract class Smarty_Resource {
|
||||
// give up
|
||||
throw new SmartyException("Unkown resource type '{$type}'");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* extract resource_type and resource_name from template_resource and config_resource
|
||||
*
|
||||
@ -434,8 +436,8 @@ abstract class Smarty_Resource {
|
||||
$name = $parts[1];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* modify resource_name according to resource handlers specifications
|
||||
*
|
||||
@ -443,11 +445,11 @@ abstract class Smarty_Resource {
|
||||
* @param string $resource_name resource_name to make unique
|
||||
* @return string unique resource name
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* modify template_resource according to resource handlers specifications
|
||||
*
|
||||
* @param string $smarty Smarty instance
|
||||
* @param string $smarty Smarty instance
|
||||
* @param string $template_resource template_resource to extracate resource handler and name of
|
||||
* @return string unique resource name
|
||||
*/
|
||||
@ -458,7 +460,7 @@ abstract class Smarty_Resource {
|
||||
$resource = Smarty_Resource::load($smarty, $type);
|
||||
return $resource->buildUniqueResourceName($smarty, $name);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* initialize Source Object for given resource
|
||||
*
|
||||
@ -475,7 +477,7 @@ abstract class Smarty_Resource {
|
||||
$smarty = $_template->smarty;
|
||||
$template_resource = $_template->template_resource;
|
||||
}
|
||||
|
||||
|
||||
// parse resource_name, load resource handler, identify unique resource name
|
||||
self::parseResourceName($template_resource, $smarty->default_resource_type, $name, $type);
|
||||
$resource = Smarty_Resource::load($smarty, $type);
|
||||
@ -486,7 +488,7 @@ abstract class Smarty_Resource {
|
||||
if (isset(self::$sources[$_cache_key])) {
|
||||
return self::$sources[$_cache_key];
|
||||
}
|
||||
|
||||
|
||||
// create source
|
||||
$source = new Smarty_Template_Source($resource, $smarty, $template_resource, $type, $name, $unique_resource_name);
|
||||
$resource->populate($source, $_template);
|
||||
@ -507,10 +509,10 @@ abstract class Smarty_Resource {
|
||||
static $_incompatible_resources = array('eval' => true, 'string' => true, 'extends' => true, 'php' => true);
|
||||
$config_resource = $_config->config_resource;
|
||||
$smarty = $_config->smarty;
|
||||
|
||||
|
||||
// parse resource_name
|
||||
self::parseResourceName($config_resource, $smarty->default_config_type, $name, $type);
|
||||
|
||||
|
||||
// make sure configs are not loaded via anything smarty can't handle
|
||||
if (isset($_incompatible_resources[$type])) {
|
||||
throw new SmartyException ("Unable to use resource '{$type}' for config");
|
||||
@ -519,17 +521,17 @@ abstract class Smarty_Resource {
|
||||
// load resource handler, identify unique resource name
|
||||
$resource = Smarty_Resource::load($smarty, $type);
|
||||
$unique_resource_name = $resource->buildUniqueResourceName($smarty, $name);
|
||||
|
||||
|
||||
// check runtime cache
|
||||
$_cache_key = 'config|' . $unique_resource_name;
|
||||
if (isset(self::$sources[$_cache_key])) {
|
||||
return self::$sources[$_cache_key];
|
||||
}
|
||||
|
||||
|
||||
// create source
|
||||
$source = new Smarty_Config_Source($resource, $smarty, $config_resource, $type, $name, $unique_resource_name);
|
||||
$resource->populate($source, null);
|
||||
|
||||
|
||||
// runtime cache
|
||||
self::$sources[$_cache_key] = $source;
|
||||
return $source;
|
||||
@ -594,7 +596,7 @@ class Smarty_Template_Source {
|
||||
* @var string
|
||||
*/
|
||||
public $name = null;
|
||||
|
||||
|
||||
/**
|
||||
* Unique Resource Name
|
||||
* @var string
|
||||
|
@ -48,6 +48,12 @@ class Smarty_Security {
|
||||
* @var array
|
||||
*/
|
||||
public $trusted_dir = array();
|
||||
/**
|
||||
* List of regular expressions (PCRE) that include trusted URIs
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $trusted_uri = array();
|
||||
/**
|
||||
* This is an array of trusted static classes.
|
||||
*
|
||||
@ -374,7 +380,33 @@ class Smarty_Security {
|
||||
// give up
|
||||
throw new SmartyException("directory '{$_filepath}' not allowed by security setting");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check if URI (e.g. {fetch} or {html_image}) is trusted
|
||||
*
|
||||
* To simplify things, isTrustedUri() resolves all input to "{$PROTOCOL}://{$HOSTNAME}".
|
||||
* So "http://username:password@hello.world.example.org:8080/some-path?some=query-string"
|
||||
* is reduced to "http://hello.world.example.org" prior to applying the patters from {@link $trusted_uri}.
|
||||
* @param string $uri
|
||||
* @return boolean true if URI is trusted
|
||||
* @throws SmartyException if URI is not trusted
|
||||
* @uses $trusted_uri for list of patterns to match against $uri
|
||||
*/
|
||||
public function isTrustedUri($uri)
|
||||
{
|
||||
$_uri = parse_url($uri);
|
||||
if (!empty($_uri['scheme']) && !empty($_uri['host'])) {
|
||||
$_uri = $_uri['scheme'] . '://' . $_uri['host'];
|
||||
foreach ($this->trusted_uri as $pattern) {
|
||||
if (preg_match($pattern, $_uri)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
throw new SmartyException("URI '{$uri}' not allowed by security setting");
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if directory of file resource is trusted.
|
||||
*
|
||||
|
Loading…
x
Reference in New Issue
Block a user