aboutsummaryrefslogtreecommitdiff
path: root/engine/classes/ElggPluginManifestParser17.php
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/classes/ElggPluginManifestParser17.php
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/classes/ElggPluginManifestParser17.php')
-rw-r--r--engine/classes/ElggPluginManifestParser17.php54
1 files changed, 54 insertions, 0 deletions
diff --git a/engine/classes/ElggPluginManifestParser17.php b/engine/classes/ElggPluginManifestParser17.php
new file mode 100644
index 000000000..49b91ef52
--- /dev/null
+++ b/engine/classes/ElggPluginManifestParser17.php
@@ -0,0 +1,54 @@
+<?php
+/**
+ * Plugin manifest.xml parser for Elgg 1.7 and lower.
+ *
+ * @package Elgg.Core
+ * @subpackage Plugins
+ */
+class ElggPluginManifestParser17 extends ElggPluginManifestParser {
+ /**
+ * The valid top level attributes and defaults for a 1.7 manifest
+ */
+ protected $validAttributes = array(
+ 'author' => null,
+ 'version' => null,
+ 'description' => null,
+ 'website' => null,
+ 'copyright' => null,
+ 'license' => 'GNU Public License version 2',
+ 'elgg_version' => null,
+
+ // were never really used and not enforced in code.
+ 'requires' => null,
+ 'recommends' => null,
+ 'conflicts' => null
+ );
+
+ /**
+ * Parse a manifest object from 1.7 or earlier.
+ *
+ * @return void
+ */
+ public function parse() {
+ foreach ($this->manifestObject->children as $element) {
+ $key = $element->attributes['key'];
+ $value = $element->attributes['value'];
+
+ // 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;
+ }
+ }
+
+ $this->manifest = $elements;
+
+ return true;
+ }
+} \ No newline at end of file