/** * Adds a related report to the {@link $related_reports} property. If the report * references the one that is currently being displayed, it will not be added to the related * report list. * * @param string $relatedReport The plugin and method of the report, eg, `'DevicesDetection.getBrowsers'`. * @param string $title The report's display name, eg, `'Browsers'`. * @param array $queryParams Any extra query parameters to set in releated report's URL, eg, * `array('idGoal' => 'ecommerceOrder')`. */ public function addRelatedReport($relatedReport, $title, $queryParams = array()) { list($module, $action) = explode('.', $relatedReport); // don't add the related report if it references this report if ($this->controllerName == $module && $this->controllerAction == $action) { if (empty($queryParams)) { return; } } $url = ApiRequest::getBaseReportUrl($module, $action, $queryParams); $this->related_reports[$url] = $title; }
/** * Constructor. Initializes display and request properties to their default values. * Posts the {@hook ViewDataTable.configure} event which plugins can use to configure the * way reports are displayed. */ public function __construct($controllerAction, $apiMethodToRequestDataTable, $overrideParams = array()) { list($controllerName, $controllerAction) = explode('.', $controllerAction); $this->requestConfig = static::getDefaultRequestConfig(); $this->config = static::getDefaultConfig(); $this->config->subtable_controller_action = $controllerAction; $this->config->setController($controllerName, $controllerAction); $this->request = new ViewDataTableRequest($this->requestConfig); $this->requestConfig->idSubtable = Common::getRequestVar('idSubtable', false, 'int'); $this->config->self_url = Request::getBaseReportUrl($controllerName, $controllerAction); $this->requestConfig->apiMethodToRequestDataTable = $apiMethodToRequestDataTable; $report = Report::factory($this->requestConfig->getApiModuleToRequest(), $this->requestConfig->getApiMethodToRequest()); if (!empty($report)) { /** @var Report $report */ $subtable = $report->getActionToLoadSubTables(); if (!empty($subtable)) { $this->config->subtable_controller_action = $subtable; } $this->config->show_goals = $report->hasGoalMetrics(); $relatedReports = $report->getRelatedReports(); if (!empty($relatedReports)) { foreach ($relatedReports as $relatedReport) { $widgetTitle = $relatedReport->getWidgetTitle(); if ($widgetTitle && Common::getRequestVar('widget', 0, 'int')) { $relatedReportName = $widgetTitle; } else { $relatedReportName = $relatedReport->getName(); } $this->config->addRelatedReport($relatedReport->getModule() . '.' . $relatedReport->getAction(), $relatedReportName); } } $metrics = $report->getMetrics(); if (!empty($metrics)) { $this->config->addTranslations($metrics); } $processedMetrics = $report->getProcessedMetrics(); if (!empty($processedMetrics)) { $this->config->addTranslations($processedMetrics); } $report->configureView($this); } /** * Triggered during {@link ViewDataTable} construction. Subscribers should customize * the view based on the report that is being displayed. * * Plugins that define their own reports must subscribe to this event in order to * specify how the Piwik UI should display the report. * * **Example** * * // event handler * public function configureViewDataTable(ViewDataTable $view) * { * switch ($view->requestConfig->apiMethodToRequestDataTable) { * case 'VisitTime.getVisitInformationPerServerTime': * $view->config->enable_sort = true; * $view->requestConfig->filter_limit = 10; * break; * } * } * * @param ViewDataTable $view The instance to configure. */ Piwik::postEvent('ViewDataTable.configure', array($this)); $this->assignRelatedReportsTitle(); $this->config->show_footer_icons = false == $this->requestConfig->idSubtable; // the exclude low population threshold value is sometimes obtained by requesting data. // to avoid issuing unecessary requests when display properties are determined by metadata, // we allow it to be a closure. if (isset($this->requestConfig->filter_excludelowpop_value) && $this->requestConfig->filter_excludelowpop_value instanceof \Closure) { $function = $this->requestConfig->filter_excludelowpop_value; $this->requestConfig->filter_excludelowpop_value = $function(); } $this->overrideViewPropertiesWithParams($overrideParams); $this->overrideViewPropertiesWithQueryParams(); }
/** * Constructor. Initializes display and request properties to their default values. * Posts the {@hook ViewDataTable.configure} event which plugins can use to configure the * way reports are displayed. */ public function __construct($controllerAction, $apiMethodToRequestDataTable) { list($controllerName, $controllerAction) = explode('.', $controllerAction); $this->requestConfig = static::getDefaultRequestConfig(); $this->config = static::getDefaultConfig(); $this->config->subtable_controller_action = $controllerAction; $this->config->setController($controllerName, $controllerAction); $this->request = new ViewDataTableRequest($this->requestConfig); $this->requestConfig->idSubtable = Common::getRequestVar('idSubtable', false, 'int'); $this->config->self_url = Request::getBaseReportUrl($controllerName, $controllerAction); $this->requestConfig->apiMethodToRequestDataTable = $apiMethodToRequestDataTable; /** * Triggered during {@link ViewDataTable} construction. Subscribers should customize * the view based on the report that is being displayed. * * Plugins that define their own reports must subscribe to this event in order to * specify how the Piwik UI should display the report. * * **Example** * * // event handler * public function configureViewDataTable(ViewDataTable $view) * { * switch ($view->requestConfig->apiMethodToRequestDataTable) { * case 'VisitTime.getVisitInformationPerServerTime': * $view->config->enable_sort = true; * $view->requestConfig->filter_limit = 10; * break; * } * } * * @param ViewDataTable $view The instance to configure. */ Piwik::postEvent('ViewDataTable.configure', array($this)); $this->config->show_footer_icons = false == $this->requestConfig->idSubtable; // the exclude low population threshold value is sometimes obtained by requesting data. // to avoid issuing unecessary requests when display properties are determined by metadata, // we allow it to be a closure. if (isset($this->requestConfig->filter_excludelowpop_value) && $this->requestConfig->filter_excludelowpop_value instanceof \Closure) { $function = $this->requestConfig->filter_excludelowpop_value; $this->requestConfig->filter_excludelowpop_value = $function(); } $this->overrideViewPropertiesWithQueryParams(); }