Skip to content

Commit

Permalink
Merge pull request PrestaShop#33555 from SharakPL/smarty_config_patch
Browse files Browse the repository at this point in the history
Remove duplicates from smarty.config.inc.php
  • Loading branch information
Hlavtox authored Aug 7, 2023
2 parents 2d439ee + b20a790 commit b7c0ae1
Showing 1 changed file with 34 additions and 41 deletions.
75 changes: 34 additions & 41 deletions config/smarty.config.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,32 +34,32 @@
}

$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_) {
return;
}

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)
Expand All @@ -81,56 +81,49 @@ 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');
// PrestaShop & Smarty functions
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', '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', 'end', 'smarty_endWithoutReference');
smartyRegisterFunction($smarty, 'modifier', 'date', 'date');
smartyRegisterFunction($smarty, 'modifier', 'explode', 'explode');
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', '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', 'lcfirst', 'lcfirst');
smartyRegisterFunction($smarty, 'modifier', 'md5', 'md5');
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', 'ucfirst', 'ucfirst');
smartyRegisterFunction($smarty, 'modifier', 'urlencode', 'urlencode');
smartyRegisterFunction($smarty, 'modifier', 'var_dump', 'var_dump');

function smarty_modifier_htmlentitiesUTF8($string)
{
Expand Down Expand Up @@ -216,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;
}

Expand Down

0 comments on commit b7c0ae1

Please sign in to comment.