From fdaf025d3de7e8a43089ee067f5d5dabd35709dc Mon Sep 17 00:00:00 2001 From: SharakPL Date: Mon, 7 Aug 2023 09:58:05 +0200 Subject: [PATCH 1/3] order by type and and function --- config/smarty.config.inc.php | 65 ++++++++++++++++++------------------ 1 file changed, 33 insertions(+), 32 deletions(-) diff --git a/config/smarty.config.inc.php b/config/smarty.config.inc.php index 6fa40c63e7857..6723d88f5a999 100644 --- a/config/smarty.config.inc.php +++ b/config/smarty.config.inc.php @@ -81,56 +81,57 @@ function smartyEscape($string, $esc_type = 'html', $char_set = null, $double_enc } } -smartyRegisterFunction($smarty, 'modifier', 'escape', 'smartyEscape'); -smartyRegisterFunction($smarty, 'modifier', 'truncate', 'smarty_modifier_truncate'); -smartyRegisterFunction($smarty, 'function', 'l', 'smartyTranslate', false); -smartyRegisterFunction($smarty, 'function', 'hook', 'smartyHook'); -smartyRegisterFunction($smarty, 'modifier', 'json_encode', 'json_encode'); -smartyRegisterFunction($smarty, 'modifier', 'json_decode', 'json_decode'); smartyRegisterFunction($smarty, 'function', 'dateFormat', array('Tools', 'dateFormat')); +smartyRegisterFunction($smarty, 'function', 'hook', 'smartyHook'); +smartyRegisterFunction($smarty, 'function', 'l', 'smartyTranslate', false); +smartyRegisterFunction($smarty, 'function', 'url', array('Link', 'getUrlSmarty')); + smartyRegisterFunction($smarty, 'modifier', 'boolval', array('Tools', 'boolval')); -smartyRegisterFunction($smarty, 'modifier', 'cleanHtml', 'smartyCleanHtml'); smartyRegisterFunction($smarty, 'modifier', 'classname', 'smartyClassname'); smartyRegisterFunction($smarty, 'modifier', 'classnames', 'smartyClassnames'); -smartyRegisterFunction($smarty, 'function', 'url', array('Link', 'getUrlSmarty')); +smartyRegisterFunction($smarty, 'modifier', 'cleanHtml', 'smartyCleanHtml'); +smartyRegisterFunction($smarty, 'modifier', 'end', 'smarty_endWithoutReference'); +smartyRegisterFunction($smarty, 'modifier', 'escape', 'smartyEscape'); +smartyRegisterFunction($smarty, 'modifier', 'json_decode', 'json_decode'); +smartyRegisterFunction($smarty, 'modifier', 'json_encode', 'json_encode'); +smartyRegisterFunction($smarty, 'modifier', 'truncate', 'smarty_modifier_truncate'); // Native PHP Functions smartyRegisterFunction($smarty, 'modifier', 'addcslashes', 'addcslashes'); smartyRegisterFunction($smarty, 'modifier', 'addslashes', 'addslashes'); -smartyRegisterFunction($smarty, 'modifier', 'date','date'); -smartyRegisterFunction($smarty, 'modifier', 'end', 'smarty_endWithoutReference'); +smartyRegisterFunction($smarty, 'modifier', 'date', 'date'); +smartyRegisterFunction($smarty, 'modifier', 'date', 'date'); +smartyRegisterFunction($smarty, 'modifier', 'explode', 'explode'); +smartyRegisterFunction($smarty, 'modifier', 'floatval', 'floatval'); smartyRegisterFunction($smarty, 'modifier', 'floatval', 'floatval'); smartyRegisterFunction($smarty, 'modifier', 'htmlentities', 'htmlentities'); +smartyRegisterFunction($smarty, 'modifier', 'htmlspecialchars', 'htmlspecialchars'); +smartyRegisterFunction($smarty, 'modifier', 'implode', 'implode'); +smartyRegisterFunction($smarty, 'modifier', 'in_array', 'in_array'); +smartyRegisterFunction($smarty, 'modifier', 'in_array', 'in_array'); +smartyRegisterFunction($smarty, 'modifier', 'intval', 'intval'); smartyRegisterFunction($smarty, 'modifier', 'intval', 'intval'); smartyRegisterFunction($smarty, 'modifier', 'json_decode', 'json_decode'); smartyRegisterFunction($smarty, 'modifier', 'json_encode', 'json_encode'); -smartyRegisterFunction($smarty, 'modifier', 'mt_rand','mt_rand'); -smartyRegisterFunction($smarty, 'modifier', 'rand','rand'); -smartyRegisterFunction($smarty, 'modifier', 'strtolower','strtolower'); -smartyRegisterFunction($smarty, 'modifier', 'str_replace','str_replace'); -smartyRegisterFunction($smarty, 'modifier', 'strval','strval'); -smartyRegisterFunction($smarty, 'modifier', 'trim', 'trim'); -smartyRegisterFunction($smarty, 'modifier', 'ucfirst', 'ucfirst'); -smartyRegisterFunction($smarty, 'modifier', 'urlencode','urlencode'); -smartyRegisterFunction($smarty, 'modifier', 'htmlspecialchars','htmlspecialchars'); -smartyRegisterFunction($smarty, 'modifier', 'implode', 'implode'); -smartyRegisterFunction($smarty, 'modifier', 'explode', 'explode'); -smartyRegisterFunction($smarty, 'modifier', 'print_r', 'print_r'); -smartyRegisterFunction($smarty, 'modifier', 'var_dump', 'var_dump'); +smartyRegisterFunction($smarty, 'modifier', 'json_encode', 'json_encode'); smartyRegisterFunction($smarty, 'modifier', 'lcfirst', 'lcfirst'); +smartyRegisterFunction($smarty, 'modifier', 'md5', 'md5'); +smartyRegisterFunction($smarty, 'modifier', 'mt_rand', 'mt_rand'); +smartyRegisterFunction($smarty, 'modifier', 'mt_rand', 'mt_rand'); smartyRegisterFunction($smarty, 'modifier', 'nl2br', 'nl2br'); +smartyRegisterFunction($smarty, 'modifier', 'print_r', 'print_r'); +smartyRegisterFunction($smarty, 'modifier', 'rand', 'rand'); smartyRegisterFunction($smarty, 'modifier', 'sizeof', 'sizeof'); -smartyRegisterFunction($smarty, 'modifier', 'in_array', 'in_array'); +smartyRegisterFunction($smarty, 'modifier', 'str_replace', 'str_replace'); +smartyRegisterFunction($smarty, 'modifier', 'stripslashes', 'stripslashes'); +smartyRegisterFunction($smarty, 'modifier', 'strtolower', 'strtolower'); +smartyRegisterFunction($smarty, 'modifier', 'strval', 'strval'); smartyRegisterFunction($smarty, 'modifier', 'substr', 'substr'); -smartyRegisterFunction($smarty, 'modifier', 'intval', 'intval'); -smartyRegisterFunction($smarty, 'modifier', 'date', 'date'); smartyRegisterFunction($smarty, 'modifier', 'trim', 'trim'); -smartyRegisterFunction($smarty, 'modifier', 'json_encode', 'json_encode'); -smartyRegisterFunction($smarty, 'modifier', 'in_array', 'in_array'); -smartyRegisterFunction($smarty, 'modifier', 'stripslashes', 'stripslashes'); -smartyRegisterFunction($smarty, 'modifier', 'mt_rand', 'mt_rand'); -smartyRegisterFunction($smarty, 'modifier', 'md5', 'md5'); -smartyRegisterFunction($smarty, 'modifier', 'floatval', 'floatval'); +smartyRegisterFunction($smarty, 'modifier', 'trim', 'trim'); +smartyRegisterFunction($smarty, 'modifier', 'ucfirst', 'ucfirst'); +smartyRegisterFunction($smarty, 'modifier', 'urlencode', 'urlencode'); +smartyRegisterFunction($smarty, 'modifier', 'var_dump', 'var_dump'); function smarty_modifier_htmlentitiesUTF8($string) { From cdb0e351aeb210f9c3c1640ce7d822013a04bba5 Mon Sep 17 00:00:00 2001 From: SharakPL Date: Mon, 7 Aug 2023 10:02:04 +0200 Subject: [PATCH 2/3] remove duplications --- config/smarty.config.inc.php | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/config/smarty.config.inc.php b/config/smarty.config.inc.php index 6723d88f5a999..4793cb042fe95 100644 --- a/config/smarty.config.inc.php +++ b/config/smarty.config.inc.php @@ -81,6 +81,7 @@ function smartyEscape($string, $esc_type = 'html', $char_set = null, $double_enc } } +// PrestaShop & Smarty functions smartyRegisterFunction($smarty, 'function', 'dateFormat', array('Tools', 'dateFormat')); smartyRegisterFunction($smarty, 'function', 'hook', 'smartyHook'); smartyRegisterFunction($smarty, 'function', 'l', 'smartyTranslate', false); @@ -92,32 +93,24 @@ function smartyEscape($string, $esc_type = 'html', $char_set = null, $double_enc smartyRegisterFunction($smarty, 'modifier', 'cleanHtml', 'smartyCleanHtml'); smartyRegisterFunction($smarty, 'modifier', 'end', 'smarty_endWithoutReference'); smartyRegisterFunction($smarty, 'modifier', 'escape', 'smartyEscape'); -smartyRegisterFunction($smarty, 'modifier', 'json_decode', 'json_decode'); -smartyRegisterFunction($smarty, 'modifier', 'json_encode', 'json_encode'); smartyRegisterFunction($smarty, 'modifier', 'truncate', 'smarty_modifier_truncate'); -// Native PHP Functions +// Native PHP functions smartyRegisterFunction($smarty, 'modifier', 'addcslashes', 'addcslashes'); smartyRegisterFunction($smarty, 'modifier', 'addslashes', 'addslashes'); smartyRegisterFunction($smarty, 'modifier', 'date', 'date'); -smartyRegisterFunction($smarty, 'modifier', 'date', 'date'); smartyRegisterFunction($smarty, 'modifier', 'explode', 'explode'); smartyRegisterFunction($smarty, 'modifier', 'floatval', 'floatval'); -smartyRegisterFunction($smarty, 'modifier', 'floatval', 'floatval'); smartyRegisterFunction($smarty, 'modifier', 'htmlentities', 'htmlentities'); smartyRegisterFunction($smarty, 'modifier', 'htmlspecialchars', 'htmlspecialchars'); smartyRegisterFunction($smarty, 'modifier', 'implode', 'implode'); smartyRegisterFunction($smarty, 'modifier', 'in_array', 'in_array'); -smartyRegisterFunction($smarty, 'modifier', 'in_array', 'in_array'); -smartyRegisterFunction($smarty, 'modifier', 'intval', 'intval'); smartyRegisterFunction($smarty, 'modifier', 'intval', 'intval'); smartyRegisterFunction($smarty, 'modifier', 'json_decode', 'json_decode'); smartyRegisterFunction($smarty, 'modifier', 'json_encode', 'json_encode'); -smartyRegisterFunction($smarty, 'modifier', 'json_encode', 'json_encode'); smartyRegisterFunction($smarty, 'modifier', 'lcfirst', 'lcfirst'); smartyRegisterFunction($smarty, 'modifier', 'md5', 'md5'); smartyRegisterFunction($smarty, 'modifier', 'mt_rand', 'mt_rand'); -smartyRegisterFunction($smarty, 'modifier', 'mt_rand', 'mt_rand'); smartyRegisterFunction($smarty, 'modifier', 'nl2br', 'nl2br'); smartyRegisterFunction($smarty, 'modifier', 'print_r', 'print_r'); smartyRegisterFunction($smarty, 'modifier', 'rand', 'rand'); @@ -128,7 +121,6 @@ function smartyEscape($string, $esc_type = 'html', $char_set = null, $double_enc smartyRegisterFunction($smarty, 'modifier', 'strval', 'strval'); smartyRegisterFunction($smarty, 'modifier', 'substr', 'substr'); smartyRegisterFunction($smarty, 'modifier', 'trim', 'trim'); -smartyRegisterFunction($smarty, 'modifier', 'trim', 'trim'); smartyRegisterFunction($smarty, 'modifier', 'ucfirst', 'ucfirst'); smartyRegisterFunction($smarty, 'modifier', 'urlencode', 'urlencode'); smartyRegisterFunction($smarty, 'modifier', 'var_dump', 'var_dump'); From b20a790df021762152cef825ed37b9a41b4e05ea Mon Sep 17 00:00:00 2001 From: SharakPL Date: Mon, 7 Aug 2023 10:03:24 +0200 Subject: [PATCH 3/3] formatting --- config/smarty.config.inc.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/config/smarty.config.inc.php b/config/smarty.config.inc.php index 4793cb042fe95..bcba3c6c10505 100644 --- a/config/smarty.config.inc.php +++ b/config/smarty.config.inc.php @@ -34,19 +34,19 @@ } $smarty->setConfigDir([]); -$smarty->setCompileDir(_PS_CACHE_DIR_.'smarty/compile'); -$smarty->setCacheDir(_PS_CACHE_DIR_.'smarty/cache'); +$smarty->setCompileDir(_PS_CACHE_DIR_ . 'smarty/compile'); +$smarty->setCacheDir(_PS_CACHE_DIR_ . 'smarty/cache'); $smarty->use_sub_dirs = true; $smarty->caching = Smarty::CACHING_OFF; /* @phpstan-ignore-next-line */ if (_PS_SMARTY_CACHING_TYPE_ == 'mysql') { - include _PS_CLASS_DIR_.'Smarty/SmartyCacheResourceMysql.php'; + include _PS_CLASS_DIR_ . 'Smarty/SmartyCacheResourceMysql.php'; $smarty->caching_type = 'mysql'; } $smarty->force_compile = Configuration::get('PS_SMARTY_FORCE_COMPILE') == _PS_SMARTY_FORCE_COMPILE_; $smarty->compile_check = (Configuration::get('PS_SMARTY_FORCE_COMPILE') >= _PS_SMARTY_CHECK_COMPILE_) ? Smarty::COMPILECHECK_ON : Smarty::COMPILECHECK_OFF; -$smarty->debug_tpl = _PS_ALL_THEMES_DIR_.'debug.tpl'; +$smarty->debug_tpl = _PS_ALL_THEMES_DIR_ . 'debug.tpl'; /* Use this constant if you want to load smarty without all PrestaShop functions */ if (defined('_PS_SMARTY_FAST_LOAD_') && _PS_SMARTY_FAST_LOAD_) { @@ -54,12 +54,12 @@ } if (defined('_PS_ADMIN_DIR_')) { - require_once dirname(__FILE__).'/smartyadmin.config.inc.php'; + require_once dirname(__FILE__) . '/smartyadmin.config.inc.php'; } else { - require_once dirname(__FILE__).'/smartyfront.config.inc.php'; + require_once dirname(__FILE__) . '/smartyfront.config.inc.php'; } -require_once SMARTY_PLUGINS_DIR.'modifier.truncate.php'; +require_once SMARTY_PLUGINS_DIR . 'modifier.truncate.php'; // This escape modifier is required for invoice PDF generation function smartyEscape($string, $esc_type = 'html', $char_set = null, $double_encode = true) @@ -209,7 +209,7 @@ function smartyCleanHtml($data) function smartyClassname($classname) { $classname = Tools::replaceAccentedChars(strtolower($classname)); - $classname = preg_replace(['/[^A-Za-z0-9-_]/', '/-{3,}/', '/-+$/'], ['-', '-', ''] , $classname); + $classname = preg_replace(['/[^A-Za-z0-9-_]/', '/-{3,}/', '/-+$/'], ['-', '-', ''], $classname); return $classname; }