diff --git a/plugins/CoreConsole/Commands/GenerateWidget.php b/plugins/CoreConsole/Commands/GenerateWidget.php index c7fabb1c44241337f2fe6ac5d18d434e2082225b..53552e684423465b97d22f7d7a59e8cf341cc163 100644 --- a/plugins/CoreConsole/Commands/GenerateWidget.php +++ b/plugins/CoreConsole/Commands/GenerateWidget.php @@ -34,7 +34,7 @@ class GenerateWidget extends GeneratePluginBase $category = $this->getCategory($input, $output); $exampleFolder = PIWIK_INCLUDE_PATH . '/plugins/ExamplePlugin'; - $replace = array('ExampleRssWidget' => $pluginName, + $replace = array('ExamplePlugin' => $pluginName, 'Example Category' => $category); $whitelistFiles = array('/Widgets.php'); diff --git a/plugins/DevicesDetection/DevicesDetection.php b/plugins/DevicesDetection/DevicesDetection.php index e1b09be333e9b45a73b63742eab8e78ff337de66..6e018d77127e89f6ac98eb2a4f0b27565e4f008f 100644 --- a/plugins/DevicesDetection/DevicesDetection.php +++ b/plugins/DevicesDetection/DevicesDetection.php @@ -50,7 +50,7 @@ class DevicesDetection extends \Piwik\Plugin if (!PluginManager::getInstance()->isPluginActivated('UserSettings')) { $instance = new UserSettings(); - $instance->extendVisitorDetails(&$visitor, $details); + $instance->extendVisitorDetails($visitor, $details); } } diff --git a/plugins/Insights/templates/insightsOverviewWidget.twig b/plugins/Insights/templates/insightsOverviewWidget.twig index cf8bfe166d7ce5dea72dedf0e1fc4f3db64c2f20..7a3ec6e1d16c0ff18f453bf10e1fbae6702226e9 100644 --- a/plugins/Insights/templates/insightsOverviewWidget.twig +++ b/plugins/Insights/templates/insightsOverviewWidget.twig @@ -1,5 +1,14 @@ -{% set allMetadata = reports.getFirstRow.getAllTableMetadata %} -{% set consideredGrowth = 'Insights_TitleConsideredInsightsGrowth'|translate(allMetadata.minGrowthPercentPositive, allMetadata.lastDate|prettyDate(allMetadata.period)) %} +{% if reports.getRowsCount %} + {% set allMetadata = reports.getFirstRow.getAllTableMetadata %} + {% set consideredGrowth = 'Insights_TitleConsideredInsightsGrowth'|translate(allMetadata.minGrowthPercentPositive, allMetadata.lastDate|prettyDate(allMetadata.period)) %} + +{% else %} + {% set allMetadata = {} %} + {% set consideredGrowth = '' %} +{% endif %} + {% set consideredChanges = '' %} -{% include "@Insights/overviewWidget.twig" %} \ No newline at end of file +{% include "@Insights/overviewWidget.twig" %} + + diff --git a/plugins/Insights/templates/moversAndShakersOverviewWidget.twig b/plugins/Insights/templates/moversAndShakersOverviewWidget.twig index f2326df1eae3565c6f6445500beacff3806d9097..bc79edcfb1f0c9f1c69e4794479606bf332bcb05 100644 --- a/plugins/Insights/templates/moversAndShakersOverviewWidget.twig +++ b/plugins/Insights/templates/moversAndShakersOverviewWidget.twig @@ -1,6 +1,13 @@ -{% set allMetadata = reports.getFirstRow.getAllTableMetadata %} +{% if reports.getRowsCount %} + {% set allMetadata = reports.getFirstRow.getAllTableMetadata %} -{% set consideredGrowth = 'Insights_TitleConsideredMoversAndShakersGrowth'|translate(allMetadata.metricName, allMetadata.lastTotalValue, allMetadata.totalValue, allMetadata.lastDate|prettyDate(allMetadata.period), allMetadata.evolutionTotal) %} -{% set consideredChanges = 'Insights_TitleConsideredMoversAndShakersChanges'|translate(allMetadata.minGrowthPercentPositive, allMetadata.minGrowthPercentNegative, allMetadata.minNewPercent, allMetadata.minIncreaseNew, allMetadata.minDisappearedPercent, allMetadata.minDecreaseDisappeared, allMetadata.totalValue) %} + {% set consideredGrowth = 'Insights_TitleConsideredMoversAndShakersGrowth'|translate(allMetadata.metricName, allMetadata.lastTotalValue, allMetadata.totalValue, allMetadata.lastDate|prettyDate(allMetadata.period), allMetadata.evolutionTotal) %} + {% set consideredChanges = 'Insights_TitleConsideredMoversAndShakersChanges'|translate(allMetadata.minGrowthPercentPositive, allMetadata.minGrowthPercentNegative, allMetadata.minNewPercent, allMetadata.minIncreaseNew, allMetadata.minDisappearedPercent, allMetadata.minDecreaseDisappeared, allMetadata.totalValue) %} +{% else %} + {% set allMetadata = {} %} + + {% set consideredGrowth = '' %} + {% set consideredChanges = '' %} +{% endif %} {% include "@Insights/overviewWidget.twig" %} \ No newline at end of file diff --git a/plugins/UserCountryMap/Menu.php b/plugins/UserCountryMap/Menu.php index 298eda1e176d21719bf1890bcf53835389ba5dc3..fa32a8f9b7940ee968e19da319e75dd9e08f6632 100644 --- a/plugins/UserCountryMap/Menu.php +++ b/plugins/UserCountryMap/Menu.php @@ -9,12 +9,16 @@ namespace Piwik\Plugins\UserCountryMap; use Piwik\Menu\MenuReporting; +use Piwik\Plugin\Manager as PluginManager; class Menu extends \Piwik\Plugin\Menu { public function configureReportingMenu(MenuReporting $menu) { - $menu->addVisitorsItem('UserCountryMap_RealTimeMap', - array('module' => 'UserCountryMap', 'action' => 'realtimeWorldMap'), $order = 70); + if (PluginManager::getInstance()->isPluginActivated('UserCountry')) { + $menu->addVisitorsItem('UserCountryMap_RealTimeMap', + array('module' => 'UserCountryMap', 'action' => 'realtimeWorldMap'), + $order = 70); + } } } diff --git a/plugins/UserCountryMap/UserCountryMap.php b/plugins/UserCountryMap/UserCountryMap.php index 2ff43f1bbb652d6b5d48e4c18af4a3bd832e518a..fdedc1085dff4c4b6bb205ed3519ce093a52f33b 100644 --- a/plugins/UserCountryMap/UserCountryMap.php +++ b/plugins/UserCountryMap/UserCountryMap.php @@ -34,9 +34,6 @@ class UserCountryMap extends \Piwik\Plugin public function postLoad() { - WidgetsList::add('General_Visitors', Piwik::translate('UserCountryMap_VisitorMap'), 'UserCountryMap', 'visitorMap'); - WidgetsList::add('Live!', Piwik::translate('UserCountryMap_RealTimeMap'), 'UserCountryMap', 'realtimeMap'); - Piwik::addAction('Template.leftColumnUserCountry', array('Piwik\Plugins\UserCountryMap\UserCountryMap', 'insertMapInLocationReport')); } diff --git a/plugins/UserCountryMap/Widgets.php b/plugins/UserCountryMap/Widgets.php new file mode 100644 index 0000000000000000000000000000000000000000..b2142f4ee4f421d7a660a7481d7ce28f86b1bfa9 --- /dev/null +++ b/plugins/UserCountryMap/Widgets.php @@ -0,0 +1,38 @@ +<?php +/** + * Piwik - free/libre analytics platform + * + * @link http://piwik.org + * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later + * + */ +namespace Piwik\Plugins\UserCountryMap; + +use Piwik\Piwik; +use Piwik\View; +use Piwik\Plugin\Manager as PluginManager; + +/** + * This class allows you to add your own widgets to the Piwik platform. In case you want to remove widgets from another + * plugin please have a look at the "configureWidgetsList()" method. + * To configure a widget simply call the corresponding methods as described in the API-Reference: + * http://developer.piwik.org/api-reference/Piwik/Plugin\Widgets + */ +class Widgets extends \Piwik\Plugin\Widgets +{ + /** + * Here you can define the category the widget belongs to. You can reuse any existing widget category or define + * your own category. + * @var string + */ + protected $category = 'General_Visitor'; + + protected function init() + { + if (PluginManager::getInstance()->isPluginActivated('UserCountry')) { + $this->addWidget(Piwik::translate('UserCountryMap_VisitorMap'), 'visitorMap'); + $this->addWidgetWithCustomCategory('Live!', Piwik::translate('UserCountryMap_RealTimeMap'), 'realtimeMap'); + } + } + +}