]> gitweb.fluxo.info Git - lorea/elgg.git/commitdiff
Renamed 'elgg' manifest requirment to 'elgg_version' to be more in line with the...
authorbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>
Mon, 6 Dec 2010 15:23:01 +0000 (15:23 +0000)
committerbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>
Mon, 6 Dec 2010 15:23:01 +0000 (15:23 +0000)
git-svn-id: http://code.elgg.org/elgg/trunk@7550 36083f99-b078-4883-b0ff-0f9b5a30f544

engine/classes/ElggPluginManifest.php
engine/classes/ElggPluginManifestParser17.php
engine/classes/ElggPluginManifestParser18.php
engine/classes/ElggPluginPackage.php
engine/tests/api/plugins.php
engine/tests/test_files/plugin_18/manifest.xml

index ccd0d984a45281851431c05bea1237ccde4acbc2..01dcd1046670e3e403f42e0af2d8ac993a32b5b9 100644 (file)
@@ -234,7 +234,9 @@ class ElggPluginManifest {
         * @return string
         */
        public function getBlurb() {
-               if (!$blurb = elgg_echo($this->parser->getAttribute('blurb'))) {
+               $blurb = elgg_echo($this->parser->getAttribute('blurb'));
+
+               if (!$blurb) {
                        $blurb = elgg_get_excerpt($this->getDescription());
                }
 
@@ -293,7 +295,9 @@ class ElggPluginManifest {
         * @return array
         */
        public function getCategories() {
-               if (!$cats = $this->parser->getAttribute('category')) {
+               $cats = $this->parser->getAttribute('category');
+
+               if (!$cats) {
                        $cats = array();
                }
 
@@ -306,7 +310,9 @@ class ElggPluginManifest {
         * @return array
         */
        public function getScreenshots() {
-               if (!$ss = $this->parser->getAttribute('screenshot')) {
+               $ss = $this->parser->getAttribute('screenshot');
+
+               if (!$ss) {
                        $ss = array();
                }
 
@@ -324,7 +330,9 @@ class ElggPluginManifest {
         * @return array
         */
        public function getProvides() {
-               if (!$provides = $this->parser->getAttribute('provides')) {
+               $provides = $this->parser->getAttribute('provides');
+
+               if (!$provides) {
                        $provides = array();
                }
 
@@ -351,7 +359,23 @@ class ElggPluginManifest {
         * @return array
         */
        public function getRequires() {
-               if (!$reqs = $this->parser->getAttribute('requires')) {
+               // rewrite the 1.7 style elgg_version as a real requires.
+               if ($this->apiVersion < 1.8) {
+                       $elgg_version = $this->parser->getAttribute('elgg_version');
+                       if ($elgg_version) {
+                               $reqs = array(
+                                       array(
+                                               'type' => 'elgg_version',
+                                               'version' => $elgg_version,
+                                               'comparison' => 'ge'
+                                       )
+                               );
+                       }
+               } else {
+                       $reqs = $this->parser->getAttribute('requires');
+               }
+
+               if (!$reqs) {
                        $reqs = array();
                }
 
@@ -359,7 +383,7 @@ class ElggPluginManifest {
                foreach ($reqs as $req) {
 
                        switch ($req['type']) {
-                               case 'elgg':
+                               case 'elgg_version':
                                case 'elgg_release':
                                        $struct = $this->_depsRequiresStructElgg;
                                        break;
@@ -441,7 +465,9 @@ class ElggPluginManifest {
         * @return array
         */
        public function getConflicts() {
-               if (!$conflicts = $this->parser->getAttribute('conflicts')) {
+               $conflicts = $this->parser->getAttribute('conflicts');
+
+               if (!$conflicts) {
                        $conflicts = array();
                }
 
index f439b5af0cbdfd412a9a3977cd8d3aa53c3b0d9c..8e4a79e4fdcb71ae56e72c8b7667ab0702945eda 100644 (file)
@@ -45,7 +45,9 @@ class ElggPluginManifestParser17 extends ElggPluginManifestParser {
                        }
                }
 
-               if (!$this->manifest = $elements) {
+               $this->manifest = $elements;
+
+               if (!$this->manifest) {
                        return false;
                }
 
index 54aa9603f7273de183a60ff5eecfbf5094d3a3ca..9a4cfb2b7abccc6e7b56182c51081ca76e427b49 100644 (file)
@@ -91,7 +91,9 @@ class ElggPluginManifestParser18 extends ElggPluginManifestParser {
                        }
                }
 
-               if (!$this->manifest = $parsed) {
+               $this->manifest = $parsed;
+
+               if (!$this->manifest) {
                        return false;
                }
 
index c00df7f8d902f5f4fb3910f445edad83f7c77028..8bb1f2a696be58ec8460896592c83d07bc108b99 100644 (file)
@@ -42,7 +42,7 @@ class ElggPluginPackage {
         * @var array
         */
        private $_depsSupportedTypes = array(
-               'elgg', 'elgg_release', 'php_extension', 'php_ini', 'plugin'
+               'elgg_version', 'elgg_release', 'php_extension', 'php_ini', 'plugin'
        );
 
        /**
@@ -274,7 +274,9 @@ class ElggPluginPackage {
         */
        private function _loadManifest() {
                $file = $this->path . 'manifest.xml';
-               if ($this->manifest = new ElggPluginManifest($file, $this->id)) {
+               $this->manifest = new ElggPluginManifest($file, $this->id);
+
+               if ($this->manifest) {
                        return true;
                }
 
@@ -312,7 +314,7 @@ class ElggPluginPackage {
 
                        foreach (${$dep_type} as $dep) {
                                switch ($dep['type']) {
-                                       case 'elgg':
+                                       case 'elgg_version':
                                                $result = $this->_checkDepElgg($dep, get_version());
                                                break;
 
@@ -484,7 +486,7 @@ class ElggPluginPackage {
 
                foreach ($requires as $require) {
                        switch ($require['type']) {
-                               case 'elgg':
+                               case 'elgg_version':
                                        $result = $this->_checkRequiresElgg($require, get_version());
                                        break;
 
index 61e2cdde6c2bacfc2cc641027f8c592e2c15ab04..c996095590217baeb06bf21494e4a5fd5e42c17f 100644 (file)
@@ -72,7 +72,7 @@ class ElggCorePluginsAPITest extends ElggCoreUnitTest {
                        'license' => 'GNU Public License version 2',
 
                        'requires' => array(
-                               array('type' => 'elgg', 'version' => '3009030802', 'comparison' => 'lt'),
+                               array('type' => 'elgg_version', 'version' => '3009030802', 'comparison' => 'lt'),
                                array('type' => 'elgg_release', 'version' => '1.8-svn'),
                                array('type' => 'php_extension', 'name' => 'gd'),
                                array('type' => 'php_ini', 'name' => 'short_open_tag', 'value' => 'off'),
@@ -175,7 +175,7 @@ class ElggCorePluginsAPITest extends ElggCoreUnitTest {
 
        public function testElggPluginManifestGetRequires() {
                $requires = array(
-                       array('type' => 'elgg', 'version' => '3009030802', 'comparison' => 'lt'),
+                       array('type' => 'elgg_version', 'version' => '3009030802', 'comparison' => 'lt'),
                        array('type' => 'elgg_release', 'version' => '1.8-svn', 'comparison' => 'ge'),
                        array('type' => 'php_extension', 'name' => 'gd', 'version' => '', 'comparison' => '='),
                        array('type' => 'php_ini', 'name' => 'short_open_tag', 'value' => 'off', 'comparison' => '='),
@@ -187,7 +187,11 @@ class ElggCorePluginsAPITest extends ElggCoreUnitTest {
 
                $this->assertEqual($this->package18->getManifest()->getRequires(), $requires);
 
-               $this->assertEqual($this->package17->getManifest()->getRequires(), array());
+               $requires = array(
+                       array('type' => 'elgg_version', 'version' => '2009030702', 'comparison' => 'ge')
+               );
+
+               $this->assertEqual($this->package17->getManifest()->getRequires(), $requires);
        }
 
        public function testElggPluginManifestGetDescription() {
index 182117a503341573eae4cd5f9061e464963bca5c..454a418f668be64b6c37411d1b7db2d8110fd45e 100644 (file)
@@ -10,7 +10,7 @@
        <license>GNU Public License version 2</license>
 
        <requires>
-               <type>elgg</type>
+               <type>elgg_version</type>
                <version>3009030802</version>
                <comparison>lt</comparison>
        </requires>