From bdbbdbb0eddd125bec167da5f42bbd95c770151f Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Tue, 16 Feb 2021 16:59:21 +0300 Subject: [PATCH] rework controls to accept parameters as array --- classes/feeds.php | 2 +- classes/pref/feeds.php | 15 ++++++------- classes/pref/filters.php | 8 +++---- classes/pref/prefs.php | 4 ++-- classes/pref/system.php | 2 +- include/controls.php | 47 +++++++++++++++++++++++++--------------- include/login_form.php | 3 ++- plugins/mail/init.php | 3 ++- 8 files changed, 49 insertions(+), 35 deletions(-) diff --git a/classes/feeds.php b/classes/feeds.php index 4e6fdbaf8..43c8bf584 100755 --- a/classes/feeds.php +++ b/classes/feeds.php @@ -608,7 +608,7 @@ class Feeds extends Handler_Protected { print "
"; print ""; print \Controls\select_tag("search_language", get_pref('DEFAULT_SEARCH_LANGUAGE'), Pref_Feeds::get_ts_languages(), - "title=\"".__('Used for word stemming')."\""); + ["title" => __('Used for word stemming')]); print "
"; } diff --git a/classes/pref/feeds.php b/classes/pref/feeds.php index 636f2d69b..ce2d321bd 100755 --- a/classes/pref/feeds.php +++ b/classes/pref/feeds.php @@ -644,8 +644,10 @@ class Pref_Feeds extends Handler_Protected { $local_purge_intervals = [ T_nsprintf('%d day', '%d days', $purge_interval, $purge_interval) ]; } - print \Controls\select_hash("purge_interval", $purge_interval, $local_purge_intervals, - ((FORCE_ARTICLE_PURGE == 0) ? "" : 'disabled="1"')); + print \Controls\select_hash("purge_interval", + $purge_interval, + $local_purge_intervals, + (FORCE_ARTICLE_PURGE == 0) ? [] : ["disabled" => 1]); print ""; @@ -815,8 +817,6 @@ class Pref_Feeds extends Handler_Protected { print_notice("Enable the options you wish to apply using checkboxes on the right:"); - print "

"; - print \Controls\hidden_tag("ids", "$feed_ids"); print \Controls\hidden_tag("op", "pref-feeds"); print \Controls\hidden_tag("method", "batchEditSave"); @@ -846,8 +846,7 @@ class Pref_Feeds extends Handler_Protected { print "

"; print " "; - print \Controls\select_tag("feed_language", "", $this::get_ts_languages(), - 'disabled="1"'); + print \Controls\select_tag("feed_language", "", $this::get_ts_languages(), ["disabled"=> 1]); $this->batch_edit_cbox("feed_language"); @@ -868,7 +867,7 @@ class Pref_Feeds extends Handler_Protected { $local_update_intervals = $update_intervals; $local_update_intervals[0] .= sprintf(" (%s)", $update_intervals[get_pref("DEFAULT_UPDATE_INTERVAL")]); - print \Controls\select_hash("update_interval", "", $local_update_intervals, 'disabled="1"'); + print \Controls\select_hash("update_interval", "", $local_update_intervals, ["disabled" => 1]); $this->batch_edit_cbox("update_interval"); @@ -890,7 +889,7 @@ class Pref_Feeds extends Handler_Protected { else $local_purge_intervals[0] .= " " . sprintf("(%s)", __("Disabled")); - print \Controls\select_hash("purge_interval", "", $local_purge_intervals, 'disabled="1"'); + print \Controls\select_hash("purge_interval", "", $local_purge_intervals, ["disabled" => 1]); $this->batch_edit_cbox("purge_interval"); diff --git a/classes/pref/filters.php b/classes/pref/filters.php index caefb1ea7..e9c58cc3e 100755 --- a/classes/pref/filters.php +++ b/classes/pref/filters.php @@ -894,7 +894,7 @@ class Pref_Filters extends Handler_Protected { dojoType='fox.form.Select'");*/ print \Controls\select_labels("action_param_label", $action_param, - "style=\"$label_param_hidden\"", + ["style" => $label_param_hidden], "filterDlg_actionParamLabel"); $filter_actions = PluginHost::getInstance()->get_filter_actions(); @@ -909,16 +909,16 @@ class Pref_Filters extends Handler_Protected { } if (count($filter_action_hash) == 0) { - $filter_plugin_disabled = "disabled"; + $filter_plugin_disabled = ["disabled" => "1"]; $filter_action_hash["no-data"] = __("No actions available"); } else { - $filter_plugin_disabled = ""; + $filter_plugin_disabled = []; } print \Controls\select_hash("action_param_plugin", $action_param, $filter_action_hash, - "style=\"$plugin_param_hidden\" $filter_plugin_disabled", + array_merge(["style" => $plugin_param_hidden], $filter_plugin_disabled), "filterDlg_actionParamPlugin"); print ""; diff --git a/classes/pref/prefs.php b/classes/pref/prefs.php index d8491995d..3bc8a9a9c 100644 --- a/classes/pref/prefs.php +++ b/classes/pref/prefs.php @@ -664,13 +664,13 @@ class Pref_Prefs extends Handler_Protected { if ($pref_name == "USER_LANGUAGE") { print \Controls\select_hash($pref_name, $value, get_translations(), - "style='width : 220px; margin : 0px'"); + ["style" => 'width : 220px; margin : 0px']); } else if ($pref_name == "USER_TIMEZONE") { $timezones = explode("\n", file_get_contents("lib/timezones.txt")); - print \Controls\select_tag($pref_name, $value, $timezones, 'dojoType="dijit.form.FilteringSelect"'); + print \Controls\select_tag($pref_name, $value, $timezones, ["dojoType" => "dijit.form.FilteringSelect"]); } else if ($pref_name == "BLACKLISTED_TAGS") { # TODO: other possible