don't init plugins when loading everything to make a list, duh

This commit is contained in:
Andrew Dolgov 2015-10-08 17:02:32 +03:00
parent 9cc29abd41
commit 583f163f40
3 changed files with 8 additions and 8 deletions

View File

@ -133,7 +133,7 @@ class PluginHost {
return array(); return array();
} }
} }
function load_all($kind, $owner_uid = false) { function load_all($kind, $owner_uid = false, $skip_init = false) {
$plugins = array_merge(glob("plugins/*"), glob("plugins.local/*")); $plugins = array_merge(glob("plugins/*"), glob("plugins.local/*"));
$plugins = array_filter($plugins, "is_dir"); $plugins = array_filter($plugins, "is_dir");
@ -141,10 +141,10 @@ class PluginHost {
asort($plugins); asort($plugins);
$this->load(join(",", $plugins), $kind, $owner_uid); $this->load(join(",", $plugins), $kind, $owner_uid, $skip_init);
} }
function load($classlist, $kind, $owner_uid = false) { function load($classlist, $kind, $owner_uid = false, $skip_init = false) {
$plugins = explode(",", $classlist); $plugins = explode(",", $classlist);
$this->owner_uid = (int) $owner_uid; $this->owner_uid = (int) $owner_uid;
@ -181,18 +181,18 @@ class PluginHost {
switch ($kind) { switch ($kind) {
case $this::KIND_SYSTEM: case $this::KIND_SYSTEM:
if ($this->is_system($plugin)) { if ($this->is_system($plugin)) {
$plugin->init($this); if (!$skip_init) $plugin->init($this);
$this->register_plugin($class, $plugin); $this->register_plugin($class, $plugin);
} }
break; break;
case $this::KIND_USER: case $this::KIND_USER:
if (!$this->is_system($plugin)) { if (!$this->is_system($plugin)) {
$plugin->init($this); if (!$skip_init) $plugin->init($this);
$this->register_plugin($class, $plugin); $this->register_plugin($class, $plugin);
} }
break; break;
case $this::KIND_ALL: case $this::KIND_ALL:
$plugin->init($this); if (!$skip_init) $plugin->init($this);
$this->register_plugin($class, $plugin); $this->register_plugin($class, $plugin);
break; break;
} }

View File

@ -746,7 +746,7 @@ class Pref_Prefs extends Handler_Protected {
$user_enabled = array_map("trim", explode(",", get_pref("_ENABLED_PLUGINS"))); $user_enabled = array_map("trim", explode(",", get_pref("_ENABLED_PLUGINS")));
$tmppluginhost = new PluginHost(); $tmppluginhost = new PluginHost();
$tmppluginhost->load_all($tmppluginhost::KIND_ALL, $_SESSION["uid"]); $tmppluginhost->load_all($tmppluginhost::KIND_ALL, $_SESSION["uid"], true);
$tmppluginhost->load_data(true); $tmppluginhost->load_data(true);
foreach ($tmppluginhost->get_plugins() as $name => $plugin) { foreach ($tmppluginhost->get_plugins() as $name => $plugin) {

View File

@ -365,7 +365,7 @@
if (isset($options["list-plugins"])) { if (isset($options["list-plugins"])) {
$tmppluginhost = new PluginHost(); $tmppluginhost = new PluginHost();
$tmppluginhost->load_all($tmppluginhost::KIND_ALL); $tmppluginhost->load_all($tmppluginhost::KIND_ALL, false);
$enabled = array_map("trim", explode(",", PLUGINS)); $enabled = array_map("trim", explode(",", PLUGINS));
echo "List of all available plugins:\n"; echo "List of all available plugins:\n";