From c0cd2346fd7fca7c1daa2c49c12523f2eb9bad7d Mon Sep 17 00:00:00 2001 From: Alex Tselegidis Date: Sun, 29 Mar 2020 14:05:34 +0200 Subject: [PATCH] Created new render helper for the timezone dropdown. --- application/config/autoload.php | 2 +- application/helpers/render_helper.php | 33 +++++++++++++++++++ .../views/partial/timezone_dropdown.php | 10 ++++++ 3 files changed, 44 insertions(+), 1 deletion(-) create mode 100644 application/helpers/render_helper.php create mode 100644 application/views/partial/timezone_dropdown.php diff --git a/application/config/autoload.php b/application/config/autoload.php index ac7826a6..00dbce27 100644 --- a/application/config/autoload.php +++ b/application/config/autoload.php @@ -65,7 +65,7 @@ $autoload['libraries'] = ['database']; | $autoload['helper'] = array('url', 'file'); */ -$autoload['helper'] = ['custom_exceptions', 'url', 'file', 'language', 'asset', 'config']; +$autoload['helper'] = ['custom_exceptions', 'url', 'file', 'language', 'asset', 'config', 'render']; /* diff --git a/application/helpers/render_helper.php b/application/helpers/render_helper.php new file mode 100644 index 00000000..bddbd394 --- /dev/null +++ b/application/helpers/render_helper.php @@ -0,0 +1,33 @@ + + * @copyright Copyright (c) 2013 - 2020, Alex Tselegidis + * @license http://opensource.org/licenses/GPL-3.0 - GPLv3 + * @link http://easyappointments.org + * @since v1.4.0 + * ---------------------------------------------------------------------------- */ + +/** + * Render the HTML output of a timezone dropdown element. + * + * @param string $attributes HTML element attributes of the dropdown. + * @return false|string + */ +function render_timezone_dropdown($attributes = '') +{ + $framework = get_instance(); + + $framework->load->model('timezones_model'); + + $timezones = $framework->timezones_model->to_grouped_array(); + + ob_start(); + + require __DIR__ . '/../views/partial/timezone_dropdown.php'; + + return ob_get_clean(); +} diff --git a/application/views/partial/timezone_dropdown.php b/application/views/partial/timezone_dropdown.php new file mode 100644 index 00000000..fc53d7f3 --- /dev/null +++ b/application/views/partial/timezone_dropdown.php @@ -0,0 +1,10 @@ +