diff options
author | Luke Shumaker <LukeShu@sbcglobal.net> | 2010-11-21 00:37:54 -0500 |
---|---|---|
committer | Luke Shumaker <LukeShu@sbcglobal.net> | 2010-11-21 00:37:54 -0500 |
commit | d6877baca9b8c56ce3e1565791fa260cdc983d95 (patch) | |
tree | 8107511c9c449680af10b00cf5cbd845e3f63717 /lib | |
parent | 3a336843e1cdd340dd3630747b3e6265b6effa39 (diff) |
Load data for all plugins on plugin management page.
include.php: file to include to make creation of entry points easy
index.php: move most of this file into include.php (and include it)
plugindata.php: a separate entry point using include.php; load ALL plugins found, and write data gathered to plugindata.out.php
.gitignore: add plugindata.out.php
actions/pluginsadminpanel.php:
* use plugindata.out.php's common_plugindata() instead of StatusNet::getPlugins()
* give a button linking to plugindata.php, to refresh plugin data
lib/pluginlist.php:
* use plugindata.out.php's common_plugindata() instead of thowing the 'PluginVersion' event to currently enabled plugins
* for the enable/disable forms: was: if (!$disabled) now: if ($enabled && (!$disabled))
lib/statusnet.php: move the list of filenames for a plugin into it's own public static function; this is used by plugindata.php
Diffstat (limited to 'lib')
-rw-r--r-- | lib/pluginlist.php | 13 | ||||
-rw-r--r-- | lib/statusnet.php | 26 |
2 files changed, 27 insertions, 12 deletions
diff --git a/lib/pluginlist.php b/lib/pluginlist.php index 07a17ba39..0e1a81249 100644 --- a/lib/pluginlist.php +++ b/lib/pluginlist.php @@ -154,11 +154,13 @@ class PluginListItem extends Widget */ protected function getControlForm() { - $key = 'disable-' . $this->plugin; - if (common_config('plugins', $key)) { - return new PluginEnableForm($this->out, $this->plugin); - } else { + $enabled = array_key_exists($this->plugin, StatusNet::getPlugins()); + $disabled = common_config('plugins', 'disable-'.$this->plugin); + + if ( $enabled && (!$disabled) ) { // then return new PluginDisableForm($this->out, $this->plugin); + } else { + return new PluginEnableForm($this->out, $this->plugin); } } @@ -204,8 +206,7 @@ class PluginListItem extends Widget protected static function getPluginVersions() { if (!is_array(self::$versions)) { - $versions = array(); - Event::handle('PluginVersion', array(&$versions)); + $versions = common_plugindata(); self::$versions = $versions; } return self::$versions; diff --git a/lib/statusnet.php b/lib/statusnet.php index f8bf87960..63d8cb3da 100644 --- a/lib/statusnet.php +++ b/lib/statusnet.php @@ -34,6 +34,25 @@ class StatusNet protected static $plugins = array(); /** + * Return a list of possible filenames that plugin $name can be in. + * + * @param string $name class name & plugin file/subdir name + */ + public static function pluginFiles($name) { + $name = ucfirst($name); + $pluginclass = "{$name}Plugin"; + + $files = array("local/plugins/{$pluginclass}.php", + "local/plugins/{$name}/{$pluginclass}.php", + "local/{$pluginclass}.php", + "local/{$name}/{$pluginclass}.php", + "plugins/{$pluginclass}.php", + "plugins/{$name}/{$pluginclass}.php"); + + return $files; + } + + /** * Configure and instantiate a plugin into the current configuration. * Class definitions will be loaded from standard paths if necessary. * Note that initialization events won't be fired until later. @@ -50,12 +69,7 @@ class StatusNet if (!class_exists($pluginclass)) { - $files = array("local/plugins/{$pluginclass}.php", - "local/plugins/{$name}/{$pluginclass}.php", - "local/{$pluginclass}.php", - "local/{$name}/{$pluginclass}.php", - "plugins/{$pluginclass}.php", - "plugins/{$name}/{$pluginclass}.php"); + $files = self::pluginFiles($name); foreach ($files as $file) { $fullpath = INSTALLDIR.'/'.$file; |