Teknik is a suite of services with attractive and functional interfaces. https://www.teknik.io/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

GetExampleReport.php 4.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. <?php
  2. /**
  3. * Piwik - free/libre analytics platform
  4. *
  5. * @link http://piwik.org
  6. * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
  7. *
  8. */
  9. namespace Piwik\Plugins\ExampleReport\Reports;
  10. use Piwik\Piwik;
  11. use Piwik\Plugin\Report;
  12. use Piwik\Plugin\ViewDataTable;
  13. use Piwik\Plugins\Actions\Columns\ExitPageUrl;
  14. use Piwik\View;
  15. /**
  16. * This class defines a new report.
  17. *
  18. * See {@link http://developer.piwik.org/api-reference/Piwik/Plugin/Report} for more information.
  19. */
  20. class GetExampleReport extends Base
  21. {
  22. protected function init()
  23. {
  24. parent::init();
  25. $this->name = Piwik::translate('ExampleReportName');
  26. $this->dimension = new ExitPageUrl();
  27. $this->documentation = Piwik::translate('ExampleReportDocumentation');
  28. // This defines in which order your report appears in the mobile app, in the menu and in the list of widgets
  29. $this->order = 999;
  30. // By default standard metrics are defined but you can customize them by defining an array of metric names
  31. // $this->metrics = array('nb_visits', 'nb_hits');
  32. // Uncomment the next line if your report does not contain any processed metrics, otherwise default
  33. // processed metrics will be assigned
  34. // $this->processedMetrics = array();
  35. // Uncomment the next line if your report defines goal metrics
  36. // $this->hasGoalMetrics = true;
  37. // Uncomment the next line if your report should be able to load subtables. You can define any action here
  38. // $this->actionToLoadSubTables = $this->action;
  39. // Uncomment the next line if your report always returns a constant count of rows, for instance always
  40. // 24 rows for 1-24hours
  41. // $this->constantRowsCount = true;
  42. // If a menu title is specified, the report will be displayed in the menu
  43. // $this->menuTitle = 'ExampleReportName';
  44. // If a widget title is specified, the report will be displayed in the list of widgets and the report can be
  45. // exported as a widget
  46. // $this->widgetTitle = 'ExampleReportName';
  47. }
  48. /**
  49. * Here you can configure how your report should be displayed. For instance whether your report supports a search
  50. * etc. You can also change the default request config. For instance change how many rows are displayed by default.
  51. *
  52. * @param ViewDataTable $view
  53. */
  54. public function configureView(ViewDataTable $view)
  55. {
  56. if (!empty($this->dimension)) {
  57. $view->config->addTranslations(array('label' => $this->dimension->getName()));
  58. }
  59. // $view->config->show_search = false;
  60. // $view->requestConfig->filter_sort_column = 'nb_visits';
  61. // $view->requestConfig->filter_limit = 10';
  62. $view->config->columns_to_display = array_merge(array('label'), $this->metrics);
  63. }
  64. /**
  65. * Here you can define related reports that will be shown below the reports. Just return an array of related
  66. * report instances if there are any.
  67. *
  68. * @return \Piwik\Plugin\Report[]
  69. */
  70. public function getRelatedReports()
  71. {
  72. return array(); // eg return array(new XyzReport());
  73. }
  74. /**
  75. * A report is usually completely automatically rendered for you but you can render the report completely
  76. * customized if you wish. Just overwrite the method and make sure to return a string containing the content of the
  77. * report. Don't forget to create the defined twig template within the templates folder of your plugin in order to
  78. * make it work. Usually you should NOT have to overwrite this render method.
  79. *
  80. * @return string
  81. public function render()
  82. {
  83. $view = new View('@ExampleReport/getExampleReport');
  84. $view->myData = array();
  85. return $view->render();
  86. }
  87. */
  88. /**
  89. * By default your report is available to all users having at least view access. If you do not want this, you can
  90. * limit the audience by overwriting this method.
  91. *
  92. * @return bool
  93. public function isEnabled()
  94. {
  95. return Piwik::hasUserSuperUserAccess()
  96. }
  97. */
  98. }