]> gitweb.fluxo.info Git - lorea/elgg.git/commitdiff
Fixes #2928: Invalid plugins are shown on the advance page with details about the...
authorbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>
Mon, 14 Mar 2011 23:07:31 +0000 (23:07 +0000)
committerbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>
Mon, 14 Mar 2011 23:07:31 +0000 (23:07 +0000)
git-svn-id: http://code.elgg.org/elgg/trunk@8709 36083f99-b078-4883-b0ff-0f9b5a30f544

engine/classes/ElggPlugin.php
engine/classes/ElggPluginPackage.php
languages/en.php
views/default/admin/plugins/advanced.php
views/default/object/plugin/invalid.php

index 69b3b1c673994c9b8b891d3a22d7da7955ede02d..55be2b887ee5c8b150f4d72edaac48715faf032d 100644 (file)
@@ -14,6 +14,7 @@ class ElggPlugin extends ElggObject {
 
        private $path;
        private $pluginID;
+       private $errorMsg = '';
 
        /**
         * Set subtype to 'plugin'
@@ -86,6 +87,7 @@ class ElggPlugin extends ElggObject {
                } catch (Exception $e) {
                        // we always have to allow the entity to load.
                        elgg_log("Failed to load $this->guid as a plugin. " . $e->getMessage(), 'WARNING');
+                       $this->errorMsg = $e->getmessage();
                }
        }
 
@@ -547,14 +549,17 @@ class ElggPlugin extends ElggObject {
         */
        public function isValid() {
                if (!$this->getID()) {
+                       $this->errorMsg = elgg_echo('ElggPlugin:NoId', array($this->guid));
                        return false;
                }
 
                if (!$this->package instanceof ElggPluginPackage) {
+                       $this->errorMsg = elgg_echo('ElggPlugin:NoPluginPackagePackage', array($this->getID(), $this->guid));
                        return false;
                }
 
                if (!$this->package->isValid()) {
+                       $this->errorMsg = $this->package->getError();
                        return false;
                }
 
@@ -951,4 +956,13 @@ class ElggPlugin extends ElggObject {
                        return remove_entity_relationship($this->guid, 'active_plugin', $site->guid);
                }
        }
+
+       /**
+        * Returns the last error message registered.
+        *
+        * @return string|null
+        */
+       public function getError() {
+               return $this->errorMsg;
+       }
 }
index 567ec129f7b7daa822bcd16190787a4481a123b0..59d5a95bf6e6de3f2ef8d9efcaff53385f800267 100644 (file)
@@ -48,7 +48,7 @@ class ElggPluginPackage {
        /**
         * An invalid plugin error.
         */
-       private $invalidPluginError = '';
+       private $errorMsg = '';
 
        /**
         * Any dependencies messages
@@ -122,9 +122,9 @@ class ElggPluginPackage {
                $this->id = $id;
 
                if ($validate && !$this->isValid()) {
-                       if ($this->invalidPluginError) {
+                       if ($this->errorMsg) {
                                throw new PluginException(elgg_echo('PluginException:InvalidPlugin:Details',
-                                                       array($plugin, $this->invalidPluginError)));
+                                                       array($plugin, $this->errorMsg)));
                        } else {
                                throw new PluginException(elgg_echo('PluginException:InvalidPlugin', array($plugin)));
                        }
@@ -155,14 +155,12 @@ class ElggPluginPackage {
                        return $this->valid;
                }
 
-               $valid = true;
-
                // check required files.
                $have_req_files = true;
                foreach ($this->requiredFiles as $file) {
                        if (!is_readable($this->path . $file)) {
                                $have_req_files = false;
-                               $this->invalidPluginError =
+                               $this->errorMsg =
                                        elgg_echo('ElggPluginPackage:InvalidPlugin:MissingFile', array($file));
                                break;
                        }
@@ -170,23 +168,21 @@ class ElggPluginPackage {
 
                // check required files
                if (!$have_req_files) {
-                       $valid = false;
+                       return $this->valid = false;
                }
 
                // check for valid manifest.
                if (!$this->loadManifest()) {
-                       $valid = false;
+                       return $this->valid = false;
                }
 
                // can't require or conflict with yourself or something you provide.
                // make sure provides are all valid.
                if (!$this->isSaneDeps()) {
-                       $valid = false;
+                       return $this->valid = false;
                }
 
-               $this->valid = $valid;
-
-               return $valid;
+               return $this->valid = true;
        }
 
        /**
@@ -213,7 +209,7 @@ class ElggPluginPackage {
                foreach ($provides as $provide) {
                        // only valid provide types
                        if (!in_array($provide['type'], $this->providesSupportedTypes)) {
-                               $this->invalidPluginError =
+                               $this->errorMsg =
                                        elgg_echo('ElggPluginPackage:InvalidPlugin:InvalidProvides', array($provide['type']));
                                return false;
                        }
@@ -223,7 +219,7 @@ class ElggPluginPackage {
                        foreach (array('conflicts', 'requires') as $dep_type) {
                                foreach (${$dep_type} as $dep) {
                                        if (!in_array($dep['type'], $this->depsSupportedTypes)) {
-                                               $this->invalidPluginError =
+                                               $this->errorMsg =
                                                        elgg_echo('ElggPluginPackage:InvalidPlugin:InvalidDependency', array($dep['type']));
                                                return false;
                                        }
@@ -233,7 +229,7 @@ class ElggPluginPackage {
                                                $version_compare = version_compare($provide['version'], $dep['version'], $dep['comparison']);
 
                                                if ($version_compare) {
-                                                       $this->invalidPluginError =
+                                                       $this->errorMsg =
                                                                elgg_echo('ElggPluginPackage:InvalidPlugin:CircularDep',
                                                                        array($dep['type'], $dep['name'], $this->id));
 
@@ -279,6 +275,7 @@ class ElggPluginPackage {
                try {
                        $this->manifest = new ElggPluginManifest($file, $this->id);
                } catch (Exception $e) {
+                       $this->errorMsg = $e->getMessage();
                        return false;
                }
 
@@ -605,4 +602,12 @@ class ElggPluginPackage {
                return $this->id;
        }
 
+       /**
+        * Returns the last error message.
+        * 
+        * @return string
+        */
+       public function getError() {
+               return $this->errorMsg;
+       }
 }
