aboutsummaryrefslogtreecommitdiff
path: root/engine/lib
diff options
context:
space:
mode:
authorbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>2010-11-30 03:56:34 +0000
committerbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>2010-11-30 03:56:34 +0000
commit8173f672f06ad2783d3d0112e7b285d2240f488b (patch)
tree283496b227e083fb18ee628f9a6b8b40a0b24edb /engine/lib
parentcaef932790b72de1efa5b8ef2065dd3ca3b9eb5a (diff)
downloadelgg-8173f672f06ad2783d3d0112e7b285d2240f488b.tar.gz
elgg-8173f672f06ad2783d3d0112e7b285d2240f488b.tar.bz2
Refs #1986 #2170 #2225 Added ElggPluginManifest, ElggPluginManifestParser, and its parser classes for 1.7 and 1.8 style manifests. Changed load_plugin_manifest() to use new parser. Added initial unit tests.
git-svn-id: http://code.elgg.org/elgg/trunk@7481 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'engine/lib')
-rw-r--r--engine/lib/plugins.php63
1 files changed, 27 insertions, 36 deletions
diff --git a/engine/lib/plugins.php b/engine/lib/plugins.php
index 80b68eb5c..163a9fa82 100644
--- a/engine/lib/plugins.php
+++ b/engine/lib/plugins.php
@@ -273,43 +273,15 @@ function get_plugin_name($mainfilename = false) {
* @return array of values
*/
function load_plugin_manifest($plugin) {
- global $CONFIG;
-
- $xml = xml_to_object(file_get_contents($CONFIG->pluginspath . $plugin . "/manifest.xml"));
-
- if ($xml) {
- // set up some defaults to normalize expected values to arrays
- $elements = array(
- 'screenshot' => array(),
- 'category' => array()
- );
-
- foreach ($xml->children as $element) {
- $key = $element->attributes['key'];
- $value = $element->attributes['value'];
+ $xml_file = get_config('pluginspath') . "$plugin/manifest.xml";
- // create arrays if multiple fields are set
- if (array_key_exists($key, $elements)) {
- if (!is_array($elements[$key])) {
- $orig = $elements[$key];
- $elements[$key] = array($orig);
- }
-
- $elements[$key][] = $value;
- } else {
- $elements[$key] = $value;
- }
- }
-
- // handle plugins that don't define a name
- if (!isset($elements['name'])) {
- $elements['name'] = ucwords($plugin);
- }
-
- return $elements;
+ try {
+ $manifest = ElggPluginManifest($xml_file);
+ } catch(Exception $e) {
+ return false;
}
- return false;
+ return $manifest->getManifest();
}
/**
@@ -858,6 +830,23 @@ function plugin_run_once() {
add_subtype("object", "plugin", "ElggPlugin");
}
+
+/**
+ * Runs unit tests for the entity objects.
+ *
+ * @param sting $hook unit_test
+ * @param string $type system
+ * @param mixed $value Array of tests
+ * @param mixed $params Params
+ *
+ * @return array
+ */
+function plugins_test($hook, $type, $value, $params) {
+ global $CONFIG;
+ $value[] = $CONFIG->path . 'engine/tests/api/plugins.php';
+ return $value;
+}
+
/**
* Initialise the file modules.
* Listens to system boot and registers any appropriate file types and classes
@@ -867,14 +856,16 @@ function plugin_run_once() {
function plugin_init() {
run_function_once("plugin_run_once");
+ elgg_register_plugin_hook_handler('unit_test', 'system', 'plugins_test');
+
elgg_register_action("plugins/settings/save", '', 'admin');
elgg_register_action("plugins/usersettings/save");
-
+
elgg_register_action('admin/plugins/enable', '', 'admin');
elgg_register_action('admin/plugins/disable', '', 'admin');
elgg_register_action('admin/plugins/enableall', '', 'admin');
elgg_register_action('admin/plugins/disableall', '', 'admin');
-
+
elgg_register_action('admin/plugins/reorder', '', 'admin');
}