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.

Controller.php 2.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  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\Events;
  10. use Piwik\View;
  11. /**
  12. * Events controller
  13. *
  14. */
  15. class Controller extends \Piwik\Plugin\Controller
  16. {
  17. public function index()
  18. {
  19. $view = new View('@Events/index');
  20. $view->leftMenuReports = $this->getLeftMenuReports();
  21. return $view->render();
  22. }
  23. private function getLeftMenuReports()
  24. {
  25. $reports = new View\ReportsByDimension('Events');
  26. foreach(Events::getLabelTranslations() as $apiAction => $translations) {
  27. // 'getCategory' is the API method, but we are loading 'indexCategory' which displays <h2>
  28. $count = 1;
  29. $controllerAction = str_replace("get", "index", $apiAction, $count);
  30. $params = array(
  31. 'secondaryDimension' => API::getInstance()->getDefaultSecondaryDimension($apiAction)
  32. );
  33. $reports->addReport('Events_TopEvents', $translations[0], 'Events.' . $controllerAction, $params);
  34. }
  35. return $reports->render();
  36. }
  37. public function indexCategory()
  38. {
  39. return $this->indexEvent(__FUNCTION__);
  40. }
  41. public function indexAction()
  42. {
  43. return $this->indexEvent(__FUNCTION__);
  44. }
  45. public function indexName()
  46. {
  47. return $this->indexEvent(__FUNCTION__);
  48. }
  49. public function getActionFromCategoryId()
  50. {
  51. return $this->renderReport(__FUNCTION__);
  52. }
  53. public function getNameFromCategoryId()
  54. {
  55. return $this->renderReport(__FUNCTION__);
  56. }
  57. public function getCategoryFromActionId()
  58. {
  59. return $this->renderReport(__FUNCTION__);
  60. }
  61. public function getNameFromActionId()
  62. {
  63. return $this->renderReport(__FUNCTION__);
  64. }
  65. public function getActionFromNameId()
  66. {
  67. return $this->renderReport(__FUNCTION__);
  68. }
  69. public function getCategoryFromNameId()
  70. {
  71. return $this->renderReport(__FUNCTION__);
  72. }
  73. protected function indexEvent($controllerMethod)
  74. {
  75. $count = 1;
  76. $apiMethod = str_replace('index', 'get', $controllerMethod, $count);
  77. $events = new Events;
  78. $title = $events->getReportTitleTranslation($apiMethod);
  79. if (method_exists($this, $apiMethod)) {
  80. $content = $this->$apiMethod();
  81. } else {
  82. $content = $this->renderReport($apiMethod);
  83. }
  84. return View::singleReport(
  85. $title,
  86. $content
  87. );
  88. }
  89. }