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-07-16 07:27:03 +0400
committermattab <matthieu.aubry@gmail.com>2013-07-16 07:27:03 +0400
commit7198b79753e92b387639e29e2a98cc3449e4073e (patch)
tree9b9019bd7a442f42f37b51182c3df8c706beabcc
parent432dd5d880edc35d7ab2a092e39ddcc00e06e2cb (diff)
Refs #3942
* Zeitgeist is the foundation of our vision for an Open, Extendable Analytics Platform: Piwik 2. * This is the default theme for Piwik 2 from which other themes automatically inherit. * Plugins do not need a PluginName.php class anymore: plugin can be just a theme! (a json file + less/css/templates overloads) * Displaying themes Zeitgeist and PleineLune in the Themes listing
-rw-r--r--core/Plugin.php20
-rw-r--r--core/PluginsArchiver.php2
-rw-r--r--core/PluginsManager.php44
-rw-r--r--lang/en.php2
-rw-r--r--plugins/CorePluginsAdmin/Controller.php26
-rw-r--r--plugins/CorePluginsAdmin/CorePluginsAdmin.php4
-rw-r--r--plugins/CorePluginsAdmin/templates/macros.twig2
-rw-r--r--plugins/Widgetize/piwik.plugin.json17
-rw-r--r--plugins/Zeitgeist/piwik.plugin.json18
-rw-r--r--plugins/Zeitgeist/plugin.piwik.json5
10 files changed, 73 insertions, 67 deletions
diff --git a/core/Plugin.php b/core/Plugin.php
index c2e5fafca6..374c179f1c 100644
--- a/core/Plugin.php
+++ b/core/Plugin.php
@@ -15,7 +15,7 @@
*
* @package Piwik
*/
-abstract class Piwik_Plugin
+class Piwik_Plugin
{
/**
* Returns the plugin details
@@ -45,7 +45,8 @@ abstract class Piwik_Plugin
'theme' => false,
);
- $infoFromJson = Piwik_PluginsManager::getInstance()->loadInfoFromJson($this);
+ $pluginName = $this->getPluginName();
+ $infoFromJson = Piwik_PluginsManager::getInstance()->loadInfoFromJson($pluginName);
if(!empty($infoFromJson)) {
$info = array_merge($info, $infoFromJson);
}
@@ -121,7 +122,7 @@ abstract class Piwik_Plugin
*
* @return string
*/
- public function getVersion()
+ final public function getVersion()
{
$info = $this->getInformation();
return $info['version'];
@@ -137,6 +138,7 @@ abstract class Piwik_Plugin
$info = $this->getInformation();
return !empty($info['theme']) && (bool)$info['theme'];
}
+ protected $pluginName;
/**
* Returns the plugin's base class name without the "Piwik_" prefix,
@@ -146,6 +148,16 @@ abstract class Piwik_Plugin
*/
final public function getPluginName()
{
- return Piwik_Common::unprefixClass(get_class($this));
+ if(!empty($this->pluginName)) {
+ return $this->pluginName;
+ }
+ $this->pluginName = Piwik_Common::unprefixClass(get_class($this));
+ return $this->pluginName;
}
+
+ final public function setPluginName($pluginName)
+ {
+ $this->pluginName = $pluginName;
+ }
+
}
diff --git a/core/PluginsArchiver.php b/core/PluginsArchiver.php
index e322108033..6d1b047939 100644
--- a/core/PluginsArchiver.php
+++ b/core/PluginsArchiver.php
@@ -27,7 +27,7 @@ abstract class Piwik_PluginsArchiver
abstract public function archivePeriod();
- // TODO: Review this concept / each plugin should somehow maintain the list of report names they generate
+ // todo: review this concept, each plugin should somehow maintain the list of report names they generate
public function shouldArchive()
{
$pluginName = Piwik_Common::unprefixClass(get_class($this));
diff --git a/core/PluginsManager.php b/core/PluginsManager.php
index bf3cf47bd8..21157458c1 100644
--- a/core/PluginsManager.php
+++ b/core/PluginsManager.php
@@ -51,6 +51,9 @@ class Piwik_PluginsManager
'API',
'Proxy',
'LanguagesManager',
+
+ // default Piwik theme, always enabled
+ Piwik_Twig::DEFAULT_THEME,
);
// If a plugin hooks onto at least an event starting with "Tracker.", we load the plugin during tracker
@@ -154,8 +157,8 @@ class Piwik_PluginsManager
if ($pluginsName != false) {
foreach ($pluginsName as $path) {
$name = basename($path);
- if (file_exists($path . '/' . $name . '.php')) // only add folder if a Plugin/Plugin.php file exists
- {
+ $pluginStructureLooksValid = file_exists($path . "/" . $name . ".php") || file_exists($path . "/" . self::PLUGIN_JSON_FILENAME);
+ if ($pluginStructureLooksValid) {
$result[] = $name;
}
}
@@ -163,9 +166,9 @@ class Piwik_PluginsManager
return $result;
}
- public function loadInfoFromJson(Piwik_Plugin $plugin)
+ public function loadInfoFromJson($pluginName)
{
- $path = $this->getPluginsDirectory() . $plugin->getPluginName() . '/' . self::PLUGIN_JSON_FILENAME;
+ $path = $this->getPluginsDirectory() . $pluginName . '/' . self::PLUGIN_JSON_FILENAME;
if(!file_exists($path)) {
return false;
}
@@ -410,6 +413,22 @@ class Piwik_PluginsManager
if (isset($this->loadedPlugins[$pluginName])) {
return $this->loadedPlugins[$pluginName];
}
+ $newPlugin = $this->makePluginClass($pluginName);
+
+ $this->addLoadedPlugin($pluginName, $newPlugin);
+
+ Piwik_EventDispatcher::getInstance()->postPendingEventsTo($newPlugin);
+
+ return $newPlugin;
+ }
+
+ /**
+ * @param $pluginName
+ * @return Piwik_Plugin
+ * @throws Exception
+ */
+ protected function makePluginClass($pluginName)
+ {
$pluginFileName = sprintf("%s/%s.php", $pluginName, $pluginName);
$pluginClassName = sprintf('Piwik_%s', $pluginName);
@@ -420,14 +439,14 @@ class Piwik_PluginsManager
$path = $this->getPluginsDirectory() . $pluginFileName;
if (!file_exists($path)) {
- // ToDo: We should log this - but this will crash in Tracker mode since core/Piwik is not loaded
- //Piwik::log(sprintf("Unable to load plugin '%s' because '%s' couldn't be found.", $pluginName, $path));
- throw new Exception(sprintf("Unable to load plugin '%s' because '%s' couldn't be found.", $pluginName, $path));
+ // Create the smallest minimal Piwik Plugin
+ // Eg. Used for Zeitgeist default theme which does not have a Zeitgeist.php file
+ $minimalistPlugin = new Piwik_Plugin();
+ $minimalistPlugin->setPluginName($pluginName);
+ return $minimalistPlugin;
}
- // Don't remove this.
- // Our autoloader can't find plugins/PluginName/PluginName.php
- require_once $path; // prefixed by PIWIK_INCLUDE_PATH
+ require_once $path;
if (!class_exists($pluginClassName, false)) {
throw new Exception("The class $pluginClassName couldn't be found in the file '$path'");
@@ -437,11 +456,6 @@ class Piwik_PluginsManager
if (!($newPlugin instanceof Piwik_Plugin)) {
throw new Exception("The plugin $pluginClassName in the file $path must inherit from Piwik_Plugin.");
}
-
- $this->addLoadedPlugin($pluginName, $newPlugin);
-
- Piwik_EventDispatcher::getInstance()->postPendingEventsTo($newPlugin);
-
return $newPlugin;
}
diff --git a/lang/en.php b/lang/en.php
index 10ad333bfd..cfc07bf943 100644
--- a/lang/en.php
+++ b/lang/en.php
@@ -734,7 +734,7 @@ Piwik will let you track visitors to your website for free. You should definitel
'CorePluginsAdmin_Deactivate' => 'Deactivate',
'CorePluginsAdmin_Activate' => 'Activate',
'CorePluginsAdmin_MenuPlatform' => 'Platform',
- 'CorePluginsAdmin_MenuMarketplace' => 'Marketplace',
+ 'CorePluginsAdmin_MenuExtend' => 'Extend',
'CorePluginsAdmin_PluginCannotBeFound' => 'This plugin cannot be found!',
'CoreUpdater_PluginDescription' => 'Piwik updating mechanism',
'CoreUpdater_UpdateTitle' => 'Update',
diff --git a/plugins/CorePluginsAdmin/Controller.php b/plugins/CorePluginsAdmin/Controller.php
index 5338909d66..baa04f6da4 100644
--- a/plugins/CorePluginsAdmin/Controller.php
+++ b/plugins/CorePluginsAdmin/Controller.php
@@ -15,9 +15,9 @@
*/
class Piwik_CorePluginsAdmin_Controller extends Piwik_Controller_Admin
{
- function marketplace()
+ function extend()
{
- $view = $this->configureView('@CorePluginsAdmin/marketplace');
+ $view = $this->configureView('@CorePluginsAdmin/extend');
echo $view->render();
}
@@ -66,7 +66,6 @@ class Piwik_CorePluginsAdmin_Controller extends Piwik_Controller_Admin
foreach ($loadedPlugins as $oPlugin) {
$pluginName = $oPlugin->getPluginName();
$plugins[$pluginName]['info'] = $oPlugin->getInformation();
- $plugins[$pluginName]['theme'] = $oPlugin->isTheme();
}
foreach ($plugins as $pluginName => &$plugin) {
@@ -80,12 +79,23 @@ class Piwik_CorePluginsAdmin_Controller extends Piwik_Controller_Admin
}
}
+ $pluginsFiltered = $this->keepPluginsOrThemes($themesOnly, $plugins);
+ return $pluginsFiltered;
+ }
+
+ protected function keepPluginsOrThemes($themesOnly, $plugins)
+ {
$pluginsFiltered = array();
- foreach($plugins as $name => $plugin) {
- $isTheme = $plugin['theme'];
- if( ($themesOnly && $isTheme)
- || (!$themesOnly && !$isTheme)) {
- $pluginsFiltered[$name] = $plugin;
+ foreach ($plugins as $name => $thisPlugin) {
+
+ $isTheme = false;
+ if (!empty($thisPlugin['info']['theme'])) {
+ $isTheme = (bool)$thisPlugin['info']['theme'];
+ }
+ if (($themesOnly && $isTheme)
+ || (!$themesOnly && !$isTheme)
+ ) {
+ $pluginsFiltered[$name] = $thisPlugin;
}
}
return $pluginsFiltered;
diff --git a/plugins/CorePluginsAdmin/CorePluginsAdmin.php b/plugins/CorePluginsAdmin/CorePluginsAdmin.php
index 88fa697684..732f26f5b2 100644
--- a/plugins/CorePluginsAdmin/CorePluginsAdmin.php
+++ b/plugins/CorePluginsAdmin/CorePluginsAdmin.php
@@ -34,8 +34,8 @@ class Piwik_CorePluginsAdmin extends Piwik_Plugin
array('module' => 'CorePluginsAdmin', 'action' => 'themes'),
Piwik::isUserIsSuperUser(),
$order = 3);
- Piwik_AddAdminSubMenu('CorePluginsAdmin_MenuPlatform', 'CorePluginsAdmin_MenuMarketplace',
- array('module' => 'CorePluginsAdmin', 'action' => 'marketplace'),
+ Piwik_AddAdminSubMenu('CorePluginsAdmin_MenuPlatform', 'CorePluginsAdmin_MenuExtend',
+ array('module' => 'CorePluginsAdmin', 'action' => 'extend'),
Piwik::isUserIsSuperUser(),
$order = 5);
}
diff --git a/plugins/CorePluginsAdmin/templates/macros.twig b/plugins/CorePluginsAdmin/templates/macros.twig
index fd38899c1f..7da709fb30 100644
--- a/plugins/CorePluginsAdmin/templates/macros.twig
+++ b/plugins/CorePluginsAdmin/templates/macros.twig
@@ -13,7 +13,7 @@
</thead>
<tbody id="plugins">
{% for name,plugin in pluginsInfo %}
- {% if plugin.alwaysActivated is defined and not plugin.alwaysActivated %}
+ {% if (plugin.alwaysActivated is defined and not plugin.alwaysActivated) or isTheme %}
<tr {% if plugin.activated %}class="highlighted"{% endif %}>
<td class="name">
{% if plugin.info.homepage is defined %}
diff --git a/plugins/Widgetize/piwik.plugin.json b/plugins/Widgetize/piwik.plugin.json
deleted file mode 100644
index d768a65644..0000000000
--- a/plugins/Widgetize/piwik.plugin.json
+++ /dev/null
@@ -1,17 +0,0 @@
-{
- "name": "Widgetize",
- "description": "The plugin makes it easy to export any Piwik Widget in your Blog, Website or on Igoogle and Netvibes!",
- "keywords": ["core"],
- "homepage": "http://piwik.org",
- "license": "GPL-3.0+",
- "authors": [
- {
- "name": "Piwik",
- "email": "hello@piwik.org",
- "homepage": "http://piwik.org"
- }
- ],
- "require": {
- "php": ">=5.3.0"
- }
-}
diff --git a/plugins/Zeitgeist/piwik.plugin.json b/plugins/Zeitgeist/piwik.plugin.json
deleted file mode 100644
index 5d639268d0..0000000000
--- a/plugins/Zeitgeist/piwik.plugin.json
+++ /dev/null
@@ -1,18 +0,0 @@
-{
- "name": "Zeitgeist",
- "description": "This is the default theme for Piwik",
- "keywords": ["theme"],
- "homepage": "http://piwik.org",
- "license": "GPL-3.0+",
- "authors": [
- {
- "name": "Piwik",
- "email": "hello@piwik.org",
- "homepage": "http://piwik.org"
- }
- ],
- "require": {
- "piwik": ">=2.0"
- },
- "theme": true
-} \ No newline at end of file
diff --git a/plugins/Zeitgeist/plugin.piwik.json b/plugins/Zeitgeist/plugin.piwik.json
new file mode 100644
index 0000000000..1761842434
--- /dev/null
+++ b/plugins/Zeitgeist/plugin.piwik.json
@@ -0,0 +1,5 @@
+{
+ "name": "Zeitgeist",
+ "description": "Zeitgeist is the foundation of our vision for an Open, Extendable Analytics Platform: Piwik 2. This is the default theme for Piwik 2 from which other themes automatically inherit.",
+ "theme": true
+} \ No newline at end of file