Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormattab <matthieu.aubry@gmail.com>2013-09-18 03:26:46 +0400
committermattab <matthieu.aubry@gmail.com>2013-09-18 03:26:46 +0400
commitdde9833f409263ab6651acf81eec28c02f7b4812 (patch)
tree94d793870bf0f21261e346759cb7784cb673efac
parent5aa9eef454d97f8450aa0966755b8494e4ec064b (diff)
Fixes #4143 In admin UI, display a message explaining that the plugins could not be loaded because they are not compatible with Piwik 2
-rw-r--r--core/Controller/Admin.php24
-rw-r--r--core/PluginsManager.php44
-rw-r--r--core/Updater.php1
-rw-r--r--lang/en.json6
-rw-r--r--plugins/CoreAdminHome/templates/generalSettings.twig2
-rw-r--r--plugins/CorePluginsAdmin/Controller.php10
-rw-r--r--plugins/CorePluginsAdmin/templates/macros.twig10
-rw-r--r--plugins/Zeitgeist/templates/admin.twig6
8 files changed, 72 insertions, 31 deletions
diff --git a/core/Controller/Admin.php b/core/Controller/Admin.php
index 57f5302cfe..7891c804a2 100644
--- a/core/Controller/Admin.php
+++ b/core/Controller/Admin.php
@@ -13,6 +13,7 @@ namespace Piwik\Controller;
use Piwik\Config;
use Piwik\Piwik;
use Piwik\Controller;
+use Piwik\Version;
use Piwik\View;
use Piwik\Url;
use Piwik\PluginsManager;
@@ -66,13 +67,16 @@ abstract class Admin extends Controller
$missingPlugins = PluginsManager::getInstance()->getMissingPlugins();
if (!empty($missingPlugins)) {
$pluginsLink = Url::getCurrentQueryStringWithParametersModified(array(
- 'module' => 'CorePluginsAdmin', 'action' => 'index'
- ));
- $view->missingPluginsWarning = Piwik_Translate('CoreAdminHome_MissingPluginsWarning', array(
- '<strong>' . implode('</strong>,&nbsp;<strong>', $missingPlugins) . '</strong>',
- '<a href="' . $pluginsLink . '"/>',
- '</a>'
- ));
+ 'module' => 'CorePluginsAdmin', 'action' => 'plugins'
+ ));
+ $view->invalidPluginsWarning = Piwik_Translate('CoreAdminHome_InvalidPluginsWarning', array(
+ self::getPiwikVersion(),
+ '<strong>' . implode('</strong>,&nbsp;<strong>', $missingPlugins) . '</strong>'))
+ . '<br/>'
+ . Piwik_Translate('CoreAdminHome_InvalidPluginsYouCanUninstall', array(
+ '<a href="' . $pluginsLink . '"/>',
+ '</a>'
+ ));
}
self::checkPhpVersion($view);
@@ -80,6 +84,12 @@ abstract class Admin extends Controller
$view->menu = Piwik_GetAdminMenu();
}
+ static protected function getPiwikVersion()
+ {
+ return "Piwik " . Version::VERSION;
+ }
+
+
/**
* Check if the current PHP version is >= 5.3. If not, a warning is displayed
* to the user.
diff --git a/core/PluginsManager.php b/core/PluginsManager.php
index 48e13ead16..5cf6cf4a74 100644
--- a/core/PluginsManager.php
+++ b/core/PluginsManager.php
@@ -361,17 +361,22 @@ class PluginsManager
// If the plugin is not core and looks bogus, do not load
if($this->isPluginThirdPartyAndBogus($pluginName))
{
-// echo $pluginName;
- continue;
+ $info = array(
+ 'invalid' => true,
+ 'activated' => false,
+ 'alwaysActivated' => false,
+ 'uninstallable' => true,
+ );
+ } else {
+ $this->loadPlugin($pluginName);
+ $info = array(
+ 'activated' => $this->isPluginActivated($pluginName),
+ 'alwaysActivated' => $this->isPluginAlwaysActivated($pluginName),
+ 'uninstallable' => $this->isPluginUninstallable($pluginName),
+ );
}
- $this->loadPlugin($pluginName);
-
- $plugins[$pluginName] = array(
- 'activated' => $this->isPluginActivated($pluginName),
- 'alwaysActivated' => $this->isPluginAlwaysActivated($pluginName),
- 'uninstallable' => $this->isPluginUninstallable($pluginName),
- );
+ $plugins[$pluginName] = $info;
}
$this->loadPluginTranslations();
@@ -402,8 +407,9 @@ class PluginsManager
protected function isPluginThirdPartyAndBogus($pluginName)
{
$path = $this->getPluginsDirectory() . $pluginName;
- return !$this->isPluginBundledWithCore($pluginName)
- && !$this->isManifestFileFound($path);
+ $isBogus = !$this->isPluginBundledWithCore($pluginName)
+ && !$this->isManifestFileFound($path);
+ return $isBogus;
}
@@ -519,7 +525,8 @@ class PluginsManager
}
foreach ($this->pluginsToLoad as $pluginName) {
- if (!$this->isPluginLoaded($pluginName)) {
+ if (!$this->isPluginLoaded($pluginName)
+ && !$this->isPluginThirdPartyAndBogus($pluginName)) {
$newPlugin = $this->loadPlugin($pluginName);
if ($newPlugin === null) {
continue;
@@ -528,6 +535,18 @@ class PluginsManager
}
}
+ public function getIgnoredBogusPlugins()
+ {
+ $ignored = array();
+ foreach($this->pluginsToLoad as $pluginName) {
+ if($this->isPluginThirdPartyAndBogus($pluginName)) {
+ $ignored[] = $pluginName;
+ }
+ }
+ return $ignored;
+ }
+
+
/**
* Loads the plugin filename and instantiates the plugin with the given name, eg. UserCountry
* Do NOT give the class name ie. UserCountry, but give the plugin name ie. UserCountry
@@ -566,6 +585,7 @@ class PluginsManager
$path = self::getPluginsDirectory() . $pluginFileName;
+
if (!file_exists($path)) {
// Create the smallest minimal Piwik Plugin
// Eg. Used for Zeitgeist default theme which does not have a Zeitgeist.php file
diff --git a/core/Updater.php b/core/Updater.php
index eca0d3fd4f..9fef7ff41f 100644
--- a/core/Updater.php
+++ b/core/Updater.php
@@ -165,6 +165,7 @@ class Updater
$className = $this->getUpdateClassName($componentName, $fileVersion);
if (class_exists($className, false)) {
+ // update()
call_user_func(array($className, 'update'));
}
diff --git a/lang/en.json b/lang/en.json
index a310b7760d..d6c3a4adcc 100644
--- a/lang/en.json
+++ b/lang/en.json
@@ -537,7 +537,8 @@
"TrustedHostConfirm": "Are you sure you want to change the trusted Piwik hostname?",
"PiwikIsInstalledAt": "Piwik is installed at",
"ValidPiwikHostname": "Valid Piwik Hostname",
- "MissingPluginsWarning": "The following plugins were not loaded because they could not be found in the 'plugins' directory: %1$s. You can disable these plugins on the %2$sManage Plugins%3$s page.",
+ "InvalidPluginsWarning": "The following plugins are not compatible with %1$s and could not be loaded: %2$s. ",
+ "InvalidPluginsYouCanUninstall": "You can update or uninstall these plugins on the %1$sManage Plugins%2$s page.",
"JSTrackingIntro1": "You can track visitors to your website many different ways. The recommended way to do it is through JavaScript. To use this method you must make sure every webpage of your website has some JavaScript code, which you can generate here.",
"JSTrackingIntro2": "Once you have the JavaScript tracking code for your website, copy and paste it to all the pages you want to track with Piwik.",
"JSTrackingIntro3": "In most websites, blogs, CMS, etc. you can use a pre-made plugin to do the technical work for you. (See our %1$slist of plugins used to integrate Piwik%2$s.) If no plugin exists you can edit your website templates and add this code in the \"footer\" file.",
@@ -720,7 +721,8 @@
"Activate": "Activate",
"MenuPlatform": "Platform",
"MenuExtend": "Extend",
- "PluginCannotBeFound": "This plugin cannot be found!"
+ "PluginNotCompatibleWith": "%1$s plugin is not compatible with %2$s.",
+ "PluginAskDevToUpdate": "If you enjoyed this plugin, maybe you can ask the developers to update it to work on the latest Piwik. "
},
"CoreUpdater": {
"PluginDescription": "Piwik updating mechanism",
diff --git a/plugins/CoreAdminHome/templates/generalSettings.twig b/plugins/CoreAdminHome/templates/generalSettings.twig
index 51e457a62f..b388a55776 100644
--- a/plugins/CoreAdminHome/templates/generalSettings.twig
+++ b/plugins/CoreAdminHome/templates/generalSettings.twig
@@ -214,7 +214,7 @@
<div id='logoSettings'>
{% set giveUsFeedbackText %}"{{ 'General_GiveUsYourFeedback'|translate }}"{% endset %}
{% set customLogoHelp %}
- {{ 'CoreAdminHome_CustomLogoFeedbackInfo'|translate(giveUsFeedbackText,"<a href='?module=CorePluginsAdmin&action=index' target='_blank'>","</a>")|raw }}
+ {{ 'CoreAdminHome_CustomLogoFeedbackInfo'|translate(giveUsFeedbackText,"<a href='?module=CorePluginsAdmin&action=plugins' target='_blank'>","</a>")|raw }}
{% endset %}
{{ piwik.inlineHelp(customLogoHelp) }}
<form id="logoUploadForm" method="post" enctype="multipart/form-data" action="index.php?module=CoreAdminHome&format=json&action=uploadCustomLogo">
diff --git a/plugins/CorePluginsAdmin/Controller.php b/plugins/CorePluginsAdmin/Controller.php
index 566ab4f76c..36d494bf1b 100644
--- a/plugins/CorePluginsAdmin/Controller.php
+++ b/plugins/CorePluginsAdmin/Controller.php
@@ -18,6 +18,7 @@ use Piwik\Nonce;
use Piwik\Piwik;
use Piwik\Plugin;
use Piwik\Url;
+use Piwik\Version;
use Piwik\View;
use Piwik\PluginsManager;
@@ -173,6 +174,7 @@ class Controller extends \Piwik\Controller\Admin
$view->updateNonce = Nonce::getNonce('CorePluginsAdmin.updatePlugin');
$view->pluginsInfo = $pluginsInfo;
+
$view->pluginsHavingUpdate = $this->getPluginsHavingUpdate($pluginsInfo, $themesOnly = false);
echo $view->render();
@@ -206,9 +208,13 @@ class Controller extends \Piwik\Controller\Admin
foreach ($plugins as $pluginName => &$plugin) {
if (!isset($plugin['info'])) {
+ $description = '<strong><em>'
+ . Piwik_Translate('CorePluginsAdmin_PluginNotCompatibleWith', array($pluginName, self::getPiwikVersion()))
+ . '</strong> <br/> '
+ . Piwik_Translate('CorePluginsAdmin_PluginAskDevToUpdate')
+ . '</em>';
$plugin['info'] = array(
- 'description' => '<strong><em>' . Piwik_Translate('CorePluginsAdmin_PluginCannotBeFound')
- . '</strong></em>',
+ 'description' => $description,
'version' => Piwik_Translate('General_Unknown'),
'theme' => false,
);
diff --git a/plugins/CorePluginsAdmin/templates/macros.twig b/plugins/CorePluginsAdmin/templates/macros.twig
index b658796b06..8e724798fd 100644
--- a/plugins/CorePluginsAdmin/templates/macros.twig
+++ b/plugins/CorePluginsAdmin/templates/macros.twig
@@ -90,10 +90,12 @@
</td>
<td class="togl action-links">
- {% if plugin.activated %}
- <a href='index.php?module=CorePluginsAdmin&action=deactivate&pluginName={{ name }}&token_auth={{ token_auth }}'>{{ 'CorePluginsAdmin_Deactivate'|translate }}</a>
- {% else %}
- <a href='index.php?module=CorePluginsAdmin&action=activate&pluginName={{ name }}&token_auth={{ token_auth }}'>{{ 'CorePluginsAdmin_Activate'|translate }}</a>
+ {% if plugin.invalid is not defined %}
+ {% if plugin.activated %}
+ <a href='index.php?module=CorePluginsAdmin&action=deactivate&pluginName={{ name }}&token_auth={{ token_auth }}'>{{ 'CorePluginsAdmin_Deactivate'|translate }}</a>
+ {% else %}
+ <a href='index.php?module=CorePluginsAdmin&action=activate&pluginName={{ name }}&token_auth={{ token_auth }}'>{{ 'CorePluginsAdmin_Activate'|translate }}</a>
+ {% endif %}
{% endif %}
</td>
</tr>
diff --git a/plugins/Zeitgeist/templates/admin.twig b/plugins/Zeitgeist/templates/admin.twig
index 515c10e6a3..9994b4ce7a 100644
--- a/plugins/Zeitgeist/templates/admin.twig
+++ b/plugins/Zeitgeist/templates/admin.twig
@@ -61,9 +61,9 @@
{% include "@CoreHome/_warningInvalidHost.twig" %}
{# missing plugins warning #}
- {% if isSuperUser and missingPluginsWarning is defined %}
+ {% if isSuperUser and invalidPluginsWarning is defined %}
<div class="ajaxSuccess">
- <strong>{{ 'General_Warning'|translate }}:&nbsp;</strong>{{ missingPluginsWarning }}
+ <strong>{{ 'General_Warning'|translate }}:&nbsp;</strong>{{ invalidPluginsWarning|raw }}
</div>
{% endif %}
@@ -71,7 +71,7 @@
{% if isSuperUser and usingOldGeoIPPlugin is not empty %}
<div class="ajaxSuccess">
<strong>{{ 'General_Warning'|translate }}
- :&nbsp;</strong>{{ 'UserCountry_OldGeoIPWarning'|translate('<a href="index.php?module=CorePluginsAdmin&action=index&idSite=1&period=day&date=yesterday">','</a>','<a href="index.php?module=UserCountry&action=adminIndex&idSite=1&period=day&date=yesterday#location-providers">','</a>','<a href="http://piwik.org/faq/how-to/#faq_167">','</a>','<a href="http://piwik.org/faq/how-to/#faq_59">','</a>')|raw }}
+ :&nbsp;</strong>{{ 'UserCountry_OldGeoIPWarning'|translate('<a href="index.php?module=CorePluginsAdmin&action=plugins&idSite=1&period=day&date=yesterday">','</a>','<a href="index.php?module=UserCountry&action=adminIndex&idSite=1&period=day&date=yesterday#location-providers">','</a>','<a href="http://piwik.org/faq/how-to/#faq_167">','</a>','<a href="http://piwik.org/faq/how-to/#faq_59">','</a>')|raw }}
</div>
{% endif %}