From 9f08ce329ea7aa16c152bc00c8d3094dbcdbc17e Mon Sep 17 00:00:00 2001 From: Alex Tselegidis Date: Tue, 18 Jan 2022 08:45:02 +0100 Subject: [PATCH] Replace direct use of variables inside views with the new "vars" helper method. --- application/helpers/config_helper.php | 28 +++++++ .../views/components/appointments_modal.php | 55 ++++++-------- .../views/components/backend_footer.php | 7 +- .../views/components/backend_header.php | 17 ++--- .../components/booking_cancellation_frame.php | 11 +-- .../views/components/booking_final_step.php | 8 +- .../views/components/booking_header.php | 8 +- .../views/components/booking_info_step.php | 75 +++++++------------ .../views/components/booking_time_step.php | 8 +- .../views/components/booking_type_step.php | 14 +--- .../views/components/cookie_notice_modal.php | 7 +- .../views/components/js_lang_script.php | 7 +- .../views/components/js_vars_script.php | 7 +- .../views/components/privacy_policy_modal.php | 8 +- .../components/terms_and_conditions_modal.php | 8 +- .../views/components/timezone_dropdown.php | 11 +-- .../components/unavailabilities_modal.php | 9 +-- .../views/emails/account_recovery_email.php | 16 +--- .../emails/appointment_deleted_email.php | 40 +++------- .../views/emails/appointment_saved_email.php | 28 +++---- application/views/layouts/account_layout.php | 7 -- application/views/layouts/backend_layout.php | 6 -- application/views/layouts/booking_layout.php | 28 +------ application/views/layouts/message_layout.php | 8 +- application/views/pages/about.php | 6 -- application/views/pages/admins.php | 7 -- application/views/pages/booking.php | 22 ------ .../views/pages/booking_cancellation.php | 10 --- application/views/pages/booking_message.php | 8 -- application/views/pages/calendar.php | 56 ++++---------- application/views/pages/categories.php | 7 -- application/views/pages/customers.php | 53 +++++-------- application/views/pages/legal_settings.php | 13 +--- application/views/pages/login.php | 7 -- application/views/pages/providers.php | 8 -- application/views/pages/secretaries.php | 8 -- application/views/pages/services.php | 7 -- application/views/pages/update.php | 11 +-- 38 files changed, 169 insertions(+), 475 deletions(-) diff --git a/application/helpers/config_helper.php b/application/helpers/config_helper.php index d29d6b69..a05c5abd 100644 --- a/application/helpers/config_helper.php +++ b/application/helpers/config_helper.php @@ -153,3 +153,31 @@ if ( ! function_exists('html_vars')) return $value ?? $default; } } + +if ( ! function_exists('vars')) +{ + /** + * Get / set the specified HTML & JS config value. + * + * If an array is passed as the key, we will assume you want to set an array of values. + * + * Example "Get": + * + * $version = vars('version', '1.0.0'); + * + * Example "Set": + * + * vars(['version' => '1.0.0']); + * + * @param array|string $key Configuration key. + * @param mixed $default Default value in case the requested config has no value. + * + * @return mixed|NULL Returns the requested value or NULL if you assign a new configuration value. + * + * @throws InvalidArgumentException + */ + function vars($key = NULL, $default = NULL) + { + return html_vars($key) ?? script_vars($key) ?? $default; + } +} diff --git a/application/views/components/appointments_modal.php b/application/views/components/appointments_modal.php index 950c2421..76933d05 100644 --- a/application/views/components/appointments_modal.php +++ b/application/views/components/appointments_modal.php @@ -1,16 +1,3 @@ -