mirror of
https://github.com/smarty-php/smarty.git
synced 2026-05-03 19:30:49 +02:00
code cleanup and optimizations 3.1.32-dev-34
This commit is contained in:
@@ -75,11 +75,11 @@ function smarty_block_textformat($params, $content, $template, &$repeat)
|
||||
break;
|
||||
|
||||
default:
|
||||
trigger_error("textformat: unknown attribute '$_key'");
|
||||
trigger_error("textformat: unknown attribute '{$_key}'");
|
||||
}
|
||||
}
|
||||
|
||||
if ($style == 'email') {
|
||||
if ($style === 'email') {
|
||||
$wrap = 72;
|
||||
}
|
||||
// split into paragraphs
|
||||
|
||||
@@ -63,7 +63,7 @@ function smarty_function_counter($params, $template)
|
||||
$counter[ 'direction' ] = $params[ 'direction' ];
|
||||
}
|
||||
|
||||
if ($counter[ 'direction' ] == "down") {
|
||||
if ($counter[ 'direction' ] === 'down') {
|
||||
$counter[ 'count' ] -= $counter[ 'skip' ];
|
||||
} else {
|
||||
$counter[ 'count' ] += $counter[ 'skip' ];
|
||||
|
||||
@@ -55,12 +55,12 @@ function smarty_function_cycle($params, $template)
|
||||
|
||||
if (!isset($params[ 'values' ])) {
|
||||
if (!isset($cycle_vars[ $name ][ 'values' ])) {
|
||||
trigger_error("cycle: missing 'values' parameter");
|
||||
trigger_error('cycle: missing \'values\' parameter');
|
||||
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
if (isset($cycle_vars[ $name ][ 'values' ]) && $cycle_vars[ $name ][ 'values' ] != $params[ 'values' ]) {
|
||||
if (isset($cycle_vars[ $name ][ 'values' ]) && $cycle_vars[ $name ][ 'values' ] !== $params[ 'values' ]) {
|
||||
$cycle_vars[ $name ][ 'index' ] = 0;
|
||||
}
|
||||
$cycle_vars[ $name ][ 'values' ] = $params[ 'values' ];
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
function smarty_function_fetch($params, $template)
|
||||
{
|
||||
if (empty($params[ 'file' ])) {
|
||||
trigger_error("[plugin] fetch parameter 'file' cannot be empty", E_USER_NOTICE);
|
||||
trigger_error('[plugin] fetch parameter \'file\' cannot be empty', E_USER_NOTICE);
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -55,15 +55,15 @@ function smarty_function_fetch($params, $template)
|
||||
}
|
||||
|
||||
$content = '';
|
||||
if ($protocol == 'http') {
|
||||
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 = "";
|
||||
$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;
|
||||
@@ -81,29 +81,29 @@ function smarty_function_fetch($params, $template)
|
||||
// loop through parameters, setup headers
|
||||
foreach ($params as $param_key => $param_value) {
|
||||
switch ($param_key) {
|
||||
case "file":
|
||||
case "assign":
|
||||
case "assign_headers":
|
||||
case 'file':
|
||||
case 'assign':
|
||||
case 'assign_headers':
|
||||
break;
|
||||
case "user":
|
||||
case 'user':
|
||||
if (!empty($param_value)) {
|
||||
$user = $param_value;
|
||||
}
|
||||
break;
|
||||
case "pass":
|
||||
case 'pass':
|
||||
if (!empty($param_value)) {
|
||||
$pass = $param_value;
|
||||
}
|
||||
break;
|
||||
case "accept":
|
||||
case 'accept':
|
||||
if (!empty($param_value)) {
|
||||
$accept = $param_value;
|
||||
}
|
||||
break;
|
||||
case "header":
|
||||
case 'header':
|
||||
if (!empty($param_value)) {
|
||||
if (!preg_match('![\w\d-]+: .+!', $param_value)) {
|
||||
trigger_error("[plugin] invalid header format '" . $param_value . "'", E_USER_NOTICE);
|
||||
trigger_error("[plugin] invalid header format '{$param_value}'", E_USER_NOTICE);
|
||||
|
||||
return;
|
||||
} else {
|
||||
@@ -111,41 +111,41 @@ function smarty_function_fetch($params, $template)
|
||||
}
|
||||
}
|
||||
break;
|
||||
case "proxy_host":
|
||||
case 'proxy_host':
|
||||
if (!empty($param_value)) {
|
||||
$proxy_host = $param_value;
|
||||
}
|
||||
break;
|
||||
case "proxy_port":
|
||||
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);
|
||||
trigger_error("[plugin] invalid value for attribute '{$param_key }'", E_USER_NOTICE);
|
||||
|
||||
return;
|
||||
}
|
||||
break;
|
||||
case "agent":
|
||||
case 'agent':
|
||||
if (!empty($param_value)) {
|
||||
$agent = $param_value;
|
||||
}
|
||||
break;
|
||||
case "referer":
|
||||
case 'referer':
|
||||
if (!empty($param_value)) {
|
||||
$referer = $param_value;
|
||||
}
|
||||
break;
|
||||
case "timeout":
|
||||
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);
|
||||
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);
|
||||
trigger_error("[plugin] unrecognized attribute '{$param_key}'", E_USER_NOTICE);
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -185,7 +185,7 @@ function smarty_function_fetch($params, $template)
|
||||
}
|
||||
}
|
||||
if (!empty($user) && !empty($pass)) {
|
||||
fputs($fp, "Authorization: BASIC " . base64_encode("$user:$pass") . "\r\n");
|
||||
fputs($fp, 'Authorization: BASIC ' . base64_encode("$user:$pass") . "\r\n");
|
||||
}
|
||||
|
||||
fputs($fp, "\r\n");
|
||||
|
||||
@@ -90,11 +90,11 @@ function smarty_function_html_checkboxes($params, $template)
|
||||
$selected = array();
|
||||
foreach ($_val as $_sel) {
|
||||
if (is_object($_sel)) {
|
||||
if (method_exists($_sel, "__toString")) {
|
||||
if (method_exists($_sel, '__toString')) {
|
||||
$_sel = smarty_function_escape_special_chars((string) $_sel->__toString());
|
||||
} else {
|
||||
trigger_error("html_checkboxes: selected attribute contains an object of class '" .
|
||||
get_class($_sel) . "' without __toString() method", E_USER_NOTICE);
|
||||
trigger_error('html_checkboxes: selected attribute contains an object of class \'' .
|
||||
get_class($_sel) . '\' without __toString() method', E_USER_NOTICE);
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
@@ -103,11 +103,11 @@ function smarty_function_html_checkboxes($params, $template)
|
||||
$selected[ $_sel ] = true;
|
||||
}
|
||||
} elseif (is_object($_val)) {
|
||||
if (method_exists($_val, "__toString")) {
|
||||
if (method_exists($_val, '__toString')) {
|
||||
$selected = smarty_function_escape_special_chars((string) $_val->__toString());
|
||||
} else {
|
||||
trigger_error("html_checkboxes: selected attribute is an object of class '" . get_class($_val) .
|
||||
"' without __toString() method", E_USER_NOTICE);
|
||||
trigger_error('html_checkboxes: selected attribute is an object of class \'' . get_class($_val) .
|
||||
'\' without __toString() method', E_USER_NOTICE);
|
||||
}
|
||||
} else {
|
||||
$selected = smarty_function_escape_special_chars((string) $_val);
|
||||
@@ -130,7 +130,7 @@ function smarty_function_html_checkboxes($params, $template)
|
||||
case 'readonly':
|
||||
if (!empty($params[ 'strict' ])) {
|
||||
if (!is_scalar($_val)) {
|
||||
trigger_error("html_options: $_key attribute must be a scalar, only boolean true or string '$_key' will actually add the attribute",
|
||||
trigger_error("html_options: {$_key} attribute must be a scalar, only boolean true or string '{$_key}' will actually add the attribute",
|
||||
E_USER_NOTICE);
|
||||
}
|
||||
|
||||
@@ -146,7 +146,7 @@ function smarty_function_html_checkboxes($params, $template)
|
||||
if (!is_array($_val)) {
|
||||
$extra .= ' ' . $_key . '="' . smarty_function_escape_special_chars($_val) . '"';
|
||||
} else {
|
||||
trigger_error("html_checkboxes: extra attribute '$_key' cannot be an array", E_USER_NOTICE);
|
||||
trigger_error("html_checkboxes: extra attribute '{$_key}' cannot be an array", E_USER_NOTICE);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -198,11 +198,11 @@ function smarty_function_html_checkboxes_output($name, $value, $output, $selecte
|
||||
$_output = '';
|
||||
|
||||
if (is_object($value)) {
|
||||
if (method_exists($value, "__toString")) {
|
||||
if (method_exists($value, '__toString')) {
|
||||
$value = (string) $value->__toString();
|
||||
} else {
|
||||
trigger_error("html_options: value is an object of class '" . get_class($value) .
|
||||
"' without __toString() method", E_USER_NOTICE);
|
||||
trigger_error('html_options: value is an object of class \'' . get_class($value) .
|
||||
'\' without __toString() method', E_USER_NOTICE);
|
||||
|
||||
return '';
|
||||
}
|
||||
@@ -211,11 +211,11 @@ function smarty_function_html_checkboxes_output($name, $value, $output, $selecte
|
||||
}
|
||||
|
||||
if (is_object($output)) {
|
||||
if (method_exists($output, "__toString")) {
|
||||
if (method_exists($output, '__toString')) {
|
||||
$output = (string) $output->__toString();
|
||||
} else {
|
||||
trigger_error("html_options: output is an object of class '" . get_class($output) .
|
||||
"' without __toString() method", E_USER_NOTICE);
|
||||
trigger_error('html_options: output is an object of class \'' . get_class($output) .
|
||||
'\' without __toString() method', E_USER_NOTICE);
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
@@ -67,7 +67,7 @@ function smarty_function_html_image($params, $template)
|
||||
if (!is_array($_val)) {
|
||||
$$_key = smarty_function_escape_special_chars($_val);
|
||||
} else {
|
||||
throw new SmartyException ("html_image: extra attribute '$_key' cannot be an array", E_USER_NOTICE);
|
||||
throw new SmartyException ("html_image: extra attribute '{$_key}' cannot be an array", E_USER_NOTICE);
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -81,19 +81,19 @@ function smarty_function_html_image($params, $template)
|
||||
if (!is_array($_val)) {
|
||||
$extra .= ' ' . $_key . '="' . smarty_function_escape_special_chars($_val) . '"';
|
||||
} else {
|
||||
throw new SmartyException ("html_image: extra attribute '$_key' cannot be an array", E_USER_NOTICE);
|
||||
throw new SmartyException ("html_image: extra attribute '{$_key}' cannot be an array", E_USER_NOTICE);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($file)) {
|
||||
trigger_error("html_image: missing 'file' parameter", E_USER_NOTICE);
|
||||
trigger_error('html_image: missing \'file\' parameter', E_USER_NOTICE);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if ($file[ 0 ] == '/') {
|
||||
if ($file[ 0 ] === '/') {
|
||||
$_image_path = $basedir . $file;
|
||||
} else {
|
||||
$_image_path = $file;
|
||||
@@ -127,15 +127,15 @@ function smarty_function_html_image($params, $template)
|
||||
// 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);
|
||||
trigger_error("html_image: unable to find '{$_image_path}'", E_USER_NOTICE);
|
||||
|
||||
return;
|
||||
} elseif (!is_readable($_image_path)) {
|
||||
trigger_error("html_image: unable to read '$_image_path'", E_USER_NOTICE);
|
||||
trigger_error("html_image: unable to read '{$_image_path}'", E_USER_NOTICE);
|
||||
|
||||
return;
|
||||
} else {
|
||||
trigger_error("html_image: '$_image_path' is not a valid image file", E_USER_NOTICE);
|
||||
trigger_error("html_image: '{$_image_path}' is not a valid image file", E_USER_NOTICE);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -74,11 +74,11 @@ function smarty_function_html_options($params, Smarty_Internal_Template $templat
|
||||
$selected = array();
|
||||
foreach ($_val as $_sel) {
|
||||
if (is_object($_sel)) {
|
||||
if (method_exists($_sel, "__toString")) {
|
||||
if (method_exists($_sel, '__toString')) {
|
||||
$_sel = smarty_function_escape_special_chars((string) $_sel->__toString());
|
||||
} else {
|
||||
trigger_error("html_options: selected attribute contains an object of class '" .
|
||||
get_class($_sel) . "' without __toString() method", E_USER_NOTICE);
|
||||
trigger_error('html_options: selected attribute contains an object of class \'' .
|
||||
get_class($_sel) . '\' without __toString() method', E_USER_NOTICE);
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
@@ -87,11 +87,11 @@ function smarty_function_html_options($params, Smarty_Internal_Template $templat
|
||||
$selected[ $_sel ] = true;
|
||||
}
|
||||
} elseif (is_object($_val)) {
|
||||
if (method_exists($_val, "__toString")) {
|
||||
if (method_exists($_val, '__toString')) {
|
||||
$selected = smarty_function_escape_special_chars((string) $_val->__toString());
|
||||
} else {
|
||||
trigger_error("html_options: selected attribute is an object of class '" . get_class($_val) .
|
||||
"' without __toString() method", E_USER_NOTICE);
|
||||
trigger_error('html_options: selected attribute is an object of class \'' . get_class($_val) .
|
||||
'\' without __toString() method', E_USER_NOTICE);
|
||||
}
|
||||
} else {
|
||||
$selected = smarty_function_escape_special_chars((string) $_val);
|
||||
@@ -105,7 +105,7 @@ function smarty_function_html_options($params, Smarty_Internal_Template $templat
|
||||
case 'readonly':
|
||||
if (!empty($params[ 'strict' ])) {
|
||||
if (!is_scalar($_val)) {
|
||||
trigger_error("html_options: $_key attribute must be a scalar, only boolean true or string '$_key' will actually add the attribute",
|
||||
trigger_error("html_options: {$_key} attribute must be a scalar, only boolean true or string '{$_key}' will actually add the attribute",
|
||||
E_USER_NOTICE);
|
||||
}
|
||||
|
||||
@@ -121,7 +121,7 @@ function smarty_function_html_options($params, Smarty_Internal_Template $templat
|
||||
if (!is_array($_val)) {
|
||||
$extra .= ' ' . $_key . '="' . smarty_function_escape_special_chars($_val) . '"';
|
||||
} else {
|
||||
trigger_error("html_options: extra attribute '$_key' cannot be an array", E_USER_NOTICE);
|
||||
trigger_error("html_options: extra attribute '{$_key}' cannot be an array", E_USER_NOTICE);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -182,11 +182,11 @@ function smarty_function_html_options_optoutput($key, $value, $selected, $id, $c
|
||||
$_html_class = !empty($class) ? ' class="' . $class . ' option"' : '';
|
||||
$_html_id = !empty($id) ? ' id="' . $id . '-' . $idx . '"' : '';
|
||||
if (is_object($value)) {
|
||||
if (method_exists($value, "__toString")) {
|
||||
if (method_exists($value, '__toString')) {
|
||||
$value = smarty_function_escape_special_chars((string) $value->__toString());
|
||||
} else {
|
||||
trigger_error("html_options: value is an object of class '" . get_class($value) .
|
||||
"' without __toString() method", E_USER_NOTICE);
|
||||
trigger_error('html_options: value is an object of class \'' . get_class($value) .
|
||||
'\' without __toString() method', E_USER_NOTICE);
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
@@ -73,11 +73,11 @@ function smarty_function_html_radios($params, $template)
|
||||
if (is_array($_val)) {
|
||||
trigger_error('html_radios: the "' . $_key . '" attribute cannot be an array', E_USER_WARNING);
|
||||
} elseif (is_object($_val)) {
|
||||
if (method_exists($_val, "__toString")) {
|
||||
if (method_exists($_val, '__toString')) {
|
||||
$selected = smarty_function_escape_special_chars((string) $_val->__toString());
|
||||
} else {
|
||||
trigger_error("html_radios: selected attribute is an object of class '" . get_class($_val) .
|
||||
"' without __toString() method", E_USER_NOTICE);
|
||||
trigger_error('html_radios: selected attribute is an object of class \'' . get_class($_val) .
|
||||
'\' without __toString() method', E_USER_NOTICE);
|
||||
}
|
||||
} else {
|
||||
$selected = (string) $_val;
|
||||
@@ -115,7 +115,7 @@ function smarty_function_html_radios($params, $template)
|
||||
case 'readonly':
|
||||
if (!empty($params[ 'strict' ])) {
|
||||
if (!is_scalar($_val)) {
|
||||
trigger_error("html_options: $_key attribute must be a scalar, only boolean true or string '$_key' will actually add the attribute",
|
||||
trigger_error("html_options: {$_key} attribute must be a scalar, only boolean true or string '$_key' will actually add the attribute",
|
||||
E_USER_NOTICE);
|
||||
}
|
||||
|
||||
@@ -131,7 +131,7 @@ function smarty_function_html_radios($params, $template)
|
||||
if (!is_array($_val)) {
|
||||
$extra .= ' ' . $_key . '="' . smarty_function_escape_special_chars($_val) . '"';
|
||||
} else {
|
||||
trigger_error("html_radios: extra attribute '$_key' cannot be an array", E_USER_NOTICE);
|
||||
trigger_error("html_radios: extra attribute '{$_key}' cannot be an array", E_USER_NOTICE);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -185,11 +185,11 @@ function smarty_function_html_radios_output($name, $value, $output, $selected, $
|
||||
$_output = '';
|
||||
|
||||
if (is_object($value)) {
|
||||
if (method_exists($value, "__toString")) {
|
||||
if (method_exists($value, '__toString')) {
|
||||
$value = (string) $value->__toString();
|
||||
} else {
|
||||
trigger_error("html_options: value is an object of class '" . get_class($value) .
|
||||
"' without __toString() method", E_USER_NOTICE);
|
||||
trigger_error('html_options: value is an object of class \'' . get_class($value) .
|
||||
'\' without __toString() method', E_USER_NOTICE);
|
||||
|
||||
return '';
|
||||
}
|
||||
@@ -198,11 +198,11 @@ function smarty_function_html_radios_output($name, $value, $output, $selected, $
|
||||
}
|
||||
|
||||
if (is_object($output)) {
|
||||
if (method_exists($output, "__toString")) {
|
||||
if (method_exists($output, '__toString')) {
|
||||
$output = (string) $output->__toString();
|
||||
} else {
|
||||
trigger_error("html_options: output is an object of class '" . get_class($output) .
|
||||
"' without __toString() method", E_USER_NOTICE);
|
||||
trigger_error('html_options: output is an object of class \'' . get_class($output) .
|
||||
'\' without __toString() method', E_USER_NOTICE);
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
@@ -65,18 +65,18 @@ function smarty_function_html_select_date($params, Smarty_Internal_Template $tem
|
||||
}
|
||||
|
||||
/* Default values. */
|
||||
$prefix = "Date_";
|
||||
$prefix = 'Date_';
|
||||
$start_year = null;
|
||||
$end_year = null;
|
||||
$display_days = true;
|
||||
$display_months = true;
|
||||
$display_years = true;
|
||||
$month_format = "%B";
|
||||
$month_format = '%B';
|
||||
/* Write months as numbers by default GL */
|
||||
$month_value_format = "%m";
|
||||
$day_format = "%02d";
|
||||
$month_value_format = '%m';
|
||||
$day_format = '%02d';
|
||||
/* Write day values using this format MB */
|
||||
$day_value_format = "%d";
|
||||
$day_value_format = '%d';
|
||||
$year_as_text = false;
|
||||
/* Display years in reverse order? Ie. 2000,1999,.... */
|
||||
$reverse_years = false;
|
||||
@@ -122,10 +122,10 @@ function smarty_function_html_select_date($params, Smarty_Internal_Template $tem
|
||||
break;
|
||||
|
||||
case 'month_names':
|
||||
if (is_array($_value) && count($_value) == 12) {
|
||||
if (is_array($_value) && count($_value) === 12) {
|
||||
$$_key = $_value;
|
||||
} else {
|
||||
trigger_error("html_select_date: month_names must be an array of 12 strings", E_USER_NOTICE);
|
||||
trigger_error('html_select_date: month_names must be an array of 12 strings', E_USER_NOTICE);
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -170,7 +170,7 @@ function smarty_function_html_select_date($params, Smarty_Internal_Template $tem
|
||||
if (!is_array($_value)) {
|
||||
$extra_attrs .= ' ' . $_key . '="' . smarty_function_escape_special_chars($_value) . '"';
|
||||
} else {
|
||||
trigger_error("html_select_date: extra attribute '$_key' cannot be an array", E_USER_NOTICE);
|
||||
trigger_error("html_select_date: extra attribute '{$_key}' cannot be an array", E_USER_NOTICE);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -220,9 +220,9 @@ function smarty_function_html_select_date($params, Smarty_Internal_Template $tem
|
||||
$t = $$key;
|
||||
if ($t === null) {
|
||||
$$key = (int) $_current_year;
|
||||
} elseif ($t[ 0 ] == '+') {
|
||||
} elseif ($t[ 0 ] === '+') {
|
||||
$$key = (int) ($_current_year + (int) trim(substr($t, 1)));
|
||||
} elseif ($t[ 0 ] == '-') {
|
||||
} elseif ($t[ 0 ] === '-') {
|
||||
$$key = (int) ($_current_year - (int) trim(substr($t, 1)));
|
||||
} else {
|
||||
$$key = (int) $$key;
|
||||
@@ -310,8 +310,8 @@ function smarty_function_html_select_date($params, Smarty_Internal_Template $tem
|
||||
for ($i = 1; $i <= 12; $i ++) {
|
||||
$_val = sprintf('%02d', $i);
|
||||
$_text = isset($month_names) ? smarty_function_escape_special_chars($month_names[ $i ]) :
|
||||
($month_format == "%m" ? $_val : strftime($month_format, $_month_timestamps[ $i ]));
|
||||
$_value = $month_value_format == "%m" ? $_val : strftime($month_value_format, $_month_timestamps[ $i ]);
|
||||
($month_format === '%m' ? $_val : strftime($month_format, $_month_timestamps[ $i ]));
|
||||
$_value = $month_value_format === '%m' ? $_val : strftime($month_value_format, $_month_timestamps[ $i ]);
|
||||
$_html_months .= '<option value="' . $_value . '"' . ($_val == $_month ? ' selected="selected"' : '') .
|
||||
'>' . $_text . '</option>' . $option_separator;
|
||||
}
|
||||
@@ -348,8 +348,8 @@ function smarty_function_html_select_date($params, Smarty_Internal_Template $tem
|
||||
|
||||
for ($i = 1; $i <= 31; $i ++) {
|
||||
$_val = sprintf('%02d', $i);
|
||||
$_text = $day_format == '%02d' ? $_val : sprintf($day_format, $i);
|
||||
$_value = $day_value_format == '%02d' ? $_val : sprintf($day_value_format, $i);
|
||||
$_text = $day_format === '%02d' ? $_val : sprintf($day_format, $i);
|
||||
$_value = $day_value_format === '%02d' ? $_val : sprintf($day_value_format, $i);
|
||||
$_html_days .= '<option value="' . $_value . '"' . ($_val == $_day ? ' selected="selected"' : '') . '>' .
|
||||
$_text . '</option>' . $option_separator;
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ function smarty_function_html_select_time($params, Smarty_Internal_Template $tem
|
||||
require_once(SMARTY_PLUGINS_DIR . 'shared.make_timestamp.php');
|
||||
$template->smarty->_cache[ '_required_smt' ] = true;
|
||||
}
|
||||
$prefix = "Time_";
|
||||
$prefix = 'Time_';
|
||||
$field_array = null;
|
||||
$field_separator = "\n";
|
||||
$option_separator = "\n";
|
||||
@@ -143,7 +143,7 @@ function smarty_function_html_select_time($params, Smarty_Internal_Template $tem
|
||||
if (!is_array($_value)) {
|
||||
$extra_attrs .= ' ' . $_key . '="' . smarty_function_escape_special_chars($_value) . '"';
|
||||
} else {
|
||||
trigger_error("html_select_date: extra attribute '$_key' cannot be an array", E_USER_NOTICE);
|
||||
trigger_error("html_select_date: extra attribute '{$_key}' cannot be an array", E_USER_NOTICE);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -224,8 +224,8 @@ function smarty_function_html_select_time($params, Smarty_Internal_Template $tem
|
||||
$end = $use_24_hours ? 23 : 12;
|
||||
for ($i = $start; $i <= $end; $i ++) {
|
||||
$_val = sprintf('%02d', $i);
|
||||
$_text = $hour_format == '%02d' ? $_val : sprintf($hour_format, $i);
|
||||
$_value = $hour_value_format == '%02d' ? $_val : sprintf($hour_value_format, $i);
|
||||
$_text = $hour_format === '%02d' ? $_val : sprintf($hour_format, $i);
|
||||
$_value = $hour_value_format === '%02d' ? $_val : sprintf($hour_value_format, $i);
|
||||
|
||||
if (!$use_24_hours) {
|
||||
$_hour12 = $_hour == 0 ? 12 : ($_hour <= 12 ? $_hour : $_hour - 12);
|
||||
@@ -271,8 +271,8 @@ function smarty_function_html_select_time($params, Smarty_Internal_Template $tem
|
||||
$selected = $_minute !== null ? ($_minute - $_minute % $minute_interval) : null;
|
||||
for ($i = 0; $i <= 59; $i += $minute_interval) {
|
||||
$_val = sprintf('%02d', $i);
|
||||
$_text = $minute_format == '%02d' ? $_val : sprintf($minute_format, $i);
|
||||
$_value = $minute_value_format == '%02d' ? $_val : sprintf($minute_value_format, $i);
|
||||
$_text = $minute_format === '%02d' ? $_val : sprintf($minute_format, $i);
|
||||
$_value = $minute_value_format === '%02d' ? $_val : sprintf($minute_value_format, $i);
|
||||
$_html_minutes .= '<option value="' . $_value . '"' . ($selected === $i ? ' selected="selected"' : '') .
|
||||
'>' . $_text . '</option>' . $option_separator;
|
||||
}
|
||||
@@ -312,8 +312,8 @@ function smarty_function_html_select_time($params, Smarty_Internal_Template $tem
|
||||
$selected = $_second !== null ? ($_second - $_second % $second_interval) : null;
|
||||
for ($i = 0; $i <= 59; $i += $second_interval) {
|
||||
$_val = sprintf('%02d', $i);
|
||||
$_text = $second_format == '%02d' ? $_val : sprintf($second_format, $i);
|
||||
$_value = $second_value_format == '%02d' ? $_val : sprintf($second_value_format, $i);
|
||||
$_text = $second_format === '%02d' ? $_val : sprintf($second_format, $i);
|
||||
$_value = $second_value_format === '%02d' ? $_val : sprintf($second_value_format, $i);
|
||||
$_html_seconds .= '<option value="' . $_value . '"' . ($selected === $i ? ' selected="selected"' : '') .
|
||||
'>' . $_text . '</option>' . $option_separator;
|
||||
}
|
||||
|
||||
@@ -127,7 +127,7 @@ function smarty_function_html_table($params)
|
||||
}
|
||||
|
||||
if (is_array($cols)) {
|
||||
$cols = ($hdir == 'right') ? $cols : array_reverse($cols);
|
||||
$cols = ($hdir === 'right') ? $cols : array_reverse($cols);
|
||||
$output .= "<thead><tr>\n";
|
||||
|
||||
for ($r = 0; $r < $cols_count; $r ++) {
|
||||
@@ -141,11 +141,11 @@ function smarty_function_html_table($params)
|
||||
$output .= "<tbody>\n";
|
||||
for ($r = 0; $r < $rows; $r ++) {
|
||||
$output .= "<tr" . smarty_function_html_table_cycle('tr', $tr_attr, $r) . ">\n";
|
||||
$rx = ($vdir == 'down') ? $r * $cols_count : ($rows - 1 - $r) * $cols_count;
|
||||
$rx = ($vdir === 'down') ? $r * $cols_count : ($rows - 1 - $r) * $cols_count;
|
||||
|
||||
for ($c = 0; $c < $cols_count; $c ++) {
|
||||
$x = ($hdir == 'right') ? $rx + $c : $rx + $cols_count - 1 - $c;
|
||||
if ($inner != 'cols') {
|
||||
$x = ($hdir === 'right') ? $rx + $c : $rx + $cols_count - 1 - $c;
|
||||
if ($inner !== 'cols') {
|
||||
/* shuffle x to loop over rows*/
|
||||
$x = floor($x / $cols_count) + ($x % $cols_count) * $rows;
|
||||
}
|
||||
|
||||
@@ -103,7 +103,7 @@ function smarty_function_mailto($params)
|
||||
return;
|
||||
}
|
||||
// FIXME: (rodneyrehm) document.write() excues me what? 1998 has passed!
|
||||
if ($encode == 'javascript') {
|
||||
if ($encode === 'javascript') {
|
||||
$string = 'document.write(\'<a href="mailto:' . $address . '" ' . $extra . '>' . $text . '</a>\');';
|
||||
|
||||
$js_encode = '';
|
||||
@@ -112,7 +112,7 @@ function smarty_function_mailto($params)
|
||||
}
|
||||
|
||||
return '<script type="text/javascript">eval(unescape(\'' . $js_encode . '\'))</script>';
|
||||
} elseif ($encode == 'javascript_charcode') {
|
||||
} elseif ($encode === 'javascript_charcode') {
|
||||
$string = '<a href="mailto:' . $address . '" ' . $extra . '>' . $text . '</a>';
|
||||
|
||||
for ($x = 0, $y = strlen($string); $x < $y; $x ++) {
|
||||
@@ -123,7 +123,7 @@ function smarty_function_mailto($params)
|
||||
implode(',', $ord) . "))" . "}\n" . "</script>\n";
|
||||
|
||||
return $_ret;
|
||||
} elseif ($encode == 'hex') {
|
||||
} elseif ($encode === 'hex') {
|
||||
preg_match('!^(.*)(\?.*)$!', $address, $match);
|
||||
if (!empty($match[ 2 ])) {
|
||||
trigger_error("mailto: hex encoding does not work with extra attributes. Try javascript.", E_USER_WARNING);
|
||||
|
||||
@@ -38,7 +38,7 @@ function smarty_function_math($params, $template)
|
||||
$equation = $params[ 'equation' ];
|
||||
|
||||
// make sure parenthesis are balanced
|
||||
if (substr_count($equation, "(") != substr_count($equation, ")")) {
|
||||
if (substr_count($equation, '(') !== substr_count($equation, ')')) {
|
||||
trigger_error("math: unbalanced parenthesis", E_USER_WARNING);
|
||||
|
||||
return;
|
||||
@@ -59,9 +59,9 @@ function smarty_function_math($params, $template)
|
||||
}
|
||||
|
||||
foreach ($params as $key => $val) {
|
||||
if ($key != "equation" && $key != "format" && $key != "assign") {
|
||||
if ($key !== 'equation' && $key !== 'format' && $key !== 'assign') {
|
||||
// make sure value is not empty
|
||||
if (strlen($val) == 0) {
|
||||
if (strlen($val) === 0) {
|
||||
trigger_error("math: parameter '{$key}' is empty", E_USER_WARNING);
|
||||
|
||||
return;
|
||||
@@ -86,7 +86,7 @@ function smarty_function_math($params, $template)
|
||||
}
|
||||
|
||||
foreach ($params as $key => $val) {
|
||||
if ($key != "equation" && $key != "format" && $key != "assign") {
|
||||
if ($key !== 'equation' && $key !== 'format' && $key !== 'assign') {
|
||||
$equation = preg_replace("/\b$key\b/", " \$params['$key'] ", $equation);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -72,7 +72,7 @@ function smarty_modifier_capitalize($string, $uc_digits = false, $lc_rest = fals
|
||||
return $upper_string;
|
||||
}
|
||||
|
||||
/*
|
||||
/*
|
||||
*
|
||||
* Bug: create_function() use exhausts memory when used in long loops
|
||||
* Fix: use declared functions for callbacks instead of using create_function()
|
||||
|
||||
@@ -42,14 +42,14 @@ function smarty_modifier_date_format($string, $format = null, $default_date = ''
|
||||
}
|
||||
$is_loaded = true;
|
||||
}
|
||||
if ($string != '' && $string != '0000-00-00' && $string != '0000-00-00 00:00:00') {
|
||||
if ($string !== '' && $string !== '0000-00-00' && $string !== '0000-00-00 00:00:00') {
|
||||
$timestamp = smarty_make_timestamp($string);
|
||||
} elseif ($default_date != '') {
|
||||
} elseif ($default_date !== '') {
|
||||
$timestamp = smarty_make_timestamp($default_date);
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
if ($formatter == 'strftime' || ($formatter == 'auto' && strpos($format, '%') !== false)) {
|
||||
if ($formatter === 'strftime' || ($formatter === 'auto' && strpos($format, '%') !== false)) {
|
||||
if (Smarty::$_IS_WINDOWS) {
|
||||
$_win_from = array('%D',
|
||||
'%h',
|
||||
|
||||
@@ -28,7 +28,7 @@ function smarty_modifier_debug_print_var($var, $max = 10, $length = 40, $depth =
|
||||
switch (gettype($var)) {
|
||||
case 'array' :
|
||||
$results = '<b>Array (' . count($var) . ')</b>';
|
||||
if ($depth == $max) {
|
||||
if ($depth === $max) {
|
||||
break;
|
||||
}
|
||||
foreach ($var as $curr_key => $curr_val) {
|
||||
@@ -46,7 +46,7 @@ function smarty_modifier_debug_print_var($var, $max = 10, $length = 40, $depth =
|
||||
$results .= ' called recursive';
|
||||
break;
|
||||
}
|
||||
if ($depth == $max) {
|
||||
if ($depth === $max) {
|
||||
break;
|
||||
}
|
||||
$objects[] = $var;
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
*/
|
||||
function smarty_modifier_truncate($string, $length = 80, $etc = '...', $break_words = false, $middle = false)
|
||||
{
|
||||
if ($length == 0) {
|
||||
if ($length === 0) {
|
||||
return '';
|
||||
}
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
*/
|
||||
function smarty_modifiercompiler_count_characters($params)
|
||||
{
|
||||
if (!isset($params[ 1 ]) || $params[ 1 ] != 'true') {
|
||||
if (!isset($params[ 1 ]) || $params[ 1 ] !== 'true') {
|
||||
return 'preg_match_all(\'/[^\s]/' . Smarty::$_UTF8_MODIFIER . '\',' . $params[ 0 ] . ', $tmp)';
|
||||
}
|
||||
if (Smarty::$_MBSTRING) {
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
*/
|
||||
function smarty_modifiercompiler_strip_tags($params)
|
||||
{
|
||||
if (!isset($params[ 1 ]) || $params[ 1 ] === true || trim($params[ 1 ], '"') == 'true') {
|
||||
if (!isset($params[ 1 ]) || $params[ 1 ] === true || trim($params[ 1 ], '"') === 'true') {
|
||||
return "preg_replace('!<[^>]*?>!', ' ', {$params[0]})";
|
||||
} else {
|
||||
return 'strip_tags(' . $params[ 0 ] . ')';
|
||||
|
||||
@@ -26,7 +26,7 @@ function smarty_modifiercompiler_unescape($params)
|
||||
if (!isset($params[ 2 ])) {
|
||||
$params[ 2 ] = '\'' . addslashes(Smarty::$_CHARSET) . '\'';
|
||||
} else {
|
||||
$params[ 2 ] = "'" . $params[ 2 ] . "'";
|
||||
$params[ 2 ] = "'{$params[ 2 ]}'";
|
||||
}
|
||||
|
||||
switch (trim($params[ 1 ], '"\'')) {
|
||||
|
||||
@@ -24,7 +24,7 @@ function smarty_outputfilter_trimwhitespace($source)
|
||||
$_offset = 0;
|
||||
|
||||
// Unify Line-Breaks to \n
|
||||
$source = preg_replace("/\015\012|\015|\012/", "\n", $source);
|
||||
$source = preg_replace('/\015\012|\015|\012/', "\n", $source);
|
||||
|
||||
// capture Internet Explorer and KnockoutJS Conditional Comments
|
||||
if (preg_match_all('#<!--((\[[^\]]+\]>.*?<!\[[^\]]+\])|(\s*/?ko\s+.+))-->#is', $source, $matches,
|
||||
|
||||
@@ -25,7 +25,7 @@ function smarty_make_timestamp($string)
|
||||
(interface_exists('DateTimeInterface', false) && $string instanceof DateTimeInterface)
|
||||
) {
|
||||
return (int) $string->format('U'); // PHP 5.2 BC
|
||||
} elseif (strlen($string) == 14 && ctype_digit($string)) {
|
||||
} elseif (strlen($string) === 14 && ctype_digit($string)) {
|
||||
// it is mysql timestamp format of YYYYMMDDHHMMSS?
|
||||
return mktime(substr($string, 8, 2), substr($string, 10, 2), substr($string, 12, 2), substr($string, 4, 2),
|
||||
substr($string, 6, 2), substr($string, 0, 4));
|
||||
@@ -35,7 +35,7 @@ function smarty_make_timestamp($string)
|
||||
} else {
|
||||
// strtotime should handle it
|
||||
$time = strtotime($string);
|
||||
if ($time == - 1 || $time === false) {
|
||||
if ($time === - 1 || $time === false) {
|
||||
// strtotime() was not able to parse $string, use "now":
|
||||
return time();
|
||||
}
|
||||
|
||||
@@ -20,12 +20,12 @@
|
||||
function smarty_mb_to_unicode($string, $encoding = null)
|
||||
{
|
||||
if ($encoding) {
|
||||
$expanded = mb_convert_encoding($string, "UTF-32BE", $encoding);
|
||||
$expanded = mb_convert_encoding($string, 'UTF-32BE', $encoding);
|
||||
} else {
|
||||
$expanded = mb_convert_encoding($string, "UTF-32BE");
|
||||
$expanded = mb_convert_encoding($string, 'UTF-32BE');
|
||||
}
|
||||
|
||||
return unpack("N*", $expanded);
|
||||
return unpack('N*', $expanded);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -46,8 +46,8 @@ function smarty_mb_from_unicode($unicode, $encoding = null)
|
||||
$encoding = mb_internal_encoding();
|
||||
}
|
||||
foreach ((array) $unicode as $utf32be) {
|
||||
$character = pack("N*", $utf32be);
|
||||
$t .= mb_convert_encoding($character, $encoding, "UTF-32BE");
|
||||
$character = pack('N*', $utf32be);
|
||||
$t .= mb_convert_encoding($character, $encoding, 'UTF-32BE');
|
||||
}
|
||||
|
||||
return $t;
|
||||
|
||||
Reference in New Issue
Block a user