From e873ade6c0a97fd2ff4b84783bf35baf465e36d3 Mon Sep 17 00:00:00 2001 From: Clemens Schwaighofer Date: Mon, 13 Mar 2023 09:15:59 +0900 Subject: [PATCH] Change the SmartyExtended Vars set calls to use options array Instead of having each parameter single, group them into an options array so we do not have to worry about updating the whole function call. Keep the main core call as is --- www/admin/class_test.smarty.php | 24 ++--- www/lib/CoreLibs/Template/SmartyExtend.php | 106 +++++++++------------ 2 files changed, 58 insertions(+), 72 deletions(-) diff --git a/www/admin/class_test.smarty.php b/www/admin/class_test.smarty.php index ba96eaa7..ebe095a4 100644 --- a/www/admin/class_test.smarty.php +++ b/www/admin/class_test.smarty.php @@ -135,17 +135,19 @@ $smarty->DATA['checkbox_test_pos_selected'] = ['0', '-1']; $smarty->setSmartyVarsAdmin( - BASE . TEMPLATES_C, - BASE . CACHE, - CSS, - FONT, - JS, - DEFAULT_ENCODING, - G_TITLE, - ADMIN_STYLESHEET, - ADMIN_JAVASCRIPT, - PAGE_WIDTH, - $_SESSION['USER_NAME'] ?? '' + [ + 'compile_dir' => BASE . TEMPLATES_C, + 'cache_dir' => BASE . CACHE, + 'js' => JS, + 'css' => CSS, + 'font' => FONT, + 'g_title' => G_TITLE, + 'default_encoding' => DEFAULT_ENCODING, + 'admin_stylesheet' => ADMIN_STYLESHEET, + 'admin_javascript' => ADMIN_JAVASCRIPT, + 'page_width' => PAGE_WIDTH, + 'user_name' => $_SESSION['USER_NAME'] ?? '' + ] ); // error message diff --git a/www/lib/CoreLibs/Template/SmartyExtend.php b/www/lib/CoreLibs/Template/SmartyExtend.php index a2a08010..f2fa74d3 100644 --- a/www/lib/CoreLibs/Template/SmartyExtend.php +++ b/www/lib/CoreLibs/Template/SmartyExtend.php @@ -452,96 +452,80 @@ class SmartyExtend extends \Smarty * wrapper call for setSmartyVars * this is for frontend type and will not set any only admin needed variables * - * @param string|null $compile_dir BASE . TEMPLATES_C - * @param string|null $cache_dir BASE . CACHE - * @param string|null $set_js JS - * @param string|null $set_css CSS - * @param string|null $set_font FONT - * @param string|null $set_default_encoding DEFAULT_ENCODING - * @param string|null $set_g_title G_TITLE - * @param string|null $set_stylesheet STYLESHEET - * @param string|null $set_javascript JAVASCRIPT + * @param array $options list with the following value: + * compile_dir :BASE . TEMPLATES_C + * cache_dir :BASE . CACHE + * js :JS + * css :CSS + * font :FONT + * default_encoding :DEFAULT_ENCODING + * g_title :G_TITLE + * stylesheet :STYLESHEET + * javascript :JAVASCRIPT * @param \CoreLibs\Admin\Backend|null $cms Optinal Admin Backend for * smarty variables merge * @return void */ public function setSmartyVarsFrontend( - ?string $compile_dir = null, - ?string $cache_dir = null, - ?string $set_js = null, - ?string $set_css = null, - ?string $set_font = null, - ?string $set_default_encoding = null, - ?string $set_g_title = null, - ?string $set_stylesheet = null, - ?string $set_javascript = null, - ?\CoreLibs\Admin\Backend $cms = null + array $options, + ?\CoreLibs\Admin\Backend $cms ): void { $this->setSmartyVars( false, $cms, - $compile_dir, - $cache_dir, - $set_js, - $set_css, - $set_font, - $set_default_encoding, - $set_g_title, + $options['compile_dir'] ?? null, + $options['cache_dir'] ?? null, + $options['js'] ?? null, + $options['css'] ?? null, + $options['font'] ?? null, + $options['default_encoding'] ?? null, + $options['g_title'] ?? null, null, null, null, null, - $set_stylesheet, - $set_javascript + $options['stylesheet'] ?? null, + $options['javascript'] ?? null ); } /** * wrapper call for setSmartyVars * this is only for admin interface and will set additional variables - * @param string|null $compile_dir BASE . TEMPLATES_C - * @param string|null $cache_dir BASE . CACHE - * @param string|null $set_js JS - * @param string|null $set_css CSS - * @param string|null $set_font FONT - * @param string|null $set_default_encoding DEFAULT_ENCODING - * @param string|null $set_g_title G_TITLE - * @param string|null $set_admin_stylesheet ADMIN_STYLESHEET - * @param string|null $set_admin_javascript ADMIN_JAVASCRIPT - * @param string|null $set_page_width PAGE_WIDTH - * @param string|null $set_user_name _SESSION['USER_NAME'] + * @param array $options list with the following value: + * compile_dir :BASE . TEMPLATES_C + * cache_dir :BASE . CACHE + * js :JS + * css :CSS + * font :FONT + * default_encoding :DEFAULT_ENCODING + * g_title :G_TITLE + * admin_stylesheet :ADMIN_STYLESHEET + * admin_javascript :ADMIN_JAVASCRIPT + * page_width :PAGE_WIDTH + * user_name :_SESSION['USER_NAME'] * @param \CoreLibs\Admin\Backend|null $cms Optinal Admin Backend for * smarty variables merge * @return void */ public function setSmartyVarsAdmin( - ?string $compile_dir = null, - ?string $cache_dir = null, - ?string $set_js = null, - ?string $set_css = null, - ?string $set_font = null, - ?string $set_default_encoding = null, - ?string $set_g_title = null, - ?string $set_admin_stylesheet = null, - ?string $set_admin_javascript = null, - ?string $set_page_width = null, - ?string $set_user_name = null, + array $options, ?\CoreLibs\Admin\Backend $cms = null ): void { $this->setSmartyVars( true, $cms, - $compile_dir, - $cache_dir, - $set_js, - $set_css, - $set_font, - $set_g_title, - $set_default_encoding, - $set_admin_stylesheet, - $set_admin_javascript, - $set_page_width, - $set_user_name, + $options['compile_dir'] ?? null, + $options['cache_dir'] ?? null, + $options['js'] ?? null, + $options['css'] ?? null, + $options['font'] ?? null, + $options['g_title'] ?? null, + $options['default_encoding'] ?? null, + $options['admin_stylesheet'] ?? null, + $options['admin_javascript'] ?? null, + $options['page_width'] ?? null, + $options['user_name'] ?? null, null, null );