diff options
author | Thomas Steur <thomas.steur@googlemail.com> | 2014-08-06 13:14:50 +0400 |
---|---|---|
committer | Thomas Steur <thomas.steur@googlemail.com> | 2014-08-06 13:14:50 +0400 |
commit | c43448866d241c7773423d99c1a4301709dd2e4c (patch) | |
tree | c9ed6e2a4be739e3f477c5749fd1b2cad0954a47 /plugins/ExampleReport | |
parent | bdb6528d3079ed846c80780d2004db23b4ff24c4 (diff) |
refs #5926 move reports to exampleReport
Diffstat (limited to 'plugins/ExampleReport')
-rw-r--r-- | plugins/ExampleReport/Reports/Base.php | 19 | ||||
-rw-r--r-- | plugins/ExampleReport/Reports/GetExampleReport.php | 116 |
2 files changed, 135 insertions, 0 deletions
diff --git a/plugins/ExampleReport/Reports/Base.php b/plugins/ExampleReport/Reports/Base.php new file mode 100644 index 0000000000..c09da78e4b --- /dev/null +++ b/plugins/ExampleReport/Reports/Base.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\ExampleReport\Reports; + +use Piwik\Plugin\Report; + +abstract class Base extends Report +{ + protected function init() + { + $this->category = 'ExampleCategory'; + } +} diff --git a/plugins/ExampleReport/Reports/GetExampleReport.php b/plugins/ExampleReport/Reports/GetExampleReport.php new file mode 100644 index 0000000000..408ba9a23d --- /dev/null +++ b/plugins/ExampleReport/Reports/GetExampleReport.php @@ -0,0 +1,116 @@ +<?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\ExampleReport\Reports; + +use Piwik\Piwik; +use Piwik\Plugin\Report; +use Piwik\Plugin\ViewDataTable; +use Piwik\Plugins\Actions\Columns\ExitPageUrl; +use Piwik\View; + +/** + * This class defines a new report. + * + * See {@link http://developer.piwik.org/api-reference/Piwik/Plugin/Report} for more information. + */ +class GetExampleReport extends Base +{ + protected function init() + { + parent::init(); + + $this->name = Piwik::translate('ExampleReportName'); + $this->dimension = new ExitPageUrl(); + $this->documentation = Piwik::translate('ExampleReportDocumentation'); + + // This defines in which order your report appears in the mobile app, in the menu and in the list of widgets + $this->order = 999; + + // By default standard metrics are defined but you can customize them by defining an array of metric names + // $this->metrics = array('nb_visits', 'nb_hits'); + + // Uncomment the next line if your report does not contain any processed metrics, otherwise default + // processed metrics will be assigned + // $this->processedMetrics = array(); + + // Uncomment the next line if your report defines goal metrics + // $this->hasGoalMetrics = true; + + // Uncomment the next line if your report should be able to load subtables. You can define any action here + // $this->actionToLoadSubTables = $this->action; + + // Uncomment the next line if your report always returns a constant count of rows, for instance always + // 24 rows for 1-24hours + // $this->constantRowsCount = true; + + // If a menu title is specified, the report will be displayed in the menu + // $this->menuTitle = 'ExampleReportName'; + + // If a widget title is specified, the report will be displayed in the list of widgets and the report can be + // exported as a widget + // $this->widgetTitle = 'ExampleReportName'; + } + + /** + * Here you can configure how your report should be displayed. For instance whether your report supports a search + * etc. You can also change the default request config. For instance change how many rows are displayed by default. + * + * @param ViewDataTable $view + */ + public function configureView(ViewDataTable $view) + { + if (!empty($this->dimension)) { + $view->config->addTranslations(array('label' => $this->dimension->getName())); + } + + // $view->config->show_search = false; + // $view->requestConfig->filter_sort_column = 'nb_visits'; + // $view->requestConfig->filter_limit = 10'; + + $view->config->columns_to_display = array_merge(array('label'), $this->metrics); + } + + /** + * Here you can define related reports that will be shown below the reports. Just return an array of related + * report instances if there are any. + * + * @return \Piwik\Plugin\Report[] + */ + public function getRelatedReports() + { + return array(); // eg return array(new XyzReport()); + } + + /** + * A report is usually completely automatically rendered for you but you can render the report completely + * customized if you wish. Just overwrite the method and make sure to return a string containing the content of the + * report. Don't forget to create the defined twig template within the templates folder of your plugin in order to + * make it work. Usually you should NOT have to overwrite this render method. + * + * @return string + public function render() + { + $view = new View('@ExampleReport/getExampleReport'); + $view->myData = array(); + + return $view->render(); + } + */ + + /** + * By default your report is available to all users having at least view access. If you do not want this, you can + * limit the audience by overwriting this method. + * + * @return bool + public function isEnabled() + { + return Piwik::hasUserSuperUserAccess() + } + */ +} |