From 473ea6255c634fa47ee8c8e24de910785b9b095b Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Sat, 6 Mar 2021 18:14:25 +0300 Subject: render list of plugins on the client --- classes/pref/prefs.php | 229 +++++++++++++------------------------------------ 1 file changed, 60 insertions(+), 169 deletions(-) (limited to 'classes/pref/prefs.php') diff --git a/classes/pref/prefs.php b/classes/pref/prefs.php index 854b70549..7e83a6e64 100644 --- a/classes/pref/prefs.php +++ b/classes/pref/prefs.php @@ -787,164 +787,73 @@ class Pref_Prefs extends Handler_Protected { config.php for all users."); - - $system_enabled = array_map("trim", explode(",", (string)Config::get(Config::PLUGINS))); - - $tmppluginhost = new PluginHost(); - $tmppluginhost->load_all($tmppluginhost::KIND_ALL, $_SESSION["uid"], true); - - foreach ($tmppluginhost->get_plugins() as $name => $plugin) { - $about = $plugin->about(); - $is_local = $tmppluginhost->is_local($plugin); - $version = htmlspecialchars($this->_get_plugin_version($plugin)); - - if ($about[3] ?? false) { - $is_checked = in_array($name, $system_enabled) ? "checked" : ""; - ?> -
- - - - get_all($plugin)) > 0) { - if (in_array($name, $system_enabled)) { ?> - - - - - - - - = 10) { ?> - - - - = 10 && $is_local) { ?> - - - - -
- -
- -
- load_all($tmppluginhost::KIND_ALL, $_SESSION["uid"], true); + $rv = []; + foreach ($tmppluginhost->get_plugins() as $name => $plugin) { $about = $plugin->about(); $is_local = $tmppluginhost->is_local($plugin); $version = htmlspecialchars($this->_get_plugin_version($plugin)); - if (empty($about[3]) || $about[3] == false) { - - $is_checked = ""; - $is_disabled = ""; - - if (in_array($name, $system_enabled)) { - $is_checked = "checked='1'"; - $is_disabled = "disabled='1'"; - } else if (in_array($name, $user_enabled)) { - $is_checked = "checked='1'"; - } - ?> - -
- - - - get_all($plugin)) > 0) { - if (in_array($name, $system_enabled) || in_array($name, $user_enabled)) { ?> - - - - - - - - = 10) { ?> - - - - = 10 && $is_local) { ?> - - + array_push($rv, [ + "name" => $name, + "is_local" => $is_local, + "system_enabled" => in_array($name, $system_enabled), + "user_enabled" => in_array($name, $user_enabled), + "has_data" => count($tmppluginhost->get_all($plugin)) > 0, + "is_system" => (bool)($about[3] ?? false), + "version" => $version, + "author" => $about[2] ?? "", + "description" => $about[1] ?? "", + "more_info" => $about[4] ?? "", + ]); + } - -
- -
- + usort($rv, function($a, $b) { return strcmp($a["name"], $b["name"]); }); -
- $rv, 'is_admin' => $_SESSION['access_level'] >= 10]); } function index_plugins() { ?>
-
+
+
+ + +
+ +
+ +
+
+
+
+
+
+
- + Helpers.Plugins.reload(); + + + - index_plugins_system() ?> - -

- - index_plugins_user() ?> +
    +
  • +
- - + "alt-primary", + "onclick" => "Helpers.Plugins.enableSelected()"]) ?> + + __("Reload"), "onclick" => "Helpers.Plugins.reload()"]) ?> + = 10) { ?> - - - @@ -1031,16 +933,8 @@ class Pref_Prefs extends Handler_Protected {
index_prefs() ?>
-
- - +
+ index_plugins() ?>
run_hooks(PluginHost::HOOK_PREFS_TAB, "prefPrefs") ?>
@@ -1119,12 +1013,9 @@ class Pref_Prefs extends Handler_Protected { } function setplugins() { - if (is_array(clean($_REQUEST["plugins"]))) - $plugins = join(",", clean($_REQUEST["plugins"])); - else - $plugins = ""; + $plugins = array_filter($_REQUEST["plugins"], 'clean') ?? []; - set_pref(Prefs::_ENABLED_PLUGINS, $plugins); + set_pref(Prefs::_ENABLED_PLUGINS, implode(",", $plugins)); } function _get_plugin_version(Plugin $plugin) { -- cgit v1.2.3