diff options
author | Thomas Steur <thomas.steur@gmail.com> | 2015-07-03 03:54:27 +0300 |
---|---|---|
committer | sgiehl <stefan@piwik.org> | 2015-10-06 18:25:13 +0300 |
commit | 9ba8f216fd7856ce5fef06bf82ecb8f8a2e7e630 (patch) | |
tree | 6ce07d18a85d00b39ab720abe042361c0775aead /plugins/Contents | |
parent | 8ccc9dc05da021325cdbf141a548637fa52f16b2 (diff) |
generate pages instead of implementing them in each controller
Diffstat (limited to 'plugins/Contents')
11 files changed, 54 insertions, 81 deletions
diff --git a/plugins/Contents/Categories/ContentsSubcategory.php b/plugins/Contents/Categories/ContentsSubcategory.php new file mode 100644 index 0000000000..735d376e4f --- /dev/null +++ b/plugins/Contents/Categories/ContentsSubcategory.php @@ -0,0 +1,19 @@ +<?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\Contents\Categories; + +use Piwik\Category\Subcategory; + +class ContentsSubcategory extends Subcategory +{ + protected $categoryId = 'General_Actions'; + protected $id = 'Contents_Contents'; + protected $order = 45; + +} diff --git a/plugins/Contents/Contents.php b/plugins/Contents/Contents.php index 10536930af..49df9a730b 100644 --- a/plugins/Contents/Contents.php +++ b/plugins/Contents/Contents.php @@ -18,7 +18,7 @@ class Contents extends \Piwik\Plugin return array( 'Metrics.getDefaultMetricTranslations' => 'addMetricTranslations', 'AssetManager.getJavaScriptFiles' => 'getJsFiles', - 'AssetManager.getStylesheetFiles' => 'getStylesheetFiles', + 'AssetManager.getStylesheetFiles' => 'getStylesheetFiles' ); } diff --git a/plugins/Contents/Controller.php b/plugins/Contents/Controller.php deleted file mode 100644 index a17ec3fdce..0000000000 --- a/plugins/Contents/Controller.php +++ /dev/null @@ -1,51 +0,0 @@ -<?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\Contents; - -use Piwik\Plugin\Report; -use Piwik\View; - -class Controller extends \Piwik\Plugin\Controller -{ - - public function index() - { - $reportsView = new View\ReportsByDimension('Contents'); - - /** @var \Piwik\Plugin\Report[] $reports */ - $contentNames = Report::factory($this->pluginName, 'getContentNames'); - $contentPieces = Report::factory($this->pluginName, 'getContentPieces'); - $reports = array($contentNames, $contentPieces); - - foreach($reports as $report) { - $reportsView->addReport( - $report->getCategory(), - $report->getName(), - 'Contents.' . Report::PREFIX_ACTION_IN_MENU . ucfirst($report->getAction()) - ); - } - - return $reportsView->render(); - } - - public function menuGetContentNames() - { - $report = Report::factory($this->pluginName, 'getContentNames'); - - return View::singleReport($report->getName(), $report->render()); - } - - public function menuGetContentPieces() - { - $report = Report::factory($this->pluginName, 'getContentPieces'); - - return View::singleReport($report->getName(), $report->render()); - } - -} diff --git a/plugins/Contents/Menu.php b/plugins/Contents/Menu.php deleted file mode 100644 index 2e0d25bb7f..0000000000 --- a/plugins/Contents/Menu.php +++ /dev/null @@ -1,24 +0,0 @@ -<?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\Contents; - -use Piwik\Menu\MenuReporting; - -/** - * This class allows you to add, remove or rename menu items. - * To configure a menu (such as Admin Menu, Reporting Menu, User Menu...) simply call the corresponding methods as - * described in the API-Reference http://developer.piwik.org/api-reference/Piwik/Menu/MenuAbstract - */ -class Menu extends \Piwik\Plugin\Menu -{ - public function configureReportingMenu(MenuReporting $menu) - { - $menu->addActionsItem('Contents_Contents', array('module' => 'Contents', 'action' => 'index'), $orderId = 40); - } -} diff --git a/plugins/Contents/Reports/Base.php b/plugins/Contents/Reports/Base.php index f07baf973d..e323bebdbe 100644 --- a/plugins/Contents/Reports/Base.php +++ b/plugins/Contents/Reports/Base.php @@ -8,18 +8,27 @@ */ namespace Piwik\Plugins\Contents\Reports; -use Piwik\Columns\Dimension; use Piwik\Common; use Piwik\Piwik; use Piwik\Plugin\Report; use Piwik\Plugin\ViewDataTable; use Piwik\Plugins\Contents\Dimensions; +use Piwik\Report\ReportWidgetFactory; +use Piwik\Widget\WidgetsList; abstract class Base extends Report { protected function init() { - $this->category = 'General_Actions'; + $this->categoryId = 'General_Actions'; + $this->subcategoryId = 'Contents_Contents'; + } + + public function configureWidgets(WidgetsList $widgetsList, ReportWidgetFactory $factory) + { + $widget = $factory->createWidget(); + + $widgetsList->addToContainerWidget('Contents', $widget); } /** diff --git a/plugins/Contents/Reports/GetContentNames.php b/plugins/Contents/Reports/GetContentNames.php index d217af5d71..6afb8e071e 100644 --- a/plugins/Contents/Reports/GetContentNames.php +++ b/plugins/Contents/Reports/GetContentNames.php @@ -32,7 +32,6 @@ class GetContentNames extends Base $this->order = 35; $this->actionToLoadSubTables = 'getContentNames'; - $this->widgetTitle = 'Contents_ContentName'; $this->metrics = array('nb_impressions', 'nb_interactions'); $this->processedMetrics = array(new InteractionRate()); } diff --git a/plugins/Contents/Reports/GetContentPieces.php b/plugins/Contents/Reports/GetContentPieces.php index 7ab3f1ed1c..ede8da9405 100644 --- a/plugins/Contents/Reports/GetContentPieces.php +++ b/plugins/Contents/Reports/GetContentPieces.php @@ -32,8 +32,6 @@ class GetContentPieces extends Base $this->order = 36; $this->actionToLoadSubTables = 'getContentPieces'; - $this->widgetTitle = 'Contents_ContentPiece'; - $this->metrics = array('nb_impressions', 'nb_interactions'); $this->processedMetrics = array(new InteractionRate()); } diff --git a/plugins/Contents/Widgets/ContentsByDimension.php b/plugins/Contents/Widgets/ContentsByDimension.php new file mode 100644 index 0000000000..3f2291e8d8 --- /dev/null +++ b/plugins/Contents/Widgets/ContentsByDimension.php @@ -0,0 +1,21 @@ +<?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\Contents\Widgets; + +use Piwik\Plugins\CoreHome\CoreHome; +use Piwik\Widget\WidgetContainerConfig; + +class ContentsByDimension extends WidgetContainerConfig +{ + protected $layout = CoreHome::WIDGET_CONTAINER_LAYOUT_BY_DIMENSION; + protected $id = 'Contents'; + protected $categoryId = 'General_Actions'; + protected $subcategoryId = 'Contents_Contents'; + +} diff --git a/plugins/Contents/tests/System/expected/.gitkeep b/plugins/Contents/tests/System/expected/.gitkeep new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/plugins/Contents/tests/System/expected/.gitkeep diff --git a/plugins/Contents/tests/System/expected/test_Contents_Contents.getContentNames_lastN__API.getProcessedReport_day.xml b/plugins/Contents/tests/System/expected/test_Contents_Contents.getContentNames_lastN__API.getProcessedReport_day.xml index 5c1cc502a7..8eed477e8b 100644 --- a/plugins/Contents/tests/System/expected/test_Contents_Contents.getContentNames_lastN__API.getProcessedReport_day.xml +++ b/plugins/Contents/tests/System/expected/test_Contents_Contents.getContentNames_lastN__API.getProcessedReport_day.xml @@ -4,6 +4,7 @@ <prettyDate>January 3 – 9, 2010</prettyDate> <metadata> <category>Actions</category> + <subcategory>Contents</subcategory> <name>Content Name</name> <module>Contents</module> <action>getContentNames</action> diff --git a/plugins/Contents/tests/System/expected/test_Contents_Contents.getContentPieces_lastN__API.getProcessedReport_day.xml b/plugins/Contents/tests/System/expected/test_Contents_Contents.getContentPieces_lastN__API.getProcessedReport_day.xml index b43860be63..f0115ea581 100644 --- a/plugins/Contents/tests/System/expected/test_Contents_Contents.getContentPieces_lastN__API.getProcessedReport_day.xml +++ b/plugins/Contents/tests/System/expected/test_Contents_Contents.getContentPieces_lastN__API.getProcessedReport_day.xml @@ -4,6 +4,7 @@ <prettyDate>January 3 – 9, 2010</prettyDate> <metadata> <category>Actions</category> + <subcategory>Contents</subcategory> <name>Content Piece</name> <module>Contents</module> <action>getContentPieces</action> |