本文整理汇总了PHP中Piwik\Plugin\Report类的典型用法代码示例。如果您正苦于以下问题:PHP Report类的具体用法?PHP Report怎么用?PHP Report使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Report类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: renderReportWidget
public function renderReportWidget(Report $report)
{
Piwik::checkUserHasSomeViewAccess();
$this->checkSitePermission();
$report->checkIsEnabled();
return $report->render();
}
示例2: createContainerWidget
/**
* Creates a new container widget based on the specified report in {@link construct()}.
*
* It will automatically use the report's categoryId, subcategoryId (if specified) and order in order to
* create the container.
*
* @param string $containerId eg 'Products' or 'Contents' see {Piwik\Widget\WidgetContainerConfig::setId()}.
* Other reports or widgets will be able to add more widgets to this container.
* This is useful when you want to show for example multiple related widgets
* together.
* @return WidgetContainerConfig
*/
public function createContainerWidget($containerId)
{
$widget = new WidgetContainerConfig();
$widget->setCategoryId($this->report->getCategoryId());
$widget->setId($containerId);
if ($this->report->getSubcategoryId()) {
$widget->setSubcategoryId($this->report->getSubcategoryId());
}
$orderThatListsReportsAtTheEndOfEachCategory = 100 + $this->report->getOrder();
$widget->setOrder($orderThatListsReportsAtTheEndOfEachCategory);
return $widget;
}
示例3: init
protected function init()
{
parent::init();
$this->reportsToMerge = $this->getReportsToMerge();
$this->module = 'API';
$this->action = 'get';
$this->categoryId = 'API';
$this->name = Piwik::translate('General_MainMetrics');
$this->documentation = '';
$this->processedMetrics = array();
foreach ($this->reportsToMerge as $report) {
if (!is_array($report->processedMetrics)) {
continue;
}
$this->processedMetrics = array_merge($this->processedMetrics, $report->processedMetrics);
}
$this->metrics = array();
foreach ($this->reportsToMerge as $report) {
if (!is_array($report->metrics)) {
continue;
}
$this->metrics = array_merge($this->metrics, $report->metrics);
}
$this->order = 6;
}
示例4: renderReportWidget
public function renderReportWidget($reportModule = null, $reportAction = null)
{
Piwik::checkUserHasSomeViewAccess();
$this->checkSitePermission();
$report = Report::factory($reportModule, $reportAction);
if (empty($report)) {
throw new Exception(Piwik::translate('General_ExceptionReportNotFound'));
}
$report->checkIsEnabled();
return $report->render();
}
示例5: get
public function get($idSite, $period, $date, $segment = false, $columns = false)
{
Piwik::checkUserHasViewAccess($idSite);
$archive = Archive::build($idSite, $period, $date, $segment);
$requestedColumns = Piwik::getArrayFromApiParameter($columns);
$report = Report::factory("VisitsSummary", "get");
$columns = $report->getMetricsRequiredForReport($this->getCoreColumns($period), $requestedColumns);
$dataTable = $archive->getDataTableFromNumeric($columns);
if (!empty($requestedColumns)) {
$columnsToShow = $requestedColumns ?: $report->getAllMetrics();
$dataTable->queueFilter('ColumnDelete', array($columnsToRemove = array(), $columnsToShow));
}
return $dataTable;
}
示例6: indexSiteSearch
public function indexSiteSearch()
{
$view = new View('@Actions/indexSiteSearch');
$keyword = Report::factory($this->pluginName, 'getSiteSearchKeywords');
$noResult = Report::factory($this->pluginName, 'getSiteSearchNoResultKeywords');
$pageUrls = Report::factory($this->pluginName, 'getPageUrlsFollowingSiteSearch');
$view->keywords = $keyword->render();
$view->noResultKeywords = $noResult->render();
$view->pagesUrlsFollowingSiteSearch = $pageUrls->render();
$categoryTrackingEnabled = Actions::isCustomVariablesPluginsEnabled();
if ($categoryTrackingEnabled) {
$categories = Report::factory($this->pluginName, 'getSiteSearchCategories');
$view->categories = $categories->render();
}
return $view->render();
}
示例7: software
public function software()
{
$view = new View('@DevicesDetection/software');
$view->osReport = $this->renderReport('getOsVersions');
$view->browserReport = $this->renderReport('getBrowsers');
$view->browserEngineReport = $this->renderReport('getBrowserEngines');
$isResolutionEnabled = PluginManager::getInstance()->isPluginActivated('Resolution');
if ($isResolutionEnabled) {
$view->configurations = $this->renderReport(Report::factory('Resolution', 'getConfiguration'));
}
$isDevicePluginsEnabled = PluginManager::getInstance()->isPluginActivated('DevicePlugins');
if ($isDevicePluginsEnabled) {
$view->browserPlugins = $this->renderReport(Report::factory('DevicePlugins', 'getPlugin'));
}
return $view->render();
}
示例8: getReportsToMerge
/**
* @return Report[]
*/
private function getReportsToMerge()
{
$result = array();
foreach (Report::getAllReportClasses() as $reportClass) {
if ($reportClass == 'Piwik\\Plugins\\API\\Reports\\Get') {
continue;
}
/** @var Report $report */
$report = new $reportClass();
if ($report->getModule() == 'API' || $report->getAction() != 'get') {
continue;
}
$metrics = $report->getMetrics();
if (!empty($report->parameters) || empty($metrics)) {
continue;
}
$result[] = $report;
}
return $result;
}
示例9: makeController
protected function makeController($module, $action, &$parameters)
{
$controllerClassName = $this->getClassNameController($module);
// TRY TO FIND ACTION IN CONTROLLER
if (class_exists($controllerClassName)) {
$class = $this->getClassNameController($module);
/** @var $controller Controller */
$controller = new $class();
$controllerAction = $action;
if ($controllerAction === false) {
$controllerAction = $controller->getDefaultAction();
}
if (is_callable(array($controller, $controllerAction))) {
return array($controller, $controllerAction);
}
if ($action === false) {
$this->triggerControllerActionNotFoundError($module, $controllerAction);
}
}
// TRY TO FIND ACTION IN WIDGET
$widget = Widgets::factory($module, $action);
if (!empty($widget)) {
$parameters['widgetModule'] = $module;
$parameters['widgetMethod'] = $action;
return array(new CoreHomeController(), 'renderWidget');
}
// TRY TO FIND ACTION IN REPORT
$report = Report::factory($module, $action);
if (!empty($report)) {
$parameters['reportModule'] = $module;
$parameters['reportAction'] = $action;
return array(new CoreHomeController(), 'renderReportWidget');
}
if (!empty($action) && 'menu' === substr($action, 0, 4)) {
$reportAction = lcfirst(substr($action, 4));
// menuGetPageUrls => getPageUrls
$report = Report::factory($module, $reportAction);
if (!empty($report)) {
$parameters['reportModule'] = $module;
$parameters['reportAction'] = $reportAction;
return array(new CoreHomeController(), 'renderReportMenu');
}
}
$this->triggerControllerActionNotFoundError($module, $action);
}
示例10: __construct
/**
* 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();
}
示例11: test_getForDimension_ShouldReturnNullIfReportPluginNotLoaded
public function test_getForDimension_ShouldReturnNullIfReportPluginNotLoaded()
{
PluginManager::getInstance()->loadPlugins(array());
$report = Report::getForDimension(new Keyword());
$this->assertNull($report);
}
示例12: renderReport
/**
* Convenience method that creates and renders a ViewDataTable for a API method.
*
* @param string|\Piwik\Plugin\Report $apiAction The name of the API action (eg, `'getResolution'`) or
* an instance of an report.
* @param bool $controllerAction The name of the Controller action name that is rendering the report. Defaults
* to the `$apiAction`.
* @param bool $fetch If `true`, the rendered string is returned, if `false` it is `echo`'d.
* @throws \Exception if `$pluginName` is not an existing plugin or if `$apiAction` is not an
* existing method of the plugin's API.
* @return string|void See `$fetch`.
* @api
*/
protected function renderReport($apiAction, $controllerAction = false)
{
if (empty($controllerAction) && is_string($apiAction)) {
$report = Report::factory($this->pluginName, $apiAction);
if (!empty($report)) {
$apiAction = $report;
}
}
if ($apiAction instanceof Report) {
$this->checkSitePermission();
$apiAction->checkIsEnabled();
return $apiAction->render();
}
$pluginName = $this->pluginName;
/** @var Proxy $apiProxy */
$apiProxy = Proxy::getInstance();
if (!$apiProxy->isExistingApiAction($pluginName, $apiAction)) {
throw new \Exception("Invalid action name '{$apiAction}' for '{$pluginName}' plugin.");
}
$apiAction = $apiProxy->buildApiActionName($pluginName, $apiAction);
if ($controllerAction !== false) {
$controllerAction = $pluginName . '.' . $controllerAction;
}
$view = ViewDataTableFactory::build(null, $apiAction, $controllerAction);
$rendered = $view->render();
return $rendered;
}
示例13: isAllMetricsReport
private function isAllMetricsReport()
{
return $this->report->getModule() == 'API' && $this->report->getAction() == 'get';
}
示例14: getAllReportsWithGoalMetrics
private static function getAllReportsWithGoalMetrics()
{
$reportsWithGoals = array();
foreach (Report::getAllReports() as $report) {
if ($report->hasGoalMetrics()) {
$reportsWithGoals[] = array('category' => $report->getCategory(), 'name' => $report->getName(), 'module' => $report->getModule(), 'action' => $report->getAction());
}
}
/**
* Triggered when gathering all reports that contain Goal metrics. The list of reports
* will be displayed on the left column of the bottom of every _Goals_ page.
*
* If plugins define reports that contain goal metrics (such as **conversions** or **revenue**),
* they can use this event to make sure their reports can be viewed on Goals pages.
*
* **Example**
*
* public function getReportsWithGoalMetrics(&$reports)
* {
* $reports[] = array(
* 'category' => Piwik::translate('MyPlugin_myReportCategory'),
* 'name' => Piwik::translate('MyPlugin_myReportDimension'),
* 'module' => 'MyPlugin',
* 'action' => 'getMyReport'
* );
* }
*
* @param array &$reportsWithGoals The list of arrays describing reports that have Goal metrics.
* Each element of this array must be an array with the following
* properties:
*
* - **category**: The report category. This should be a translated string.
* - **name**: The report's translated name.
* - **module**: The plugin the report is in, eg, `'UserCountry'`.
* - **action**: The API method of the report, eg, `'getCountry'`.
* @ignore
* @deprecated since 2.5.0
*/
Piwik::postEvent('Goals.getReportsWithGoalMetrics', array(&$reportsWithGoals));
return $reportsWithGoals;
}
示例15: getGenericFiltersHavingDefaultValues
private function getGenericFiltersHavingDefaultValues()
{
$filters = self::getGenericFiltersInformation();
if ($this->report && $this->report->getDefaultSortColumn()) {
foreach ($filters as $index => $filter) {
if ($filter[0] === 'Sort') {
$filters[$index][1]['filter_sort_column'] = array('string', $this->report->getDefaultSortColumn());
$filters[$index][1]['filter_sort_order'] = array('string', $this->report->getDefaultSortOrder());
}
}
}
return $filters;
}