index 5ea31b8641659f9675846420734d375d41c8da54..32a4cbb3dd976bed108f3ebe5a9def498cfa3577 100644 (file)
@@ -68,6 +68,10 @@ $english = array(
        'PluginException:InvalidManifest' => 'Invalid manifest file for plugin %s',
        'PluginException:InvalidPlugin' => '%s is not a valid plugin.',
        'PluginException:InvalidPlugin:Details' => '%s is not a valid plugin: %s',
+
+       'ElggPlugin:MissingID' => 'Missing plugin ID (guid %s)',
+       'ElggPlugin:NoPluginPackagePackage' => 'Missing ElggPluginPackage for plugin ID %s (guid %s)',
+
        'ElggPluginPackage:InvalidPlugin:MissingFile' => 'Missing file %s in package',
        'ElggPluginPackage:InvalidPlugin:InvalidDependency' => 'Invalid dependency type "%s"',
        'ElggPluginPackage:InvalidPlugin:InvalidProvides' => 'Invalid provides type "%s"',
@@ -630,7 +634,7 @@ $english = array(
 
        'admin:plugins:warning:elgg_version_unknown' => 'This plugin uses a legacy manifest file and does not specify a compatible Elgg version. It probably will not work!',
        'admin:plugins:warning:unmet_dependencies' => 'This plugin has unmet dependencies and cannot be activated. Check dependencies under more info.',
-       'admin:plugins:warning:invalid' => '%s is not a valid Elgg plugin.  Check http://docs.elgg.org/Invalid_Plugin for more information.',
+       'admin:plugins:warning:invalid' => '%s is not a valid Elgg plugin.  Check <a href="http://docs.elgg.org/Invalid_Plugin">the Elgg documentation</a> for troublshooting tips.',
        'admin:plugins:cannot_activate' => 'Cannot Activate',
 
        'admin:plugins:set_priority:yes' => "Reordered %s.",
index e78dbe2f1d3e5c7e4db853a34e3feea9831093bf..02e9ae58b77e9ed12fd106db824d6b14305ceffa 100644 (file)
@@ -9,7 +9,7 @@
  */
 
 elgg_generate_plugin_entities();
-$installed_plugins = elgg_get_plugins('any');
+$installed_plugins = elgg_get_plugins('any', true);
 $show_category = get_input('category', null);
 
 // Get a list of the all categories
@@ -85,9 +85,6 @@ $buttons .= $category_form;
 <div id="elgg-plugin-list">
 <?php
 
-$options = array(
-
-);
 echo elgg_view_entity_list($installed_plugins, 0, 0, 0, true, false, false); 
 
 ?>
index 7fd5d6f5edd46f1135e7c030a8c835ea30b04ae0..9e239b7ca824a506f07a1e8dc82954697635b608 100644 (file)
@@ -15,10 +15,28 @@ $plugin = $vars['entity'];
 $id = $plugin->getID();
 $path = htmlspecialchars($plugin->getPath());
 $message = elgg_echo('admin:plugins:warning:invalid', array($id));
+$error = $plugin->getError();
 
 ?>
 
-<div class="elgg-plugin elgg-state-inactive elgg-state-error">
-       <p><?php echo $message; ?></p>
-       <p><?php echo elgg_echo('admin:plugins:label:location') . ": " . $path; ?></p>
-</div>
+<div class="elgg-state-draggable elgg-plugin elgg-state-inactive elgg-state-error" id="elgg-plugin-<?php echo $plugin->guid; ?>">
+       <div class="elgg-head"><h3><?php echo $id; ?></h3></div>
+       <div class="elgg-body">
+               <p><?php echo $message; ?></p>
+               
+               <div class="pts">
+                       <?php
+                               echo elgg_view('output/url', array(
+                                       'href' => "#elgg-plugin-manifest-{$plugin->getID()}",
+                                       'text' => elgg_echo("admin:plugins:label:moreinfo"),
+                                       'class' => 'elgg-toggler',
+                               ));
+                       ?>
+               </div>
+
+               <div class="hidden manifest_file" id="elgg-plugin-manifest-<?php echo $plugin->getID(); ?>">
+                       <p><?php echo elgg_echo('admin:plugins:label:location') . ": " . $path; ?></p>
+                       <p><?php echo $error; ?></p>
+               </div>
+       </div>
+</div>
\ No newline at end of file