From 481bd7610059cfa09282a03e1a9c8dbc213f4819 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Fri, 12 Feb 2021 21:51:32 +0300 Subject: pref helpers: move some methods to their own sections --- classes/pref/prefs.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'classes/pref/prefs.php') diff --git a/classes/pref/prefs.php b/classes/pref/prefs.php index d40dc87c0..cfe63ce85 100644 --- a/classes/pref/prefs.php +++ b/classes/pref/prefs.php @@ -715,7 +715,7 @@ class Pref_Prefs extends Handler_Protected { print ""; print " "; + onclick=\"Helpers.Prefs.customizeCSS()\">" . __('Customize') . ""; print " "; @@ -830,10 +830,10 @@ class Pref_Prefs extends Handler_Protected { "; - print " "; - print ""; print " "; @@ -968,7 +968,7 @@ class Pref_Prefs extends Handler_Protected { if (count($tmppluginhost->get_all($plugin)) > 0) { if (in_array($name, $system_enabled) || in_array($name, $user_enabled)) { print " "; } } -- cgit v1.2.3-54-g00ecf From 8e75551f95ec2ade517afce2afe76150d5ffda24 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Sun, 14 Feb 2021 11:29:38 +0300 Subject: pref prefs: split index into manageable chunks --- classes/pref/prefs.php | 837 +++++++++++++++++++++++++------------------------ 1 file changed, 435 insertions(+), 402 deletions(-) (limited to 'classes/pref/prefs.php') diff --git a/classes/pref/prefs.php b/classes/pref/prefs.php index cfe63ce85..a37ae99b5 100644 --- a/classes/pref/prefs.php +++ b/classes/pref/prefs.php @@ -4,6 +4,7 @@ class Pref_Prefs extends Handler_Protected { private $pref_help = []; private $pref_item_map = []; + private $pref_help_bottom = []; private $pref_blacklist = []; private $profile_blacklist = []; @@ -272,34 +273,7 @@ class Pref_Prefs extends Handler_Protected { echo __("Your preferences are now set to default values."); } - function index() { - - global $access_level_names; - - $_SESSION["prefs_op_result"] = ""; - - print "
"; - print "
person ".__('Personal data / Authentication')."\">"; - - print "
"; - print "
"; - - print "
"; - - print ""; + private function index_auth_personal() { $sth = $this->pdo->prepare("SELECT email,full_name,otp_enabled, access_level FROM ttrss_users @@ -311,179 +285,214 @@ class Pref_Prefs extends Handler_Protected { $full_name = htmlspecialchars($row["full_name"]); $otp_enabled = sql_bool_to_bool($row["otp_enabled"]); - print "
"; - print ""; - print ""; - print "
"; - - print "
"; - print ""; - print ""; - print "
"; - - if (!SINGLE_USER_MODE && !empty($_SESSION["hide_hello"])) { + ?> + - $access_level = $row["access_level"]; - print "
"; - print ""; - print $access_level_names[$access_level]; - print "
"; - } - - print_hidden("op", "pref-prefs"); - print_hidden("method", "changeemail"); - - print "
"; + + - print ""; - - print "
"; + + +
+ + +
+ +
+ + +
+ + +
+ + +
+ + +
+ + + + get_plugin($_SESSION["auth_module"]); } else { $authenticator = false; } - print "
"; + $otp_enabled = $this->is_otp_enabled(); if ($authenticator && method_exists($authenticator, "change_password")) { + ?> - print ""; + - print "
"; + - print ""; + const warn = $('default_pass_warning'); + if (warn) Element.hide(warn); + } - if ($otp_enabled) { - print_notice(__("Changing your current password will disable OTP.")); - } + new Effect.Appear('pwd_change_infobox'); + } + }); + this.reset(); + } + - print "
"; - print ""; - print ""; - print "
"; + - print "
"; - print ""; - print ""; - print "
"; +
+ + +
- print "
"; - print ""; - print ""; - print "
"; +
+ + +
- print_hidden("op", "pref-prefs"); - print_hidden("method", "changepassword"); +
+ + +
- print "
"; +
- print ""; + +
- print ""; + %s) does not provide an ability to set passwords.", $_SESSION["auth_module"])); } + } - print "
"; # content pane + private function index_auth_app_passwords() { + print_notice("You can create separate passwords for API clients. Using one is required if you enable OTP."); + ?> - print "
"; +
+ appPasswordList() ?> +
- print_notice("You can create separate passwords for API clients. Using one is required if you enable OTP."); +
- print "
"; - $this->appPasswordList(); - print "
"; + + + - print "
"; + " . - __('Generate new password') . " "; + private function is_otp_enabled() { + $sth = $this->pdo->prepare("SELECT otp_enabled FROM ttrss_users + WHERE id = ?"); + $sth->execute([$_SESSION["uid"]]); - print ""; + if ($row = $sth->fetch()) { + return sql_bool_to_bool($row["otp_enabled"]); + } - print "
"; # content pane + return false; + } - print "
"; + private function index_auth_2fa() { + $otp_enabled = $this->is_otp_enabled(); if ($_SESSION["auth_module"] == "auth_internal") { - if ($otp_enabled) { - print_warning("One time passwords are currently enabled. Enter your current password below to disable."); + ?> + +
+ + + + - print ""; - - print ""; - - print "
"; - print ""; - print ""; - print "
"; +
+ + +
- print_hidden("op", "pref-prefs"); - print_hidden("method", "otpdisable"); +
- print "
"; + - print ""; +
- print ""; + " . __("Scan the following code by the Authenticator application or copy the key manually") . ""; - $csrf_token_hash = sha1($_SESSION["csrf_token"]); print "otp qr-code"; } else { @@ -500,105 +508,86 @@ class Pref_Prefs extends Handler_Protected { print "

" . __("Use the following OTP key with a compatible Authenticator application") . "

"; } - print "
"; - $otp_secret = $this->otpsecret(); + ?> + + + + + + +
+ + +
+ + - print "
"; - print ""; - print ""; - print "
"; - - print_hidden("op", "pref-prefs"); - print_hidden("method", "otpenable"); - - print ""; - - print "
"; - print ""; - print ""; - print "
"; +
+ + +
- print "
"; - print ""; - print ""; - print "
"; +
+ + +
- print "
"; - print ""; +
- print "
"; + + + auth_internal authentication module."); } + } - print "
"; # content pane - - print "
"; # tab container - - PluginHost::getInstance()->run_hooks(PluginHost::HOOK_PREFS_TAB_SECTION, "prefPrefsAuth"); - - print "
"; #pane - - print "
settings ".__('Preferences')."\">"; - - print "
"; - - print ""; - - print '
'; - - print '
'; + private function index_auth() { + ?> +
+
+ index_auth_personal() ?> +
+
+ index_auth_password() ?> +
+
+ index_auth_app_passwords() ?> +
+
+ index_auth_2fa() ?> +
+
+ initialize_user_prefs($_SESSION["uid"], $profile); } else { $this->initialize_user_prefs($_SESSION["uid"]); @@ -660,7 +649,9 @@ class Pref_Prefs extends Handler_Protected { continue; } - if (isset($prefs_available[$pref_name]) &&$item = $prefs_available[$pref_name]) { + if (isset($prefs_available[$pref_name])) { + + $item = $prefs_available[$pref_name]; print "
"; @@ -735,16 +726,16 @@ class Pref_Prefs extends Handler_Protected { array_push($listed_boolean_prefs, $pref_name); - $checked = ($value == "true") ? "checked=\"checked\"" : ""; + $is_checked = ($value == "true") ? "checked=\"checked\"" : ""; if ($pref_name == "PURGE_UNREAD_ARTICLES" && FORCE_ARTICLE_PURGE != 0) { - $disabled = "disabled=\"1\""; - $checked = "checked=\"checked\""; + $is_disabled = "disabled=\"1\""; + $is_checked = "checked=\"checked\""; } else { - $disabled = ""; + $is_disabled = ""; } - print ""; } else if (in_array($pref_name, ['FRESH_ARTICLE_MAX_AGE', @@ -753,19 +744,19 @@ class Pref_Prefs extends Handler_Protected { $regexp = ($type_name == 'integer') ? 'regexp="^\d*$"' : ''; if ($pref_name == "PURGE_OLD_DAYS" && FORCE_ARTICLE_PURGE != 0) { - $disabled = "disabled='1'"; + $is_disabled = "disabled='1'"; $value = FORCE_ARTICLE_PURGE; } else { - $disabled = ""; + $is_disabled = ""; } if ($type_name == 'integer') print ""; else print ""; } else if ($pref_name == "SSL_CERT_SERIAL") { @@ -808,204 +799,246 @@ class Pref_Prefs extends Handler_Protected { } } } + print_hidden("boolean_prefs", htmlspecialchars(join(",", $listed_boolean_prefs))); + } - $listed_boolean_prefs = htmlspecialchars(join(",", $listed_boolean_prefs)); - - print_hidden("boolean_prefs", "$listed_boolean_prefs"); - - PluginHost::getInstance()->run_hooks(PluginHost::HOOK_PREFS_TAB_SECTION, "prefPrefsPrefsInside"); - - print '
'; # inside pane - print '
'; - - print_hidden("op", "pref-prefs"); - print_hidden("method", "saveconfig"); + private function index_prefs() { + ?> + + + + + +
+
+ index_prefs_list() ?> + run_hooks(PluginHost::HOOK_PREFS_TAB_SECTION, "prefPrefsPrefsInside") ?> +
+
+ +
+ +
+
+ +
+
+
+ + + + + + run_hooks(PluginHost::HOOK_PREFS_TAB_SECTION, "prefPrefsPrefsOutside") ?> +
-
"; - - print " "; - - print ""; - - print " "; - - PluginHost::getInstance()->run_hooks(PluginHost::HOOK_PREFS_TAB_SECTION, "prefPrefsPrefsOutside"); - - print ""; - print '
'; # inner pane - print '
'; # border container - - print "
"; #pane - - print "
extension ".__('Plugins')."\">"; - - print "
"; - - print ""; - - print_hidden("op", "pref-prefs"); - print_hidden("method", "setplugins"); - - print '
'; - print '
'; - - if (ini_get("open_basedir") && function_exists("curl_init") && !defined("NO_CURL")) { - print_warning("Your PHP configuration has open_basedir restrictions enabled. Some plugins relying on CURL for functionality may not work correctly."); - } - - if ($_SESSION["safe_mode"]) { - print_error("You have logged in using safe mode, no user plugins will be actually enabled until you login again."); - } - - $feed_handler_whitelist = [ "Af_Comics" ]; - - $feed_handlers = array_merge( - PluginHost::getInstance()->get_hooks(PluginHost::HOOK_FEED_FETCHED), - PluginHost::getInstance()->get_hooks(PluginHost::HOOK_FEED_PARSED), - PluginHost::getInstance()->get_hooks(PluginHost::HOOK_FETCH_FEED)); - - $feed_handlers = array_filter($feed_handlers, function($plugin) use ($feed_handler_whitelist) { - return in_array(get_class($plugin), $feed_handler_whitelist) === false; }); - - if (count($feed_handlers) > 0) { - print_error( - T_sprintf("The following plugins use per-feed content hooks. This may cause excessive data usage and origin server load resulting in a ban of your instance: %s" , - implode(", ", array_map(function($plugin) { return get_class($plugin); }, $feed_handlers)) - ) . " (".__("More info...").")" - ); - } + + ".__("System plugins").""; + private function index_plugins_system() { print_notice("System plugins are enabled in config.php for all users."); - $system_enabled = array_map("trim", explode(",", PLUGINS)); - $user_enabled = array_map("trim", explode(",", get_pref("_ENABLED_PLUGINS"))); + $system_enabled = array_map("trim", explode(",", (string)PLUGINS)); $tmppluginhost = new PluginHost(); $tmppluginhost->load_all($tmppluginhost::KIND_ALL, $_SESSION["uid"], true); - //$tmppluginhost->load_data(true); foreach ($tmppluginhost->get_plugins() as $name => $plugin) { $about = $plugin->about(); if ($about[3] ?? false) { - if (in_array($name, $system_enabled)) { - $checked = "checked='1'"; - } else { - $checked = ""; - } - - print "
- - "; - - if ($about[4] ?? false) { - print ""; - } - - print "
". - htmlspecialchars(T_sprintf("v%.2f, by %s", $about[0], $about[2])). - "
"; - - print "
"; - + $is_checked = in_array($name, $system_enabled) ? "checked" : ""; + ?> +
+ + + + + + + +
+ +
+
+ ".__("User plugins").""; + private function index_plugins_user() { + $system_enabled = array_map("trim", explode(",", (string)PLUGINS)); + $user_enabled = array_map("trim", explode(",", get_pref("_ENABLED_PLUGINS"))); + + $tmppluginhost = new PluginHost(); + $tmppluginhost->load_all($tmppluginhost::KIND_ALL, $_SESSION["uid"], true); foreach ($tmppluginhost->get_plugins() as $name => $plugin) { $about = $plugin->about(); if (empty($about[3]) || $about[3] == false) { - $checked = ""; - $disabled = ""; + $is_checked = ""; + $is_disabled = ""; if (in_array($name, $system_enabled)) { - $checked = "checked='1'"; - $disabled = "disabled='1'"; + $is_checked = "checked='1'"; + $is_disabled = "disabled='1'"; } else if (in_array($name, $user_enabled)) { - $checked = "checked='1'"; + $is_checked = "checked='1'"; } - print "
- - "; - - if (count($tmppluginhost->get_all($plugin)) > 0) { - if (in_array($name, $system_enabled) || in_array($name, $user_enabled)) { - print " "; - } - } + ?> + +
+ + + + get_all($plugin)) > 0) { + if (in_array($name, $system_enabled) || in_array($name, $user_enabled)) { ?> + + + + + + + +
+ +
+ +
+ - open_in_new ".__("More info...").""; + private function index_plugins() { + ?> +
+ - print "
". - htmlspecialchars(T_sprintf("v%.2f, by %s", $about[0], $about[2])). - "
"; + + - print "
"; - } - } +
+
+ "; #content-pane - print '
'; + $feed_handler_whitelist = [ "Af_Comics" ]; - print ""; + $feed_handlers = array_merge( + PluginHost::getInstance()->get_hooks(PluginHost::HOOK_FEED_FETCHED), + PluginHost::getInstance()->get_hooks(PluginHost::HOOK_FEED_PARSED), + PluginHost::getInstance()->get_hooks(PluginHost::HOOK_FETCH_FEED)); - print ""; - print "
"; #pane + $feed_handlers = array_filter($feed_handlers, function($plugin) use ($feed_handler_whitelist) { + return in_array(get_class($plugin), $feed_handler_whitelist) === false; }); - print "
"; #pane - print "
"; #border-container + if (count($feed_handlers) > 0) { + print_error( + T_sprintf("The following plugins use per-feed content hooks. This may cause excessive data usage and origin server load resulting in a ban of your instance: %s" , + implode(", ", array_map(function($plugin) { return get_class($plugin); }, $feed_handlers)) + ) . " (".__("More info...").")" + ); + } + ?> - print ""; +

+ + index_plugins_system() ?> - PluginHost::getInstance()->run_hooks(PluginHost::HOOK_PREFS_TAB, "prefPrefs"); +

- print "
"; #container + index_plugins_user() ?> +
+
+ + +
+
+ + +
+
+ index_auth() ?> +
+
+ index_prefs() ?> +
+
+ index_plugins() ?> +
+ run_hooks(PluginHost::HOOK_PREFS_TAB, "prefPrefs") ?> +
+ Date: Sun, 14 Feb 2021 11:39:26 +0300 Subject: appPasswordList: markup cleanup --- classes/pref/prefs.php | 90 ++++++++++++++++++++++++-------------------------- 1 file changed, 44 insertions(+), 46 deletions(-) (limited to 'classes/pref/prefs.php') diff --git a/classes/pref/prefs.php b/classes/pref/prefs.php index a37ae99b5..ec7fbf607 100644 --- a/classes/pref/prefs.php +++ b/classes/pref/prefs.php @@ -1317,53 +1317,51 @@ class Pref_Prefs extends Handler_Protected { } private function appPasswordList() { - print "
"; - print "
" . - "" . __('Select') . ""; - print "
"; - print "
" . __('All') . "
"; - print "
" . __('None') . "
"; - print "
"; - print "
"; #toolbar - - print "
"; - print ""; - print ""; - print ""; - print ""; - print ""; - print ""; - print ""; - - $sth = $this->pdo->prepare("SELECT id, title, created, last_used - FROM ttrss_app_passwords WHERE owner_uid = ?"); - $sth->execute([$_SESSION['uid']]); - - while ($row = $sth->fetch()) { - - $row_id = $row["id"]; - - print ""; - - print ""; - print ""; - - print ""; - - print ""; - - print ""; - } + ?> +
+
+ +
+
+
+
+
+
- print "
".__("Description")."".__("Created")."".__("Last used")."
- " . htmlspecialchars($row["title"]) . ""; - print TimeHelper::make_local_datetime($row['created'], false); - print ""; - print TimeHelper::make_local_datetime($row['last_used'], false); - print "
"; - print "
"; +
+ + + + + + + + pdo->prepare("SELECT id, title, created, last_used + FROM ttrss_app_passwords WHERE owner_uid = ?"); + $sth->execute([$_SESSION['uid']]); + + while ($row = $sth->fetch()) { ?> + '> + + + + + + +
+ + + + + + + +
+
+ Date: Sun, 14 Feb 2021 12:25:41 +0300 Subject: pref prefs: load secondary tabs when needed --- classes/pref/prefs.php | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) (limited to 'classes/pref/prefs.php') diff --git a/classes/pref/prefs.php b/classes/pref/prefs.php index ec7fbf607..19f5221eb 100644 --- a/classes/pref/prefs.php +++ b/classes/pref/prefs.php @@ -564,7 +564,7 @@ class Pref_Prefs extends Handler_Protected { } } - private function index_auth() { + function index_auth() { ?>
@@ -953,7 +953,7 @@ class Pref_Prefs extends Handler_Protected { } } - private function index_plugins() { + function index_plugins() { ?>
+
index_prefs() ?>
- index_plugins() ?> + +
run_hooks(PluginHost::HOOK_PREFS_TAB, "prefPrefs") ?>
-- cgit v1.2.3-54-g00ecf From 1c7e4782aa426dd1a003948756c51cf9d61f2163 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Sun, 14 Feb 2021 12:29:08 +0300 Subject: prefs system: load phpinfo using inline method --- classes/pref/prefs.php | 2 -- classes/pref/system.php | 13 +++++++++---- js/PrefHelpers.js | 6 +----- 3 files changed, 10 insertions(+), 11 deletions(-) (limited to 'classes/pref/prefs.php') diff --git a/classes/pref/prefs.php b/classes/pref/prefs.php index 19f5221eb..6e4deb223 100644 --- a/classes/pref/prefs.php +++ b/classes/pref/prefs.php @@ -1032,7 +1032,6 @@ class Pref_Prefs extends Handler_Protected { if (this.domNode.querySelector('.loading')) window.setTimeout(() => { xhrPost("backend.php", {op: 'pref-prefs', method: 'index_auth'}, (transport) => { - console.log(this); this.attr('content', transport.responseText); }); }, 100); @@ -1047,7 +1046,6 @@ class Pref_Prefs extends Handler_Protected { if (this.domNode.querySelector('.loading')) window.setTimeout(() => { xhrPost("backend.php", {op: 'pref-prefs', method: 'index_plugins'}, (transport) => { - console.log(this); this.attr('content', transport.responseText); }); }, 200); diff --git a/classes/pref/system.php b/classes/pref/system.php index 1adddf116..14df6f8d1 100644 --- a/classes/pref/system.php +++ b/classes/pref/system.php @@ -173,10 +173,15 @@ class Pref_System extends Handler_Protected {
'> - -
+ +
run_hooks(PluginHost::HOOK_PREFS_TAB, "prefSystem") ?> diff --git a/js/PrefHelpers.js b/js/PrefHelpers.js index b09beb995..7a3d38d02 100644 --- a/js/PrefHelpers.js +++ b/js/PrefHelpers.js @@ -54,11 +54,7 @@ const Helpers = { }, }, System: { - getPHPInfo: function(widget) { - xhrPost("backend.php", {op: 'pref-system', method: 'getphpinfo'}, (transport) => { - widget.attr('content', transport.responseText); - }); - } + // }, EventLog: { log_page: 0, -- cgit v1.2.3-54-g00ecf From 8e79f1717d5270558ffd30c20cc75840b0ecc955 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Mon, 15 Feb 2021 16:07:22 +0300 Subject: prefs: unify naming --- classes/handler/public.php | 2 +- classes/pref/filters.php | 32 ++++++++++++++++---------------- classes/pref/prefs.php | 20 ++++++++++---------- classes/pref/system.php | 4 ++-- classes/pref/users.php | 8 ++++---- classes/rpc.php | 2 +- classes/userhelper.php | 4 ++-- 7 files changed, 36 insertions(+), 36 deletions(-) (limited to 'classes/pref/prefs.php') diff --git a/classes/handler/public.php b/classes/handler/public.php index b11c8ba04..ea2a0c5ef 100755 --- a/classes/handler/public.php +++ b/classes/handler/public.php @@ -950,7 +950,7 @@ class Handler_Public extends Handler { WHERE id = ?"); $sth->execute([$id]); - Pref_Users::resetUserPassword($id, true); + Pref_Users::_reset_password($id, true); print "

"."Completed."."

"; diff --git a/classes/pref/filters.php b/classes/pref/filters.php index 62bcb8f59..95f0fcfc0 100755 --- a/classes/pref/filters.php +++ b/classes/pref/filters.php @@ -162,7 +162,7 @@ class Pref_Filters extends Handler_Protected { print json_encode($rv); } - private function getfilterrules_list($filter_id) { + private function _get_rules_list($filter_id) { $sth = $this->pdo->prepare("SELECT reg_exp, inverse, match_on, @@ -250,7 +250,7 @@ class Pref_Filters extends Handler_Protected { while ($line = $sth->fetch()) { - $name = $this->getFilterName($line["id"]); + $name = $this->_get_name($line["id"]); $match_ok = false; if ($filter_search) { @@ -292,7 +292,7 @@ class Pref_Filters extends Handler_Protected { $filter['checkbox'] = false; $filter['last_triggered'] = $line["last_triggered"] ? TimeHelper::make_local_datetime($line["last_triggered"], false) : null; $filter['enabled'] = sql_bool_to_bool($line["enabled"]); - $filter['rules'] = $this->getfilterrules_list($line['id']); + $filter['rules'] = $this->_get_rules_list($line['id']); if (!$filter_search || $match_ok) { array_push($folder['items'], $filter); @@ -391,7 +391,7 @@ class Pref_Filters extends Handler_Protected { $data = htmlspecialchars((string)json_encode($line)); print "
  • - ".$this->getRuleName($line)."". + ".$this->_get_rule_name($line)."". format_hidden("rule[]", $data)."
  • "; } } @@ -433,7 +433,7 @@ class Pref_Filters extends Handler_Protected { $data = htmlspecialchars((string)json_encode($line)); print "
  • - ".$this->getActionName($line)."". + ".$this->_get_action_name($line)."". format_hidden("action[]", $data)."
  • "; } } @@ -482,7 +482,7 @@ class Pref_Filters extends Handler_Protected { } } - private function getRuleName($rule) { + private function _get_rule_name($rule) { if (!$rule) $rule = json_decode(clean($_REQUEST["rule"]), true); $feeds = $rule["feed_id"]; @@ -523,10 +523,10 @@ class Pref_Filters extends Handler_Protected { } function printRuleName() { - print $this->getRuleName(json_decode(clean($_REQUEST["rule"]), true)); + print $this->_get_rule_name(json_decode(clean($_REQUEST["rule"]), true)); } - private function getActionName($action) { + private function _get_action_name($action) { $sth = $this->pdo->prepare("SELECT description FROM ttrss_filter_actions WHERE id = ?"); $sth->execute([(int)$action["action_id"]]); @@ -561,7 +561,7 @@ class Pref_Filters extends Handler_Protected { } function printActionName() { - print $this->getActionName(json_decode(clean($_REQUEST["action"]), true)); + print $this->_get_action_name(json_decode(clean($_REQUEST["action"]), true)); } function editSave() { @@ -581,7 +581,7 @@ class Pref_Filters extends Handler_Protected { $sth->execute([$enabled, $match_any_rule, $inverse, $title, $filter_id, $_SESSION['uid']]); - $this->saveRulesAndActions($filter_id); + $this->_save_rules_and_actions($filter_id); $this->pdo->commit(); } @@ -596,7 +596,7 @@ class Pref_Filters extends Handler_Protected { $sth->execute(array_merge($ids, [$_SESSION['uid']])); } - private function saveRulesAndActions($filter_id) + private function _save_rules_and_actions($filter_id) { $sth = $this->pdo->prepare("DELETE FROM ttrss_filters2_rules WHERE filter_id = ?"); @@ -696,7 +696,7 @@ class Pref_Filters extends Handler_Protected { if ($row = $sth->fetch()) { $filter_id = $row['id']; - $this->saveRulesAndActions($filter_id); + $this->_save_rules_and_actions($filter_id); } $this->pdo->commit(); @@ -941,7 +941,7 @@ class Pref_Filters extends Handler_Protected { print ""; } - private function getFilterName($id) { + private function _get_name($id) { $sth = $this->pdo->prepare( "SELECT title,match_any_rule,f.inverse AS inverse,COUNT(DISTINCT r.id) AS num_rules,COUNT(DISTINCT a.id) AS num_actions @@ -970,7 +970,7 @@ class Pref_Filters extends Handler_Protected { $actions = ""; if ($line = $sth->fetch()) { - $actions = $this->getActionName($line); + $actions = $this->_get_action_name($line); $num_actions -= 1; } @@ -1012,12 +1012,12 @@ class Pref_Filters extends Handler_Protected { $this->pdo->commit(); - $this->optimizeFilter($base_id); + $this->_optimize($base_id); } } - private function optimizeFilter($id) { + private function _optimize($id) { $this->pdo->beginTransaction(); diff --git a/classes/pref/prefs.php b/classes/pref/prefs.php index 6e4deb223..81b7767eb 100644 --- a/classes/pref/prefs.php +++ b/classes/pref/prefs.php @@ -268,7 +268,7 @@ class Pref_Prefs extends Handler_Protected { AND owner_uid = :uid"); $sth->execute([":profile" => $_SESSION['profile'], ":uid" => $_SESSION['uid']]); - $this->initialize_user_prefs($_SESSION["uid"], $_SESSION["profile"]); + $this->_init_user_prefs($_SESSION["uid"], $_SESSION["profile"]); echo __("Your preferences are now set to default values."); } @@ -588,9 +588,9 @@ class Pref_Prefs extends Handler_Protected { if ($profile) { print_notice(__("Some preferences are only available in default profile.")); - $this->initialize_user_prefs($_SESSION["uid"], $profile); + $this->_init_user_prefs($_SESSION["uid"], $profile); } else { - $this->initialize_user_prefs($_SESSION["uid"]); + $this->_init_user_prefs($_SESSION["uid"]); } $prefs_available = []; @@ -621,7 +621,7 @@ class Pref_Prefs extends Handler_Protected { } $pref_name = $line["pref_name"]; - $short_desc = $this->getShortDesc($pref_name); + $short_desc = $this->_get_short_desc($pref_name); if (!$short_desc) continue; @@ -629,7 +629,7 @@ class Pref_Prefs extends Handler_Protected { $prefs_available[$pref_name] = [ 'type_name' => $line["type_name"], 'value' => $line['value'], - 'help_text' => $this->getHelpText($pref_name), + 'help_text' => $this->_get_help_text($pref_name), 'short_desc' => $short_desc ]; } @@ -1318,14 +1318,14 @@ class Pref_Prefs extends Handler_Protected { } - private function getShortDesc($pref_name) { + private function _get_short_desc($pref_name) { if (isset($this->pref_help[$pref_name][0])) { return $this->pref_help[$pref_name][0]; } return ""; } - private function getHelpText($pref_name) { + private function _get_help_text($pref_name) { if (isset($this->pref_help[$pref_name][1])) { return $this->pref_help[$pref_name][1]; } @@ -1380,7 +1380,7 @@ class Pref_Prefs extends Handler_Protected { encryptAppPassword($new_password); + $new_password_hash = $this->_encrypt_app_password($new_password); print_warning(T_sprintf("Generated password %s for %s. Please remember it for future reference.", $new_password, $title)); @@ -1413,7 +1413,7 @@ class Pref_Prefs extends Handler_Protected { $this->appPasswordList(); } - static function initialize_user_prefs($uid, $profile = false) { + static function _init_user_prefs($uid, $profile = false) { if (get_schema_version() < 63) $profile_qpart = ""; diff --git a/classes/pref/system.php b/classes/pref/system.php index 2a97ec6f0..f0a5f7b7f 100644 --- a/classes/pref/system.php +++ b/classes/pref/system.php @@ -23,7 +23,7 @@ class Pref_System extends Handler_Administrative { print preg_replace( '%^.*(.*).*$%ms','$1', (string)$info); } - private function log_viewer(int $page, int $severity) { + private function _log_viewer(int $page, int $severity) { $errno_values = []; switch ($severity) { @@ -154,7 +154,7 @@ class Pref_System extends Handler_Administrative {
    '> log_viewer($page, $severity); + $this->_log_viewer($page, $severity); } else { print_notice("Please set LOG_DESTINATION to 'sql' in config.php to enable database logging."); } diff --git a/classes/pref/users.php b/classes/pref/users.php index bc125d0ce..d2dd06fd8 100644 --- a/classes/pref/users.php +++ b/classes/pref/users.php @@ -166,7 +166,7 @@ class Pref_Users extends Handler_Administrative { } } - static function resetUserPassword($uid, $format_output = false) { + static function _reset_password($uid, $format_output = false) { $pdo = Db::pdo(); @@ -199,7 +199,7 @@ class Pref_Users extends Handler_Administrative { function resetPass() { $uid = clean($_REQUEST["id"]); - self::resetUserPassword($uid); + self::_reset_password($uid); } function index() { @@ -220,7 +220,7 @@ class Pref_Users extends Handler_Administrative { $sort = "login"; } - $sort = $this->validate_field($sort, + $sort = $this->_validate_field($sort, ["login", "access_level", "created", "num_feeds", "created", "last_login"], "login"); if ($sort != "login") $sort = "$sort DESC"; @@ -314,7 +314,7 @@ class Pref_Users extends Handler_Administrative { Date: Tue, 16 Feb 2021 14:23:00 +0300 Subject: add namespaced controls with unified naming; deprecated old-style control shortcuts --- classes/feeds.php | 22 ++- classes/handler/public.php | 4 +- classes/pref/feeds.php | 27 ++-- classes/pref/filters.php | 21 +-- classes/pref/prefs.php | 41 +++-- classes/pref/system.php | 4 +- include/controls.php | 383 +++++++++++--------------------------------- include/controls_compat.php | 312 ++++++++++++++++++++++++++++++++++++ include/functions.php | 1 + include/login_form.php | 2 +- plugins/mail/init.php | 2 +- 11 files changed, 470 insertions(+), 349 deletions(-) create mode 100644 include/controls_compat.php (limited to 'classes/pref/prefs.php') diff --git a/classes/feeds.php b/classes/feeds.php index f3ce1e48b..aa1f889e0 100755 --- a/classes/feeds.php +++ b/classes/feeds.php @@ -583,7 +583,7 @@ class Feeds extends Handler_Protected { function subscribeToFeed() { print json_encode([ - "cat_select" => format_feed_cat_select("cat", false, 'dojoType="fox.form.Select"') + "cat_select" => \Controls\select_feeds_cats("cat") ]); } @@ -607,8 +607,8 @@ class Feeds extends Handler_Protected { if (DB_TYPE == "pgsql") { print "
    "; print ""; - print_select("search_language", get_pref('DEFAULT_SEARCH_LANGUAGE'), Pref_Feeds::get_ts_languages(), - "dojoType='fox.form.Select' title=\"".__('Used for word stemming')."\""); + print \Controls\select_tag("search_language", get_pref('DEFAULT_SEARCH_LANGUAGE'), Pref_Feeds::get_ts_languages(), + "title=\"".__('Used for word stemming')."\""); print "
    "; } @@ -668,6 +668,15 @@ class Feeds extends Handler_Protected { display : none; } + - - + +
    diff --git a/classes/pref/system.php b/classes/pref/system.php index f0a5f7b7f..d3b733364 100644 --- a/classes/pref/system.php +++ b/classes/pref/system.php @@ -90,12 +90,12 @@ class Pref_System extends Handler_Administrative {
    - __("Errors"), E_USER_WARNING => __("Warnings"), E_USER_NOTICE => __("Everything") - ], 'dojoType="fox.form.Select" onchange="Helpers.EventLog.refresh()"') ?> + ], 'onchange="Helpers.EventLog.refresh()"', "severity") ?>
    diff --git a/include/controls.php b/include/controls.php index f706931db..34a4af1f2 100755 --- a/include/controls.php +++ b/include/controls.php @@ -1,326 +1,133 @@ "; - foreach ($values as $v) { - if ($v == $default) - $sel = "selected=\"1\""; - else - $sel = ""; + $rv = ""; -} + $rv .= ""; + } -function print_select_hash($id, $default, $values, $attributes = "", $name = "") { - if (!$name) $name = $id; + $rv .= ""; - print ""; -} + $values = []; -function format_hidden($name, $value) { - return ""; -} + while ($row = $sth->fetch()) { + array_push($values, $row["caption"]); + } -function print_hidden($name, $value) { - print format_hidden($name, $value); -} + return select_tag($name, $value, $values, $attributes, $id); + } -function format_checkbox($id, $checked, $value = "", $attributes = "") { - $checked_str = $checked ? "checked" : ""; - $value_str = $value ? "value=\"$value\"" : ""; + function select_hash(string $name, $value, array $values, string $attributes = "", string $id = "") { + $dojo_type = strpos($attributes, "dojoType") === false ? "dojoType='fox.form.Select'" : ""; - return ""; -} + $rv = ""; - if ($v == $default) - $sel = "checked"; - else - $sel = ""; + return $rv; + } - if ($v == $true_is) { - $sel .= " value=\"1\""; - } else { - $sel .= " value=\"0\""; - } + function hidden_tag(string $name, string $value) { + return ""; + } - print " $v "; + function checkbox_tag(string $name, bool $checked, string $value = "", string $attributes = "", string $id = "") { + $is_checked = $checked ? "checked" : ""; + $value_str = $value ? "value=\"".htmlspecialchars($value)."\"" : ""; - } -} + return ""; + } -function print_feed_multi_select($id, $default_ids = [], - $attributes = "", $include_all_feeds = true, - $root_id = null, $nest_level = 0) { + function select_feeds_cats(string $name, int $default_id = null, string $attributes = "", + bool $include_all_cats = true, string $root_id = null, int $nest_level = 0, string $id = "") { - $pdo = Db::pdo(); + $ret = ""; - print_r(in_array("CAT:6",$default_ids)); + if (!$root_id) { + $ret .= ""; - if ($include_all_feeds) { - $is_selected = (in_array("0", $default_ids)) ? "selected=\"1\"" : ""; - print ""; - } - } + $pdo = \Db::pdo(); - if (get_pref('ENABLE_FEED_CATS')) { + if (!$root_id) $root_id = null; - if (!$root_id) $root_id = null; + $sth = $pdo->prepare("SELECT id,title, + (SELECT COUNT(id) FROM ttrss_feed_categories AS c2 WHERE + c2.parent_cat = ttrss_feed_categories.id) AS num_children + FROM ttrss_feed_categories + WHERE owner_uid = :uid AND + (parent_cat = :root_id OR (:root_id IS NULL AND parent_cat IS NULL)) ORDER BY title"); + $sth->execute([":uid" => $_SESSION['uid'], ":root_id" => $root_id]); - $sth = $pdo->prepare("SELECT id,title, - (SELECT COUNT(id) FROM ttrss_feed_categories AS c2 WHERE - c2.parent_cat = ttrss_feed_categories.id) AS num_children - FROM ttrss_feed_categories - WHERE owner_uid = :uid AND - (parent_cat = :root_id OR (:root_id IS NULL AND parent_cat IS NULL)) ORDER BY title"); + $found = 0; - $sth->execute([":uid" => $_SESSION['uid'], ":root_id" => $root_id]); + while ($line = $sth->fetch()) { + ++$found; - while ($line = $sth->fetch()) { + if ($line["id"] == $default_id) { + $is_selected = "selected=\"1\""; + } else { + $is_selected = ""; + } - for ($i = 0; $i < $nest_level; $i++) - $line["title"] = " " . $line["title"]; + for ($i = 0; $i < $nest_level; $i++) + $line["title"] = " " . $line["title"]; - $is_selected = in_array("CAT:".$line["id"], $default_ids) ? "selected=\"1\"" : ""; + if ($line["title"]) + $ret .= sprintf("", + $line["id"], htmlspecialchars($line["title"])); - printf("", - $line["id"], htmlspecialchars($line["title"])); + if ($line["num_children"] > 0) + $ret .= select_feeds_cats($id, $default_id, $attributes, + $include_all_cats, $line["id"], $nest_level+1, $id); + } - if ($line["num_children"] > 0) - print_feed_multi_select($id, $default_ids, $attributes, - $include_all_feeds, $line["id"], $nest_level+1); + if (!$root_id) { + if ($include_all_cats) { + if ($found > 0) { + $ret .= ""; + } - $f_sth = $pdo->prepare("SELECT id,title FROM ttrss_feeds - WHERE cat_id = ? AND owner_uid = ? ORDER BY title"); + if ($default_id == 0) { + $is_selected = "selected=\"1\""; + } else { + $is_selected = ""; + } - $f_sth->execute([$line['id'], $_SESSION['uid']]); + $ret .= ""; + } + $ret .= ""; + } - while ($fline = $f_sth->fetch()) { - $is_selected = (in_array($fline["id"], $default_ids)) ? "selected=\"1\"" : ""; + return $ret; + } - $fline["title"] = " " . $fline["title"]; - - for ($i = 0; $i < $nest_level; $i++) - $fline["title"] = " " . $fline["title"]; - - printf("", - $fline["id"], htmlspecialchars($fline["title"])); - } - } - - if (!$root_id) { - $is_selected = in_array("CAT:0", $default_ids) ? "selected=\"1\"" : ""; - - printf("", - __("Uncategorized")); - - $f_sth = $pdo->prepare("SELECT id,title FROM ttrss_feeds - WHERE cat_id IS NULL AND owner_uid = ? ORDER BY title"); - $f_sth->execute([$_SESSION['uid']]); - - while ($fline = $f_sth->fetch()) { - $is_selected = in_array($fline["id"], $default_ids) ? "selected=\"1\"" : ""; - - $fline["title"] = " " . $fline["title"]; - - for ($i = 0; $i < $nest_level; $i++) - $fline["title"] = " " . $fline["title"]; - - printf("", - $fline["id"], htmlspecialchars($fline["title"])); - } - } - - } else { - $sth = $pdo->prepare("SELECT id,title FROM ttrss_feeds - WHERE owner_uid = ? ORDER BY title"); - $sth->execute([$_SESSION['uid']]); - - while ($line = $sth->fetch()) { - - $is_selected = (in_array($line["id"], $default_ids)) ? "selected=\"1\"" : ""; - - printf("", - $line["id"], htmlspecialchars($line["title"])); - } - } - - if (!$root_id) { - print ""; - } -} - -function print_feed_cat_select($id, $default_id, $attributes, $include_all_cats = true, - $root_id = null, $nest_level = 0) { - - print format_feed_cat_select($id, $default_id, $attributes, $include_all_cats, $root_id, $nest_level); -} - -function format_feed_cat_select($id, $default_id, $attributes, $include_all_cats = true, - $root_id = null, $nest_level = 0) { - - $ret = ""; - - if (!$root_id) { - $ret .= ""; - } - - return $ret; -} - -function stylesheet_tag($filename, $id = false) { - $timestamp = filemtime($filename); - - $id_part = $id ? "id=\"$id\"" : ""; - - return "\n"; -} - -function javascript_tag($filename) { - $query = ""; - - if (!(strpos($filename, "?") === false)) { - $query = substr($filename, strpos($filename, "?")+1); - $filename = substr($filename, 0, strpos($filename, "?")); - } - - $timestamp = filemtime($filename); - - if ($query) $timestamp .= "&$query"; - - return "\n"; -} - -function format_warning($msg, $id = "") { - return "
    $msg
    "; -} - -function format_notice($msg, $id = "") { - return "
    $msg
    "; -} - -function format_error($msg, $id = "") { - return "
    $msg
    "; -} - -function print_notice($msg) { - return print format_notice($msg); -} - -function print_warning($msg) { - return print format_warning($msg); -} - -function print_error($msg) { - return print format_error($msg); -} - -function print_label_select($name, $value, $attributes = "") { - - $pdo = Db::pdo(); - - $sth = $pdo->prepare("SELECT caption FROM ttrss_labels2 - WHERE owner_uid = ? ORDER BY caption"); - $sth->execute([$_SESSION['uid']]); - - print ""; - - -} diff --git a/include/controls_compat.php b/include/controls_compat.php new file mode 100644 index 000000000..3d2779b08 --- /dev/null +++ b/include/controls_compat.php @@ -0,0 +1,312 @@ +"; + foreach ($values as $v) { + if ($v == $default) + $sel = "selected=\"1\""; + else + $sel = ""; + + $v = trim($v); + + print ""; + } + print ""; +} + +function print_select_hash($id, $default, $values, $attributes = "", $name = "") { + if (!$name) $name = $id; + + print ""; +} + +function format_hidden($name, $value) { + return ""; +} + +function print_hidden($name, $value) { + print format_hidden($name, $value); +} + +function format_checkbox($id, $checked, $value = "", $attributes = "") { + $checked_str = $checked ? "checked" : ""; + $value_str = $value ? "value=\"$value\"" : ""; + + return ""; +} + +function print_checkbox($id, $checked, $value = "", $attributes = "") { + print format_checkbox($id, $checked, $value, $attributes); +} + +function format_button($type, $value, $attributes = "") { + return ""; +} + +function print_button($type, $value, $attributes = "") { + print format_button($type, $value, $attributes); +} + +function print_feed_multi_select($id, $default_ids = [], + $attributes = "", $include_all_feeds = true, + $root_id = null, $nest_level = 0) { + + $pdo = Db::pdo(); + + print_r(in_array("CAT:6",$default_ids)); + + if (!$root_id) { + print ""; + } +} + +function print_feed_cat_select($id, $default_id, $attributes, $include_all_cats = true, + $root_id = null, $nest_level = 0) { + + print format_feed_cat_select($id, $default_id, $attributes, $include_all_cats, $root_id, $nest_level); +} + +function format_feed_cat_select($id, $default_id, $attributes, $include_all_cats = true, + $root_id = null, $nest_level = 0) { + + $ret = ""; + + if (!$root_id) { + $ret .= ""; + } + + return $ret; +} + +function stylesheet_tag($filename, $id = false) { + $timestamp = filemtime($filename); + + $id_part = $id ? "id=\"$id\"" : ""; + + return "\n"; +} + +function javascript_tag($filename) { + $query = ""; + + if (!(strpos($filename, "?") === false)) { + $query = substr($filename, strpos($filename, "?")+1); + $filename = substr($filename, 0, strpos($filename, "?")); + } + + $timestamp = filemtime($filename); + + if ($query) $timestamp .= "&$query"; + + return "\n"; +} + +function format_warning($msg, $id = "") { + return "
    $msg
    "; +} + +function format_notice($msg, $id = "") { + return "
    $msg
    "; +} + +function format_error($msg, $id = "") { + return "
    $msg
    "; +} + +function print_notice($msg) { + return print format_notice($msg); +} + +function print_warning($msg) { + return print format_warning($msg); +} + +function print_error($msg) { + return print format_error($msg); +} + +function print_label_select($name, $value, $attributes = "") { + + $pdo = Db::pdo(); + + $sth = $pdo->prepare("SELECT caption FROM ttrss_labels2 + WHERE owner_uid = ? ORDER BY caption"); + $sth->execute([$_SESSION['uid']]); + + print ""; + + +} diff --git a/include/functions.php b/include/functions.php index 4557c0411..174ef39f0 100644 --- a/include/functions.php +++ b/include/functions.php @@ -203,6 +203,7 @@ require_once 'db-prefs.php'; require_once 'controls.php'; + require_once 'controls_compat.php'; define('SELF_USER_AGENT', 'Tiny Tiny RSS/' . get_version() . ' (http://tt-rss.org/)'); ini_set('user_agent', SELF_USER_AGENT); diff --git a/include/login_form.php b/include/login_form.php index aa6a72260..798efa624 100755 --- a/include/login_form.php +++ b/include/login_form.php @@ -97,7 +97,7 @@
    - + diff --git a/plugins/mail/init.php b/plugins/mail/init.php index 829620ebc..b1263ece5 100644 --- a/plugins/mail/init.php +++ b/plugins/mail/init.php @@ -160,7 +160,7 @@ class Mail extends Plugin { style=\"width : 30em;\" name=\"destination\" id=\"emailArticleDlg_destination\">"; */ - print_select("destination", "", $addresslist, 'style="width: 30em" dojoType="dijit.form.ComboBox"'); + print \Controls\select_tag("destination", "", $addresslist, 'style="width: 30em" dojoType="dijit.form.ComboBox"'); /* print "
    "; */ -- cgit v1.2.3-54-g00ecf From bdbbdbb0eddd125bec167da5f42bbd95c770151f Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Tue, 16 Feb 2021 16:59:21 +0300 Subject: 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(-) (limited to 'classes/pref/prefs.php') 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