Fix linting
This commit is contained in:
parent
5b17a7dbd7
commit
1614145b18
262 changed files with 45324 additions and 42695 deletions
|
|
@ -72,32 +72,29 @@ function smarty_block_textformat($params, $content, &$smarty)
|
|||
}
|
||||
|
||||
// split into paragraphs
|
||||
$_paragraphs = preg_split('![\r\n][\r\n]!',$content);
|
||||
$_paragraphs = preg_split('![\r\n][\r\n]!', $content);
|
||||
$_output = '';
|
||||
|
||||
for($_x = 0, $_y = count($_paragraphs); $_x < $_y; $_x++) {
|
||||
for ($_x = 0, $_y = count($_paragraphs); $_x < $_y; $_x++) {
|
||||
if ($_paragraphs[$_x] == '') {
|
||||
continue;
|
||||
}
|
||||
// convert mult. spaces & special chars to single space
|
||||
$_paragraphs[$_x] = preg_replace(array('!\s+!','!(^\s+)|(\s+$)!'), array(' ',''), $_paragraphs[$_x]);
|
||||
// indent first line
|
||||
if($indent_first > 0) {
|
||||
if ($indent_first > 0) {
|
||||
$_paragraphs[$_x] = str_repeat($indent_char, $indent_first) . $_paragraphs[$_x];
|
||||
}
|
||||
// wordwrap sentences
|
||||
$_paragraphs[$_x] = wordwrap($_paragraphs[$_x], $wrap - $indent, $wrap_char, $wrap_cut);
|
||||
// indent lines
|
||||
if($indent > 0) {
|
||||
if ($indent > 0) {
|
||||
$_paragraphs[$_x] = preg_replace('!^!m', str_repeat($indent_char, $indent), $_paragraphs[$_x]);
|
||||
}
|
||||
}
|
||||
$_output = implode($wrap_char . $wrap_char, $_paragraphs);
|
||||
|
||||
return $assign ? $smarty->assign($assign, $_output) : $_output;
|
||||
|
||||
}
|
||||
|
||||
/* vim: set expandtab: */
|
||||
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -36,5 +36,3 @@ function smarty_compiler_assign($tag_attrs, &$compiler)
|
|||
}
|
||||
|
||||
/* vim: set expandtab: */
|
||||
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -36,5 +36,3 @@ function smarty_function_assign_debug_info($params, &$smarty)
|
|||
}
|
||||
|
||||
/* vim: set expandtab: */
|
||||
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -26,117 +26,117 @@
|
|||
*/
|
||||
function smarty_function_config_load($params, &$smarty)
|
||||
{
|
||||
if ($smarty->debugging) {
|
||||
$_params = array();
|
||||
require_once(SMARTY_CORE_DIR . 'core.get_microtime.php');
|
||||
$_debug_start_time = smarty_core_get_microtime($_params, $smarty);
|
||||
}
|
||||
if ($smarty->debugging) {
|
||||
$_params = array();
|
||||
require_once(SMARTY_CORE_DIR . 'core.get_microtime.php');
|
||||
$_debug_start_time = smarty_core_get_microtime($_params, $smarty);
|
||||
}
|
||||
|
||||
$_file = isset($params['file']) ? $smarty->_dequote($params['file']) : null;
|
||||
$_section = isset($params['section']) ? $smarty->_dequote($params['section']) : null;
|
||||
$_scope = isset($params['scope']) ? $smarty->_dequote($params['scope']) : 'global';
|
||||
$_global = isset($params['global']) ? $smarty->_dequote($params['global']) : false;
|
||||
$_file = isset($params['file']) ? $smarty->_dequote($params['file']) : null;
|
||||
$_section = isset($params['section']) ? $smarty->_dequote($params['section']) : null;
|
||||
$_scope = isset($params['scope']) ? $smarty->_dequote($params['scope']) : 'global';
|
||||
$_global = isset($params['global']) ? $smarty->_dequote($params['global']) : false;
|
||||
|
||||
if (!isset($_file) || strlen($_file) == 0) {
|
||||
$smarty->trigger_error("missing 'file' attribute in config_load tag", E_USER_ERROR, __FILE__, __LINE__);
|
||||
}
|
||||
if (!isset($_file) || strlen($_file) == 0) {
|
||||
$smarty->trigger_error("missing 'file' attribute in config_load tag", E_USER_ERROR, __FILE__, __LINE__);
|
||||
}
|
||||
|
||||
if (isset($_scope)) {
|
||||
if ($_scope != 'local' &&
|
||||
if (isset($_scope)) {
|
||||
if ($_scope != 'local' &&
|
||||
$_scope != 'parent' &&
|
||||
$_scope != 'global') {
|
||||
$smarty->trigger_error("invalid 'scope' attribute value", E_USER_ERROR, __FILE__, __LINE__);
|
||||
}
|
||||
$smarty->trigger_error("invalid 'scope' attribute value", E_USER_ERROR, __FILE__, __LINE__);
|
||||
}
|
||||
} else {
|
||||
if ($_global) {
|
||||
$_scope = 'parent';
|
||||
} else {
|
||||
if ($_global) {
|
||||
$_scope = 'parent';
|
||||
} else {
|
||||
$_scope = 'local';
|
||||
}
|
||||
$_scope = 'local';
|
||||
}
|
||||
}
|
||||
|
||||
$_params = array('resource_name' => $_file,
|
||||
'resource_base_path' => $smarty->config_dir,
|
||||
'get_source' => false);
|
||||
$smarty->_parse_resource_name($_params);
|
||||
$_file_path = $_params['resource_type'] . ':' . $_params['resource_name'];
|
||||
if (isset($_section)) {
|
||||
$_compile_file = $smarty->_get_compile_path($_file_path.'|'.$_section);
|
||||
} else {
|
||||
$_compile_file = $smarty->_get_compile_path($_file_path);
|
||||
}
|
||||
|
||||
if ($smarty->force_compile || !file_exists($_compile_file)) {
|
||||
$_compile = true;
|
||||
} elseif ($smarty->compile_check) {
|
||||
$_params = array('resource_name' => $_file,
|
||||
'resource_base_path' => $smarty->config_dir,
|
||||
'get_source' => false);
|
||||
$_compile = $smarty->_fetch_resource_info($_params) &&
|
||||
$_params['resource_timestamp'] > filemtime($_compile_file);
|
||||
} else {
|
||||
$_compile = false;
|
||||
}
|
||||
|
||||
if ($_compile) {
|
||||
// compile config file
|
||||
if (!is_object($smarty->_conf_obj)) {
|
||||
require_once SMARTY_DIR . $smarty->config_class . '.class.php';
|
||||
$smarty->_conf_obj = new $smarty->config_class();
|
||||
$smarty->_conf_obj->overwrite = $smarty->config_overwrite;
|
||||
$smarty->_conf_obj->booleanize = $smarty->config_booleanize;
|
||||
$smarty->_conf_obj->read_hidden = $smarty->config_read_hidden;
|
||||
$smarty->_conf_obj->fix_newlines = $smarty->config_fix_newlines;
|
||||
}
|
||||
|
||||
$_params = array('resource_name' => $_file,
|
||||
'resource_base_path' => $smarty->config_dir,
|
||||
'get_source' => false);
|
||||
$smarty->_parse_resource_name($_params);
|
||||
$_file_path = $_params['resource_type'] . ':' . $_params['resource_name'];
|
||||
if (isset($_section))
|
||||
$_compile_file = $smarty->_get_compile_path($_file_path.'|'.$_section);
|
||||
else
|
||||
$_compile_file = $smarty->_get_compile_path($_file_path);
|
||||
|
||||
if($smarty->force_compile || !file_exists($_compile_file)) {
|
||||
$_compile = true;
|
||||
} elseif ($smarty->compile_check) {
|
||||
$_params = array('resource_name' => $_file,
|
||||
'resource_base_path' => $smarty->config_dir,
|
||||
'get_source' => false);
|
||||
$_compile = $smarty->_fetch_resource_info($_params) &&
|
||||
$_params['resource_timestamp'] > filemtime($_compile_file);
|
||||
} else {
|
||||
$_compile = false;
|
||||
}
|
||||
|
||||
if($_compile) {
|
||||
// compile config file
|
||||
if(!is_object($smarty->_conf_obj)) {
|
||||
require_once SMARTY_DIR . $smarty->config_class . '.class.php';
|
||||
$smarty->_conf_obj = new $smarty->config_class();
|
||||
$smarty->_conf_obj->overwrite = $smarty->config_overwrite;
|
||||
$smarty->_conf_obj->booleanize = $smarty->config_booleanize;
|
||||
$smarty->_conf_obj->read_hidden = $smarty->config_read_hidden;
|
||||
$smarty->_conf_obj->fix_newlines = $smarty->config_fix_newlines;
|
||||
}
|
||||
|
||||
$_params = array('resource_name' => $_file,
|
||||
'resource_base_path' => $smarty->config_dir,
|
||||
$_params['get_source'] = true);
|
||||
if (!$smarty->_fetch_resource_info($_params)) {
|
||||
return;
|
||||
}
|
||||
$smarty->_conf_obj->set_file_contents($_file, $_params['source_content']);
|
||||
$_config_vars = array_merge($smarty->_conf_obj->get($_file),
|
||||
$smarty->_conf_obj->get($_file, $_section));
|
||||
if(function_exists('var_export')) {
|
||||
$_output = '<?php $_config_vars = ' . var_export($_config_vars, true) . '; ?>';
|
||||
} else {
|
||||
$_output = '<?php $_config_vars = unserialize(\'' . strtr(serialize($_config_vars),array('\''=>'\\\'', '\\'=>'\\\\')) . '\'); ?>';
|
||||
}
|
||||
$_params = (array('compile_path' => $_compile_file, 'compiled_content' => $_output, 'resource_timestamp' => $_params['resource_timestamp']));
|
||||
require_once(SMARTY_CORE_DIR . 'core.write_compiled_resource.php');
|
||||
smarty_core_write_compiled_resource($_params, $smarty);
|
||||
if (!$smarty->_fetch_resource_info($_params)) {
|
||||
return;
|
||||
}
|
||||
$smarty->_conf_obj->set_file_contents($_file, $_params['source_content']);
|
||||
$_config_vars = array_merge(
|
||||
$smarty->_conf_obj->get($_file),
|
||||
$smarty->_conf_obj->get($_file, $_section)
|
||||
);
|
||||
if (function_exists('var_export')) {
|
||||
$_output = '<?php $_config_vars = ' . var_export($_config_vars, true) . '; ?>';
|
||||
} else {
|
||||
include($_compile_file);
|
||||
$_output = '<?php $_config_vars = unserialize(\'' . strtr(serialize($_config_vars), array('\''=>'\\\'', '\\'=>'\\\\')) . '\'); ?>';
|
||||
}
|
||||
$_params = (array('compile_path' => $_compile_file, 'compiled_content' => $_output, 'resource_timestamp' => $_params['resource_timestamp']));
|
||||
require_once(SMARTY_CORE_DIR . 'core.write_compiled_resource.php');
|
||||
smarty_core_write_compiled_resource($_params, $smarty);
|
||||
} else {
|
||||
include($_compile_file);
|
||||
}
|
||||
|
||||
if ($smarty->caching) {
|
||||
$smarty->_cache_info['config'][$_file] = true;
|
||||
if ($smarty->caching) {
|
||||
$smarty->_cache_info['config'][$_file] = true;
|
||||
}
|
||||
|
||||
$smarty->_config[0]['vars'] = @array_merge($smarty->_config[0]['vars'], $_config_vars);
|
||||
$smarty->_config[0]['files'][$_file] = true;
|
||||
|
||||
if ($_scope == 'parent') {
|
||||
$smarty->_config[1]['vars'] = @array_merge($smarty->_config[1]['vars'], $_config_vars);
|
||||
$smarty->_config[1]['files'][$_file] = true;
|
||||
} elseif ($_scope == 'global') {
|
||||
for ($i = 1, $for_max = count($smarty->_config); $i < $for_max; $i++) {
|
||||
$smarty->_config[$i]['vars'] = @array_merge($smarty->_config[$i]['vars'], $_config_vars);
|
||||
$smarty->_config[$i]['files'][$_file] = true;
|
||||
}
|
||||
}
|
||||
|
||||
$smarty->_config[0]['vars'] = @array_merge($smarty->_config[0]['vars'], $_config_vars);
|
||||
$smarty->_config[0]['files'][$_file] = true;
|
||||
|
||||
if ($_scope == 'parent') {
|
||||
$smarty->_config[1]['vars'] = @array_merge($smarty->_config[1]['vars'], $_config_vars);
|
||||
$smarty->_config[1]['files'][$_file] = true;
|
||||
} else if ($_scope == 'global') {
|
||||
for ($i = 1, $for_max = count($smarty->_config); $i < $for_max; $i++) {
|
||||
$smarty->_config[$i]['vars'] = @array_merge($smarty->_config[$i]['vars'], $_config_vars);
|
||||
$smarty->_config[$i]['files'][$_file] = true;
|
||||
}
|
||||
}
|
||||
|
||||
if ($smarty->debugging) {
|
||||
$_params = array();
|
||||
require_once(SMARTY_CORE_DIR . 'core.get_microtime.php');
|
||||
$smarty->_smarty_debug_info[] = array('type' => 'config',
|
||||
if ($smarty->debugging) {
|
||||
$_params = array();
|
||||
require_once(SMARTY_CORE_DIR . 'core.get_microtime.php');
|
||||
$smarty->_smarty_debug_info[] = array('type' => 'config',
|
||||
'filename' => $_file.' ['.$_section.'] '.$_scope,
|
||||
'depth' => $smarty->_inclusion_depth,
|
||||
'exec_time' => smarty_core_get_microtime($_params, $smarty) - $_debug_start_time);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/* vim: set expandtab: */
|
||||
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -66,15 +66,13 @@ function smarty_function_counter($params, &$smarty)
|
|||
$counter['direction'] = $params['direction'];
|
||||
}
|
||||
|
||||
if ($counter['direction'] == "down")
|
||||
if ($counter['direction'] == "down") {
|
||||
$counter['count'] -= $counter['skip'];
|
||||
else
|
||||
} else {
|
||||
$counter['count'] += $counter['skip'];
|
||||
}
|
||||
|
||||
return $retval;
|
||||
|
||||
}
|
||||
|
||||
/* vim: set expandtab: */
|
||||
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -51,13 +51,13 @@ function smarty_function_cycle($params, &$smarty)
|
|||
$reset = (isset($params['reset'])) ? (bool)$params['reset'] : false;
|
||||
|
||||
if (!in_array('values', array_keys($params))) {
|
||||
if(!isset($cycle_vars[$name]['values'])) {
|
||||
if (!isset($cycle_vars[$name]['values'])) {
|
||||
$smarty->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'];
|
||||
|
|
@ -66,16 +66,16 @@ function smarty_function_cycle($params, &$smarty)
|
|||
if (isset($params['delimiter'])) {
|
||||
$cycle_vars[$name]['delimiter'] = $params['delimiter'];
|
||||
} elseif (!isset($cycle_vars[$name]['delimiter'])) {
|
||||
$cycle_vars[$name]['delimiter'] = ',';
|
||||
$cycle_vars[$name]['delimiter'] = ',';
|
||||
}
|
||||
|
||||
if(is_array($cycle_vars[$name]['values'])) {
|
||||
if (is_array($cycle_vars[$name]['values'])) {
|
||||
$cycle_array = $cycle_vars[$name]['values'];
|
||||
} else {
|
||||
$cycle_array = explode($cycle_vars[$name]['delimiter'],$cycle_vars[$name]['values']);
|
||||
$cycle_array = explode($cycle_vars[$name]['delimiter'], $cycle_vars[$name]['values']);
|
||||
}
|
||||
|
||||
if(!isset($cycle_vars[$name]['index']) || $reset ) {
|
||||
if (!isset($cycle_vars[$name]['index']) || $reset) {
|
||||
$cycle_vars[$name]['index'] = 0;
|
||||
}
|
||||
|
||||
|
|
@ -84,14 +84,14 @@ function smarty_function_cycle($params, &$smarty)
|
|||
$smarty->assign($params['assign'], $cycle_array[$cycle_vars[$name]['index']]);
|
||||
}
|
||||
|
||||
if($print) {
|
||||
if ($print) {
|
||||
$retval = $cycle_array[$cycle_vars[$name]['index']];
|
||||
} else {
|
||||
$retval = null;
|
||||
}
|
||||
|
||||
if($advance) {
|
||||
if ( $cycle_vars[$name]['index'] >= count($cycle_array) -1 ) {
|
||||
if ($advance) {
|
||||
if ($cycle_vars[$name]['index'] >= count($cycle_array) -1) {
|
||||
$cycle_vars[$name]['index'] = 0;
|
||||
} else {
|
||||
$cycle_vars[$name]['index']++;
|
||||
|
|
@ -102,5 +102,3 @@ function smarty_function_cycle($params, &$smarty)
|
|||
}
|
||||
|
||||
/* vim: set expandtab: */
|
||||
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -31,5 +31,3 @@ function smarty_function_debug($params, &$smarty)
|
|||
}
|
||||
|
||||
/* vim: set expandtab: */
|
||||
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -20,13 +20,12 @@
|
|||
*/
|
||||
function smarty_function_eval($params, &$smarty)
|
||||
{
|
||||
|
||||
if (!isset($params['var'])) {
|
||||
$smarty->trigger_error("eval: missing 'var' parameter");
|
||||
return;
|
||||
}
|
||||
|
||||
if($params['var'] == '') {
|
||||
if ($params['var'] == '') {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -45,5 +44,3 @@ function smarty_function_eval($params, &$smarty)
|
|||
}
|
||||
|
||||
/* vim: set expandtab: */
|
||||
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -31,15 +31,15 @@ function smarty_function_fetch($params, &$smarty)
|
|||
if ($smarty->security && !preg_match('!^(http|ftp)://!i', $params['file'])) {
|
||||
$_params = array('resource_type' => 'file', 'resource_name' => $params['file']);
|
||||
require_once(SMARTY_CORE_DIR . 'core.is_secure.php');
|
||||
if(!smarty_core_is_secure($_params, $smarty)) {
|
||||
if (!smarty_core_is_secure($_params, $smarty)) {
|
||||
$smarty->_trigger_fatal_error('[plugin] (secure mode) fetch \'' . $params['file'] . '\' is not allowed');
|
||||
return;
|
||||
}
|
||||
|
||||
// fetch the file
|
||||
if($fp = @fopen($params['file'],'r')) {
|
||||
while(!feof($fp)) {
|
||||
$content .= fgets ($fp,4096);
|
||||
if ($fp = @fopen($params['file'], 'r')) {
|
||||
while (!feof($fp)) {
|
||||
$content .= fgets($fp, 4096);
|
||||
}
|
||||
fclose($fp);
|
||||
} else {
|
||||
|
|
@ -48,9 +48,9 @@ function smarty_function_fetch($params, &$smarty)
|
|||
}
|
||||
} else {
|
||||
// not a local file
|
||||
if(preg_match('!^http://!i',$params['file'])) {
|
||||
if (preg_match('!^http://!i', $params['file'])) {
|
||||
// http fetch
|
||||
if($uri_parts = parse_url($params['file'])) {
|
||||
if ($uri_parts = parse_url($params['file'])) {
|
||||
// set defaults
|
||||
$host = $server_name = $uri_parts['host'];
|
||||
$timeout = 30;
|
||||
|
|
@ -60,42 +60,42 @@ function smarty_function_fetch($params, &$smarty)
|
|||
$uri = !empty($uri_parts['path']) ? $uri_parts['path'] : '/';
|
||||
$uri .= !empty($uri_parts['query']) ? '?' . $uri_parts['query'] : '';
|
||||
$_is_proxy = false;
|
||||
if(empty($uri_parts['port'])) {
|
||||
if (empty($uri_parts['port'])) {
|
||||
$port = 80;
|
||||
} else {
|
||||
$port = $uri_parts['port'];
|
||||
}
|
||||
if(!empty($uri_parts['user'])) {
|
||||
if (!empty($uri_parts['user'])) {
|
||||
$user = $uri_parts['user'];
|
||||
}
|
||||
if(!empty($uri_parts['pass'])) {
|
||||
if (!empty($uri_parts['pass'])) {
|
||||
$pass = $uri_parts['pass'];
|
||||
}
|
||||
// loop through parameters, setup headers
|
||||
foreach($params as $param_key => $param_value) {
|
||||
switch($param_key) {
|
||||
foreach ($params as $param_key => $param_value) {
|
||||
switch ($param_key) {
|
||||
case "file":
|
||||
case "assign":
|
||||
case "assign_headers":
|
||||
break;
|
||||
case "user":
|
||||
if(!empty($param_value)) {
|
||||
if (!empty($param_value)) {
|
||||
$user = $param_value;
|
||||
}
|
||||
break;
|
||||
case "pass":
|
||||
if(!empty($param_value)) {
|
||||
if (!empty($param_value)) {
|
||||
$pass = $param_value;
|
||||
}
|
||||
break;
|
||||
case "accept":
|
||||
if(!empty($param_value)) {
|
||||
if (!empty($param_value)) {
|
||||
$accept = $param_value;
|
||||
}
|
||||
break;
|
||||
case "header":
|
||||
if(!empty($param_value)) {
|
||||
if(!preg_match('![\w\d-]+: .+!',$param_value)) {
|
||||
if (!empty($param_value)) {
|
||||
if (!preg_match('![\w\d-]+: .+!', $param_value)) {
|
||||
$smarty->_trigger_fatal_error("[plugin] invalid header format '".$param_value."'");
|
||||
return;
|
||||
} else {
|
||||
|
|
@ -104,12 +104,12 @@ function smarty_function_fetch($params, &$smarty)
|
|||
}
|
||||
break;
|
||||
case "proxy_host":
|
||||
if(!empty($param_value)) {
|
||||
if (!empty($param_value)) {
|
||||
$proxy_host = $param_value;
|
||||
}
|
||||
break;
|
||||
case "proxy_port":
|
||||
if(!preg_match('!\D!', $param_value)) {
|
||||
if (!preg_match('!\D!', $param_value)) {
|
||||
$proxy_port = (int) $param_value;
|
||||
} else {
|
||||
$smarty->_trigger_fatal_error("[plugin] invalid value for attribute '".$param_key."'");
|
||||
|
|
@ -117,17 +117,17 @@ function smarty_function_fetch($params, &$smarty)
|
|||
}
|
||||
break;
|
||||
case "agent":
|
||||
if(!empty($param_value)) {
|
||||
if (!empty($param_value)) {
|
||||
$agent = $param_value;
|
||||
}
|
||||
break;
|
||||
case "referer":
|
||||
if(!empty($param_value)) {
|
||||
if (!empty($param_value)) {
|
||||
$referer = $param_value;
|
||||
}
|
||||
break;
|
||||
case "timeout":
|
||||
if(!preg_match('!\D!', $param_value)) {
|
||||
if (!preg_match('!\D!', $param_value)) {
|
||||
$timeout = (int) $param_value;
|
||||
} else {
|
||||
$smarty->_trigger_fatal_error("[plugin] invalid value for attribute '".$param_key."'");
|
||||
|
|
@ -139,54 +139,54 @@ function smarty_function_fetch($params, &$smarty)
|
|||
return;
|
||||
}
|
||||
}
|
||||
if(!empty($proxy_host) && !empty($proxy_port)) {
|
||||
if (!empty($proxy_host) && !empty($proxy_port)) {
|
||||
$_is_proxy = true;
|
||||
$fp = fsockopen($proxy_host,$proxy_port,$errno,$errstr,$timeout);
|
||||
$fp = fsockopen($proxy_host, $proxy_port, $errno, $errstr, $timeout);
|
||||
} else {
|
||||
$fp = fsockopen($server_name,$port,$errno,$errstr,$timeout);
|
||||
$fp = fsockopen($server_name, $port, $errno, $errstr, $timeout);
|
||||
}
|
||||
|
||||
if(!$fp) {
|
||||
if (!$fp) {
|
||||
$smarty->_trigger_fatal_error("[plugin] unable to fetch: $errstr ($errno)");
|
||||
return;
|
||||
} else {
|
||||
if($_is_proxy) {
|
||||
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)) {
|
||||
if (!empty($host)) {
|
||||
fputs($fp, "Host: $host\r\n");
|
||||
}
|
||||
if(!empty($accept)) {
|
||||
if (!empty($accept)) {
|
||||
fputs($fp, "Accept: $accept\r\n");
|
||||
}
|
||||
if(!empty($agent)) {
|
||||
if (!empty($agent)) {
|
||||
fputs($fp, "User-Agent: $agent\r\n");
|
||||
}
|
||||
if(!empty($referer)) {
|
||||
if (!empty($referer)) {
|
||||
fputs($fp, "Referer: $referer\r\n");
|
||||
}
|
||||
if(isset($extra_headers) && is_array($extra_headers)) {
|
||||
foreach($extra_headers as $curr_header) {
|
||||
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)) {
|
||||
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);
|
||||
while (!feof($fp)) {
|
||||
$content .= fgets($fp, 4096);
|
||||
}
|
||||
fclose($fp);
|
||||
$csplit = preg_split("!\r\n\r\n!",$content,2);
|
||||
$csplit = preg_split("!\r\n\r\n!", $content, 2);
|
||||
|
||||
$content = $csplit[1];
|
||||
|
||||
if(!empty($params['assign_headers'])) {
|
||||
$smarty->assign($params['assign_headers'],preg_split("!\r\n!",$csplit[0]));
|
||||
if (!empty($params['assign_headers'])) {
|
||||
$smarty->assign($params['assign_headers'], preg_split("!\r\n!", $csplit[0]));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
|
@ -195,9 +195,9 @@ function smarty_function_fetch($params, &$smarty)
|
|||
}
|
||||
} else {
|
||||
// ftp fetch
|
||||
if($fp = @fopen($params['file'],'r')) {
|
||||
while(!feof($fp)) {
|
||||
$content .= fgets ($fp,4096);
|
||||
if ($fp = @fopen($params['file'], 'r')) {
|
||||
while (!feof($fp)) {
|
||||
$content .= fgets($fp, 4096);
|
||||
}
|
||||
fclose($fp);
|
||||
} else {
|
||||
|
|
@ -205,17 +205,14 @@ function smarty_function_fetch($params, &$smarty)
|
|||
return;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
if (!empty($params['assign'])) {
|
||||
$smarty->assign($params['assign'],$content);
|
||||
$smarty->assign($params['assign'], $content);
|
||||
} else {
|
||||
return $content;
|
||||
}
|
||||
}
|
||||
|
||||
/* vim: set expandtab: */
|
||||
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@
|
|||
*/
|
||||
function smarty_function_html_checkboxes($params, &$smarty)
|
||||
{
|
||||
require_once $smarty->_get_plugin_filepath('shared','escape_special_chars');
|
||||
require_once $smarty->_get_plugin_filepath('shared', 'escape_special_chars');
|
||||
|
||||
$name = 'checkbox';
|
||||
$values = null;
|
||||
|
|
@ -52,8 +52,8 @@ function smarty_function_html_checkboxes($params, &$smarty)
|
|||
|
||||
$extra = '';
|
||||
|
||||
foreach($params as $_key => $_val) {
|
||||
switch($_key) {
|
||||
foreach ($params as $_key => $_val) {
|
||||
switch ($_key) {
|
||||
case 'name':
|
||||
case 'separator':
|
||||
$$_key = $_val;
|
||||
|
|
@ -86,7 +86,7 @@ function smarty_function_html_checkboxes($params, &$smarty)
|
|||
break;
|
||||
|
||||
default:
|
||||
if(!is_array($_val)) {
|
||||
if (!is_array($_val)) {
|
||||
$extra .= ' '.$_key.'="'.smarty_function_escape_special_chars($_val).'"';
|
||||
} else {
|
||||
$smarty->trigger_error("html_checkboxes: extra attribute '$_key' cannot be an array", E_USER_NOTICE);
|
||||
|
|
@ -95,37 +95,37 @@ function smarty_function_html_checkboxes($params, &$smarty)
|
|||
}
|
||||
}
|
||||
|
||||
if (!isset($options) && !isset($values))
|
||||
return ''; /* raise error here? */
|
||||
if (!isset($options) && !isset($values)) {
|
||||
return '';
|
||||
} /* raise error here? */
|
||||
|
||||
settype($selected, 'array');
|
||||
$_html_result = array();
|
||||
|
||||
if (isset($options)) {
|
||||
|
||||
foreach ($options as $_key=>$_val)
|
||||
foreach ($options as $_key=>$_val) {
|
||||
$_html_result[] = smarty_function_html_checkboxes_output($name, $_key, $_val, $selected, $extra, $separator, $labels);
|
||||
|
||||
|
||||
}
|
||||
} else {
|
||||
foreach ($values as $_i=>$_key) {
|
||||
$_val = isset($output[$_i]) ? $output[$_i] : '';
|
||||
$_html_result[] = smarty_function_html_checkboxes_output($name, $_key, $_val, $selected, $extra, $separator, $labels);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if(!empty($params['assign'])) {
|
||||
if (!empty($params['assign'])) {
|
||||
$smarty->assign($params['assign'], $_html_result);
|
||||
} else {
|
||||
return implode("\n",$_html_result);
|
||||
return implode("\n", $_html_result);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function smarty_function_html_checkboxes_output($name, $value, $output, $selected, $extra, $separator, $labels) {
|
||||
function smarty_function_html_checkboxes_output($name, $value, $output, $selected, $extra, $separator, $labels)
|
||||
{
|
||||
$_output = '';
|
||||
if ($labels) $_output .= '<label>';
|
||||
if ($labels) {
|
||||
$_output .= '<label>';
|
||||
}
|
||||
$_output .= '<input type="checkbox" name="'
|
||||
. smarty_function_escape_special_chars($name) . '[]" value="'
|
||||
. smarty_function_escape_special_chars($value) . '"';
|
||||
|
|
@ -134,10 +134,10 @@ function smarty_function_html_checkboxes_output($name, $value, $output, $selecte
|
|||
$_output .= ' checked="checked"';
|
||||
}
|
||||
$_output .= $extra . ' />' . $output;
|
||||
if ($labels) $_output .= '</label>';
|
||||
if ($labels) {
|
||||
$_output .= '</label>';
|
||||
}
|
||||
$_output .= $separator;
|
||||
|
||||
return $_output;
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@
|
|||
*/
|
||||
function smarty_function_html_image($params, &$smarty)
|
||||
{
|
||||
require_once $smarty->_get_plugin_filepath('shared','escape_special_chars');
|
||||
require_once $smarty->_get_plugin_filepath('shared', 'escape_special_chars');
|
||||
|
||||
$alt = '';
|
||||
$file = '';
|
||||
|
|
@ -48,8 +48,8 @@ function smarty_function_html_image($params, &$smarty)
|
|||
$path_prefix = '';
|
||||
$server_vars = ($smarty->request_use_auto_globals) ? $_SERVER : $GLOBALS['HTTP_SERVER_VARS'];
|
||||
$basedir = isset($server_vars['DOCUMENT_ROOT']) ? $server_vars['DOCUMENT_ROOT'] : '';
|
||||
foreach($params as $_key => $_val) {
|
||||
switch($_key) {
|
||||
foreach ($params as $_key => $_val) {
|
||||
switch ($_key) {
|
||||
case 'file':
|
||||
case 'height':
|
||||
case 'width':
|
||||
|
|
@ -60,7 +60,7 @@ function smarty_function_html_image($params, &$smarty)
|
|||
break;
|
||||
|
||||
case 'alt':
|
||||
if(!is_array($_val)) {
|
||||
if (!is_array($_val)) {
|
||||
$$_key = smarty_function_escape_special_chars($_val);
|
||||
} else {
|
||||
$smarty->trigger_error("html_image: extra attribute '$_key' cannot be an array", E_USER_NOTICE);
|
||||
|
|
@ -74,7 +74,7 @@ function smarty_function_html_image($params, &$smarty)
|
|||
break;
|
||||
|
||||
default:
|
||||
if(!is_array($_val)) {
|
||||
if (!is_array($_val)) {
|
||||
$extra .= ' '.$_key.'="'.smarty_function_escape_special_chars($_val).'"';
|
||||
} else {
|
||||
$smarty->trigger_error("html_image: extra attribute '$_key' cannot be an array", E_USER_NOTICE);
|
||||
|
|
@ -88,18 +88,18 @@ function smarty_function_html_image($params, &$smarty)
|
|||
return;
|
||||
}
|
||||
|
||||
if (substr($file,0,1) == '/') {
|
||||
if (substr($file, 0, 1) == '/') {
|
||||
$_image_path = $basedir . $file;
|
||||
} else {
|
||||
$_image_path = $file;
|
||||
}
|
||||
|
||||
if(!isset($params['width']) || !isset($params['height'])) {
|
||||
if(!$_image_data = @getimagesize($_image_path)) {
|
||||
if(!file_exists($_image_path)) {
|
||||
if (!isset($params['width']) || !isset($params['height'])) {
|
||||
if (!$_image_data = @getimagesize($_image_path)) {
|
||||
if (!file_exists($_image_path)) {
|
||||
$smarty->trigger_error("html_image: unable to find '$_image_path'", E_USER_NOTICE);
|
||||
return;
|
||||
} else if(!is_readable($_image_path)) {
|
||||
} elseif (!is_readable($_image_path)) {
|
||||
$smarty->trigger_error("html_image: unable to read '$_image_path'", E_USER_NOTICE);
|
||||
return;
|
||||
} else {
|
||||
|
|
@ -110,21 +110,20 @@ function smarty_function_html_image($params, &$smarty)
|
|||
if ($smarty->security &&
|
||||
($_params = array('resource_type' => 'file', 'resource_name' => $_image_path)) &&
|
||||
(require_once(SMARTY_CORE_DIR . 'core.is_secure.php')) &&
|
||||
(!smarty_core_is_secure($_params, $smarty)) ) {
|
||||
(!smarty_core_is_secure($_params, $smarty))) {
|
||||
$smarty->trigger_error("html_image: (secure) '$_image_path' not in secure directory", E_USER_NOTICE);
|
||||
}
|
||||
}
|
||||
|
||||
if(!isset($params['width'])) {
|
||||
if (!isset($params['width'])) {
|
||||
$width = $_image_data[0];
|
||||
}
|
||||
if(!isset($params['height'])) {
|
||||
if (!isset($params['height'])) {
|
||||
$height = $_image_data[1];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if(isset($params['dpi'])) {
|
||||
if(strstr($server_vars['HTTP_USER_AGENT'], 'Mac')) {
|
||||
if (isset($params['dpi'])) {
|
||||
if (strstr($server_vars['HTTP_USER_AGENT'], 'Mac')) {
|
||||
$dpi_default = 72;
|
||||
} else {
|
||||
$dpi_default = 96;
|
||||
|
|
@ -138,5 +137,3 @@ function smarty_function_html_image($params, &$smarty)
|
|||
}
|
||||
|
||||
/* vim: set expandtab: */
|
||||
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@
|
|||
*/
|
||||
function smarty_function_html_options($params, &$smarty)
|
||||
{
|
||||
require_once $smarty->_get_plugin_filepath('shared','escape_special_chars');
|
||||
require_once $smarty->_get_plugin_filepath('shared', 'escape_special_chars');
|
||||
|
||||
$name = null;
|
||||
$values = null;
|
||||
|
|
@ -39,8 +39,8 @@ function smarty_function_html_options($params, &$smarty)
|
|||
|
||||
$extra = '';
|
||||
|
||||
foreach($params as $_key => $_val) {
|
||||
switch($_key) {
|
||||
foreach ($params as $_key => $_val) {
|
||||
switch ($_key) {
|
||||
case 'name':
|
||||
$$_key = (string)$_val;
|
||||
break;
|
||||
|
|
@ -59,7 +59,7 @@ function smarty_function_html_options($params, &$smarty)
|
|||
break;
|
||||
|
||||
default:
|
||||
if(!is_array($_val)) {
|
||||
if (!is_array($_val)) {
|
||||
$extra .= ' '.$_key.'="'.smarty_function_escape_special_chars($_val).'"';
|
||||
} else {
|
||||
$smarty->trigger_error("html_options: extra attribute '$_key' cannot be an array", E_USER_NOTICE);
|
||||
|
|
@ -68,39 +68,38 @@ function smarty_function_html_options($params, &$smarty)
|
|||
}
|
||||
}
|
||||
|
||||
if (!isset($options) && !isset($values))
|
||||
return ''; /* raise error here? */
|
||||
if (!isset($options) && !isset($values)) {
|
||||
return '';
|
||||
} /* raise error here? */
|
||||
|
||||
$_html_result = '';
|
||||
|
||||
if (isset($options)) {
|
||||
|
||||
foreach ($options as $_key=>$_val)
|
||||
foreach ($options as $_key=>$_val) {
|
||||
$_html_result .= smarty_function_html_options_optoutput($_key, $_val, $selected);
|
||||
|
||||
}
|
||||
} else {
|
||||
|
||||
foreach ($values as $_i=>$_key) {
|
||||
$_val = isset($output[$_i]) ? $output[$_i] : '';
|
||||
$_html_result .= smarty_function_html_options_optoutput($_key, $_val, $selected);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if(!empty($name)) {
|
||||
if (!empty($name)) {
|
||||
$_html_result = '<select name="' . $name . '"' . $extra . '>' . "\n" . $_html_result . '</select>' . "\n";
|
||||
}
|
||||
|
||||
return $_html_result;
|
||||
|
||||
}
|
||||
|
||||
function smarty_function_html_options_optoutput($key, $value, $selected) {
|
||||
if(!is_array($value)) {
|
||||
function smarty_function_html_options_optoutput($key, $value, $selected)
|
||||
{
|
||||
if (!is_array($value)) {
|
||||
$_html_result = '<option label="' . smarty_function_escape_special_chars($value) . '" value="' .
|
||||
smarty_function_escape_special_chars($key) . '"';
|
||||
if (in_array((string)$key, $selected))
|
||||
if (in_array((string)$key, $selected)) {
|
||||
$_html_result .= ' selected="selected"';
|
||||
}
|
||||
$_html_result .= '>' . smarty_function_escape_special_chars($value) . '</option>' . "\n";
|
||||
} else {
|
||||
$_html_result = smarty_function_html_options_optgroup($key, $value, $selected);
|
||||
|
|
@ -108,7 +107,8 @@ function smarty_function_html_options_optoutput($key, $value, $selected) {
|
|||
return $_html_result;
|
||||
}
|
||||
|
||||
function smarty_function_html_options_optgroup($key, $values, $selected) {
|
||||
function smarty_function_html_options_optgroup($key, $values, $selected)
|
||||
{
|
||||
$optgroup_html = '<optgroup label="' . smarty_function_escape_special_chars($key) . '">' . "\n";
|
||||
foreach ($values as $key => $value) {
|
||||
$optgroup_html .= smarty_function_html_options_optoutput($key, $value, $selected);
|
||||
|
|
@ -118,5 +118,3 @@ function smarty_function_html_options_optgroup($key, $values, $selected) {
|
|||
}
|
||||
|
||||
/* vim: set expandtab: */
|
||||
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@
|
|||
*/
|
||||
function smarty_function_html_radios($params, &$smarty)
|
||||
{
|
||||
require_once $smarty->_get_plugin_filepath('shared','escape_special_chars');
|
||||
require_once $smarty->_get_plugin_filepath('shared', 'escape_special_chars');
|
||||
|
||||
$name = 'radio';
|
||||
$values = null;
|
||||
|
|
@ -52,8 +52,8 @@ function smarty_function_html_radios($params, &$smarty)
|
|||
$output = null;
|
||||
$extra = '';
|
||||
|
||||
foreach($params as $_key => $_val) {
|
||||
switch($_key) {
|
||||
foreach ($params as $_key => $_val) {
|
||||
switch ($_key) {
|
||||
case 'name':
|
||||
case 'separator':
|
||||
$$_key = (string)$_val;
|
||||
|
|
@ -61,7 +61,7 @@ function smarty_function_html_radios($params, &$smarty)
|
|||
|
||||
case 'checked':
|
||||
case 'selected':
|
||||
if(is_array($_val)) {
|
||||
if (is_array($_val)) {
|
||||
$smarty->trigger_error('html_radios: the "' . $_key . '" attribute cannot be an array', E_USER_WARNING);
|
||||
} else {
|
||||
$selected = (string)$_val;
|
||||
|
|
@ -91,7 +91,7 @@ function smarty_function_html_radios($params, &$smarty)
|
|||
break;
|
||||
|
||||
default:
|
||||
if(!is_array($_val)) {
|
||||
if (!is_array($_val)) {
|
||||
$extra .= ' '.$_key.'="'.smarty_function_escape_special_chars($_val).'"';
|
||||
} else {
|
||||
$smarty->trigger_error("html_radios: extra attribute '$_key' cannot be an array", E_USER_NOTICE);
|
||||
|
|
@ -100,57 +100,57 @@ function smarty_function_html_radios($params, &$smarty)
|
|||
}
|
||||
}
|
||||
|
||||
if (!isset($options) && !isset($values))
|
||||
return ''; /* raise error here? */
|
||||
if (!isset($options) && !isset($values)) {
|
||||
return '';
|
||||
} /* raise error here? */
|
||||
|
||||
$_html_result = array();
|
||||
|
||||
if (isset($options)) {
|
||||
|
||||
foreach ($options as $_key=>$_val)
|
||||
foreach ($options as $_key=>$_val) {
|
||||
$_html_result[] = smarty_function_html_radios_output($name, $_key, $_val, $selected, $extra, $separator, $labels, $label_ids);
|
||||
|
||||
}
|
||||
} else {
|
||||
|
||||
foreach ($values as $_i=>$_key) {
|
||||
$_val = isset($output[$_i]) ? $output[$_i] : '';
|
||||
$_html_result[] = smarty_function_html_radios_output($name, $_key, $_val, $selected, $extra, $separator, $labels, $label_ids);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if(!empty($params['assign'])) {
|
||||
if (!empty($params['assign'])) {
|
||||
$smarty->assign($params['assign'], $_html_result);
|
||||
} else {
|
||||
return implode("\n",$_html_result);
|
||||
return implode("\n", $_html_result);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function smarty_function_html_radios_output($name, $value, $output, $selected, $extra, $separator, $labels, $label_ids) {
|
||||
function smarty_function_html_radios_output($name, $value, $output, $selected, $extra, $separator, $labels, $label_ids)
|
||||
{
|
||||
$_output = '';
|
||||
if ($labels) {
|
||||
if($label_ids) {
|
||||
$_id = smarty_function_escape_special_chars(preg_replace('![^\w\-\.]!', '_', $name . '_' . $value));
|
||||
$_output .= '<label for="' . $_id . '">';
|
||||
} else {
|
||||
$_output .= '<label>';
|
||||
}
|
||||
}
|
||||
$_output .= '<input type="radio" name="'
|
||||
if ($label_ids) {
|
||||
$_id = smarty_function_escape_special_chars(preg_replace('![^\w\-\.]!', '_', $name . '_' . $value));
|
||||
$_output .= '<label for="' . $_id . '">';
|
||||
} else {
|
||||
$_output .= '<label>';
|
||||
}
|
||||
}
|
||||
$_output .= '<input type="radio" name="'
|
||||
. smarty_function_escape_special_chars($name) . '" value="'
|
||||
. smarty_function_escape_special_chars($value) . '"';
|
||||
|
||||
if ($labels && $label_ids) $_output .= ' id="' . $_id . '"';
|
||||
if ($labels && $label_ids) {
|
||||
$_output .= ' id="' . $_id . '"';
|
||||
}
|
||||
|
||||
if ((string)$value==$selected) {
|
||||
$_output .= ' checked="checked"';
|
||||
}
|
||||
$_output .= $extra . ' />' . $output;
|
||||
if ($labels) $_output .= '</label>';
|
||||
if ($labels) {
|
||||
$_output .= '</label>';
|
||||
}
|
||||
$_output .= $separator;
|
||||
|
||||
return $_output;
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -37,9 +37,9 @@
|
|||
*/
|
||||
function smarty_function_html_select_date($params, &$smarty)
|
||||
{
|
||||
require_once $smarty->_get_plugin_filepath('shared','escape_special_chars');
|
||||
require_once $smarty->_get_plugin_filepath('shared','make_timestamp');
|
||||
require_once $smarty->_get_plugin_filepath('function','html_options');
|
||||
require_once $smarty->_get_plugin_filepath('shared', 'escape_special_chars');
|
||||
require_once $smarty->_get_plugin_filepath('shared', 'make_timestamp');
|
||||
require_once $smarty->_get_plugin_filepath('function', 'html_options');
|
||||
/* Default values. */
|
||||
$prefix = "Date_";
|
||||
$start_year = strftime("%Y");
|
||||
|
|
@ -124,7 +124,7 @@ function smarty_function_html_select_date($params, &$smarty)
|
|||
break;
|
||||
|
||||
default:
|
||||
if(!is_array($_value)) {
|
||||
if (!is_array($_value)) {
|
||||
$extra_attrs .= ' '.$_key.'="'.smarty_function_escape_special_chars($_value).'"';
|
||||
} else {
|
||||
$smarty->trigger_error("html_select_date: extra attribute '$_key' cannot be an array", E_USER_NOTICE);
|
||||
|
|
@ -168,7 +168,7 @@ function smarty_function_html_select_date($params, &$smarty)
|
|||
// force start year to include given date if not explicitly set
|
||||
$start_year = $time[0];
|
||||
}
|
||||
if($end_year < $time[0] && !isset($params['end_year'])) {
|
||||
if ($end_year < $time[0] && !isset($params['end_year'])) {
|
||||
// force end year to include given date if not explicitly set
|
||||
$end_year = $time[0];
|
||||
}
|
||||
|
|
@ -180,10 +180,10 @@ function smarty_function_html_select_date($params, &$smarty)
|
|||
|
||||
$field_separator_count = -1;
|
||||
if ($display_months) {
|
||||
$field_separator_count++;
|
||||
$field_separator_count++;
|
||||
$month_names = array();
|
||||
$month_values = array();
|
||||
if(isset($month_empty)) {
|
||||
if (isset($month_empty)) {
|
||||
$month_names[''] = $month_empty;
|
||||
$month_values[''] = '';
|
||||
}
|
||||
|
|
@ -193,32 +193,34 @@ function smarty_function_html_select_date($params, &$smarty)
|
|||
}
|
||||
|
||||
$month_result .= '<select name=';
|
||||
if (null !== $field_array){
|
||||
if (null !== $field_array) {
|
||||
$month_result .= '"' . $field_array . '[' . $prefix . 'Month]"';
|
||||
} else {
|
||||
$month_result .= '"' . $prefix . 'Month"';
|
||||
}
|
||||
if (null !== $month_size){
|
||||
if (null !== $month_size) {
|
||||
$month_result .= ' size="' . $month_size . '"';
|
||||
}
|
||||
if (null !== $month_extra){
|
||||
if (null !== $month_extra) {
|
||||
$month_result .= ' ' . $month_extra;
|
||||
}
|
||||
if (null !== $all_extra){
|
||||
if (null !== $all_extra) {
|
||||
$month_result .= ' ' . $all_extra;
|
||||
}
|
||||
$month_result .= $extra_attrs . '>'."\n";
|
||||
|
||||
$month_result .= smarty_function_html_options(array('output' => $month_names,
|
||||
$month_result .= smarty_function_html_options(
|
||||
array('output' => $month_names,
|
||||
'values' => $month_values,
|
||||
'selected' => (int)$time[1] ? strftime($month_value_format, mktime(0, 0, 0, (int)$time[1], 1, 2000)) : '',
|
||||
'print_result' => false),
|
||||
$smarty);
|
||||
$smarty
|
||||
);
|
||||
$month_result .= '</select>';
|
||||
}
|
||||
|
||||
if ($display_days) {
|
||||
$field_separator_count++;
|
||||
$field_separator_count++;
|
||||
$days = array();
|
||||
if (isset($day_empty)) {
|
||||
$days[''] = $day_empty;
|
||||
|
|
@ -230,42 +232,44 @@ function smarty_function_html_select_date($params, &$smarty)
|
|||
}
|
||||
|
||||
$day_result .= '<select name=';
|
||||
if (null !== $field_array){
|
||||
if (null !== $field_array) {
|
||||
$day_result .= '"' . $field_array . '[' . $prefix . 'Day]"';
|
||||
} else {
|
||||
$day_result .= '"' . $prefix . 'Day"';
|
||||
}
|
||||
if (null !== $day_size){
|
||||
if (null !== $day_size) {
|
||||
$day_result .= ' size="' . $day_size . '"';
|
||||
}
|
||||
if (null !== $all_extra){
|
||||
if (null !== $all_extra) {
|
||||
$day_result .= ' ' . $all_extra;
|
||||
}
|
||||
if (null !== $day_extra){
|
||||
if (null !== $day_extra) {
|
||||
$day_result .= ' ' . $day_extra;
|
||||
}
|
||||
$day_result .= $extra_attrs . '>'."\n";
|
||||
$day_result .= smarty_function_html_options(array('output' => $days,
|
||||
$day_result .= smarty_function_html_options(
|
||||
array('output' => $days,
|
||||
'values' => $day_values,
|
||||
'selected' => $time[2],
|
||||
'print_result' => false),
|
||||
$smarty);
|
||||
$smarty
|
||||
);
|
||||
$day_result .= '</select>';
|
||||
}
|
||||
|
||||
if ($display_years) {
|
||||
$field_separator_count++;
|
||||
if (null !== $field_array){
|
||||
$field_separator_count++;
|
||||
if (null !== $field_array) {
|
||||
$year_name = $field_array . '[' . $prefix . 'Year]';
|
||||
} else {
|
||||
$year_name = $prefix . 'Year';
|
||||
}
|
||||
if ($year_as_text) {
|
||||
$year_result .= '<input type="text" name="' . $year_name . '" value="' . $time[0] . '" size="4" maxlength="4"';
|
||||
if (null !== $all_extra){
|
||||
if (null !== $all_extra) {
|
||||
$year_result .= ' ' . $all_extra;
|
||||
}
|
||||
if (null !== $year_extra){
|
||||
if (null !== $year_extra) {
|
||||
$year_result .= ' ' . $year_extra;
|
||||
}
|
||||
$year_result .= ' />';
|
||||
|
|
@ -277,34 +281,36 @@ function smarty_function_html_select_date($params, &$smarty)
|
|||
sort($years, SORT_NUMERIC);
|
||||
}
|
||||
$yearvals = $years;
|
||||
if(isset($year_empty)) {
|
||||
if (isset($year_empty)) {
|
||||
array_unshift($years, $year_empty);
|
||||
array_unshift($yearvals, '');
|
||||
}
|
||||
$year_result .= '<select name="' . $year_name . '"';
|
||||
if (null !== $year_size){
|
||||
if (null !== $year_size) {
|
||||
$year_result .= ' size="' . $year_size . '"';
|
||||
}
|
||||
if (null !== $all_extra){
|
||||
if (null !== $all_extra) {
|
||||
$year_result .= ' ' . $all_extra;
|
||||
}
|
||||
if (null !== $year_extra){
|
||||
if (null !== $year_extra) {
|
||||
$year_result .= ' ' . $year_extra;
|
||||
}
|
||||
$year_result .= $extra_attrs . '>'."\n";
|
||||
$year_result .= smarty_function_html_options(array('output' => $years,
|
||||
$year_result .= smarty_function_html_options(
|
||||
array('output' => $years,
|
||||
'values' => $yearvals,
|
||||
'selected' => $time[0],
|
||||
'print_result' => false),
|
||||
$smarty);
|
||||
$smarty
|
||||
);
|
||||
$year_result .= '</select>';
|
||||
}
|
||||
}
|
||||
|
||||
// Loop thru the field_order field
|
||||
for ($i = 0; $i <= 2; $i++){
|
||||
for ($i = 0; $i <= 2; $i++) {
|
||||
$c = substr($field_order, $i, 1);
|
||||
switch ($c){
|
||||
switch ($c) {
|
||||
case 'D':
|
||||
$html_result .= $day_result;
|
||||
break;
|
||||
|
|
@ -318,7 +324,7 @@ function smarty_function_html_select_date($params, &$smarty)
|
|||
break;
|
||||
}
|
||||
// Add the field seperator
|
||||
if($i < $field_separator_count) {
|
||||
if ($i < $field_separator_count) {
|
||||
$html_result .= $field_separator;
|
||||
}
|
||||
}
|
||||
|
|
@ -327,5 +333,3 @@ function smarty_function_html_select_date($params, &$smarty)
|
|||
}
|
||||
|
||||
/* vim: set expandtab: */
|
||||
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -23,8 +23,8 @@
|
|||
*/
|
||||
function smarty_function_html_select_time($params, &$smarty)
|
||||
{
|
||||
require_once $smarty->_get_plugin_filepath('shared','make_timestamp');
|
||||
require_once $smarty->_get_plugin_filepath('function','html_options');
|
||||
require_once $smarty->_get_plugin_filepath('shared', 'make_timestamp');
|
||||
require_once $smarty->_get_plugin_filepath('function', 'html_options');
|
||||
/* Default values. */
|
||||
$prefix = "Time_";
|
||||
$time = time();
|
||||
|
|
@ -84,33 +84,37 @@ function smarty_function_html_select_time($params, &$smarty)
|
|||
if ($display_hours) {
|
||||
$hours = $use_24_hours ? range(0, 23) : range(1, 12);
|
||||
$hour_fmt = $use_24_hours ? '%H' : '%I';
|
||||
for ($i = 0, $for_max = count($hours); $i < $for_max; $i++)
|
||||
for ($i = 0, $for_max = count($hours); $i < $for_max; $i++) {
|
||||
$hours[$i] = sprintf('%02d', $hours[$i]);
|
||||
}
|
||||
$html_result .= '<select name=';
|
||||
if (null !== $field_array) {
|
||||
$html_result .= '"' . $field_array . '[' . $prefix . 'Hour]"';
|
||||
} else {
|
||||
$html_result .= '"' . $prefix . 'Hour"';
|
||||
}
|
||||
if (null !== $hour_extra){
|
||||
if (null !== $hour_extra) {
|
||||
$html_result .= ' ' . $hour_extra;
|
||||
}
|
||||
if (null !== $all_extra){
|
||||
if (null !== $all_extra) {
|
||||
$html_result .= ' ' . $all_extra;
|
||||
}
|
||||
$html_result .= '>'."\n";
|
||||
$html_result .= smarty_function_html_options(array('output' => $hours,
|
||||
$html_result .= smarty_function_html_options(
|
||||
array('output' => $hours,
|
||||
'values' => $hours,
|
||||
'selected' => strftime($hour_fmt, $time),
|
||||
'print_result' => false),
|
||||
$smarty);
|
||||
$smarty
|
||||
);
|
||||
$html_result .= "</select>\n";
|
||||
}
|
||||
|
||||
if ($display_minutes) {
|
||||
$all_minutes = range(0, 59);
|
||||
for ($i = 0, $for_max = count($all_minutes); $i < $for_max; $i+= $minute_interval)
|
||||
for ($i = 0, $for_max = count($all_minutes); $i < $for_max; $i+= $minute_interval) {
|
||||
$minutes[] = sprintf('%02d', $all_minutes[$i]);
|
||||
}
|
||||
$selected = intval(floor(strftime('%M', $time) / $minute_interval) * $minute_interval);
|
||||
$html_result .= '<select name=';
|
||||
if (null !== $field_array) {
|
||||
|
|
@ -118,26 +122,29 @@ function smarty_function_html_select_time($params, &$smarty)
|
|||
} else {
|
||||
$html_result .= '"' . $prefix . 'Minute"';
|
||||
}
|
||||
if (null !== $minute_extra){
|
||||
if (null !== $minute_extra) {
|
||||
$html_result .= ' ' . $minute_extra;
|
||||
}
|
||||
if (null !== $all_extra){
|
||||
if (null !== $all_extra) {
|
||||
$html_result .= ' ' . $all_extra;
|
||||
}
|
||||
$html_result .= '>'."\n";
|
||||
|
||||
$html_result .= smarty_function_html_options(array('output' => $minutes,
|
||||
$html_result .= smarty_function_html_options(
|
||||
array('output' => $minutes,
|
||||
'values' => $minutes,
|
||||
'selected' => $selected,
|
||||
'print_result' => false),
|
||||
$smarty);
|
||||
$smarty
|
||||
);
|
||||
$html_result .= "</select>\n";
|
||||
}
|
||||
|
||||
if ($display_seconds) {
|
||||
$all_seconds = range(0, 59);
|
||||
for ($i = 0, $for_max = count($all_seconds); $i < $for_max; $i+= $second_interval)
|
||||
for ($i = 0, $for_max = count($all_seconds); $i < $for_max; $i+= $second_interval) {
|
||||
$seconds[] = sprintf('%02d', $all_seconds[$i]);
|
||||
}
|
||||
$selected = intval(floor(strftime('%S', $time) / $second_interval) * $second_interval);
|
||||
$html_result .= '<select name=';
|
||||
if (null !== $field_array) {
|
||||
|
|
@ -146,19 +153,21 @@ function smarty_function_html_select_time($params, &$smarty)
|
|||
$html_result .= '"' . $prefix . 'Second"';
|
||||
}
|
||||
|
||||
if (null !== $second_extra){
|
||||
if (null !== $second_extra) {
|
||||
$html_result .= ' ' . $second_extra;
|
||||
}
|
||||
if (null !== $all_extra){
|
||||
if (null !== $all_extra) {
|
||||
$html_result .= ' ' . $all_extra;
|
||||
}
|
||||
$html_result .= '>'."\n";
|
||||
|
||||
$html_result .= smarty_function_html_options(array('output' => $seconds,
|
||||
$html_result .= smarty_function_html_options(
|
||||
array('output' => $seconds,
|
||||
'values' => $seconds,
|
||||
'selected' => $selected,
|
||||
'print_result' => false),
|
||||
$smarty);
|
||||
$smarty
|
||||
);
|
||||
$html_result .= "</select>\n";
|
||||
}
|
||||
|
||||
|
|
@ -170,19 +179,21 @@ function smarty_function_html_select_time($params, &$smarty)
|
|||
$html_result .= '"' . $prefix . 'Meridian"';
|
||||
}
|
||||
|
||||
if (null !== $meridian_extra){
|
||||
if (null !== $meridian_extra) {
|
||||
$html_result .= ' ' . $meridian_extra;
|
||||
}
|
||||
if (null !== $all_extra){
|
||||
if (null !== $all_extra) {
|
||||
$html_result .= ' ' . $all_extra;
|
||||
}
|
||||
$html_result .= '>'."\n";
|
||||
|
||||
$html_result .= smarty_function_html_options(array('output' => array('AM', 'PM'),
|
||||
$html_result .= smarty_function_html_options(
|
||||
array('output' => array('AM', 'PM'),
|
||||
'values' => array('am', 'pm'),
|
||||
'selected' => strtolower(strftime('%p', $time)),
|
||||
'print_result' => false),
|
||||
$smarty);
|
||||
$smarty
|
||||
);
|
||||
$html_result .= "</select>\n";
|
||||
}
|
||||
|
||||
|
|
@ -190,5 +201,3 @@ function smarty_function_html_select_time($params, &$smarty)
|
|||
}
|
||||
|
||||
/* vim: set expandtab: */
|
||||
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@
|
|||
* - tr_attr = table row attributes (arrays are cycled)
|
||||
* - td_attr = table cell attributes (arrays are cycled)
|
||||
* - trailpad = value to pad trailing cells with
|
||||
* - caption = text for caption element
|
||||
* - caption = text for caption element
|
||||
* - vdir = vertical direction (default: "down", means top-to-bottom)
|
||||
* - hdir = horizontal direction (default: "right", means left-to-right)
|
||||
* - inner = inner loop (default "cols": print $loop line by line,
|
||||
|
|
@ -161,8 +161,9 @@ function smarty_function_html_table($params, &$smarty)
|
|||
return $output;
|
||||
}
|
||||
|
||||
function smarty_function_html_table_cycle($name, $var, $no) {
|
||||
if(!is_array($var)) {
|
||||
function smarty_function_html_table_cycle($name, $var, $no)
|
||||
{
|
||||
if (!is_array($var)) {
|
||||
$ret = $var;
|
||||
} else {
|
||||
$ret = $var[$no % count($var)];
|
||||
|
|
@ -173,5 +174,3 @@ function smarty_function_html_table_cycle($name, $var, $no) {
|
|||
|
||||
|
||||
/* vim: set expandtab: */
|
||||
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -70,8 +70,9 @@ function smarty_function_mailto($params, &$smarty)
|
|||
case 'cc':
|
||||
case 'bcc':
|
||||
case 'followupto':
|
||||
if (!empty($value))
|
||||
$mail_parms[] = $var.'='.str_replace($search,$replace,rawurlencode($value));
|
||||
if (!empty($value)) {
|
||||
$mail_parms[] = $var.'='.str_replace($search, $replace, rawurlencode($value));
|
||||
}
|
||||
break;
|
||||
|
||||
case 'subject':
|
||||
|
|
@ -83,6 +84,7 @@ function smarty_function_mailto($params, &$smarty)
|
|||
case 'text':
|
||||
$$var = $value;
|
||||
|
||||
// no break
|
||||
default:
|
||||
}
|
||||
}
|
||||
|
|
@ -95,12 +97,12 @@ function smarty_function_mailto($params, &$smarty)
|
|||
$address .= $mail_parm_vals;
|
||||
|
||||
$encode = (empty($params['encode'])) ? 'none' : $params['encode'];
|
||||
if (!in_array($encode,array('javascript','javascript_charcode','hex','none')) ) {
|
||||
if (!in_array($encode, array('javascript','javascript_charcode','hex','none'))) {
|
||||
$smarty->trigger_error("mailto: 'encode' parameter must be none, javascript or hex");
|
||||
return;
|
||||
}
|
||||
|
||||
if ($encode == 'javascript' ) {
|
||||
if ($encode == 'javascript') {
|
||||
$string = 'document.write(\'<a href="mailto:'.$address.'" '.$extra.'>'.$text.'</a>\');';
|
||||
|
||||
$js_encode = '';
|
||||
|
|
@ -109,36 +111,32 @@ function smarty_function_mailto($params, &$smarty)
|
|||
}
|
||||
|
||||
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++ ) {
|
||||
$ord[] = ord($string[$x]);
|
||||
for ($x = 0, $y = strlen($string); $x < $y; $x++) {
|
||||
$ord[] = ord($string[$x]);
|
||||
}
|
||||
|
||||
$_ret = "<script type=\"text/javascript\" language=\"javascript\">\n";
|
||||
$_ret .= "<!--\n";
|
||||
$_ret .= "{document.write(String.fromCharCode(";
|
||||
$_ret .= implode(',',$ord);
|
||||
$_ret .= implode(',', $ord);
|
||||
$_ret .= "))";
|
||||
$_ret .= "}\n";
|
||||
$_ret .= "//-->\n";
|
||||
$_ret .= "</script>\n";
|
||||
|
||||
return $_ret;
|
||||
|
||||
|
||||
} elseif ($encode == 'hex') {
|
||||
|
||||
preg_match('!^(.*)(\?.*)$!',$address,$match);
|
||||
if(!empty($match[2])) {
|
||||
preg_match('!^(.*)(\?.*)$!', $address, $match);
|
||||
if (!empty($match[2])) {
|
||||
$smarty->trigger_error("mailto: hex encoding does not work with extra attributes. Try javascript.");
|
||||
return;
|
||||
}
|
||||
$address_encode = '';
|
||||
for ($x=0; $x < strlen($address); $x++) {
|
||||
if(preg_match('!\w!',$address[$x])) {
|
||||
if (preg_match('!\w!', $address[$x])) {
|
||||
$address_encode .= '%' . bin2hex($address[$x]);
|
||||
} else {
|
||||
$address_encode .= $address[$x];
|
||||
|
|
@ -151,15 +149,10 @@ function smarty_function_mailto($params, &$smarty)
|
|||
|
||||
$mailto = "mailto:";
|
||||
return '<a href="'.$mailto.$address_encode.'" '.$extra.'>'.$text_encode.'</a>';
|
||||
|
||||
} else {
|
||||
// no encoding
|
||||
return '<a href="mailto:'.$address.'" '.$extra.'>'.$text.'</a>';
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* vim: set expandtab: */
|
||||
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -29,14 +29,15 @@ function smarty_function_popup($params, &$smarty)
|
|||
case 'function':
|
||||
case 'inarray':
|
||||
$$_key = (string)$_value;
|
||||
if ($_key == 'function' || $_key == 'inarray')
|
||||
if ($_key == 'function' || $_key == 'inarray') {
|
||||
$append .= ',' . strtoupper($_key) . ",'$_value'";
|
||||
}
|
||||
break;
|
||||
|
||||
case 'caption':
|
||||
case 'closetext':
|
||||
case 'status':
|
||||
$append .= ',' . strtoupper($_key) . ",'" . str_replace("'","\'",$_value) . "'";
|
||||
$append .= ',' . strtoupper($_key) . ",'" . str_replace("'", "\'", $_value) . "'";
|
||||
break;
|
||||
|
||||
case 'fgcolor':
|
||||
|
|
@ -90,7 +91,9 @@ function smarty_function_popup($params, &$smarty)
|
|||
case 'mouseoff':
|
||||
case 'followmouse':
|
||||
case 'closeclick':
|
||||
if ($_value) $append .= ',' . strtoupper($_key);
|
||||
if ($_value) {
|
||||
$append .= ',' . strtoupper($_key);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
|
|
@ -103,17 +106,18 @@ function smarty_function_popup($params, &$smarty)
|
|||
return false;
|
||||
}
|
||||
|
||||
if (empty($trigger)) { $trigger = "onmouseover"; }
|
||||
if (empty($trigger)) {
|
||||
$trigger = "onmouseover";
|
||||
}
|
||||
|
||||
$retval = $trigger . '="return overlib(\''.preg_replace(array("!'!","![\r\n]!"),array("\'",'\r'),$text).'\'';
|
||||
$retval = $trigger . '="return overlib(\''.preg_replace(array("!'!","![\r\n]!"), array("\'",'\r'), $text).'\'';
|
||||
$retval .= $append . ');"';
|
||||
if ($trigger == 'onmouseover')
|
||||
$retval .= ' onmouseout="nd();"';
|
||||
if ($trigger == 'onmouseover') {
|
||||
$retval .= ' onmouseout="nd();"';
|
||||
}
|
||||
|
||||
|
||||
return $retval;
|
||||
}
|
||||
|
||||
/* vim: set expandtab: */
|
||||
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -36,5 +36,3 @@ function smarty_function_popup_init($params, &$smarty)
|
|||
}
|
||||
|
||||
/* vim: set expandtab: */
|
||||
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -28,16 +28,14 @@ function smarty_modifier_capitalize_ucfirst($string, $uc_digits = null)
|
|||
{
|
||||
static $_uc_digits = false;
|
||||
|
||||
if(isset($uc_digits)) {
|
||||
if (isset($uc_digits)) {
|
||||
$_uc_digits = $uc_digits;
|
||||
return;
|
||||
}
|
||||
|
||||
if(substr($string[0],0,1) != "'" && !preg_match("!\d!",$string[0]) || $_uc_digits)
|
||||
if (substr($string[0], 0, 1) != "'" && !preg_match("!\d!", $string[0]) || $_uc_digits) {
|
||||
return ucfirst($string[0]);
|
||||
else
|
||||
} else {
|
||||
return $string[0];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -29,5 +29,3 @@ function smarty_modifier_cat($string, $cat)
|
|||
}
|
||||
|
||||
/* vim: set expandtab: */
|
||||
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -21,12 +21,11 @@
|
|||
*/
|
||||
function smarty_modifier_count_characters($string, $include_spaces = false)
|
||||
{
|
||||
if ($include_spaces)
|
||||
return(strlen($string));
|
||||
if ($include_spaces) {
|
||||
return(strlen($string));
|
||||
}
|
||||
|
||||
return preg_match_all("/[^\s]/",$string, $match);
|
||||
return preg_match_all("/[^\s]/", $string, $match);
|
||||
}
|
||||
|
||||
/* vim: set expandtab: */
|
||||
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -25,5 +25,3 @@ function smarty_modifier_count_paragraphs($string)
|
|||
}
|
||||
|
||||
/* vim: set expandtab: */
|
||||
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -25,5 +25,3 @@ function smarty_modifier_count_sentences($string)
|
|||
}
|
||||
|
||||
/* vim: set expandtab: */
|
||||
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@
|
|||
function smarty_modifier_count_words($string)
|
||||
{
|
||||
// split text by ' ',\r,\n,\f,\t
|
||||
$split_array = preg_split('/\s+/',$string);
|
||||
$split_array = preg_split('/\s+/', $string);
|
||||
// count matches that contain alphanumerics
|
||||
$word_count = preg_grep('/[a-zA-Z0-9\\x80-\\xff]/', $split_array);
|
||||
|
||||
|
|
@ -29,5 +29,3 @@ function smarty_modifier_count_words($string)
|
|||
}
|
||||
|
||||
/* vim: set expandtab: */
|
||||
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -20,11 +20,9 @@
|
|||
*/
|
||||
function smarty_modifier_countdown($timer)
|
||||
{
|
||||
if ($timer > 3600)
|
||||
if ($timer > 3600) {
|
||||
return intVal($timer/3600) . ":" . intVal(($timer%3600)/60) . ":" . ($timer%3600)%60;
|
||||
else
|
||||
} else {
|
||||
return intVal($timer/60) . ":" . $timer%60;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -54,5 +54,3 @@ function smarty_modifier_date_format($string, $format = '%b %e, %Y', $default_da
|
|||
}
|
||||
|
||||
/* vim: set expandtab: */
|
||||
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -29,28 +29,28 @@ function smarty_modifier_debug_print_var($var, $depth = 0, $length = 40)
|
|||
);
|
||||
|
||||
switch (gettype($var)) {
|
||||
case 'array' :
|
||||
case 'array':
|
||||
$results = '<b>Array (' . count($var) . ')</b>';
|
||||
foreach ($var as $curr_key => $curr_val) {
|
||||
$results .= '<br>' . str_repeat(' ', $depth * 2)
|
||||
. '<b>' . strtr($curr_key, $_replace) . '</b> => '
|
||||
. smarty_modifier_debug_print_var($curr_val, ++$depth, $length);
|
||||
$depth--;
|
||||
$depth--;
|
||||
}
|
||||
break;
|
||||
case 'object' :
|
||||
case 'object':
|
||||
$object_vars = get_object_vars($var);
|
||||
$results = '<b>' . get_class($var) . ' Object (' . count($object_vars) . ')</b>';
|
||||
foreach ($object_vars as $curr_key => $curr_val) {
|
||||
$results .= '<br>' . str_repeat(' ', $depth * 2)
|
||||
. '<b> ->' . strtr($curr_key, $_replace) . '</b> = '
|
||||
. smarty_modifier_debug_print_var($curr_val, ++$depth, $length);
|
||||
$depth--;
|
||||
$depth--;
|
||||
}
|
||||
break;
|
||||
case 'boolean' :
|
||||
case 'NULL' :
|
||||
case 'resource' :
|
||||
case 'boolean':
|
||||
case 'NULL':
|
||||
case 'resource':
|
||||
if (true === $var) {
|
||||
$results = 'true';
|
||||
} elseif (false === $var) {
|
||||
|
|
@ -62,21 +62,21 @@ function smarty_modifier_debug_print_var($var, $depth = 0, $length = 40)
|
|||
}
|
||||
$results = '<i>' . $results . '</i>';
|
||||
break;
|
||||
case 'integer' :
|
||||
case 'float' :
|
||||
case 'integer':
|
||||
case 'float':
|
||||
$results = htmlspecialchars((string) $var);
|
||||
break;
|
||||
case 'string' :
|
||||
case 'string':
|
||||
$results = strtr($var, $_replace);
|
||||
if (strlen($var) > $length ) {
|
||||
if (strlen($var) > $length) {
|
||||
$results = substr($var, 0, $length - 3) . '...';
|
||||
}
|
||||
$results = htmlspecialchars('"' . $results . '"');
|
||||
break;
|
||||
case 'unknown type' :
|
||||
default :
|
||||
case 'unknown type':
|
||||
default:
|
||||
$results = strtr((string) $var, $_replace);
|
||||
if (strlen($results) > $length ) {
|
||||
if (strlen($results) > $length) {
|
||||
$results = substr($results, 0, $length - 3) . '...';
|
||||
}
|
||||
$results = htmlspecialchars($results);
|
||||
|
|
@ -86,5 +86,3 @@ function smarty_modifier_debug_print_var($var, $depth = 0, $length = 40)
|
|||
}
|
||||
|
||||
/* vim: set expandtab: */
|
||||
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -21,12 +21,11 @@
|
|||
*/
|
||||
function smarty_modifier_default($string, $default = '')
|
||||
{
|
||||
if (!isset($string) || $string === '')
|
||||
if (!isset($string) || $string === '') {
|
||||
return $default;
|
||||
else
|
||||
} else {
|
||||
return $string;
|
||||
}
|
||||
}
|
||||
|
||||
/* vim: set expandtab: */
|
||||
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ function smarty_modifier_escape($string, $esc_type = 'html', $char_set = 'ISO-88
|
|||
return rawurlencode($string);
|
||||
|
||||
case 'urlpathinfo':
|
||||
return str_replace('%2F','/',rawurlencode($string));
|
||||
return str_replace('%2F', '/', rawurlencode($string));
|
||||
|
||||
case 'quotes':
|
||||
// escape unescaped single quotes
|
||||
|
|
@ -66,18 +66,17 @@ function smarty_modifier_escape($string, $esc_type = 'html', $char_set = 'ISO-88
|
|||
|
||||
case 'mail':
|
||||
// safe way to display e-mail address on a web page
|
||||
return str_replace(array('@', '.'),array(' [AT] ', ' [DOT] '), $string);
|
||||
return str_replace(array('@', '.'), array(' [AT] ', ' [DOT] '), $string);
|
||||
|
||||
case 'nonstd':
|
||||
// escape non-standard chars, such as ms document quotes
|
||||
$_res = '';
|
||||
for($_i = 0, $_len = strlen($string); $_i < $_len; $_i++) {
|
||||
for ($_i = 0, $_len = strlen($string); $_i < $_len; $_i++) {
|
||||
$_ord = ord(substr($string, $_i, 1));
|
||||
// non-standard char, escape it
|
||||
if($_ord >= 126){
|
||||
if ($_ord >= 126) {
|
||||
$_res .= '&#' . $_ord . ';';
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$_res .= substr($string, $_i, 1);
|
||||
}
|
||||
}
|
||||
|
|
@ -89,5 +88,3 @@ function smarty_modifier_escape($string, $esc_type = 'html', $char_set = 'ISO-88
|
|||
}
|
||||
|
||||
/* vim: set expandtab: */
|
||||
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -20,9 +20,7 @@
|
|||
* @param string
|
||||
* @return string
|
||||
*/
|
||||
function smarty_modifier_indent($string,$chars=4,$char=" ")
|
||||
function smarty_modifier_indent($string, $chars=4, $char=" ")
|
||||
{
|
||||
return preg_replace('!^!m',str_repeat($char,$chars),$string);
|
||||
return preg_replace('!^!m', str_repeat($char, $chars), $string);
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -22,5 +22,3 @@ function smarty_modifier_lower($string)
|
|||
{
|
||||
return strtolower($string);
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -31,5 +31,3 @@ function smarty_modifier_nl2br($string)
|
|||
}
|
||||
|
||||
/* vim: set expandtab: */
|
||||
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -21,10 +21,8 @@
|
|||
*/
|
||||
function smarty_modifier_nom($string, $type)
|
||||
{
|
||||
global ${$type};
|
||||
global ${$type};
|
||||
return ${$type}[$string];
|
||||
}
|
||||
|
||||
/* vim: set expandtab: */
|
||||
|
||||
?>
|
||||
|
|
@ -22,20 +22,22 @@
|
|||
*/
|
||||
function smarty_modifier_regex_replace($string, $search, $replace)
|
||||
{
|
||||
if(is_array($search)) {
|
||||
foreach($search as $idx => $s)
|
||||
$search[$idx] = _smarty_regex_replace_check($s);
|
||||
if (is_array($search)) {
|
||||
foreach ($search as $idx => $s) {
|
||||
$search[$idx] = _smarty_regex_replace_check($s);
|
||||
}
|
||||
} else {
|
||||
$search = _smarty_regex_replace_check($search);
|
||||
}
|
||||
$search = _smarty_regex_replace_check($search);
|
||||
}
|
||||
|
||||
return preg_replace($search, $replace, $string);
|
||||
}
|
||||
|
||||
function _smarty_regex_replace_check($search)
|
||||
{
|
||||
if (($pos = strpos($search,"\0")) !== false)
|
||||
$search = substr($search,0,$pos);
|
||||
if (($pos = strpos($search, "\0")) !== false) {
|
||||
$search = substr($search, 0, $pos);
|
||||
}
|
||||
if (preg_match('!([a-zA-Z\s]+)$!s', $search, $match) && (strpos($match[1], 'e') !== false)) {
|
||||
/* remove eval-modifier from $search */
|
||||
$search = substr($search, 0, -strlen($match[1])) . preg_replace('![e\s]+!', '', $match[1]);
|
||||
|
|
@ -44,5 +46,3 @@ function _smarty_regex_replace_check($search)
|
|||
}
|
||||
|
||||
/* vim: set expandtab: */
|
||||
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -26,5 +26,3 @@ function smarty_modifier_replace($string, $search, $replace)
|
|||
}
|
||||
|
||||
/* vim: set expandtab: */
|
||||
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -25,5 +25,3 @@ function smarty_modifier_separerNombres($string)
|
|||
}
|
||||
|
||||
/* vim: set expandtab: */
|
||||
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -21,10 +21,10 @@
|
|||
*/
|
||||
function smarty_modifier_spacify($string, $spacify_char = ' ')
|
||||
{
|
||||
return implode($spacify_char,
|
||||
preg_split('//', $string, -1, PREG_SPLIT_NO_EMPTY));
|
||||
return implode(
|
||||
$spacify_char,
|
||||
preg_split('//', $string, -1, PREG_SPLIT_NO_EMPTY)
|
||||
);
|
||||
}
|
||||
|
||||
/* vim: set expandtab: */
|
||||
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -21,23 +21,35 @@
|
|||
*/
|
||||
function smarty_modifier_sprintf($string, $var0 = null, $var1 = null, $var2 = null, $var3 = null, $var4 = null, $var5 = null, $var6 = null, $var7 = null, $var8 = null, $var9 = null)
|
||||
{
|
||||
for($i = -1; $i<9; $i++) {
|
||||
if (empty(${'var'.($i+1)})) break;
|
||||
for ($i = -1; $i<9; $i++) {
|
||||
if (empty(${'var'.($i+1)})) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ($i == 0) return sprintf($string, $var0);
|
||||
elseif ($i == 1) return sprintf($string, $var0, $var1);
|
||||
elseif ($i == 2) return sprintf($string, $var0, $var1, $var2);
|
||||
elseif ($i == 3) return sprintf($string, $var0, $var1, $var2, $var3);
|
||||
elseif ($i == 4) return sprintf($string, $var0, $var1, $var2, $var3, $var4);
|
||||
elseif ($i == 5) return sprintf($string, $var0, $var1, $var2, $var3, $var4, $var5);
|
||||
elseif ($i == 6) return sprintf($string, $var0, $var1, $var2, $var3, $var4, $var5, $var6);
|
||||
elseif ($i == 7) return sprintf($string, $var0, $var1, $var2, $var3, $var4, $var5, $var6, $var7);
|
||||
elseif ($i == 8) return sprintf($string, $var0, $var1, $var2, $var3, $var4, $var5, $var6, $var7, $var8);
|
||||
elseif ($i == 9) return sprintf($string, $var0, $var1, $var2, $var3, $var4, $var5, $var6, $var7, $var8, $var9);
|
||||
else return $string;
|
||||
if ($i == 0) {
|
||||
return sprintf($string, $var0);
|
||||
} elseif ($i == 1) {
|
||||
return sprintf($string, $var0, $var1);
|
||||
} elseif ($i == 2) {
|
||||
return sprintf($string, $var0, $var1, $var2);
|
||||
} elseif ($i == 3) {
|
||||
return sprintf($string, $var0, $var1, $var2, $var3);
|
||||
} elseif ($i == 4) {
|
||||
return sprintf($string, $var0, $var1, $var2, $var3, $var4);
|
||||
} elseif ($i == 5) {
|
||||
return sprintf($string, $var0, $var1, $var2, $var3, $var4, $var5);
|
||||
} elseif ($i == 6) {
|
||||
return sprintf($string, $var0, $var1, $var2, $var3, $var4, $var5, $var6);
|
||||
} elseif ($i == 7) {
|
||||
return sprintf($string, $var0, $var1, $var2, $var3, $var4, $var5, $var6, $var7);
|
||||
} elseif ($i == 8) {
|
||||
return sprintf($string, $var0, $var1, $var2, $var3, $var4, $var5, $var6, $var7, $var8);
|
||||
} elseif ($i == 9) {
|
||||
return sprintf($string, $var0, $var1, $var2, $var3, $var4, $var5, $var6, $var7, $var8, $var9);
|
||||
} else {
|
||||
return $string;
|
||||
}
|
||||
}
|
||||
|
||||
/* vim: set expandtab: */
|
||||
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -25,5 +25,3 @@ function smarty_modifier_string_format($string, $format)
|
|||
}
|
||||
|
||||
/* vim: set expandtab: */
|
||||
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -29,5 +29,3 @@ function smarty_modifier_strip($text, $replace = ' ')
|
|||
}
|
||||
|
||||
/* vim: set expandtab: */
|
||||
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -21,12 +21,11 @@
|
|||
*/
|
||||
function smarty_modifier_strip_tags($string, $replace_with_space = true)
|
||||
{
|
||||
if ($replace_with_space)
|
||||
if ($replace_with_space) {
|
||||
return preg_replace('!<[^>]*?>!', ' ', $string);
|
||||
else
|
||||
} else {
|
||||
return strip_tags($string);
|
||||
}
|
||||
}
|
||||
|
||||
/* vim: set expandtab: */
|
||||
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -25,5 +25,3 @@ function smarty_modifier_temps($secondes)
|
|||
}
|
||||
|
||||
/* vim: set expandtab: */
|
||||
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -24,18 +24,23 @@
|
|||
* @param boolean
|
||||
* @return string
|
||||
*/
|
||||
function smarty_modifier_truncate($string, $length = 80, $etc = '...',
|
||||
$break_words = false, $middle = false)
|
||||
{
|
||||
if ($length == 0)
|
||||
function smarty_modifier_truncate(
|
||||
$string,
|
||||
$length = 80,
|
||||
$etc = '...',
|
||||
$break_words = false,
|
||||
$middle = false
|
||||
) {
|
||||
if ($length == 0) {
|
||||
return '';
|
||||
}
|
||||
|
||||
if (strlen($string) > $length) {
|
||||
$length -= min($length, strlen($etc));
|
||||
if (!$break_words && !$middle) {
|
||||
$string = preg_replace('/\s+?(\S+)?$/', '', substr($string, 0, $length+1));
|
||||
}
|
||||
if(!$middle) {
|
||||
if (!$middle) {
|
||||
return substr($string, 0, $length) . $etc;
|
||||
} else {
|
||||
return substr($string, 0, $length/2) . $etc . substr($string, -$length/2);
|
||||
|
|
@ -46,5 +51,3 @@ function smarty_modifier_truncate($string, $length = 80, $etc = '...',
|
|||
}
|
||||
|
||||
/* vim: set expandtab: */
|
||||
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -21,11 +21,9 @@
|
|||
function smarty_modifier_ucfirst($chaine)
|
||||
{
|
||||
$chaineS = strtr($chaine, "áà âäãéèêëẽÃìîïĩóòôöõúùûüũýỳŷÿỹ", "ÃÃÃÃÃÃÃÃÃẼÃÃÃÃĨÃÃÃÃÃÃÃÃÃŨÃỲŶŸỸ");
|
||||
if ($chaineS[0].$chaineS[1] != $chaine[0].$chaine[1])
|
||||
if ($chaineS[0].$chaineS[1] != $chaine[0].$chaine[1]) {
|
||||
return $chaineS[0].$chaineS[1].substr($chaine, 2);
|
||||
else
|
||||
} else {
|
||||
return ucfirst($chaine);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -22,5 +22,3 @@ function smarty_modifier_upper($string)
|
|||
{
|
||||
return strtoupper($string);
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -21,9 +21,7 @@
|
|||
* @param boolean
|
||||
* @return string
|
||||
*/
|
||||
function smarty_modifier_wordwrap($string,$length=80,$break="\n",$cut=false)
|
||||
function smarty_modifier_wordwrap($string, $length=80, $break="\n", $cut=false)
|
||||
{
|
||||
return wordwrap($string,$length,$break,$cut);
|
||||
return wordwrap($string, $length, $break, $cut);
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -30,46 +30,55 @@ function smarty_outputfilter_trimwhitespace($source, &$smarty)
|
|||
// Pull out the script blocks
|
||||
preg_match_all("!<script[^>]*?>.*?</script>!is", $source, $match);
|
||||
$_script_blocks = $match[0];
|
||||
$source = preg_replace("!<script[^>]*?>.*?</script>!is",
|
||||
'@@@SMARTY:TRIM:SCRIPT@@@', $source);
|
||||
$source = preg_replace(
|
||||
"!<script[^>]*?>.*?</script>!is",
|
||||
'@@@SMARTY:TRIM:SCRIPT@@@',
|
||||
$source
|
||||
);
|
||||
|
||||
// Pull out the pre blocks
|
||||
preg_match_all("!<pre[^>]*?>.*?</pre>!is", $source, $match);
|
||||
$_pre_blocks = $match[0];
|
||||
$source = preg_replace("!<pre[^>]*?>.*?</pre>!is",
|
||||
'@@@SMARTY:TRIM:PRE@@@', $source);
|
||||
$source = preg_replace(
|
||||
"!<pre[^>]*?>.*?</pre>!is",
|
||||
'@@@SMARTY:TRIM:PRE@@@',
|
||||
$source
|
||||
);
|
||||
|
||||
// Pull out the textarea blocks
|
||||
preg_match_all("!<textarea[^>]*?>.*?</textarea>!is", $source, $match);
|
||||
$_textarea_blocks = $match[0];
|
||||
$source = preg_replace("!<textarea[^>]*?>.*?</textarea>!is",
|
||||
'@@@SMARTY:TRIM:TEXTAREA@@@', $source);
|
||||
$source = preg_replace(
|
||||
"!<textarea[^>]*?>.*?</textarea>!is",
|
||||
'@@@SMARTY:TRIM:TEXTAREA@@@',
|
||||
$source
|
||||
);
|
||||
|
||||
// remove all leading spaces, tabs and carriage returns NOT
|
||||
// preceeded by a php close tag.
|
||||
$source = trim(preg_replace('/((?<!\?>)\n)[\s]+/m', '\1', $source));
|
||||
|
||||
// replace textarea blocks
|
||||
smarty_outputfilter_trimwhitespace_replace("@@@SMARTY:TRIM:TEXTAREA@@@",$_textarea_blocks, $source);
|
||||
smarty_outputfilter_trimwhitespace_replace("@@@SMARTY:TRIM:TEXTAREA@@@", $_textarea_blocks, $source);
|
||||
|
||||
// replace pre blocks
|
||||
smarty_outputfilter_trimwhitespace_replace("@@@SMARTY:TRIM:PRE@@@",$_pre_blocks, $source);
|
||||
smarty_outputfilter_trimwhitespace_replace("@@@SMARTY:TRIM:PRE@@@", $_pre_blocks, $source);
|
||||
|
||||
// replace script blocks
|
||||
smarty_outputfilter_trimwhitespace_replace("@@@SMARTY:TRIM:SCRIPT@@@",$_script_blocks, $source);
|
||||
smarty_outputfilter_trimwhitespace_replace("@@@SMARTY:TRIM:SCRIPT@@@", $_script_blocks, $source);
|
||||
|
||||
return $source;
|
||||
}
|
||||
|
||||
function smarty_outputfilter_trimwhitespace_replace($search_str, $replace, &$subject) {
|
||||
function smarty_outputfilter_trimwhitespace_replace($search_str, $replace, &$subject)
|
||||
{
|
||||
$_len = strlen($search_str);
|
||||
$_pos = 0;
|
||||
for ($_i=0, $_count=count($replace); $_i<$_count; $_i++)
|
||||
if (($_pos=strpos($subject, $search_str, $_pos))!==false)
|
||||
for ($_i=0, $_count=count($replace); $_i<$_count; $_i++) {
|
||||
if (($_pos=strpos($subject, $search_str, $_pos))!==false) {
|
||||
$subject = substr_replace($subject, $replace[$_i], $_pos, $_len);
|
||||
else
|
||||
} else {
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@
|
|||
*/
|
||||
function smarty_function_escape_special_chars($string)
|
||||
{
|
||||
if(!is_array($string)) {
|
||||
if (!is_array($string)) {
|
||||
$string = preg_replace('!&(#?\w+);!', '%%%SMARTY_START%%%\\1%%%SMARTY_END%%%', $string);
|
||||
$string = htmlspecialchars($string);
|
||||
$string = str_replace(array('%%%SMARTY_START%%%','%%%SMARTY_END%%%'), array('&',';'), $string);
|
||||
|
|
@ -27,5 +27,3 @@ function smarty_function_escape_special_chars($string)
|
|||
}
|
||||
|
||||
/* vim: set expandtab: */
|
||||
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -16,19 +16,22 @@
|
|||
*/
|
||||
function smarty_make_timestamp($string)
|
||||
{
|
||||
if(empty($string)) {
|
||||
if (empty($string)) {
|
||||
// use "now":
|
||||
$time = time();
|
||||
|
||||
} elseif (preg_match('/^\d{14}$/', $string)) {
|
||||
// it is mysql timestamp format of YYYYMMDDHHMMSS?
|
||||
$time = 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));
|
||||
|
||||
// it is mysql timestamp format of YYYYMMDDHHMMSS?
|
||||
$time = 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)
|
||||
);
|
||||
} elseif (is_numeric($string)) {
|
||||
// it is a numeric string, we handle it as timestamp
|
||||
$time = (int)$string;
|
||||
|
||||
} else {
|
||||
// strtotime should handle it
|
||||
$time = strtotime($string);
|
||||
|
|
@ -38,9 +41,6 @@ function smarty_make_timestamp($string)
|
|||
}
|
||||
}
|
||||
return $time;
|
||||
|
||||
}
|
||||
|
||||
/* vim: set expandtab: */
|
||||
|
||||
?>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue