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
path: root/core
diff options
context:
space:
mode:
authormattab <matthieu.aubry@gmail.com>2013-07-16 08:02:51 +0400
committermattab <matthieu.aubry@gmail.com>2013-07-16 08:02:51 +0400
commit53654d581f0502e311f054dcb8ae400597e85a46 (patch)
tree09209ff20974c0c26e32e887a9517963a4625650 /core
parent7198b79753e92b387639e29e2a98cc3449e4073e (diff)
Refs #3942
* Enabling one theme a time: automatically deactivates another theme if it was enabled (except Zeitgeist which is always on)
Diffstat (limited to 'core')
-rw-r--r--core/PluginsManager.php41
1 files changed, 35 insertions, 6 deletions
diff --git a/core/PluginsManager.php b/core/PluginsManager.php
index 21157458c1..7b49d9ff30 100644
--- a/core/PluginsManager.php
+++ b/core/PluginsManager.php
@@ -192,10 +192,13 @@ class Piwik_PluginsManager
* Deactivate plugin
*
* @param string $pluginName Name of plugin
+ * @param array $plugins Array of plugin names
*/
- public function deactivatePlugin($pluginName)
+ public function deactivatePlugin($pluginName, $plugins = false)
{
- $plugins = $this->pluginsToLoad;
+ if(empty($plugins)) {
+ $plugins = $this->pluginsToLoad;
+ }
$key = array_search($pluginName, $plugins);
$plugin = $this->loadPlugin($pluginName);
@@ -219,6 +222,8 @@ class Piwik_PluginsManager
Piwik_Config::getInstance()->forceSave();
Piwik::deleteAllCacheOnUpdate();
+
+ return $plugins;
}
/**
@@ -267,9 +272,14 @@ class Piwik_PluginsManager
// we add the plugin to the list of activated plugins
if (!in_array($pluginName, $plugins)) {
$plugins[] = $pluginName;
- } else {
- // clean up if we find a dupe
- $plugins = array_unique($plugins);
+ }
+ $plugins = array_unique($plugins);
+
+ // Only one theme enabled at a time
+ $themeAlreadyEnabled = $this->getThemeEnabled();
+ if($plugin->isTheme()
+ && $themeAlreadyEnabled) {
+ $plugins = $this->deactivatePlugin( $themeAlreadyEnabled, $plugins );
}
// the config file will automatically be saved with the new plugin
@@ -280,6 +290,25 @@ class Piwik_PluginsManager
}
/**
+ * Returns the name of the non default theme currently enabled.
+ * If Zeitgeist is enabled, returns false (nb: Zeitgeist cannot be disabled)
+ *
+ * @return string
+ */
+ protected function getThemeEnabled()
+ {
+ $plugins = $this->getLoadedPlugins();
+ foreach($plugins as $plugin) {
+ /* @var $plugin Piwik_Plugin */
+ if($plugin->isTheme()
+ && $plugin->getPluginName() != Piwik_Twig::DEFAULT_THEME) {
+ return $plugin->getPluginName();
+ }
+ }
+ return false;
+ }
+
+ /**
* Load the specified plugins
*
* @param array $pluginsToLoad Array of plugins to load
@@ -356,7 +385,7 @@ class Piwik_PluginsManager
* 'UserSettings' => Piwik_Plugin $pluginObject,
* );
*
- * @return array
+ * @return array,Piwik_Plugin
*/
public function getLoadedPlugins()
{