Skip to content

Commit

Permalink
Refs #3942 Now themes don't need to have a PHP file, themes can simpl…
Browse files Browse the repository at this point in the history
…y specify a "stylesheet" entry in the plugin.piwik.json, this CSS/less file will be loaded as if it was registered with the css event
  • Loading branch information
mattab committed Aug 11, 2013
1 parent 7ef891e commit 2340530
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 44 deletions.
2 changes: 1 addition & 1 deletion config/global.ini.php
Expand Up @@ -236,7 +236,7 @@
; maximum number of rows for any of the Actions tables (pages, downloads, outlinks)
datatable_archiving_maximum_rows_actions = 500
; maximum number of rows for pages in categories (sub pages, when clicking on the + for a page category)
; note: should not exceed the display limit in Piwik_Actions_Controller::ACTIONS_REPORT_ROWS_DISPLAY
; note: should not exceed the display limit in Piwik\Actions\Controller::ACTIONS_REPORT_ROWS_DISPLAY
; because each subdirectory doesn't have paging at the bottom, so all data should be displayed if possible.
datatable_archiving_maximum_rows_subtable_actions = 100

Expand Down
11 changes: 11 additions & 0 deletions core/AssetManager.php
Expand Up @@ -254,7 +254,18 @@ private static function getCssFiles()
{
$cssFiles = array();
Piwik_PostEvent(self::CSS_IMPORT_EVENT, array(&$cssFiles));

$cssFiles = self::sortCssFiles($cssFiles);

// We also look for the currently enabled theme and add CSS from the json
$theme = PluginsManager::getInstance()->getThemeEnabled();
if($theme) {
$info = $theme->getInformation();
if(isset($info['stylesheet'])) {
$themeStylesheetFile = 'plugins/'. $theme->getPluginName() . '/' . $info['stylesheet'];
}
$cssFiles[] = $themeStylesheetFile;
}
return $cssFiles;
}

Expand Down
11 changes: 6 additions & 5 deletions core/PluginsManager.php
Expand Up @@ -283,8 +283,9 @@ public function activatePlugin($pluginName)
}

// Only one theme enabled at a time
$themeAlreadyEnabled = $this->getThemeEnabled();
if($themeAlreadyEnabled) {
$themeEnabled = $this->getThemeEnabled();
if($themeEnabled) {
$themeAlreadyEnabled = $themeEnabled->getPluginName();
$plugin = $this->loadPlugin($pluginName);
if($plugin->isTheme()) {
$plugins = $this->deactivatePlugin( $themeAlreadyEnabled, $plugins );
Expand Down Expand Up @@ -325,16 +326,16 @@ protected function isPluginInFilesystem($pluginName)
* Returns the name of the non default theme currently enabled.
* If Zeitgeist is enabled, returns false (nb: Zeitgeist cannot be disabled)
*
* @return string
* @return Plugin
*/
protected function getThemeEnabled()
public function getThemeEnabled()
{
$plugins = $this->getLoadedPlugins();
foreach($plugins as $plugin) {
/* @var $plugin Plugin */
if($plugin->isTheme()
&& $plugin->getPluginName() != self::DEFAULT_THEME) {
return $plugin->getPluginName();
return $plugin;
}
}
return false;
Expand Down
4 changes: 1 addition & 3 deletions core/ViewDataTable.php
Expand Up @@ -977,8 +977,7 @@ public function hasReportBeenPurged()
$reportYear = $reportDate->toString('Y');
$reportMonth = $reportDate->toString('m');

//TODOA
if (class_exists('Piwik\Plugins\PrivacyManager\PrivacyManager')
if (PluginsManager::getInstance()->isPluginActivated('PrivacyManager')
&& Plugins\PrivacyManager\PrivacyManager::shouldReportBePurged($reportYear, $reportMonth)
) {
return true;
Expand Down Expand Up @@ -1013,7 +1012,6 @@ private function getBaseReportUrl($module, $action, $queryParams = array())
*/
static public function renderReport($pluginName, $apiAction, $fetch = true)
{
//TODOA
$namespacedApiClassName = "\\Piwik\\Plugins\\$pluginName\\API";
if (!method_exists($namespacedApiClassName::getInstance(), $apiAction)) {
throw new \Exception("$namespacedApiClassName Invalid action name '$apiAction' for '$pluginName' plugin.");
Expand Down
4 changes: 2 additions & 2 deletions plugins/Goals/Archiver.php
Expand Up @@ -16,6 +16,7 @@
use Piwik\DataTable;
use Piwik\DataArray;
use Piwik\PluginsArchiver;
use Piwik\PluginsManager;
use Piwik\Tracker\GoalManager;
use Piwik\Plugins\Goals\Goals;

Expand Down Expand Up @@ -333,8 +334,7 @@ protected function cleanupRowGetLabel(&$row, $currentField)
}
$label = "Value not defined";
// Product Name/Category not defined"
//TODOA : working?
if (class_exists('Piwik\Plugins\CustomVariables\CustomVariables')) {
if (PluginsManager::getInstance()->isPluginActivated('CustomVariables')) {
$label = \Piwik\Plugins\CustomVariables\Archiver::LABEL_CUSTOM_VALUE_NOT_DEFINED;
}
}
Expand Down
32 changes: 0 additions & 32 deletions plugins/PleineLune/PleineLune.php

This file was deleted.

3 changes: 2 additions & 1 deletion plugins/PleineLune/plugin.piwik.json
@@ -1,5 +1,6 @@
{
"name": "PleineLune",
"description": "A dark theme for Piwik, ideal to view your analytics reports before sunrise.",
"theme": true
"theme": true,
"stylesheet": "stylesheets/theme.less"
}

0 comments on commit 2340530

Please sign in to comment.