aboutsummaryrefslogtreecommitdiff
path: root/engine/lib
diff options
context:
space:
mode:
authormarcus <marcus@36083f99-b078-4883-b0ff-0f9b5a30f544>2008-06-20 13:42:37 +0000
committermarcus <marcus@36083f99-b078-4883-b0ff-0f9b5a30f544>2008-06-20 13:42:37 +0000
commit28826aff64178c7422e6424c81c1771d9dfdc7dd (patch)
tree7dcc7f1b5e320120d14c5aa4e366cac349113d48 /engine/lib
parent2ef198989e91cffb4b338f9f1f975154623ec1fc (diff)
downloadelgg-28826aff64178c7422e6424c81c1771d9dfdc7dd.tar.gz
elgg-28826aff64178c7422e6424c81c1771d9dfdc7dd.tar.bz2
Further fixes #59
git-svn-id: https://code.elgg.org/elgg/trunk@1024 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'engine/lib')
-rw-r--r--engine/lib/plugins.php99
1 files changed, 60 insertions, 39 deletions
diff --git a/engine/lib/plugins.php b/engine/lib/plugins.php
index a38fc2434..dd9a75e20 100644
--- a/engine/lib/plugins.php
+++ b/engine/lib/plugins.php
@@ -58,8 +58,8 @@
if ($handle = opendir($CONFIG->pluginspath)) {
while ($mod = readdir($handle)) {
if (!in_array($mod,array('.','..','.svn','CVS')) && is_dir($CONFIG->pluginspath . "/" . $mod)) {
- //if (is_plugin_enabled($mod))
- //{
+ if (is_plugin_enabled($mod))
+ {
if (!@include($CONFIG->pluginspath . $mod . "/start.php"))
throw new PluginException(sprintf(elgg_echo('PluginException:MisconfiguredPlugin'), $mod));
if (is_dir($CONFIG->pluginspath . $mod . "/views/default")) {
@@ -68,7 +68,7 @@
if (is_dir($CONFIG->pluginspath . $mod . "/languages")) {
register_translations($CONFIG->pluginspath . $mod . "/languages/");
}
- //}
+ }
}
}
}
@@ -106,53 +106,46 @@
}
}
return false;
- }
+ }
/**
- * Register a plugin with a manifest.
- *
- * It is passed an associated array of values. Currently the following fields are recognised:
+ * Load and parse a plugin manifest from a plugin XML file.
*
- * 'author', 'description', 'version', 'website' & 'copyright'.
+ * Example file:
*
- * @param array $manifest An associative array representing the manifest.
+ * <plugin_manifest>
+ * <field key="author" value="Marcus Povey" />
+ * <field key="version" value="1.0" />
+ * <field key="description" value="My plugin description, keep it short" />
+ * <field key="website" value="http://www.elgg.org/" />
+ * <field key="copyright" value="(C) Curverider 2008" />
+ * </plugin_manifest>
+ *
+ * @param string $plugin Plugin name.
+ * @return array of values
*/
- function register_plugin_manifest(array $manifest)
+ function load_plugin_manifest($plugin)
{
global $CONFIG;
- if (!is_array($CONFIG->plugin_manifests))
- $CONFIG->plugin_manifests = array();
-
- $plugin_name = get_plugin_name();
+ $xml = xml_2_object(file_get_contents($CONFIG->pluginspath . $plugin. "/manifest.xml"));
- if ($plugin_name)
+ if ($xml)
{
- $CONFIG->plugin_manifests[$plugin_name] = $manifest;
+ $elements = array();
+
+ foreach ($xml->children as $element)
+ {
+ $key = $element->attributes['key'];
+ $value = $element->attributes['value'];
+
+ $elements[$key] = $value;
+ }
+
+ return $elements;
}
- else
- throw new PluginException(elgg_echo('PluginException:NoPluginName'));
- }
-
- /**
- * Register a basic plugin manifest.
- *
- * @param string $author The author.
- * @param string $description A description of the plugin (don't forget to internationalise this string!)
- * @param string $version The version
- * @param string $website A link to the plugin's website
- * @param string $copyright Copyright information
- * @return bool
- */
- function register_plugin_manifest_basic($author, $description, $version, $website = "", $copyright = "")
- {
- return register_plugin_manifest(array(
- 'version' => $version,
- 'author' => $author,
- 'description' => $description,
- 'website' => $website,
- 'copyright' => $copyright
- ));
+
+ return false;
}
/**
@@ -235,6 +228,34 @@
}
/**
+ * Return an array of installed plugins.
+ */
+ function get_installed_plugins()
+ {
+ global $CONFIG;
+
+ $installed_plugins = array();
+
+ if (!empty($CONFIG->pluginspath)) {
+
+ if ($handle = opendir($CONFIG->pluginspath)) {
+
+ while ($mod = readdir($handle)) {
+
+ if (!in_array($mod,array('.','..','.svn','CVS')) && is_dir($CONFIG->pluginspath . "/" . $mod)) {
+
+ $installed_plugins[$mod] = array();
+ $installed_plugins[$mod]['active'] = is_plugin_enabled($mod);
+ $installed_plugins[$mod]['manifest'] = load_plugin_manifest($mod);
+ }
+ }
+ }
+ }
+
+ return $installed_plugins;
+ }
+
+ /**
* Enable a plugin for a site (default current site)
*
* @param string $plugin The plugin name.