diff --git a/core/Menu/MenuAdmin.php b/core/Menu/MenuAdmin.php index 5c997e15660..8b11500c12f 100644 --- a/core/Menu/MenuAdmin.php +++ b/core/Menu/MenuAdmin.php @@ -59,6 +59,7 @@ public function getMenu() /** * @ignore + * @deprecated */ Piwik::postEvent('Menu.Admin.addItems', array()); diff --git a/core/Menu/MenuReporting.php b/core/Menu/MenuReporting.php index 737674d3eb6..146c6d08f11 100644 --- a/core/Menu/MenuReporting.php +++ b/core/Menu/MenuReporting.php @@ -63,6 +63,7 @@ public function getMenu() /** * @ignore + * @deprecated */ Piwik::postEvent('Menu.Reporting.addItems', array()); diff --git a/core/Menu/MenuTop.php b/core/Menu/MenuTop.php index c8f8723fea2..1b3b5431792 100644 --- a/core/Menu/MenuTop.php +++ b/core/Menu/MenuTop.php @@ -96,6 +96,7 @@ public function getMenu() /** * @ignore + * @deprecated */ Piwik::postEvent('Menu.Top.addItems', array()); diff --git a/core/Plugin/Widgets.php b/core/Plugin/Widgets.php new file mode 100644 index 00000000000..c2ea16f7cfd --- /dev/null +++ b/core/Plugin/Widgets.php @@ -0,0 +1,29 @@ +findComponents('Widgets', 'Piwik\\Plugin\\Widgets'); + $widgetsList = self::getInstance(); + + foreach ($widgets as $widget) { + $widget->configure($widgetsList); + } } } @@ -145,6 +146,11 @@ static public function add($widgetCategory, $widgetName, $controllerName, $contr } $widgetUniqueId .= $name . $value; } + + if (!array_key_exists($widgetCategory, self::$widgets)) { + self::$widgets[$widgetCategory] = array(); + } + self::$widgets[$widgetCategory][] = array( 'name' => $widgetName, 'uniqueId' => $widgetUniqueId, @@ -209,7 +215,7 @@ static public function isDefined($controllerName, $controllerAction) */ public static function _reset() { - self::$widgets = null; + self::$widgets = array(); self::$hookCalled = false; } } diff --git a/plugins/Actions/Actions.php b/plugins/Actions/Actions.php index ccfe8532f5e..f39e150fd7a 100644 --- a/plugins/Actions/Actions.php +++ b/plugins/Actions/Actions.php @@ -12,14 +12,11 @@ use Piwik\ArchiveProcessor; use Piwik\Common; use Piwik\Db; -use Piwik\Menu\MenuAbstract; -use Piwik\Menu\MenuMain; use Piwik\MetricsFormatter; use Piwik\Piwik; use Piwik\Plugin\ViewDataTable; use Piwik\Plugins\CoreVisualizations\Visualizations\HtmlTable; use Piwik\Site; -use Piwik\WidgetsList; /** * Actions plugin @@ -37,7 +34,6 @@ class Actions extends \Piwik\Plugin public function getListHooksRegistered() { $hooks = array( - 'WidgetsList.addWidgets' => 'addWidgets', 'API.getReportMetadata' => 'getReportMetadata', 'API.getSegmentDimensionMetadata' => 'getSegmentsMetadata', 'ViewDataTable.configure' => 'configureViewDataTable', @@ -462,29 +458,6 @@ public function getReportMetadata(&$reports) } } - function addWidgets() - { - WidgetsList::add('General_Actions', 'General_Pages', 'Actions', 'getPageUrls'); - WidgetsList::add('General_Actions', 'Actions_WidgetPageTitles', 'Actions', 'getPageTitles'); - WidgetsList::add('General_Actions', 'General_Outlinks', 'Actions', 'getOutlinks'); - WidgetsList::add('General_Actions', 'General_Downloads', 'Actions', 'getDownloads'); - WidgetsList::add('General_Actions', 'Actions_WidgetPagesEntry', 'Actions', 'getEntryPageUrls'); - WidgetsList::add('General_Actions', 'Actions_WidgetPagesExit', 'Actions', 'getExitPageUrls'); - WidgetsList::add('General_Actions', 'Actions_WidgetEntryPageTitles', 'Actions', 'getEntryPageTitles'); - WidgetsList::add('General_Actions', 'Actions_WidgetExitPageTitles', 'Actions', 'getExitPageTitles'); - - if ($this->isSiteSearchEnabled()) { - WidgetsList::add('Actions_SubmenuSitesearch', 'Actions_WidgetSearchKeywords', 'Actions', 'getSiteSearchKeywords'); - - if (self::isCustomVariablesPluginsEnabled()) { - WidgetsList::add('Actions_SubmenuSitesearch', 'Actions_WidgetSearchCategories', 'Actions', 'getSiteSearchCategories'); - } - WidgetsList::add('Actions_SubmenuSitesearch', 'Actions_WidgetSearchNoResultKeywords', 'Actions', 'getSiteSearchNoResultKeywords'); - WidgetsList::add('Actions_SubmenuSitesearch', 'Actions_WidgetPageUrlsFollowingSearch', 'Actions', 'getPageUrlsFollowingSiteSearch'); - WidgetsList::add('Actions_SubmenuSitesearch', 'Actions_WidgetPageTitlesFollowingSearch', 'Actions', 'getPageTitlesFollowingSiteSearch'); - } - } - public function isSiteSearchEnabled() { $idSite = Common::getRequestVar('idSite', 0, 'int'); @@ -515,12 +488,11 @@ static public function checkCustomVariablesPluginEnabled() } } - static protected function isCustomVariablesPluginsEnabled() + static public function isCustomVariablesPluginsEnabled() { return \Piwik\Plugin\Manager::getInstance()->isPluginActivated('CustomVariables'); } - public function configureViewDataTable(ViewDataTable $view) { switch ($view->requestConfig->apiMethodToRequestDataTable) { diff --git a/plugins/Actions/Widgets.php b/plugins/Actions/Widgets.php new file mode 100644 index 00000000000..eff55ceb1b0 --- /dev/null +++ b/plugins/Actions/Widgets.php @@ -0,0 +1,51 @@ +add($category, 'General_Pages', $controller, 'getPageUrls'); + $widgetsList->add($category, 'Actions_WidgetPageTitles', $controller, 'getPageTitles'); + $widgetsList->add($category, 'General_Outlinks', $controller, 'getOutlinks'); + $widgetsList->add($category, 'General_Downloads', $controller, 'getDownloads'); + $widgetsList->add($category, 'Actions_WidgetPagesEntry', $controller, 'getEntryPageUrls'); + $widgetsList->add($category, 'Actions_WidgetPagesExit', $controller, 'getExitPageUrls'); + $widgetsList->add($category, 'Actions_WidgetEntryPageTitles', $controller, 'getEntryPageTitles'); + $widgetsList->add($category, 'Actions_WidgetExitPageTitles', $controller, 'getExitPageTitles'); + + $actions = new Actions(); + if ($actions->isSiteSearchEnabled()) { + $this->addSearchWidgets($widgetsList, $controller); + } + } + + private function addSearchWidgets(WidgetsList $widgetsList, $controller) + { + $category = 'Actions_SubmenuSitesearch'; + + $widgetsList->add($category, 'Actions_WidgetSearchKeywords', $controller, 'getSiteSearchKeywords'); + + if (Actions::isCustomVariablesPluginsEnabled()) { + $widgetsList->add($category, 'Actions_WidgetSearchCategories', $controller, 'getSiteSearchCategories'); + } + + $widgetsList->add($category, 'Actions_WidgetSearchNoResultKeywords', $controller, 'getSiteSearchNoResultKeywords'); + $widgetsList->add($category, 'Actions_WidgetPageUrlsFollowingSearch', $controller, 'getPageUrlsFollowingSiteSearch'); + $widgetsList->add($category, 'Actions_WidgetPageTitlesFollowingSearch', $controller, 'getPageTitlesFollowingSiteSearch'); + } + +} diff --git a/plugins/CoreConsole/Commands/GenerateWidget.php b/plugins/CoreConsole/Commands/GenerateWidget.php new file mode 100644 index 00000000000..836ea3970a9 --- /dev/null +++ b/plugins/CoreConsole/Commands/GenerateWidget.php @@ -0,0 +1,58 @@ +setName('generate:widget') + ->setDescription('Adds a plugin widget class to an existing plugin') + ->addOption('pluginname', null, InputOption::VALUE_REQUIRED, 'The name of an existing plugin which does not have any widgets defined yet'); + } + + protected function execute(InputInterface $input, OutputInterface $output) + { + $pluginName = $this->getPluginName($input, $output); + + $exampleFolder = PIWIK_INCLUDE_PATH . '/plugins/ExamplePlugin'; + $replace = array('ExampleRssWidget' => $pluginName); + $whitelistFiles = array('/Widgets.php'); + + $this->copyTemplateToPlugin($exampleFolder, $pluginName, $replace, $whitelistFiles); + + $this->writeSuccessMessage($output, array( + sprintf('Widgets.php for %s generated.', $pluginName), + 'You can now start defining your plugin widgets', + 'Enjoy!' + )); + } + + /** + * @param InputInterface $input + * @param OutputInterface $output + * @return array + * @throws \RunTimeException + */ + protected function getPluginName(InputInterface $input, OutputInterface $output) + { + $pluginNames = $this->getPluginNamesHavingNotSpecificFile('Widgets.php'); + $invalidName = 'You have to enter the name of an existing plugin which does not already have any widgets defined'; + + return $this->askPluginNameAndValidate($input, $output, $pluginNames, $invalidName); + } + +} diff --git a/plugins/CoreHome/CoreHome.php b/plugins/CoreHome/CoreHome.php index 83e0572327a..cd4741f83e4 100644 --- a/plugins/CoreHome/CoreHome.php +++ b/plugins/CoreHome/CoreHome.php @@ -8,8 +8,6 @@ */ namespace Piwik\Plugins\CoreHome; -use Piwik\WidgetsList; - /** * */ @@ -23,20 +21,10 @@ public function getListHooksRegistered() return array( 'AssetManager.getStylesheetFiles' => 'getStylesheetFiles', 'AssetManager.getJavaScriptFiles' => 'getJsFiles', - 'WidgetsList.addWidgets' => 'addWidgets', 'Translate.getClientSideTranslationKeys' => 'getClientSideTranslationKeys' ); } - /** - * Adds the donate form widget. - */ - public function addWidgets() - { - WidgetsList::add('Example Widgets', 'CoreHome_SupportPiwik', 'CoreHome', 'getDonateForm'); - WidgetsList::add('Example Widgets', 'Installation_Welcome', 'CoreHome', 'getPromoVideo'); - } - public function getStylesheetFiles(&$stylesheets) { $stylesheets[] = "libs/jquery/themes/base/jquery-ui.css"; diff --git a/plugins/CoreHome/Widgets.php b/plugins/CoreHome/Widgets.php new file mode 100644 index 00000000000..5aba86a2cd6 --- /dev/null +++ b/plugins/CoreHome/Widgets.php @@ -0,0 +1,24 @@ +add($category, 'CoreHome_SupportPiwik', $controller, 'getDonateForm'); + $widgetsList->add($category, 'Installation_Welcome', $controller, 'getPromoVideo'); + } + +} diff --git a/plugins/CustomVariables/CustomVariables.php b/plugins/CustomVariables/CustomVariables.php index 49b35516d47..5f1c790f1c7 100644 --- a/plugins/CustomVariables/CustomVariables.php +++ b/plugins/CustomVariables/CustomVariables.php @@ -9,13 +9,10 @@ namespace Piwik\Plugins\CustomVariables; use Piwik\ArchiveProcessor; -use Piwik\Menu\MenuAbstract; -use Piwik\Menu\MenuMain; use Piwik\Piwik; use Piwik\Plugin\ViewDataTable; use Piwik\Tracker\Cache; use Piwik\Tracker; -use Piwik\WidgetsList; /** */ @@ -34,7 +31,6 @@ public function getInformation() public function getListHooksRegistered() { $hooks = array( - 'WidgetsList.addWidgets' => 'addWidgets', 'Goals.getReportsWithGoalMetrics' => 'getReportsWithGoalMetrics', 'API.getReportMetadata' => 'getReportMetadata', 'API.getSegmentDimensionMetadata' => 'getSegmentsMetadata', @@ -43,11 +39,6 @@ public function getListHooksRegistered() return $hooks; } - public function addWidgets() - { - WidgetsList::add('General_Visitors', 'CustomVariables_CustomVariables', 'CustomVariables', 'getCustomVariables'); - } - public function install() { Model::install(); diff --git a/plugins/CustomVariables/Widgets.php b/plugins/CustomVariables/Widgets.php new file mode 100644 index 00000000000..183219b2d6d --- /dev/null +++ b/plugins/CustomVariables/Widgets.php @@ -0,0 +1,20 @@ + 'parseMobileVisitData', - 'WidgetsList.addWidgets' => 'addWidgets', 'API.getReportMetadata' => 'getReportMetadata', 'API.getSegmentDimensionMetadata' => 'getSegmentsMetadata', 'ViewDataTable.configure' => 'configureViewDataTable', @@ -101,7 +99,7 @@ public function getListHooksRegistered() * * @return array Category, Report Name, API Module, API action, Translated column name, & optional segment info */ - protected function getRawMetadataReports() + public function getRawMetadataReports() { $report = array( @@ -160,16 +158,6 @@ protected function getRawMetadataReports() return $report; } - public function addWidgets() - { - foreach ($this->getRawMetadataReports() as $report) { - list($category, $name, $controllerName, $controllerAction) = $report; - if ($category == false) - continue; - WidgetsList::add($category, $name, $controllerName, $controllerAction); - } - } - /** * Get segments meta data */ diff --git a/plugins/DevicesDetection/Widgets.php b/plugins/DevicesDetection/Widgets.php new file mode 100644 index 00000000000..0df651064d7 --- /dev/null +++ b/plugins/DevicesDetection/Widgets.php @@ -0,0 +1,27 @@ +getRawMetadataReports() as $report) { + list($category, $name, $controllerName, $controllerAction) = $report; + if ($category == false) + continue; + $widgetsList->add($category, $name, $controllerName, $controllerAction); + } + } + +} diff --git a/plugins/Events/Events.php b/plugins/Events/Events.php index f39ddaf0556..bdc7522e54d 100644 --- a/plugins/Events/Events.php +++ b/plugins/Events/Events.php @@ -9,11 +9,8 @@ namespace Piwik\Plugins\Events; use Piwik\Common; -use Piwik\Menu\MenuAbstract; -use Piwik\Menu\MenuMain; use Piwik\Piwik; use Piwik\Plugin\ViewDataTable; -use Piwik\WidgetsList; /** */ @@ -28,20 +25,10 @@ public function getListHooksRegistered() 'API.getSegmentDimensionMetadata' => 'getSegmentsMetadata', 'Metrics.getDefaultMetricTranslations' => 'addMetricTranslations', 'API.getReportMetadata' => 'getReportMetadata', - 'WidgetsList.addWidgets' => 'addWidgets', 'ViewDataTable.configure' => 'configureViewDataTable', ); } - public function addWidgets() - { - foreach(self::getLabelTranslations() as $apiMethod => $labels) { - $params = array( - 'secondaryDimension' => API::getInstance()->getDefaultSecondaryDimension($apiMethod) - ); - WidgetsList::add('Events_Events', $labels[0], 'Events', $apiMethod, $params); - } - } public function addMetricTranslations(&$translations) { @@ -98,7 +85,6 @@ static public function getLabelTranslations() ); } - public function getSegmentsMetadata(&$segments) { $sqlFilter = '\\Piwik\\Tracker\\TableLogAction::getIdActionFromSegment'; diff --git a/plugins/Events/Widgets.php b/plugins/Events/Widgets.php new file mode 100644 index 00000000000..d08c285d665 --- /dev/null +++ b/plugins/Events/Widgets.php @@ -0,0 +1,25 @@ + $labels) { + $params = array( + 'secondaryDimension' => API::getInstance()->getDefaultSecondaryDimension($apiMethod) + ); + $widgetsList->add('Events_Events', $labels[0], 'Events', $apiMethod, $params); + } + } + +} diff --git a/plugins/ExamplePlugin/Widgets.php b/plugins/ExamplePlugin/Widgets.php new file mode 100644 index 00000000000..6ce0c590dcb --- /dev/null +++ b/plugins/ExamplePlugin/Widgets.php @@ -0,0 +1,25 @@ +add('Example Category', 'Example Widget Name', $controller = 'ExamplePlugin', $action = 'index'); + } + +} diff --git a/plugins/ExampleRssWidget/ExampleRssWidget.php b/plugins/ExampleRssWidget/ExampleRssWidget.php index 3a95b08dbbd..ec035f36d1d 100644 --- a/plugins/ExampleRssWidget/ExampleRssWidget.php +++ b/plugins/ExampleRssWidget/ExampleRssWidget.php @@ -8,8 +8,6 @@ */ namespace Piwik\Plugins\ExampleRssWidget; -use Piwik\WidgetsList; - /** * */ @@ -21,8 +19,7 @@ class ExampleRssWidget extends \Piwik\Plugin public function getListHooksRegistered() { return array( - 'AssetManager.getStylesheetFiles' => 'getStylesheetFiles', - 'WidgetsList.addWidgets' => 'addWidgets' + 'AssetManager.getStylesheetFiles' => 'getStylesheetFiles' ); } @@ -30,10 +27,4 @@ public function getStylesheetFiles(&$stylesheets) { $stylesheets[] = "plugins/ExampleRssWidget/stylesheets/rss.less"; } - - public function addWidgets() - { - WidgetsList::add('Example Widgets', 'Piwik.org Blog', 'ExampleRssWidget', 'rssPiwik'); - WidgetsList::add('Example Widgets', 'Piwik Changelog', 'ExampleRssWidget', 'rssChangelog'); - } } diff --git a/plugins/ExampleRssWidget/Widgets.php b/plugins/ExampleRssWidget/Widgets.php new file mode 100644 index 00000000000..56444cd9c54 --- /dev/null +++ b/plugins/ExampleRssWidget/Widgets.php @@ -0,0 +1,24 @@ +add($category, 'Piwik.org Blog', $controller, 'rssPiwik'); + $widgetsList->add($category, 'Piwik Changelog', $controller, 'rssChangelog'); + } + +} diff --git a/plugins/Goals/Goals.php b/plugins/Goals/Goals.php index 8859f3c67a0..fea8fb0b183 100644 --- a/plugins/Goals/Goals.php +++ b/plugins/Goals/Goals.php @@ -16,7 +16,6 @@ use Piwik\Site; use Piwik\Tracker\GoalManager; use Piwik\Translate; -use Piwik\WidgetsList; /** * @@ -53,6 +52,11 @@ static public function getReportsWithGoalMetrics() return $dimensionsByGroup; } + public function getEcommerceReports() + { + return $this->ecommerceReports; + } + public static function sortGoalDimensionsByModule($a, $b) { $order = array( @@ -103,7 +107,6 @@ public function getListHooksRegistered() 'Tracker.Cache.getSiteAttributes' => 'fetchGoalsFromDb', 'API.getReportMetadata.end' => 'getReportMetadata', 'API.getSegmentDimensionMetadata' => 'getSegmentsMetadata', - 'WidgetsList.addWidgets' => 'addWidgets', 'SitesManager.deleteSite.end' => 'deleteSiteGoals', 'Goals.getReportsWithGoalMetrics' => 'getActualReportsWithGoalMetrics', 'ViewDataTable.configure' => 'configureViewDataTable', @@ -468,30 +471,6 @@ public function fetchGoalsFromDb(&$array, $idSite) $array['goals'] = API::getInstance()->getGoals($idSite); } - public function addWidgets() - { - $idSite = Common::getRequestVar('idSite', null, 'int'); - - // Ecommerce widgets - $site = new Site($idSite); - if ($site->isEcommerceEnabled()) { - WidgetsList::add('Goals_Ecommerce', 'Goals_EcommerceOverview', 'Goals', 'widgetGoalReport', array('idGoal' => Piwik::LABEL_ID_GOAL_IS_ECOMMERCE_ORDER)); - WidgetsList::add('Goals_Ecommerce', 'Goals_EcommerceLog', 'Goals', 'getEcommerceLog'); - foreach ($this->ecommerceReports as $widget) { - WidgetsList::add('Goals_Ecommerce', $widget[0], $widget[1], $widget[2]); - } - } - - // Goals widgets - WidgetsList::add('Goals_Goals', 'Goals_GoalsOverview', 'Goals', 'widgetGoalsOverview'); - $goals = API::getInstance()->getGoals($idSite); - if (count($goals) > 0) { - foreach ($goals as $goal) { - WidgetsList::add('Goals_Goals', Common::sanitizeInputValue($goal['name']), 'Goals', 'widgetGoalReport', array('idGoal' => $goal['idgoal'])); - } - } - } - public function configureViewDataTable(ViewDataTable $view) { switch ($view->requestConfig->apiMethodToRequestDataTable) { diff --git a/plugins/Goals/Widgets.php b/plugins/Goals/Widgets.php new file mode 100644 index 00000000000..d7a90c9645b --- /dev/null +++ b/plugins/Goals/Widgets.php @@ -0,0 +1,53 @@ +isEcommerceEnabled()) { + $this->addEcommerceWidgets($widgetsList); + } + + $this->addGoalsWidgets($widgetsList, $idSite); + } + + private function addEcommerceWidgets(WidgetsList $widgetsList) + { + $goals = new Goals(); + + $widgetsList->add('Goals_Ecommerce', 'Goals_EcommerceOverview', 'Goals', 'widgetGoalReport', array('idGoal' => Piwik::LABEL_ID_GOAL_IS_ECOMMERCE_ORDER)); + $widgetsList->add('Goals_Ecommerce', 'Goals_EcommerceLog', 'Goals', 'getEcommerceLog'); + foreach ($goals->getEcommerceReports() as $widget) { + $widgetsList->add('Goals_Ecommerce', $widget[0], $widget[1], $widget[2]); + } + } + + private function addGoalsWidgets(WidgetsList $widgetsList, $idSite) + { + $widgetsList->add('Goals_Goals', 'Goals_GoalsOverview', 'Goals', 'widgetGoalsOverview'); + + $goals = API::getInstance()->getGoals($idSite); + if (count($goals) > 0) { + foreach ($goals as $goal) { + $widgetsList->add('Goals_Goals', Common::sanitizeInputValue($goal['name']), 'Goals', 'widgetGoalReport', array('idGoal' => $goal['idgoal'])); + } + } + } + +} diff --git a/plugins/Insights/Insights.php b/plugins/Insights/Insights.php index 3a2abc53ef8..0d9d5fe1be5 100644 --- a/plugins/Insights/Insights.php +++ b/plugins/Insights/Insights.php @@ -8,8 +8,6 @@ */ namespace Piwik\Plugins\Insights; -use Piwik\WidgetsList; - /** */ class Insights extends \Piwik\Plugin @@ -20,7 +18,6 @@ class Insights extends \Piwik\Plugin public function getListHooksRegistered() { return array( - 'WidgetsList.addWidgets' => 'addWidgets', 'AssetManager.getJavaScriptFiles' => 'getJsFiles', 'AssetManager.getStylesheetFiles' => 'getStylesheetFiles', 'ViewDataTable.addViewDataTable' => 'getAvailableVisualizations' @@ -32,12 +29,6 @@ public function getAvailableVisualizations(&$visualizations) $visualizations[] = __NAMESPACE__ . '\\Visualizations\\Insight'; } - public function addWidgets() - { - WidgetsList::add('Insights_WidgetCategory', 'Insights_OverviewWidgetTitle', 'Insights', 'getInsightsOverview'); - WidgetsList::add('Insights_WidgetCategory', 'Insights_MoversAndShakersWidgetTitle', 'Insights', 'getOverallMoversAndShakers'); - } - public function getStylesheetFiles(&$stylesheets) { $stylesheets[] = "plugins/Insights/stylesheets/insightVisualization.less"; diff --git a/plugins/Insights/Widgets.php b/plugins/Insights/Widgets.php new file mode 100644 index 00000000000..3c2f75f0b76 --- /dev/null +++ b/plugins/Insights/Widgets.php @@ -0,0 +1,24 @@ +add($category, 'Insights_OverviewWidgetTitle', $controller, 'getInsightsOverview'); + $widgetsList->add($category, 'Insights_MoversAndShakersWidgetTitle', $controller, 'getOverallMoversAndShakers'); + } + +} diff --git a/plugins/Live/Live.php b/plugins/Live/Live.php index a2a62994ff4..31efb4cf7af 100644 --- a/plugins/Live/Live.php +++ b/plugins/Live/Live.php @@ -8,10 +8,7 @@ */ namespace Piwik\Plugins\Live; -use Piwik\Menu\MenuAbstract; -use Piwik\Menu\MenuMain; use Piwik\Plugins\CoreVisualizations\Visualizations\HtmlTable; -use Piwik\WidgetsList; require_once PIWIK_INCLUDE_PATH . '/plugins/Live/VisitorLog.php'; @@ -29,7 +26,6 @@ public function getListHooksRegistered() return array( 'AssetManager.getJavaScriptFiles' => 'getJsFiles', 'AssetManager.getStylesheetFiles' => 'getStylesheetFiles', - 'WidgetsList.addWidgets' => 'addWidget', 'Translate.getClientSideTranslationKeys' => 'getClientSideTranslationKeys', 'ViewDataTable.getDefaultType' => 'getDefaultTypeViewDataTable' ); @@ -48,14 +44,6 @@ public function getJsFiles(&$jsFiles) $jsFiles[] = "plugins/Live/javascripts/visitorLog.js"; } - public function addWidget() - { - WidgetsList::add('Live!', 'Live_VisitorsInRealTime', 'Live', 'widget'); - WidgetsList::add('Live!', 'Live_VisitorLog', 'Live', 'getVisitorLog', array('small' => 1)); - WidgetsList::add('Live!', 'Live_RealTimeVisitorCount', 'Live', 'getSimpleLastVisitCount'); - WidgetsList::add('Live!', 'Live_VisitorProfile', 'Live', 'getVisitorProfilePopup'); - } - public function getClientSideTranslationKeys(&$translationKeys) { $translationKeys[] = "Live_VisitorProfile"; diff --git a/plugins/Live/Widgets.php b/plugins/Live/Widgets.php new file mode 100644 index 00000000000..bb07f553974 --- /dev/null +++ b/plugins/Live/Widgets.php @@ -0,0 +1,26 @@ +add($category, 'Live_VisitorsInRealTime', $controller, 'widget'); + $widgetsList->add($category, 'Live_VisitorLog', $controller, 'getVisitorLog', array('small' => 1)); + $widgetsList->add($category, 'Live_RealTimeVisitorCount', $controller, 'getSimpleLastVisitCount'); + $widgetsList->add($category, 'Live_VisitorProfile', $controller, 'getVisitorProfilePopup'); + } + +} diff --git a/plugins/Provider/Provider.php b/plugins/Provider/Provider.php index 2c587e1f953..710e2a49306 100644 --- a/plugins/Provider/Provider.php +++ b/plugins/Provider/Provider.php @@ -17,7 +17,6 @@ use Piwik\Piwik; use Piwik\Plugin\ViewDataTable; use Piwik\Plugins\PrivacyManager\Config as PrivacyManagerConfig; -use Piwik\WidgetsList; /** * @@ -31,7 +30,6 @@ public function getListHooksRegistered() { $hooks = array( 'Tracker.newVisitorInformation' => 'enrichVisitWithProviderInfo', - 'WidgetsList.addWidgets' => 'addWidget', 'API.getReportMetadata' => 'getReportMetadata', 'API.getSegmentDimensionMetadata' => 'getSegmentsMetadata', 'ViewDataTable.configure' => 'configureViewDataTable', @@ -86,11 +84,6 @@ public function uninstall() Db::exec($query); } - public function addWidget() - { - WidgetsList::add('General_Visitors', 'Provider_WidgetProviders', 'Provider', 'getProvider'); - } - public function postLoad() { Piwik::addAction('Template.footerUserCountry', array('Piwik\Plugins\Provider\Provider', 'footerUserCountry')); diff --git a/plugins/Provider/Widgets.php b/plugins/Provider/Widgets.php new file mode 100644 index 00000000000..911ab10411b --- /dev/null +++ b/plugins/Provider/Widgets.php @@ -0,0 +1,20 @@ +add('General_Visitors', 'Provider_WidgetProviders', 'Provider', 'getProvider'); + } + +} diff --git a/plugins/Referrers/Referrers.php b/plugins/Referrers/Referrers.php index b35d029b567..eee977c1478 100644 --- a/plugins/Referrers/Referrers.php +++ b/plugins/Referrers/Referrers.php @@ -16,7 +16,6 @@ use Piwik\Plugins\CoreVisualizations\Visualizations\HtmlTable\AllColumns; use Piwik\Plugins\CoreVisualizations\Visualizations\JqplotGraph\Pie; use Piwik\SettingsPiwik; -use Piwik\WidgetsList; /** * @see plugins/Referrers/functions.php @@ -33,7 +32,6 @@ class Referrers extends \Piwik\Plugin public function getListHooksRegistered() { $hooks = array( - 'WidgetsList.addWidgets' => 'addWidgets', 'Goals.getReportsWithGoalMetrics' => 'getReportsWithGoalMetrics', 'API.getReportMetadata' => 'getReportMetadata', 'API.getSegmentDimensionMetadata' => 'getSegmentsMetadata', diff --git a/plugins/Referrers/Widgets.php b/plugins/Referrers/Widgets.php new file mode 100644 index 00000000000..9fa85772cb4 --- /dev/null +++ b/plugins/Referrers/Widgets.php @@ -0,0 +1,34 @@ +add($category, 'Referrers_WidgetKeywords', $controller, 'getKeywords'); + $widgetsList->add($category, 'Referrers_WidgetExternalWebsites', $controller, 'getWebsites'); + $widgetsList->add($category, 'Referrers_WidgetSocials', $controller, 'getSocials'); + $widgetsList->add($category, 'Referrers_SearchEngines', $controller, 'getSearchEngines'); + $widgetsList->add($category, 'Referrers_Campaigns', $controller, 'getCampaigns'); + $widgetsList->add($category, 'General_Overview', $controller, 'getReferrerType'); + $widgetsList->add($category, 'Referrers_WidgetGetAll', $controller, 'getAll'); + + if (SettingsPiwik::isSegmentationEnabled()) { + $widgetsList->add('SEO', 'Referrers_WidgetTopKeywordsForPages', $controller, 'getKeywordsForPage'); + } + } + +} diff --git a/plugins/SEO/SEO.php b/plugins/SEO/SEO.php index 1c1c8e24c41..f295b1a28e9 100644 --- a/plugins/SEO/SEO.php +++ b/plugins/SEO/SEO.php @@ -9,7 +9,6 @@ namespace Piwik\Plugins\SEO; use Piwik\Version; -use Piwik\WidgetsList; /** */ @@ -28,18 +27,4 @@ public function getInformation() 'license_homepage' => 'http://www.gnu.org/licenses/gpl.html' ); } - - /** - * @see Piwik\Plugin::getListHooksRegistered - */ - public function getListHooksRegistered() - { - $hooks = array('WidgetsList.addWidgets' => 'addWidgets'); - return $hooks; - } - - function addWidgets() - { - WidgetsList::add('SEO', 'SEO_SeoRankings', 'SEO', 'getRank'); - } } diff --git a/plugins/SEO/Widgets.php b/plugins/SEO/Widgets.php new file mode 100644 index 00000000000..9e65a0185ca --- /dev/null +++ b/plugins/SEO/Widgets.php @@ -0,0 +1,20 @@ +add('SEO', 'SEO_SeoRankings', 'SEO', 'getRank'); + } + +} diff --git a/plugins/UserCountry/UserCountry.php b/plugins/UserCountry/UserCountry.php index 56a680d23a9..95e6f389ac4 100644 --- a/plugins/UserCountry/UserCountry.php +++ b/plugins/UserCountry/UserCountry.php @@ -20,7 +20,6 @@ use Piwik\Plugins\UserCountry\LocationProvider; use Piwik\Plugins\UserCountry\LocationProvider\DefaultProvider; use Piwik\Url; -use Piwik\WidgetsList; /** * @see plugins/UserCountry/GeoIPAutoUpdater.php @@ -38,7 +37,6 @@ class UserCountry extends \Piwik\Plugin public function getListHooksRegistered() { $hooks = array( - 'WidgetsList.addWidgets' => 'addWidgets', 'Goals.getReportsWithGoalMetrics' => 'getReportsWithGoalMetrics', 'API.getReportMetadata' => 'getReportMetadata', 'API.getSegmentDimensionMetadata' => 'getSegmentsMetadata', @@ -164,23 +162,6 @@ private function updateVisitInfoWithLocation(&$visitorInfo, $location) } } - public function addWidgets() - { - $widgetContinentLabel = Piwik::translate('UserCountry_WidgetLocation') - . ' (' . Piwik::translate('UserCountry_Continent') . ')'; - $widgetCountryLabel = Piwik::translate('UserCountry_WidgetLocation') - . ' (' . Piwik::translate('UserCountry_Country') . ')'; - $widgetRegionLabel = Piwik::translate('UserCountry_WidgetLocation') - . ' (' . Piwik::translate('UserCountry_Region') . ')'; - $widgetCityLabel = Piwik::translate('UserCountry_WidgetLocation') - . ' (' . Piwik::translate('UserCountry_City') . ')'; - - WidgetsList::add('General_Visitors', $widgetContinentLabel, 'UserCountry', 'getContinent'); - WidgetsList::add('General_Visitors', $widgetCountryLabel, 'UserCountry', 'getCountry'); - WidgetsList::add('General_Visitors', $widgetRegionLabel, 'UserCountry', 'getRegion'); - WidgetsList::add('General_Visitors', $widgetCityLabel, 'UserCountry', 'getCity'); - } - public function getSegmentsMetadata(&$segments) { $segments[] = array( diff --git a/plugins/UserCountry/Widgets.php b/plugins/UserCountry/Widgets.php new file mode 100644 index 00000000000..6044e04e8c0 --- /dev/null +++ b/plugins/UserCountry/Widgets.php @@ -0,0 +1,36 @@ + 'addWidgets', 'API.getReportMetadata' => 'getReportMetadata', 'API.getSegmentDimensionMetadata' => 'getSegmentsMetadata', 'ViewDataTable.configure' => 'configureViewDataTable', @@ -378,6 +376,11 @@ private function getBasicUserSettingsDisplayProperties(ViewDataTable $view) } } + public function getRawReportMetadata() + { + return $this->reportMetadata; + } + /** * Registers reports metadata * @@ -386,7 +389,7 @@ private function getBasicUserSettingsDisplayProperties(ViewDataTable $view) public function getReportMetadata(&$reports) { $i = 0; - foreach ($this->reportMetadata as $report) { + foreach ($this->getRawReportMetadata() as $report) { list($category, $name, $apiModule, $apiAction, $columnName) = $report; if ($category == false) continue; @@ -443,17 +446,4 @@ public function getSegmentsMetadata(&$segments) } } - /** - * Adds the various User Settings widgets - */ - function addWidgets() - { - // in this case, Widgets have same names as API reports - foreach ($this->reportMetadata as $report) { - list($category, $name, $controllerName, $controllerAction) = $report; - if ($category == false) continue; - WidgetsList::add($category, $name, $controllerName, $controllerAction); - } - } - } diff --git a/plugins/UserSettings/Widgets.php b/plugins/UserSettings/Widgets.php new file mode 100644 index 00000000000..36099b5149d --- /dev/null +++ b/plugins/UserSettings/Widgets.php @@ -0,0 +1,30 @@ +getRawReportMetadata() as $report) { + list($category, $name, $controllerName, $controllerAction) = $report; + + if ($category == false) { + continue; + } + + $widgetsList->add($category, $name, $controllerName, $controllerAction); + } + } + +} diff --git a/plugins/VisitFrequency/VisitFrequency.php b/plugins/VisitFrequency/VisitFrequency.php index d6f710b7c1a..f3dcf598b60 100644 --- a/plugins/VisitFrequency/VisitFrequency.php +++ b/plugins/VisitFrequency/VisitFrequency.php @@ -9,7 +9,6 @@ namespace Piwik\Plugins\VisitFrequency; use Piwik\Piwik; -use Piwik\WidgetsList; /** * @@ -22,7 +21,6 @@ class VisitFrequency extends \Piwik\Plugin public function getListHooksRegistered() { $hooks = array( - 'WidgetsList.addWidgets' => 'addWidgets', 'API.getReportMetadata' => 'getReportMetadata', ); return $hooks; @@ -52,11 +50,4 @@ public function getReportMetadata(&$reports) 'order' => 40 ); } - - function addWidgets() - { - WidgetsList::add('General_Visitors', 'VisitFrequency_WidgetOverview', 'VisitFrequency', 'getSparklines'); - WidgetsList::add('General_Visitors', 'VisitFrequency_WidgetGraphReturning', 'VisitFrequency', 'getEvolutionGraph', - array('columns' => array('nb_visits_returning'))); - } } diff --git a/plugins/VisitFrequency/Widgets.php b/plugins/VisitFrequency/Widgets.php new file mode 100644 index 00000000000..cea4a4348d0 --- /dev/null +++ b/plugins/VisitFrequency/Widgets.php @@ -0,0 +1,25 @@ +add($category, 'VisitFrequency_WidgetOverview', $controller, 'getSparklines'); + $widgetsList->add($category, 'VisitFrequency_WidgetGraphReturning', $controller, 'getEvolutionGraph', + array('columns' => array('nb_visits_returning'))); + } + +} diff --git a/plugins/VisitTime/VisitTime.php b/plugins/VisitTime/VisitTime.php index 1932095fb39..fbf115748c1 100644 --- a/plugins/VisitTime/VisitTime.php +++ b/plugins/VisitTime/VisitTime.php @@ -17,7 +17,6 @@ use Piwik\Plugins\CoreVisualizations\Visualizations\Graph; use Piwik\Plugins\CoreVisualizations\Visualizations\JqplotGraph\Bar; use Piwik\Site; -use Piwik\WidgetsList; /** * @@ -30,7 +29,6 @@ class VisitTime extends \Piwik\Plugin public function getListHooksRegistered() { $hooks = array( - 'WidgetsList.addWidgets' => 'addWidgets', 'Goals.getReportsWithGoalMetrics' => 'getReportsWithGoalMetrics', 'API.getReportMetadata' => 'getReportMetadata', 'API.getSegmentDimensionMetadata' => 'getSegmentsMetadata', @@ -76,13 +74,6 @@ public function getReportMetadata(&$reports) ); } - function addWidgets() - { - WidgetsList::add('VisitsSummary_VisitsSummary', 'VisitTime_WidgetLocalTime', 'VisitTime', 'getVisitInformationPerLocalTime'); - WidgetsList::add('VisitsSummary_VisitsSummary', 'VisitTime_WidgetServerTime', 'VisitTime', 'getVisitInformationPerServerTime'); - WidgetsList::add('VisitsSummary_VisitsSummary', 'VisitTime_VisitsByDayOfWeek', 'VisitTime', 'getByDayOfWeek'); - } - public function getReportsWithGoalMetrics(&$dimensions) { $dimensions[] = array('category' => Piwik::translate('VisitTime_ColumnServerTime'), diff --git a/plugins/VisitTime/Widgets.php b/plugins/VisitTime/Widgets.php new file mode 100644 index 00000000000..32541ea4f43 --- /dev/null +++ b/plugins/VisitTime/Widgets.php @@ -0,0 +1,25 @@ +add($category, 'VisitTime_WidgetLocalTime', $controller, 'getVisitInformationPerLocalTime'); + $widgetsList->add($category, 'VisitTime_WidgetServerTime', $controller, 'getVisitInformationPerServerTime'); + $widgetsList->add($category, 'VisitTime_VisitsByDayOfWeek', $controller, 'getByDayOfWeek'); + } + +} diff --git a/plugins/VisitorInterest/VisitorInterest.php b/plugins/VisitorInterest/VisitorInterest.php index 1d83b6e60b7..04018837814 100644 --- a/plugins/VisitorInterest/VisitorInterest.php +++ b/plugins/VisitorInterest/VisitorInterest.php @@ -15,7 +15,6 @@ use Piwik\Plugin\ViewDataTable; use Piwik\Plugins\CoreVisualizations\Visualizations\Cloud; use Piwik\Plugins\CoreVisualizations\Visualizations\Graph; -use Piwik\WidgetsList; /** * @@ -28,7 +27,6 @@ class VisitorInterest extends \Piwik\Plugin public function getListHooksRegistered() { $hooks = array( - 'WidgetsList.addWidgets' => 'addWidgets', 'API.getReportMetadata' => 'getReportMetadata', 'ViewDataTable.configure' => 'configureViewDataTable', 'ViewDataTable.getDefaultType' => 'getDefaultTypeViewDataTable' @@ -97,14 +95,6 @@ public function getReportMetadata(&$reports) ); } - public function addWidgets() - { - WidgetsList::add('General_Visitors', 'VisitorInterest_WidgetLengths', 'VisitorInterest', 'getNumberOfVisitsPerVisitDuration'); - WidgetsList::add('General_Visitors', 'VisitorInterest_WidgetPages', 'VisitorInterest', 'getNumberOfVisitsPerPage'); - WidgetsList::add('General_Visitors', 'VisitorInterest_visitsByVisitCount', 'VisitorInterest', 'getNumberOfVisitsByVisitCount'); - WidgetsList::add('General_Visitors', 'VisitorInterest_WidgetVisitsByDaysSinceLast', 'VisitorInterest', 'getNumberOfVisitsByDaysSinceLast'); - } - function postLoad() { Piwik::addAction('Template.headerVisitsFrequency', array('Piwik\Plugins\VisitorInterest\VisitorInterest', 'headerVisitsFrequency')); diff --git a/plugins/VisitorInterest/Widgets.php b/plugins/VisitorInterest/Widgets.php new file mode 100644 index 00000000000..8aa6f126274 --- /dev/null +++ b/plugins/VisitorInterest/Widgets.php @@ -0,0 +1,26 @@ +add($category, 'VisitorInterest_WidgetLengths', $controller, 'getNumberOfVisitsPerVisitDuration'); + $widgetsList->add($category, 'VisitorInterest_WidgetPages', $controller, 'getNumberOfVisitsPerPage'); + $widgetsList->add($category, 'VisitorInterest_visitsByVisitCount', $controller, 'getNumberOfVisitsByVisitCount'); + $widgetsList->add($category, 'VisitorInterest_WidgetVisitsByDaysSinceLast', $controller, 'getNumberOfVisitsByDaysSinceLast'); + } + +} diff --git a/plugins/VisitsSummary/VisitsSummary.php b/plugins/VisitsSummary/VisitsSummary.php index e6d77b6447c..3c3bcceda8f 100644 --- a/plugins/VisitsSummary/VisitsSummary.php +++ b/plugins/VisitsSummary/VisitsSummary.php @@ -9,7 +9,6 @@ namespace Piwik\Plugins\VisitsSummary; use Piwik\Piwik; -use Piwik\WidgetsList; /** * Note: This plugin does not hook on Daily and Period Archiving like other Plugins because it reports the @@ -27,7 +26,6 @@ public function getListHooksRegistered() { return array( 'API.getReportMetadata' => 'getReportMetadata', - 'WidgetsList.addWidgets' => 'addWidgets', 'AssetManager.getStylesheetFiles' => 'getStylesheetFiles', ); } @@ -61,13 +59,6 @@ public function getStylesheetFiles(&$stylesheets) $stylesheets[] = "plugins/VisitsSummary/stylesheets/datatable.less"; } - function addWidgets() - { - WidgetsList::add('VisitsSummary_VisitsSummary', 'VisitsSummary_WidgetLastVisits', 'VisitsSummary', 'getEvolutionGraph', array('columns' => array('nb_visits'))); - WidgetsList::add('VisitsSummary_VisitsSummary', 'VisitsSummary_WidgetVisits', 'VisitsSummary', 'getSparklines'); - WidgetsList::add('VisitsSummary_VisitsSummary', 'VisitsSummary_WidgetOverviewGraph', 'VisitsSummary', 'index'); - } - } diff --git a/plugins/VisitsSummary/Widgets.php b/plugins/VisitsSummary/Widgets.php new file mode 100644 index 00000000000..b51d8551063 --- /dev/null +++ b/plugins/VisitsSummary/Widgets.php @@ -0,0 +1,25 @@ +add($category, 'VisitsSummary_WidgetLastVisits', $controller, 'getEvolutionGraph', array('columns' => array('nb_visits'))); + $widgetsList->add($category, 'VisitsSummary_WidgetVisits', $controller, 'getSparklines'); + $widgetsList->add($category, 'VisitsSummary_WidgetOverviewGraph', $controller, 'index'); + } + +}