Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenaka Moorthi <benaka.moorthi@gmail.com>2013-07-12 10:31:39 +0400
committerBenaka Moorthi <benaka.moorthi@gmail.com>2013-07-12 10:31:39 +0400
commit01057779046dd67923bd34d123628ab60ed263bc (patch)
tree94353df4f7848f2de63f3eeb0c9eeed2020965c8 /plugins
parent98e6c9b8874ffc8c18570ed4cc062cc5f0eb80c0 (diff)
Refs #4040, #4041, move all ViewDataTable properties to the viewProperties array and allow these properties to be specified through new display metadata. Converted the Actions, Goals, UserSettings and VisitTime controllers.
Notes: - Includes refactoring of ExcludeLowPopulation filter.
Diffstat (limited to 'plugins')
-rw-r--r--plugins/Actions/API.php19
-rw-r--r--plugins/Actions/Actions.php415
-rw-r--r--plugins/Actions/Controller.php454
-rw-r--r--plugins/Goals/Controller.php139
-rw-r--r--plugins/Goals/Goals.php130
-rw-r--r--plugins/UserSettings/Controller.php173
-rw-r--r--plugins/UserSettings/UserSettings.php125
-rw-r--r--plugins/VisitTime/Controller.php73
-rw-r--r--plugins/VisitTime/VisitTime.php89
9 files changed, 838 insertions, 779 deletions
diff --git a/plugins/Actions/API.php b/plugins/Actions/API.php
index 8eec6d2d1b..6d0b2898b5 100644
--- a/plugins/Actions/API.php
+++ b/plugins/Actions/API.php
@@ -38,25 +38,6 @@ class Piwik_Actions_API
return self::$instance;
}
-
- /**
- * Backward compatibility. Fallsback to getPageTitles() instead.
- * @deprecated Deprecated since Piwik 0.5
- * @ignore
- *
- * @param int $idSite
- * @param string $period
- * @param $date
- * @param bool $segment
- * @param bool $expanded
- * @param bool|int $idSubtable
- * @return Piwik_DataTable|Piwik_DataTable_Array
- */
- public function getActions($idSite, $period, $date, $segment = false, $expanded = false, $idSubtable = false)
- {
- return $this->getPageTitles($idSite, $period, $date, $segment, $expanded, $idSubtable);
- }
-
/**
* Returns the list of metrics (pages, downloads, outlinks)
*
diff --git a/plugins/Actions/Actions.php b/plugins/Actions/Actions.php
index fdae02efd0..efbbbb4f91 100644
--- a/plugins/Actions/Actions.php
+++ b/plugins/Actions/Actions.php
@@ -18,6 +18,22 @@
*/
class Piwik_Actions extends Piwik_Plugin
{
+ const ACTIONS_REPORT_ROWS_DISPLAY = 100;
+
+ private $columnTranslations;
+
+ public function __construct()
+ {
+ $this->columnTranslations = array(
+ 'nb_hits' => Piwik_Translate('General_ColumnPageviews'),
+ 'nb_visits' => Piwik_Translate('General_ColumnUniquePageviews'),
+ 'avg_time_on_page' => Piwik_Translate('General_ColumnAverageTimeOnPage'),
+ 'bounce_rate' => Piwik_Translate('General_ColumnBounceRate'),
+ 'exit_rate' => Piwik_Translate('General_ColumnExitRate'),
+ 'avg_time_generation' => Piwik_Translate('General_ColumnAverageGenerationTime'),
+ );
+ }
+
public function getInformation()
{
$info = array(
@@ -32,16 +48,17 @@ class Piwik_Actions extends Piwik_Plugin
public function getListHooksRegistered()
{
$hooks = array(
- 'ArchiveProcessing_Day.compute' => 'archiveDay',
- 'ArchiveProcessing_Period.compute' => 'archivePeriod',
- 'WidgetsList.add' => 'addWidgets',
- 'Menu.add' => 'addMenus',
- 'API.getReportMetadata' => 'getReportMetadata',
- 'API.getSegmentsMetadata' => 'getSegmentsMetadata',
+ 'ArchiveProcessing_Day.compute' => 'archiveDay',
+ 'ArchiveProcessing_Period.compute' => 'archivePeriod',
+ 'WidgetsList.add' => 'addWidgets',
+ 'Menu.add' => 'addMenus',
+ 'API.getReportMetadata' => 'getReportMetadata',
+ 'API.getSegmentsMetadata' => 'getSegmentsMetadata',
+ 'ViewDataTable.getReportDisplayProperties' => 'getReportDisplayProperties',
);
return $hooks;
}
-
+
public function getSegmentsMetadata(&$segments)
{
$sqlFilter = array($this, 'getIdActionFromSegment');
@@ -605,5 +622,389 @@ class Piwik_Actions extends Piwik_Plugin
throw new Exception(" The segment $segmentName has an unexpected value.");
}
}
+
+ public function getReportDisplayProperties(&$properties, $apiAction)
+ {
+ $reportViewProperties = array(
+ 'Actions.getPageUrls' => $this->getDisplayPropertiesForPageUrls(),
+ 'Actions.getEntryPageUrls' => $this->getDisplayPropertiesForEntryPageUrls(),
+ 'Actions.getExitPageUrls' => $this->getDisplayPropertiesForExitPageUrls(),
+ 'Actions.getSiteSearchKeywords' => $this->getDisplayPropertiesForSiteSearchKeywords(),
+ 'Actions.getSiteSearchNoResultKeywords' => $this->getDisplayPropertiesForSiteSearchNoResultKeywords(),
+ 'Actions.getSiteSearchCategories' => $this->getDisplayPropertiesForSiteSearchCategories(),
+ 'Actions.getPageUrlsFollowingSiteSearch' => $this->getDisplayPropertiesForGetPageUrlsOrTitlesFollowingSiteSearch(false),
+ 'Actions.getPageTitlesFollowingSiteSearch' => $this->getDisplayPropertiesForGetPageUrlsOrTitlesFollowingSiteSearch(true),
+ 'Actions.getPageTitles' => $this->getDisplayPropertiesForGetPageTitles(),
+ 'Actions.getEntryPageTitles' => $this->getDisplayPropertiesForGetEntryPageTitles(),
+ 'Actions.getExitPageTitles' => $this->getDisplayPropertiesForGetExitPageTitles(),
+ 'Actions.getDownloads' => $this->getDisplayPropertiesForGetDownloads(),
+ 'Actions.getOutlinks' => $this->getDisplayPropertiesForGetOutlinks(),
+ );
+
+ if (isset($reportViewProperties[$apiAction])) {
+ $properties = $reportViewProperties[$apiAction];
+ }
+ }
+
+ private function addBaseDisplayProperties(&$result)
+ {
+ $result['datatable_css_class'] = 'dataTableActions';
+ $result['datatable_js_type'] = 'actionDataTable';
+ $result['subtable_template'] = '@CoreHome/_dataTableActions_subDataTable.twig';
+ $result['search_recursive'] = true;
+ $result['show_all_views_icons'] = false;
+ $result['show_table_all_columns'] = false;
+ $result['filter_limit'] = self::ACTIONS_REPORT_ROWS_DISPLAY;
+
+ // if the flat parameter is not provided, make sure it is set to 0 in the URL,
+ // so users can see that they can set it to 1 (see #3365)
+ $result['custom_parameters'] = array('flat' => 0);
+
+ if (Piwik_ViewDataTable::shouldLoadExpanded()) {
+ $result['show_expanded'] = true;
+
+ $result['filters'][] = function ($dataTable) {
+ Piwik_Actions::setDataTableRowLevels($dataTable);
+ };
+ }
+
+ return $result;
+ }
+
+ public static function setDataTableRowLevels($dataTable, $level = 0)
+ {
+ foreach ($dataTable->getRows() as $row) {
+ $row->setMetadata('css_class', 'level'.$level);
+
+ $subtable = $row->getSubtable();
+ if ($subtable) {
+ self::setDataTableRowLevels($subtable, $level + 1);
+ }
+ }
+ }
+
+ private function addExcludeLowPopDisplayProperties(&$result)
+ {
+ if (Piwik_Common::getRequestVar('enable_filter_excludelowpop', '0', 'string') != '0') {
+ $result['filter_excludelowpop'] = 'nb_hits';
+ $result['filter_excludelowpop_value'] = function () {
+ // computing minimum value to exclude (2 percent of the total number of actions)
+ $visitsInfo = Piwik_VisitsSummary_Controller::getVisitsSummary()->getFirstRow();
+ $nbActions = $visitsInfo->getColumn('nb_actions');
+ $nbActionsLowPopulationThreshold = floor(0.02 * $nbActions);
+
+ // we remove 1 to make sure some actions/downloads are displayed in the case we have a very few of them
+ // and each of them has 1 or 2 hits...
+ return min($visitsInfo->getColumn('max_actions') - 1, $nbActionsLowPopulationThreshold - 1);
+ };
+ }
+ }
+
+ private function addPageDisplayProperties(&$result)
+ {
+ // add common translations
+ $result['translations'] += array(
+ 'nb_hits' => Piwik_Translate('General_ColumnPageviews'),
+ 'nb_visits' => Piwik_Translate('General_ColumnUniquePageviews'),
+ 'avg_time_on_page' => Piwik_Translate('General_ColumnAverageTimeOnPage'),
+ 'bounce_rate' => Piwik_Translate('General_ColumnBounceRate'),
+ 'exit_rate' => Piwik_Translate('General_ColumnExitRate'),
+ 'avg_time_generation' => Piwik_Translate('General_ColumnAverageGenerationTime'),
+ );
+
+ // prettify avg_time_on_page column
+ $getPrettyTimeFromSeconds = array('Piwik', 'getPrettyTimeFromSeconds');
+ $result['filters'][] = array('ColumnCallbackReplace', array('avg_time_on_page', $getPrettyTimeFromSeconds));
+
+ // prettify avg_time_generation column
+ $avgTimeCallback = function ($time) {
+ return $time ? Piwik::getPrettyTimeFromSeconds($time, true, true, false) : "-";
+ };
+ $result['filters'][] = array('ColumnCallbackReplace', array('avg_time_generation', $avgTimeCallback));
+
+ // add avg_generation_time tooltip
+ $tooltipCallback = function ($hits, $min, $max) {
+ if (!$hits) {
+ return false;
+ }
+
+ return Piwik_Translate("Actions_AvgGenerationTimeTooltip", array(
+ $hits,
+ "<br />",
+ Piwik::getPrettyTimeFromSeconds($min),
+ Piwik::getPrettyTimeFromSeconds($max)
+ ));
+ };
+ $result['filters'][] = array('ColumnCallbackAddMetadata',
+ array(
+ array('nb_hits_with_time_generation', 'min_time_generation', 'max_time_generation'),
+ 'avg_time_generation_tooltip',
+ $tooltipCallback
+ )
+ );
+
+ $this->addExcludeLowPopDisplayProperties($result);
+ }
+
+ public function getDisplayPropertiesForPageUrls()
+ {
+ $result = array(
+ 'translations' => array('label' => Piwik_Translate('Actions_ColumnPageURL')),
+ 'columns_to_display' => array('label', 'nb_hits', 'nb_visits', 'bounce_rate',
+ 'avg_time_on_page', 'exit_rate', 'avg_time_generation'),
+ );
+
+ $this->addPageDisplayProperties($result);
+ $this->addBaseDisplayProperties($result);
+
+ return $result;
+ }
+
+ public function getDisplayPropertiesForEntryPageUrls()
+ {
+ // link to the page, not just the report, but only if not a widget
+ $widget = Piwik_Common::getRequestVar('widget', false);
+ $reportUrl = Piwik_API_Request::getCurrentUrlWithoutGenericFilters(array(
+ 'module' => 'Actions',
+ 'action' => $widget === false ? 'indexEntryPageUrls' : 'getEntryPageUrls'
+ ));
+
+ $result = array(
+ 'translations' => array('label' => Piwik_Translate('Actions_ColumnEntryPageURL'),
+ 'entry_bounce_count' => Piwik_Translate('General_ColumnBounces'),
+ 'entry_nb_visits' => Piwik_Translate('General_ColumnEntrances')),
+ 'columns_to_display' => array('label', 'entry_nb_visits', 'entry_bounce_count', 'bounce_rate'),
+ 'filter_sort_column' => 'entry_nb_visits',
+ 'filter_sort_order' => 'desc',
+ 'title' => Piwik_Translate('Actions_SubmenuPagesEntry'),
+ 'relatedReports' => array(
+ 'Actions.getEntryPageTitles' => Piwik_Translate('Actions_EntryPageTitles')
+ ),
+ 'self_url' => $reportUrl
+ );
+
+ $this->addPageDisplayProperties($result);
+ $this->addBaseDisplayProperties($result);
+
+ return $result;
+ }
+
+ public function getDisplayPropertiesForExitPageUrls()
+ {
+ // link to the page, not just the report, but only if not a widget
+ $widget = Piwik_Common::getRequestVar('widget', false);
+ $reportUrl = Piwik_API_Request::getCurrentUrlWithoutGenericFilters(array(
+ 'module' => 'Actions',
+ 'action' => $widget === false ? 'indexExitPageUrls' : 'getExitPageUrls'
+ ));
+
+ $result = array(
+ 'translations' => array('label' => Piwik_Translate('Actions_ColumnExitPageURL'),
+ 'exit_nb_visits' => Piwik_Translate('General_ColumnExits')),
+ 'columns_to_display' => array('label', 'exit_nb_visits', 'nb_visits', 'exit_rate'),
+ 'filter_sort_column' => 'exit_nb_visits',
+ 'filter_sort_order' => 'desc',
+ 'title' => Piwik_Translate('Actions_SubmenuPagesExit'),
+ 'relatedReports' => array(
+ 'Actions.getExitPageTitles' => Piwik_Translate('Actions_ExitPageTitles')
+ ),
+ 'self_url' => $reportUrl,
+ );
+
+ $this->addPageDisplayProperties($result);
+ $this->addBaseDisplayProperties($result);
+
+ return $result;
+ }
+
+ private function addSiteSearchDisplayProperties(&$result)
+ {
+ $result['translations'] += array(
+ 'nb_visits' => Piwik_Translate('Actions_ColumnSearches'),
+ 'exit_rate' => str_replace("% ", "%&nbsp;", Piwik_Translate('Actions_ColumnSearchExits')),
+ 'nb_pages_per_search' => Piwik_Translate('Actions_ColumnPagesPerSearch')
+ );
+ $result['show_bar_chart'] = false;
+ $result['show_table_all_columns'] = false;
+ }
+
+ public function getDisplayPropertiesForSiteSearchKeywords()
+ {
+ $result = array(
+ 'translations' => array('label' => Piwik_Translate('Actions_ColumnSearchKeyword')),
+ 'columns_to_display' => array('label', 'nb_visits', 'nb_pages_per_search', 'exit_rate'),
+ );
+
+ $this->addSiteSearchDisplayProperties($result);
+
+ return $result;
+ }
+
+ public function getDisplayPropertiesForSiteSearchNoResultKeywords()
+ {
+ $result = array(
+ 'translations' => array('label', Piwik_Translate('Actions_ColumnNoResultKeyword')),
+ 'columns_to_display' => array('label', 'nb_visits', 'exit_rate')
+ );
+
+ $this->addSiteSearchDisplayProperties($result);
+
+ return $result;
+ }
+
+ public function getDisplayPropertiesForSiteSearchCategories()
+ {
+ return array(
+ 'translations' => array(
+ 'label' => Piwik_Translate('Actions_ColumnSearchCategory'),
+ 'nb_visits' => Piwik_Translate('Actions_ColumnSearches'),
+ 'nb_pages_per_search' => Piwik_Translate('Actions_ColumnPagesPerSearch')
+ ),
+ 'columns_to_display' => array('label', 'nb_visits', 'nb_pages_per_search'),
+ 'show_table_all_columns' => false,
+ 'show_bar_chart' => false,
+ 'disable_row_evolution' => false,
+ );
+ }
+
+ public function getDisplayPropertiesForGetPageUrlsOrTitlesFollowingSiteSearch($isTitle)
+ {
+ $title = $isTitle ? Piwik_Translate('Actions_WidgetPageTitlesFollowingSearch')
+ : Piwik_Translate('Actions_WidgetPageUrlsFollowingSearch');
+
+ $relatedReports = array(
+ 'Actions.getPageTitlesFollowingSiteSearch' => Piwik_Translate('Actions_WidgetPageTitlesFollowingSearch'),
+ 'Actions.getPageUrlsFollowingSiteSearch' => Piwik_Translate('Actions_WidgetPageUrlsFollowingSearch'),
+ );
+
+ $result = array(
+ 'translations' => array(
+ 'label' => Piwik_Translate('General_ColumnDestinationPage'),
+ 'nb_hits_following_search' => Piwik_Translate('General_ColumnViewedAfterSearch'),
+ 'nb_hits' => Piwik_Translate('General_ColumnTotalPageviews')
+ ),
+ 'columns_to_display' => array('label', 'nb_hits_following_search', 'nb_hits'),
+ 'filter_sort_column' => 'nb_hits_following_search',
+ 'filter_sort_order' => 'desc',
+ 'show_exclude_low_population' => false,
+ 'title' => $title,
+ 'relatedReports' => $relatedReports
+ );
+
+ $this->addExcludeLowPopDisplayProperties($result);
+ $this->addBaseDisplayProperties($result);
+
+ return $result;
+ }
+
+ public function getDisplayPropertiesForGetPageTitles()
+ {
+ // link to the page, not just the report, but only if not a widget
+ $widget = Piwik_Common::getRequestVar('widget', false);
+ $reportUrl = Piwik_API_Request::getCurrentUrlWithoutGenericFilters(array(
+ 'module' => 'Actions',
+ 'action' => $widget === false ? 'indexPageTitles' : 'getPageTitles'
+ ));
+
+ $result = array(
+ 'translations' => array('label' => Piwik_Translate('Actions_ColumnPageName')),
+ 'columns_to_display' => array('label', 'nb_hits', 'nb_visits', 'bounce_rate',
+ 'avg_time_on_page', 'exit_rate', 'avg_time_generation'),
+ 'title' => Piwik_Translate('Actions_SubmenuPageTitles'),
+ 'relatedReports' => array(
+ 'Actions.getEntryPageTitles' => Piwik_Translate('Actions_EntryPageTitles'),
+ 'Actions.getExitPageTitles' => Piwik_Translate('Actions_ExitPageTitles'),
+ ),
+ 'self_url' => $reportUrl
+ );
+
+ $this->addPageDisplayProperties($result);
+ $this->addBaseDisplayProperties($result);
+
+ return $result;
+ }
+
+ public function getDisplayPropertiesForGetEntryPageTitles()
+ {
+ $entryPageUrlAction =
+ Piwik_Common::getRequestVar('widget', false) === false ? 'indexEntryPageUrls' : 'getEntryPageUrls';
+
+ $result = array(
+ 'translations' => array(
+ 'label' => Piwik_Translate('Actions_ColumnEntryPageTitle'),
+ 'entry_bounce_count' => Piwik_Translate('General_ColumnBounces'),
+ 'entry_nb_visits' => Piwik_Translate('General_ColumnEntrances'),
+ ),
+ 'columns_to_display' => array('label', 'entry_nb_visits', 'entry_bounce_count', 'bounce_rate'),
+ 'title' => Piwik_Translate('Actions_EntryPageTitles'),
+ 'relatedReports' => array(
+ 'Actions.getPageTitles' => Piwik_Translate('Actions_SubmenuPageTitles'),
+ "Actions.$entryPageUrlAction" => Piwik_Translate('Actions_SubmenuPagesEntry')
+ ),
+ );
+
+ $this->addPageDisplayProperties($result);
+ $this->addBaseDisplayProperties($result);
+
+ return $result;
+ }
+
+ public function getDisplayPropertiesForGetExitPageTitles()
+ {
+ $exitPageUrlAction =
+ Piwik_Common::getRequestVar('widget', false) === false ? 'indexExitPageUrls' : 'getExitPageUrls';
+
+ $result = array(
+ 'translations' => array(
+ 'label' => Piwik_Translate('Actions_ColumnExitPageTitle'),
+ 'exit_nb_visits' => Piwik_Translate('General_ColumnExits'),
+ ),
+ 'columns_to_display' => array('label', 'exit_nb_visits', 'nb_visits', 'exit_rate'),
+ 'title' => Piwik_Translate('Actions_ExitPageTitles'),
+ 'relatedReports' => array(
+ 'Actions.getPageTitles' => Piwik_Translate('Actions_SubmenuPageTitles'),
+ "Actions.$exitPageUrlAction" => Piwik_Translate('Actions_SubmenuPagesExit'),
+ ),
+ );
+
+ $this->addPageDisplayProperties($result);
+ $this->addBaseDisplayProperties($result);
+
+ return $result;
+ }
+
+ public function getDisplayPropertiesForGetDownloads()
+ {
+ $result = array(
+ 'translations' => array(
+ 'label' => Piwik_Translate('Actions_ColumnDownloadURL'),
+ 'nb_visits' => Piwik_Translate('Actions_ColumnUniqueDownloads'),
+ 'nb_hits' => Piwik_Translate('Actions_ColumnDownloads'),
+ ),
+ 'columns_to_display' => array('label', 'nb_visits', 'nb_hits'),
+ 'show_exclude_low_population' => false
+ );
+
+ $this->addBaseDisplayProperties($result);
+
+ return $result;
+ }
+
+ public function getDisplayPropertiesForGetOutlinks()
+ {
+ $result = array(
+ 'translations' => array(
+ 'label' => Piwik_Translate('Actions_ColumnClickedURL'),
+ 'nb_visits' => Piwik_Translate('Actions_ColumnUniqueClicks'),
+ 'nb_hits' => Piwik_Translate('Actions_ColumnClicks'),
+ ),
+ 'columns_to_display' => array('label', 'nb_visits', 'nb_hits'),
+ 'show_exclude_low_population' => false
+ );
+
+ $this->addBaseDisplayProperties($result);
+
+ return $result;
+ }
}
diff --git a/plugins/Actions/Controller.php b/plugins/Actions/Controller.php
index 16473b60e0..f7597825e5 100644
--- a/plugins/Actions/Controller.php
+++ b/plugins/Actions/Controller.php
@@ -16,22 +16,10 @@
*/
class Piwik_Actions_Controller extends Piwik_Controller
{
- const ACTIONS_REPORT_ROWS_DISPLAY = 100;
-
- protected function getPageUrlsView($currentAction, $controllerActionSubtable, $apiAction)
- {
- $view = Piwik_ViewDataTable::factory();
- $view->init($this->pluginName, $currentAction, $apiAction, $controllerActionSubtable);
- $view->setColumnTranslation('label', Piwik_Translate('Actions_ColumnPageURL'));
- return $view;
- }
-
- /**
- * PAGES
- * @param bool $fetch
- * @return string
- */
-
+ //
+ // Actions that render whole pages
+ //
+
public function indexPageUrls($fetch = false)
{
return Piwik_View::singleReport(
@@ -39,24 +27,6 @@ class Piwik_Actions_Controller extends Piwik_Controller
$this->getPageUrls(true), $fetch);
}
- public function getPageUrls($fetch = false)
- {
- $view = $this->getPageUrlsView(__FUNCTION__, 'getPageUrls', 'Actions.getPageUrls');
- $this->configureViewPages($view);
- $this->configureViewActions($view);
- return $this->renderView($view, $fetch);
- }
-
- protected function configureViewPages($view)
- {
- $view->setColumnsToDisplay(array('label', 'nb_hits', 'nb_visits', 'bounce_rate', 'avg_time_on_page', 'exit_rate', 'avg_time_generation'));
- }
-
- /**
- * ENTRY PAGES
- * @param bool $fetch
- * @return string|void
- */
public function indexEntryPageUrls($fetch = false)
{
return Piwik_View::singleReport(
@@ -64,30 +34,6 @@ class Piwik_Actions_Controller extends Piwik_Controller
$this->getEntryPageUrls(true), $fetch);
}
- public function getEntryPageUrls($fetch = false)
- {
- $view = $this->getPageUrlsView(__FUNCTION__, 'getEntryPageUrls', 'Actions.getEntryPageUrls');
- $this->configureViewEntryPageUrls($view);
- $this->configureViewActions($view);
- return $this->renderView($view, $fetch);
- }
-
- protected function configureViewEntryPageUrls($view)
- {
- $view->setSortedColumn('entry_nb_visits');
- $view->setColumnsToDisplay(array('label', 'entry_nb_visits', 'entry_bounce_count', 'bounce_rate'));
- $view->setColumnTranslation('label', Piwik_Translate('Actions_ColumnEntryPageURL'));
- $view->setColumnTranslation('entry_bounce_count', Piwik_Translate('General_ColumnBounces'));
- $view->setColumnTranslation('entry_nb_visits', Piwik_Translate('General_ColumnEntrances'));
- $view->addRelatedReports(Piwik_Translate('Actions_SubmenuPagesEntry'), array(
- 'Actions.getEntryPageTitles' => Piwik_Translate('Actions_EntryPageTitles')
- ));
- $view->setReportUrl('Actions', $this->getEntryPageUrlActionForLink());
- }
-
- /*
- * EXIT PAGES
- */
public function indexExitPageUrls($fetch = false)
{
return Piwik_View::singleReport(
@@ -95,29 +41,6 @@ class Piwik_Actions_Controller extends Piwik_Controller
$this->getExitPageUrls(true), $fetch);
}
- public function getExitPageUrls($fetch = false)
- {
- $view = $this->getPageUrlsView(__FUNCTION__, 'getExitPageUrls', 'Actions.getExitPageUrls');
- $this->configureViewExitPageUrls($view);
- $this->configureViewActions($view);
- return $this->renderView($view, $fetch);
- }
-
- protected function configureViewExitPageUrls($view)
- {
- $view->setSortedColumn('exit_nb_visits');
- $view->setColumnsToDisplay(array('label', 'exit_nb_visits', 'nb_visits', 'exit_rate'));
- $view->setColumnTranslation('label', Piwik_Translate('Actions_ColumnExitPageURL'));
- $view->setColumnTranslation('exit_nb_visits', Piwik_Translate('General_ColumnExits'));
- $view->addRelatedReports(Piwik_Translate('Actions_SubmenuPagesExit'), array(
- 'Actions.getExitPageTitles' => Piwik_Translate('Actions_ExitPageTitles')
- ));
- $view->setReportUrl('Actions', $this->getExitPageUrlActionForLink());
- }
-
- /*
- * SITE SEARCH
- */
public function indexSiteSearch()
{
$view = new Piwik_View('@Actions/indexSiteSearch');
@@ -134,87 +57,6 @@ class Piwik_Actions_Controller extends Piwik_Controller
echo $view->render();
}
- public function getSiteSearchKeywords($fetch = false)
- {
- $view = Piwik_ViewDataTable::factory();
- $view->init($this->pluginName, __FUNCTION__, 'Actions.getSiteSearchKeywords');
- $this->configureViewSiteSearchKeywords($view);
- return $this->renderView($view, $fetch);
- }
-
- public function getSiteSearchNoResultKeywords($fetch = false)
- {
- $view = Piwik_ViewDataTable::factory();
- $view->init($this->pluginName, __FUNCTION__, 'Actions.getSiteSearchNoResultKeywords');
- $this->configureViewSiteSearchKeywords($view);
- $view->setColumnsToDisplay(array('label', 'nb_visits', 'exit_rate'));
- $view->setColumnTranslation('label', Piwik_Translate('Actions_ColumnNoResultKeyword'));
- return $this->renderView($view, $fetch);
- }
-
- public function configureViewSiteSearchKeywords(Piwik_ViewDataTable $view)
- {
- $view->setColumnTranslation('label', Piwik_Translate('Actions_ColumnSearchKeyword'));
- $view->setColumnsToDisplay(array('label', 'nb_visits', 'nb_pages_per_search', 'exit_rate'));
- $view->setColumnTranslation('nb_visits', Piwik_Translate('Actions_ColumnSearches'));
- $view->setColumnTranslation('exit_rate', str_replace("% ", "%&nbsp;", Piwik_Translate('Actions_ColumnSearchExits')));
- $view->setColumnTranslation('nb_pages_per_search', Piwik_Translate('Actions_ColumnPagesPerSearch'));
- $view->disableShowBarChart();
- $view->disableShowAllColumns();
- }
-
- public function getSiteSearchCategories($fetch = false)
- {
- $view = Piwik_ViewDataTable::factory();
- $view->init($this->pluginName, __FUNCTION__, 'Actions.getSiteSearchCategories');
- $view->setColumnTranslation('label', Piwik_Translate('Actions_ColumnSearchCategory'));
- $view->setColumnTranslation('nb_visits', Piwik_Translate('Actions_ColumnSearches'));
- $view->setColumnsToDisplay(array('label', 'nb_visits', 'nb_pages_per_search'));
- $view->setColumnTranslation('nb_pages_per_search', Piwik_Translate('Actions_ColumnPagesPerSearch'));
- $view->disableShowAllColumns();
- $view->disableShowBarChart();
- $view->disableRowEvolution();
- return $this->renderView($view, $fetch);
- }
-
-
- public function getPageUrlsFollowingSiteSearch($fetch = false)
- {
- $view = Piwik_ViewDataTable::factory();
- $view->init($this->pluginName, __FUNCTION__, 'Actions.getPageUrlsFollowingSiteSearch', 'getPageUrlsFollowingSiteSearch');
- $view->addRelatedReports(Piwik_Translate('Actions_WidgetPageUrlsFollowingSearch'), array(
- 'Actions.getPageTitlesFollowingSiteSearch' => Piwik_Translate('Actions_WidgetPageTitlesFollowingSearch'),
- ));
- $view = $this->configureViewPagesFollowingSiteSearch($view);
- return $this->renderView($view, $fetch);
- }
-
- public function getPageTitlesFollowingSiteSearch($fetch = false)
- {
- $view = Piwik_ViewDataTable::factory();
- $view->init($this->pluginName, __FUNCTION__, 'Actions.getPageTitlesFollowingSiteSearch', 'getPageTitlesFollowingSiteSearch');
- $view->addRelatedReports(Piwik_Translate('Actions_WidgetPageTitlesFollowingSearch'), array(
- 'Actions.getPageUrlsFollowingSiteSearch' => Piwik_Translate('Actions_WidgetPageUrlsFollowingSearch'),
- ));
- $view = $this->configureViewPagesFollowingSiteSearch($view);
- return $this->renderView($view, $fetch);
- }
-
- public function configureViewPagesFollowingSiteSearch($view)
- {
- $view->setColumnsToDisplay(array('label', 'nb_hits_following_search', 'nb_hits'));
- $view->setColumnTranslation('nb_hits_following_search', Piwik_Translate('General_ColumnViewedAfterSearch'));
- $view->setColumnTranslation('label', Piwik_Translate('General_ColumnDestinationPage'));
- $view->setSortedColumn('nb_hits_following_search');
- $view->setColumnTranslation('nb_hits', Piwik_Translate('General_ColumnTotalPageviews'));
- $view->disableExcludeLowPopulation();
- $view = $this->configureViewActions($view, $doSetTranslations = false);
- return $view;
- }
-
- /*
- * PAGE TITLES
- */
public function indexPageTitles($fetch = false)
{
return Piwik_View::singleReport(
@@ -222,93 +64,6 @@ class Piwik_Actions_Controller extends Piwik_Controller
$this->getPageTitles(true), $fetch);
}
- public function getPageTitles($fetch = false)
- {
- $view = Piwik_ViewDataTable::factory();
- $view->init($this->pluginName,
- __FUNCTION__,
- 'Actions.getPageTitles',
- 'getPageTitlesSubDataTable');
- $view->setColumnTranslation('label', Piwik_Translate('Actions_ColumnPageName'));
- $view->addRelatedReports(Piwik_Translate('Actions_SubmenuPageTitles'), array(
- 'Actions.getEntryPageTitles' => Piwik_Translate('Actions_EntryPageTitles'),
- 'Actions.getExitPageTitles' => Piwik_Translate('Actions_ExitPageTitles'),
- ));
- $view->setReportUrl('Actions', $this->getPageTitlesActionForLink());
- $this->configureViewPages($view);
- $this->configureViewActions($view);
- return $this->renderView($view, $fetch);
- }
-
- public function getPageTitlesSubDataTable($fetch = false)
- {
- $view = Piwik_ViewDataTable::factory();
- $view->init($this->pluginName,
- __FUNCTION__,
- 'Actions.getPageTitles',
- 'getPageTitlesSubDataTable');
- $this->configureViewPages($view);
- $this->configureViewActions($view);
- return $this->renderView($view, $fetch);
- }
-
- /**
- * Echos or returns a report displaying analytics data for every unique entry
- * page title.
- *
- * @param bool $fetch True to return the view as a string, false to echo it.
- * @return string
- */
- public function getEntryPageTitles($fetch = false)
- {
- $view = Piwik_ViewDataTable::factory();
- $view->init($this->pluginName, __FUNCTION__, 'Actions.getEntryPageTitles', __FUNCTION__);
- $view->setColumnTranslation('label', Piwik_Translate('Actions_ColumnEntryPageTitle'));
- $view->setColumnTranslation('entry_bounce_count', Piwik_Translate('General_ColumnBounces'));
- $view->setColumnTranslation('entry_nb_visits', Piwik_Translate('General_ColumnEntrances'));
- $view->setColumnsToDisplay(array('label', 'entry_nb_visits', 'entry_bounce_count', 'bounce_rate'));
-
- $entryPageUrlAction = $this->getEntryPageUrlActionForLink();
- $view->addRelatedReports(Piwik_Translate('Actions_EntryPageTitles'), array(
- 'Actions.getPageTitles' => Piwik_Translate('Actions_SubmenuPageTitles'),
- "Actions.$entryPageUrlAction" => Piwik_Translate('Actions_SubmenuPagesEntry'),
- ));
-
- $this->configureViewActions($view);
-
- return $this->renderView($view, $fetch);
- }
-
- /**
- * Echos or returns a report displaying analytics data for every unique exit
- * page title.
- *
- * @param bool $fetch True to return the view as a string, false to echo it.
- * @return string
- */
- public function getExitPageTitles($fetch = false)
- {
- $view = Piwik_ViewDataTable::factory();
- $view->init($this->pluginName, __FUNCTION__, 'Actions.getExitPageTitles', __FUNCTION__);
- $view->setColumnTranslation('label', Piwik_Translate('Actions_ColumnExitPageTitle'));
- $view->setColumnTranslation('exit_nb_visits', Piwik_Translate('General_ColumnExits'));
- $view->setColumnsToDisplay(array('label', 'exit_nb_visits', 'nb_visits', 'exit_rate'));
-
- $exitPageUrlAction = $this->getExitPageUrlActionForLink();
- $view->addRelatedReports(Piwik_Translate('Actions_ExitPageTitles'), array(
- 'Actions.getPageTitles' => Piwik_Translate('Actions_SubmenuPageTitles'),
- "Actions.$exitPageUrlAction" => Piwik_Translate('Actions_SubmenuPagesExit'),
- ));
-
- $this->configureViewActions($view);
-
- return $this->renderView($view, $fetch);
- }
-
- /*
- * DOWNLOADS
- */
-
public function indexDownloads($fetch = false)
{
return Piwik_View::singleReport(
@@ -316,202 +71,79 @@ class Piwik_Actions_Controller extends Piwik_Controller
$this->getDownloads(true), $fetch);
}
- public function getDownloads($fetch = false)
- {
- $view = Piwik_ViewDataTable::factory();
- $view->init($this->pluginName,
- __FUNCTION__,
- 'Actions.getDownloads',
- 'getDownloadsSubDataTable');
-
- $this->configureViewDownloads($view);
- return $this->renderView($view, $fetch);
- }
-
- public function getDownloadsSubDataTable($fetch = false)
- {
- $view = Piwik_ViewDataTable::factory();
- $view->init($this->pluginName,
- __FUNCTION__,
- 'Actions.getDownloads',
- 'getDownloadsSubDataTable');
- $this->configureViewDownloads($view);
- return $this->renderView($view, $fetch);
- }
-
-
- /*
- * OUTLINKS
- */
-
public function indexOutlinks($fetch = false)
{
return Piwik_View::singleReport(
Piwik_Translate('Actions_SubmenuOutlinks'),
$this->getOutlinks(true), $fetch);
}
-
- public function getOutlinks($fetch = false)
+
+ //
+ // Actions that render individual reports
+ //
+
+ public function getPageUrls($fetch = false)
{
- $view = Piwik_ViewDataTable::factory();
- $view->init($this->pluginName,
- __FUNCTION__,
- 'Actions.getOutlinks',
- 'getOutlinksSubDataTable');
- $this->configureViewOutlinks($view);
- return $this->renderView($view, $fetch);
+ return Piwik_ViewDataTable::render($this->pluginName, __FUNCTION__, $fetch);
}
-
- public function getOutlinksSubDataTable($fetch = false)
+
+ public function getEntryPageUrls($fetch = false)
{
- $view = Piwik_ViewDataTable::factory();
- $view->init($this->pluginName,
- __FUNCTION__,
- 'Actions.getOutlinks',
- 'getOutlinksSubDataTable');
- $this->configureViewOutlinks($view);
- return $this->renderView($view, $fetch);
+ return Piwik_ViewDataTable::render($this->pluginName, __FUNCTION__, $fetch);
}
- /*
- * Page titles & Page URLs reports
- */
- protected function configureViewActions($view, $doSetTranslations = true)
+ public function getExitPageUrls($fetch = false)
{
- if ($doSetTranslations) {
- $view->setColumnTranslation('nb_hits', Piwik_Translate('General_ColumnPageviews'));
- $view->setColumnTranslation('nb_visits', Piwik_Translate('General_ColumnUniquePageviews'));
- $view->setColumnTranslation('avg_time_on_page', Piwik_Translate('General_ColumnAverageTimeOnPage'));
- $view->setColumnTranslation('bounce_rate', Piwik_Translate('General_ColumnBounceRate'));
- $view->setColumnTranslation('exit_rate', Piwik_Translate('General_ColumnExitRate'));
- $view->setColumnTranslation('avg_time_generation', Piwik_Translate('General_ColumnAverageGenerationTime'));
-
- $view->queueFilter('ColumnCallbackReplace', array('avg_time_on_page', array('Piwik', 'getPrettyTimeFromSeconds')));
-
- $avgTimeCallback = create_function('$time', 'return $time ? Piwik::getPrettyTimeFromSeconds($time, true, true, false) : "-";');
- $view->queueFilter('ColumnCallbackReplace', array('avg_time_generation', $avgTimeCallback));
-
- $tooltipCallback = create_function('$hits, $min, $max', '
- return $hits ?
- Piwik_Translate("Actions_AvgGenerationTimeTooltip", array(
- $hits, "<br />",
- Piwik::getPrettyTimeFromSeconds($min),
- Piwik::getPrettyTimeFromSeconds($max)
- ))
- : false;');
- $view->queueFilter('ColumnCallbackAddMetadata', array(
- array('nb_hits_with_time_generation', 'min_time_generation', 'max_time_generation'),
- 'avg_time_generation_tooltip', $tooltipCallback));
- }
-
- if (Piwik_Common::getRequestVar('enable_filter_excludelowpop', '0', 'string') != '0') {
- // computing minimum value to exclude
- $visitsInfo = Piwik_VisitsSummary_Controller::getVisitsSummary();
- $visitsInfo = $visitsInfo->getFirstRow();
- $nbActions = $visitsInfo->getColumn('nb_actions');
- $nbActionsLowPopulationThreshold = floor(0.02 * $nbActions); // 2 percent of the total number of actions
- // we remove 1 to make sure some actions/downloads are displayed in the case we have a very few of them
- // and each of them has 1 or 2 hits...
- $nbActionsLowPopulationThreshold = min($visitsInfo->getColumn('max_actions') - 1, $nbActionsLowPopulationThreshold - 1);
-
- $view->setExcludeLowPopulation('nb_hits', $nbActionsLowPopulationThreshold);
- }
-
- $this->configureGenericViewActions($view);
- return $view;
+ return Piwik_ViewDataTable::render($this->pluginName, __FUNCTION__, $fetch);
}
- /*
- * Downloads report
- */
- protected function configureViewDownloads($view)
+ public function getSiteSearchKeywords($fetch = false)
{
- $view->setColumnsToDisplay(array('label', 'nb_visits', 'nb_hits'));
- $view->setColumnTranslation('label', Piwik_Translate('Actions_ColumnDownloadURL'));
- $view->setColumnTranslation('nb_visits', Piwik_Translate('Actions_ColumnUniqueDownloads'));
- $view->setColumnTranslation('nb_hits', Piwik_Translate('Actions_ColumnDownloads'));
- $view->disableExcludeLowPopulation();
- $this->configureGenericViewActions($view);
+ return Piwik_ViewDataTable::render($this->pluginName, __FUNCTION__, $fetch);
}
- /*
- * Outlinks report
- */
- protected function configureViewOutlinks($view)
+ public function getSiteSearchNoResultKeywords($fetch = false)
{
- $view->setColumnsToDisplay(array('label', 'nb_visits', 'nb_hits'));
- $view->setColumnTranslation('label', Piwik_Translate('Actions_ColumnClickedURL'));
- $view->setColumnTranslation('nb_visits', Piwik_Translate('Actions_ColumnUniqueClicks'));
- $view->setColumnTranslation('nb_hits', Piwik_Translate('Actions_ColumnClicks'));
- $view->disableExcludeLowPopulation();
- $this->configureGenericViewActions($view);
+ return Piwik_ViewDataTable::render($this->pluginName, __FUNCTION__, $fetch);
}
- /*
- * Common to all Actions reports, how to use the custom Actions Datatable html
- */
- protected function configureGenericViewActions($view)
+ public function getSiteSearchCategories($fetch = false)
{
- $view->setDataTableCssClass('dataTableActions');
- $view->setJsType('actionDataTable');
- $view->setSubtableTemplate('@CoreHome/_dataTableActions_subDataTable.twig');
-
- $view->setSearchRecursive();
- if (Piwik_ViewDataTable::shouldLoadExpanded()) {
- $view->showExpanded();
-
- // set levelN css class for each row
- $self = $this;
- $view->queueFilter(function ($dataTable) use ($self) {
- $self->setDataTableRowLevels($dataTable);
- });
- }
- // disable Footer icons
- $view->disableShowAllViewsIcons();
- $view->disableShowAllColumns();
-
- $view->setLimit(self::ACTIONS_REPORT_ROWS_DISPLAY);
+ return Piwik_ViewDataTable::render($this->pluginName, __FUNCTION__, $fetch);
+ }
- // if the flat parameter is not provided, make sure it is set to 0 in the URL,
- // so users can see that they can set it to 1 (see #3365)
- if (Piwik_Common::getRequestVar('flat', false) === false) {
- $view->setCustomParameter('flat', 0);
- }
+ public function getPageUrlsFollowingSiteSearch($fetch = false)
+ {
+ return Piwik_ViewDataTable::render($this->pluginName, __FUNCTION__, $fetch);
+ }
- $view->main();
+ public function getPageTitlesFollowingSiteSearch($fetch = false)
+ {
+ return Piwik_ViewDataTable::render($this->pluginName, __FUNCTION__, $fetch);
}
-
- public function setDataTableRowLevels($dataTable, $level = 0)
+
+ public function getPageTitles($fetch = false)
{
- foreach ($dataTable->getRows() as $row) {
- $row->setMetadata('css_class', 'level'.$level);
-
- $subtable = $row->getSubtable();
- if ($subtable) {
- $this->setDataTableRowLevels($subtable, $level + 1);
- }
- }
+ return Piwik_ViewDataTable::render($this->pluginName, __FUNCTION__, $fetch);
}
- /** Returns action to use when linking to the exit page URLs report. */
- private function getExitPageUrlActionForLink()
+ public function getEntryPageTitles($fetch = false)
{
- // link to the page not, just the report, but only if not a widget
- return Piwik_Common::getRequestVar('widget', 0) == 0 ? 'indexExitPageUrls' : 'getExitPageUrls';
+ return Piwik_ViewDataTable::render($this->pluginName, __FUNCTION__, $fetch);
}
+ public function getExitPageTitles($fetch = false)
+ {
+ return Piwik_ViewDataTable::render($this->pluginName, __FUNCTION__, $fetch);
+ }
- /** Returns action to use when linking to the entry page URLs report. */
- private function getEntryPageUrlActionForLink()
+ public function getDownloads($fetch = false)
{
- // link to the page not, just the report, but only if not a widget
- return Piwik_Common::getRequestVar('widget', 0) == 0 ? 'indexEntryPageUrls' : 'getEntryPageUrls';
+ return Piwik_ViewDataTable::render($this->pluginName, __FUNCTION__, $fetch);
}
- /** Returns action to use when linking to the page titles report. */
- private function getPageTitlesActionForLink()
+ public function getOutlinks($fetch = false)
{
- // link to the page not, just the report, but only if not a widget
- return Piwik_Common::getRequestVar('widget', 0) == 0 ? 'indexPageTitles' : 'getPageTitles';
+ return Piwik_ViewDataTable::render($this->pluginName, __FUNCTION__, $fetch);
}
}
diff --git a/plugins/Goals/Controller.php b/plugins/Goals/Controller.php
index 47edc746c9..a95fea8120 100644
--- a/plugins/Goals/Controller.php
+++ b/plugins/Goals/Controller.php
@@ -82,74 +82,6 @@ class Piwik_Goals_Controller extends Piwik_Controller
echo $view->render();
}
- protected function getItemsView($fetch, $type, $function, $api, $abandonedCart = false)
- {
- $label = Piwik_Translate($type);
- $abandonedCart = Piwik_Common::getRequestVar('viewDataTable', 'ecommerceOrder', 'string') == 'ecommerceAbandonedCart';
-
- // Products in Ecommerce Orders
- if ($abandonedCart === false) {
- $view = new Piwik_ViewDataTable_HtmlTable();
- $view->setCustomParameter('viewDataTable', Piwik::LABEL_ID_GOAL_IS_ECOMMERCE_ORDER);
- $columns = Piwik_Goals::getProductReportColumns();
- $view->setMetricDocumentation('revenue', Piwik_Translate('Goals_ColumnRevenueDocumentation', Piwik_Translate('Goals_DocumentationRevenueGeneratedByProductSales')));
- $view->setMetricDocumentation('quantity', Piwik_Translate('Goals_ColumnQuantityDocumentation', $label));
- $view->setMetricDocumentation('orders', Piwik_Translate('Goals_ColumnOrdersDocumentation', $label));
- $view->setMetricDocumentation('avg_price', Piwik_Translate('Goals_ColumnAveragePriceDocumentation', $label));
- $view->setMetricDocumentation('avg_quantity', Piwik_Translate('Goals_ColumnAverageQuantityDocumentation', $label));
- $view->setMetricDocumentation('nb_visits', Piwik_Translate('Goals_ColumnVisitsProductDocumentation', $label));
- $view->setMetricDocumentation('conversion_rate', Piwik_Translate('Goals_ColumnConversionRateProductDocumentation', $label));
- } // Products in Abandoned Carts
- else {
- $view = new Piwik_ViewDataTable_HtmlTable();
- $view->setCustomParameter('viewDataTable', Piwik::LABEL_ID_GOAL_IS_ECOMMERCE_CART);
- $columns = Piwik_Goals::getProductReportColumns();
- $columns['abandoned_carts'] = Piwik_Translate('General_AbandonedCarts');
- $columns['revenue'] = Piwik_Translate('Goals_LeftInCart', Piwik_Translate('General_ProductRevenue'));
- $columns['quantity'] = Piwik_Translate('Goals_LeftInCart', Piwik_Translate('General_Quantity'));
- $columns['avg_quantity'] = Piwik_Translate('Goals_LeftInCart', Piwik_Translate('General_AverageQuantity'));
- unset($columns['orders']);
- unset($columns['conversion_rate']);
- $view->setRequestStringSuffix('&abandonedCarts=1');
- }
-
- $view->init($this->pluginName, $function, $api);
- $view->enableShowEcommerce();
- $view->disableShowAllViewsIcons();
- $view->disableShowTable();
- $view->disableExcludeLowPopulation();
- $view->disableShowAllColumns();
- $this->setPeriodVariablesView($view);
- $view->setLimit(10);
-
- $view->setColumnsTranslations(array_merge(
- array('label' => $label),
- $columns
- ));
- $columnsToDisplay = array_merge(array('label'), array_keys($columns));
- $view->setColumnsToDisplay($columnsToDisplay);
- $view->setSortedColumn('revenue', 'desc');
- foreach (array('revenue', 'avg_price') as $column) {
- $view->queueFilter('ColumnCallbackReplace', array($column, array("Piwik", "getPrettyMoney"), array($this->idSite)));
- }
- return $this->renderView($view, $fetch);
- }
-
- public function getItemsSku($fetch = false)
- {
- return $this->getItemsView($fetch, 'Goals_ProductSKU', __FUNCTION__, "Goals.getItemsSku");
- }
-
- public function getItemsName($fetch = false)
- {
- return $this->getItemsView($fetch, 'Goals_ProductName', __FUNCTION__, "Goals.getItemsName");
- }
-
- public function getItemsCategory($fetch = false)
- {
- return $this->getItemsView($fetch, 'Goals_ProductCategory', __FUNCTION__, "Goals.getItemsCategory");
- }
-
public function getEcommerceLog($fetch = false)
{
$saveGET = $_GET;
@@ -451,48 +383,6 @@ class Piwik_Goals_Controller extends Piwik_Controller
}
/**
- * Gets the 'visits to conversion' report using the requested view type.
- */
- public function getVisitsUntilConversion($fetch = false)
- {
- $view = Piwik_ViewDataTable::factory();
- $view->init($this->pluginName, __FUNCTION__, 'Goals.getVisitsUntilConversion', 'getVisitsUntilConversion');
- $view->disableSearchBox();
- $view->disableExcludeLowPopulation();
- $view->disableSubTableWhenShowGoals();
- $view->disableShowAllColumns();
- $view->setColumnsToDisplay(array('label', 'nb_conversions'));
- $view->setSortedColumn('label', 'asc');
- $view->setColumnTranslation('label', Piwik_Translate('Goals_VisitsUntilConv'));
- $view->setColumnTranslation('nb_conversions', Piwik_Translate('Goals_ColumnConversions'));
- $view->setLimit(count(Piwik_Goals_Archiver::$visitCountRanges));
- $view->disableOffsetInformationAndPaginationControls();
- $view->disableShowAllViewsIcons();
- return $this->renderView($view, $fetch);
- }
-
- /**
- * Gets the 'days to conversion' report using the requested view type.
- */
- public function getDaysToConversion($fetch = false)
- {
- $view = Piwik_ViewDataTable::factory();
- $view->init($this->pluginName, __FUNCTION__, 'Goals.getDaysToConversion', 'getDaysToConversion');
- $view->disableSearchBox();
- $view->disableExcludeLowPopulation();
- $view->disableSubTableWhenShowGoals();
- $view->disableShowAllColumns();
- $view->setColumnsToDisplay(array('label', 'nb_conversions'));
- $view->setSortedColumn('label', 'asc');
- $view->setColumnTranslation('label', Piwik_Translate('Goals_DaysToConv'));
- $view->setColumnTranslation('nb_conversions', Piwik_Translate('Goals_ColumnConversions'));
- $view->disableShowAllViewsIcons();
- $view->setLimit(count(Piwik_Goals_Archiver::$daysToConvRanges));
- $view->disableOffsetInformationAndPaginationControls();
- return $this->renderView($view, $fetch);
- }
-
- /**
* Utility function that returns HTML that displays Goal information for reports. This
* is the HTML that is at the bottom of every goals page.
*
@@ -553,4 +443,33 @@ class Piwik_Goals_Controller extends Piwik_Controller
return $goalReportsByDimension->render();
}
+
+ //
+ // Report rendering actions
+ //
+
+ public function getItemsSku($fetch = false)
+ {
+ return Piwik_ViewDataTable::render($this->pluginName, __FUNCTION__, $fetch);
+ }
+
+ public function getItemsName($fetch = false)
+ {
+ return Piwik_ViewDataTable::render($this->pluginName, __FUNCTION__, $fetch);
+ }
+
+ public function getItemsCategory($fetch = false)
+ {
+ return Piwik_ViewDataTable::render($this->pluginName, __FUNCTION__, $fetch);
+ }
+
+ public function getVisitsUntilConversion($fetch = false)
+ {
+ return Piwik_ViewDataTable::render($this->pluginName, __FUNCTION__, $fetch);
+ }
+
+ public function getDaysToConversion($fetch = false)
+ {
+ return Piwik_ViewDataTable::render($this->pluginName, __FUNCTION__, $fetch);
+ }
}
diff --git a/plugins/Goals/Goals.php b/plugins/Goals/Goals.php
index 855adb9e30..146c8a2659 100644
--- a/plugins/Goals/Goals.php
+++ b/plugins/Goals/Goals.php
@@ -87,6 +87,7 @@ class Piwik_Goals extends Piwik_Plugin
'Menu.add' => 'addMenus',
'SitesManager.deleteSite' => 'deleteSiteGoals',
'Goals.getReportsWithGoalMetrics' => 'getActualReportsWithGoalMetrics',
+ 'ViewDataTable.getReportDisplayProperties' => 'getReportDisplayProperties', // TODO: ViewDataTable should get ALL once
);
return $hooks;
}
@@ -494,4 +495,133 @@ class Piwik_Goals extends Piwik_Plugin
$archiving->archivePeriod();
}
}
+
+ public function getReportDisplayProperties(&$properties, $apiAction)
+ {
+ $reportViewProperties = array(
+ 'Goals.getItemsSku' => $this->getDisplayPropertiesForGetItemsSku(),
+ 'Goals.getItemsName' => $this->getDisplayPropertiesForGetItemsName(),
+ 'Goals.getItemsCategory' => $this->getDisplayPropertiesForGetItemsCategory(),
+ 'Goals.getVisitsUntilConversion' => $this->getDisplayPropertiesForGetVisitsUntilConversion(),
+ 'Goals.getDaysToConversion' => $this->getDisplayPropertiesForGetDaysToConversion(),
+ );
+
+ if (isset($reportViewProperties[$apiAction])) {
+ $properties = $reportViewProperties[$apiAction];
+ }
+ }
+
+ private function getDisplayPropertiesForGetItemsSku()
+ {
+ return $this->getDisplayPropertiesForItemsReport(Piwik_Translate('Goals_ProductSKU'));
+ }
+
+ private function getDisplayPropertiesForGetItemsName()
+ {
+ return $this->getDisplayPropertiesForItemsReport(Piwik_Translate('Goals_ProductName'));
+ }
+
+ private function getDisplayPropertiesForGetItemsCategory()
+ {
+ return $this->getDisplayPropertiesForItemsReport(Piwik_Translate('Goals_ProductCategory'));
+ }
+
+ private function getDisplayPropertiesForGetVisitsUntilConversion()
+ {
+ return array(
+ 'show_search' => false,
+ 'show_exclude_low_population' => false,
+ 'show_table_all_columns' => false,
+ 'columns_to_display' => array('label', 'nb_conversions'),
+ 'filter_sort_column' => 'label',
+ 'filter_sort_order' => 'asc',
+ 'translations' => array(
+ 'label' => Piwik_Translate('Goals_VisitsUntilConv'),
+ 'nb_conversions' => Piwik_Translate('Goals_ColumnConversions'),
+ ),
+ 'filter_limit' => count(Piwik_Goals_Archiver::$visitCountRanges),
+ 'show_offset_information' => false,
+ 'show_pagination_control' => false,
+ 'show_all_views_icons' => false
+ );
+ }
+
+ private function getDisplayPropertiesForGetDaysToConversion()
+ {
+ return array(
+ 'show_search' => false,
+ 'show_exclude_low_population' => false,
+ 'show_table_all_columns' => false,
+ 'columns_to_display' => array('label', 'nb_conversions'),
+ 'filter_sort_column' => 'label',
+ 'filter_sort_order' => 'asc',
+ 'translations' => array(
+ 'label' => Piwik_Translate('Goals_DaysToConv'),
+ 'nb_conversions' => Piwik_Translate('Goals_ColumnConversions'),
+ ),
+ 'filter_limit' => count(Piwik_Goals_Archiver::$daysToConvRanges),
+ 'show_all_views_icons' => false,
+ 'show_offset_information' => false,
+ 'show_pagination_control' => false,
+ );
+ }
+
+ private function getDisplayPropertiesForItemsReport($label)
+ {
+ $idSite = Piwik_Common::getRequestVar('idSite');
+
+ $moneyColumns = array('revenue', 'avg_price');
+ $prettifyMoneyColumns = array(
+ 'ColumnCallbackReplace', array($moneyColumns, array("Piwik", "getPrettyMoney"), array($idSite)));
+
+ $result = array(
+ 'show_ecommerce' => true,
+ 'show_all_views_icons' => false,
+ 'show_table' => false,
+ 'show_exclude_low_population' => false,
+ 'show_table_all_columns' => false,
+ 'filter_limit' => 10,
+ 'translations' => array('label' => $label),
+ 'filter_sort_column' => 'revenue',
+ 'filter_sort_order' => 'desc',
+ 'filters' => array($prettifyMoneyColumns)
+ );
+
+ // set columns/translations which differ based on viewDataTable TODO: shouldn't have to do this check... amount of reports should be dynamic, but metadata should be static
+ $columns = Piwik_Goals::getProductReportColumns();
+
+ $abandonedCart = Piwik_Common::getRequestVar('viewDataTable', 'ecommerceOrder', 'string') == 'ecommerceAbandonedCart';
+ if ($abandonedCart) {
+ $columns['abandoned_carts'] = Piwik_Translate('General_AbandonedCarts');
+ $columns['revenue'] = Piwik_Translate('Goals_LeftInCart', Piwik_Translate('General_ProductRevenue'));
+ $columns['quantity'] = Piwik_Translate('Goals_LeftInCart', Piwik_Translate('General_Quantity'));
+ $columns['avg_quantity'] = Piwik_Translate('Goals_LeftInCart', Piwik_Translate('General_AverageQuantity'));
+ unset($columns['orders']);
+ unset($columns['conversion_rate']);
+
+ $result['request_string_suffix'] = '&abandonedCarts=1';
+ }
+
+ $result['translations'] = array_merge(array('label' => $label), $columns);
+ $result['columns_to_display'] = array_keys($result['translations']);
+
+ // set metrics documentation in normal ecommerce report
+ if (!$abandonedCart) {
+ $result['metrics_documentation'] = array(
+ 'revenue' => Piwik_Translate('Goals_ColumnRevenueDocumentation',
+ Piwik_Translate('Goals_DocumentationRevenueGeneratedByProductSales')),
+ 'quantity' => Piwik_Translate('Goals_ColumnQuantityDocumentation', $label),
+ 'orders' => Piwik_Translate('Goals_ColumnOrdersDocumentation', $label),
+ 'avg_price' => Piwik_Translate('Goals_ColumnAveragePriceDocumentation', $label),
+ 'avg_quantity' => Piwik_Translate('Goals_ColumnAverageQuantityDocumentation', $label),
+ 'nb_visits' => Piwik_Translate('Goals_ColumnVisitsProductDocumentation', $label),
+ 'conversion_rate' => Piwik_Translate('Goals_ColumnConversionRateProductDocumentation', $label),
+ );
+ }
+
+ $result['custom_parameters']['viewDataTable'] =
+ $abandonedCart ? Piwik::LABEL_ID_GOAL_IS_ECOMMERCE_CART : Piwik::LABEL_ID_GOAL_IS_ECOMMERCE_ORDER;
+
+ return $result;
+ }
}
diff --git a/plugins/UserSettings/Controller.php b/plugins/UserSettings/Controller.php
index f5c7893783..515eacf118 100644
--- a/plugins/UserSettings/Controller.php
+++ b/plugins/UserSettings/Controller.php
@@ -15,19 +15,7 @@
*/
class Piwik_UserSettings_Controller extends Piwik_Controller
{
- /** The set of related reports displayed under the 'Operating Systems' header. */
- private $osRelatedReports = null;
-
- public function __construct()
- {
- parent::__construct();
- $this->osRelatedReports = array(
- 'UserSettings.getOSFamily' => Piwik_Translate('UserSettings_OperatingSystemFamily'),
- 'UserSettings.getOS' => Piwik_Translate('UserSettings_OperatingSystems')
- );
- }
-
- function index()
+ public function index()
{
$view = new Piwik_View('@UserSettings/index');
@@ -42,172 +30,59 @@ class Piwik_UserSettings_Controller extends Piwik_Controller
echo $view->render();
}
-
- function getResolution($fetch = false)
+
+ public function getResolution($fetch = false)
{
- $view = $this->getStandardDataTableUserSettings(
- __FUNCTION__,
- 'UserSettings.getResolution'
- );
- $view->setColumnTranslation('label', Piwik_Translate('UserSettings_ColumnResolution'));
- return $this->renderView($view, $fetch);
+ return Piwik_ViewDataTable::render($this->pluginName, __FUNCTION__, $fetch);
}
-
- function getConfiguration($fetch = false)
+
+ public function getConfiguration($fetch = false)
{
- $view = $this->getStandardDataTableUserSettings(
- __FUNCTION__,
- 'UserSettings.getConfiguration'
- );
- $view->setColumnTranslation('label', Piwik_Translate('UserSettings_ColumnConfiguration'));
- $view->setLimit(3);
- return $this->renderView($view, $fetch);
+ return Piwik_ViewDataTable::render($this->pluginName, __FUNCTION__, $fetch);
}
- function getOS($fetch = false)
+ public function getOS($fetch = false)
{
- $view = $this->getStandardDataTableUserSettings(
- __FUNCTION__,
- 'UserSettings.getOS'
- );
- $view->setColumnTranslation('label', Piwik_Translate('UserSettings_ColumnOperatingSystem'));
- $view->addRelatedReports(Piwik_Translate('UserSettings_OperatingSystems'), $this->osRelatedReports);
- return $this->renderView($view, $fetch);
+ return Piwik_ViewDataTable::render($this->pluginName, __FUNCTION__, $fetch);
}
- /**
- * Returns or echos a report displaying the number of visits by operating system family.
- */
public function getOSFamily($fetch = false)
{
- $view = $this->getStandardDataTableUserSettings(__FUNCTION__, 'UserSettings.getOSFamily');
- $view->setColumnTranslation('label', Piwik_Translate('UserSettings_OperatingSystemFamily'));
- $view->addRelatedReports(Piwik_Translate('UserSettings_OperatingSystemFamily'), $this->osRelatedReports);
- return $this->renderView($view, $fetch);
- }
-
- function getBrowserVersion($fetch = false)
- {
- $view = $this->getStandardDataTableUserSettings(
- __FUNCTION__,
- 'UserSettings.getBrowserVersion'
- );
- $view->setColumnTranslation('label', Piwik_Translate('UserSettings_ColumnBrowserVersion'));
- $view->setGraphLimit(7);
- $view->addRelatedReports(Piwik_Translate('UserSettings_ColumnBrowserVersion'), array(
- 'UserSettings.getBrowser' => Piwik_Translate('UserSettings_Browsers')
- ));
- return $this->renderView($view, $fetch);
+ return Piwik_ViewDataTable::render($this->pluginName, __FUNCTION__, $fetch);
}
- /**
- * Returns or echos a report displaying the number of visits by browser type. The browser
- * version is not included in this report.
- */
- public function getBrowser($fetch = false)
+ public function getMobileVsDesktop($fetch = false)
{
- $view = $this->getStandardDataTableUserSettings(__FUNCTION__, 'UserSettings.getBrowser');
- $view->setColumnTranslation('label', Piwik_Translate('UserSettings_ColumnBrowser'));
- $view->setGraphLimit(7);
- $view->addRelatedReports(Piwik_Translate('UserSettings_Browsers'), array(
- 'UserSettings.getBrowserVersion' => Piwik_Translate('UserSettings_ColumnBrowserVersion')
- ));
- return $this->renderView($view, $fetch);
+ return Piwik_ViewDataTable::render($this->pluginName, __FUNCTION__, $fetch);
}
- function getBrowserType($fetch = false)
+ public function getBrowserVersion($fetch = false)
{
- $view = $this->getStandardDataTableUserSettings(
- __FUNCTION__,
- 'UserSettings.getBrowserType',
- 'graphPie'
- );
- $view->setColumnTranslation('label', Piwik_Translate('UserSettings_ColumnBrowserFamily'));
- $view->disableOffsetInformationAndPaginationControls();
- return $this->renderView($view, $fetch);
+ return Piwik_ViewDataTable::render($this->pluginName, __FUNCTION__, $fetch);
}
- function getWideScreen($fetch = false)
+ public function getBrowser($fetch = false)
{
- $view = $this->getStandardDataTableUserSettings(
- __FUNCTION__,
- 'UserSettings.getWideScreen'
- );
- $view->setColumnTranslation('label', Piwik_Translate('UserSettings_ColumnTypeOfScreen'));
- $view->disableOffsetInformationAndPaginationControls();
- $view->addRelatedReports(Piwik_Translate('UserSettings_ColumnTypeOfScreen'), array(
- 'UserSettings.getMobileVsDesktop' => Piwik_Translate('UserSettings_MobileVsDesktop')
- ));
- return $this->renderView($view, $fetch);
+ return Piwik_ViewDataTable::render($this->pluginName, __FUNCTION__, $fetch);
}
- /**
- * Returns or echos a report displaying the number of visits by device type (Mobile or Desktop).
- */
- public function getMobileVsDesktop($fetch = false)
+ public function getBrowserType($fetch = false)
{
- $view = $this->getStandardDataTableUserSettings(__FUNCTION__, 'UserSettings.getMobileVsDesktop');
- $view->setColumnTranslation('label', Piwik_Translate('UserSettings_MobileVsDesktop'));
- $view->addRelatedReports(Piwik_Translate('UserSettings_MobileVsDesktop'), array(
- 'UserSettings.getWideScreen' => Piwik_Translate('UserSettings_ColumnTypeOfScreen')
- ));
- return $this->renderView($view, $fetch);
+ return Piwik_ViewDataTable::render($this->pluginName, __FUNCTION__, $fetch);
}
- function getPlugin($fetch = false)
+ public function getWideScreen($fetch = false)
{
- $view = $this->getStandardDataTableUserSettings(
- __FUNCTION__,
- 'UserSettings.getPlugin'
- );
- $view->disableShowAllViewsIcons();
- $view->disableShowAllColumns();
- $view->disableOffsetInformationAndPaginationControls();
- $view->setColumnsToDisplay(array('label', 'nb_visits_percentage', 'nb_visits'));
- $view->setColumnTranslation('label', Piwik_Translate('UserSettings_ColumnPlugin'));
- $view->setColumnTranslation('nb_visits_percentage', Piwik_Metrics::getPercentVisitColumn());
- $view->setSortedColumn('nb_visits_percentage');
- $view->setLimit(10);
- $view->setFooterMessage(Piwik_Translate('UserSettings_PluginDetectionDoesNotWorkInIE'));
- return $this->renderView($view, $fetch);
+ return Piwik_ViewDataTable::render($this->pluginName, __FUNCTION__, $fetch);
}
- protected function getStandardDataTableUserSettings($currentControllerAction,
- $APItoCall,
- $defaultDatatableType = null)
+ public function getPlugin($fetch = false)
{
- $view = Piwik_ViewDataTable::factory($defaultDatatableType);
- $view->init($this->pluginName, $currentControllerAction, $APItoCall);
- $view->disableSearchBox();
- $view->disableExcludeLowPopulation();
- $view->setLimit(5);
- $view->setGraphLimit(5);
-
- $this->setPeriodVariablesView($view);
- $this->setMetricsVariablesView($view);
-
- return $view;
+ return Piwik_ViewDataTable::render($this->pluginName, __FUNCTION__, $fetch);
}
- /**
- * Renders datatable for browser language
- *
- * @param bool $fetch
- *
- * @return string|void
- */
public function getLanguage($fetch = false)
{
- $view = Piwik_ViewDataTable::factory();
- $view->init($this->pluginName, __FUNCTION__, "UserSettings.getLanguage");
- $view->disableExcludeLowPopulation();
-
- $view->setColumnsToDisplay(array('label', 'nb_visits'));
- $view->setColumnTranslation('label', Piwik_Translate('General_Language'));
- $view->setSortedColumn('nb_visits');
- $view->disableSearchBox();
- $view->setLimit(5);
-
- return $this->renderView($view, $fetch);
+ return Piwik_ViewDataTable::render($this->pluginName, __FUNCTION__, $fetch);
}
-} \ No newline at end of file
+}
diff --git a/plugins/UserSettings/UserSettings.php b/plugins/UserSettings/UserSettings.php
index e7a15f9e79..9097213fa7 100644
--- a/plugins/UserSettings/UserSettings.php
+++ b/plugins/UserSettings/UserSettings.php
@@ -171,15 +171,128 @@ class Piwik_UserSettings extends Piwik_Plugin
function getListHooksRegistered()
{
$hooks = array(
- 'ArchiveProcessing_Day.compute' => 'archiveDay',
- 'ArchiveProcessing_Period.compute' => 'archivePeriod',
- 'WidgetsList.add' => 'addWidgets',
- 'Menu.add' => 'addMenu',
- 'API.getReportMetadata' => 'getReportMetadata',
- 'API.getSegmentsMetadata' => 'getSegmentsMetadata',
+ 'ArchiveProcessing_Day.compute' => 'archiveDay',
+ 'ArchiveProcessing_Period.compute' => 'archivePeriod',
+ 'WidgetsList.add' => 'addWidgets',
+ 'Menu.add' => 'addMenu',
+ 'API.getReportMetadata' => 'getReportMetadata',
+ 'API.getSegmentsMetadata' => 'getSegmentsMetadata',
+ 'ViewDataTable.getReportDisplayProperties' => 'getReportDisplayProperties',
);
return $hooks;
}
+
+ public function getReportDisplayProperties(&$properties, $apiAction)
+ {
+ $basicUserSettingsProperties = array('show_search' => false,
+ 'show_exclude_low_population' => false,
+ 'filter_limit' => 5,
+ 'graph_limit' => 5);
+
+ $osRelatedReports = array(
+ 'UserSettings.getOSFamily' => Piwik_Translate('UserSettings_OperatingSystemFamily'),
+ 'UserSettings.getOS' => Piwik_Translate('UserSettings_OperatingSystems')
+ );
+
+ $browserRelatedReports = array(
+ 'UserSettings.getBrowser' => Piwik_Translate('UserSettings_Browsers'),
+ 'UserSettings.getBrowserVersion' => Piwik_Translate('UserSettings_ColumnBrowserVersion')
+ );
+
+ $wideScreenDeviceTypeRelatedReports = array(
+ 'UserSettings.getMobileVsDesktop' => Piwik_Translate('UserSettings_MobileVsDesktop'),
+ 'UserSettings.getWideScreen' => Piwik_Translate('UserSettings_ColumnTypeOfScreen')
+ );
+
+ $reportViewProperties = array(
+ 'UserSettings.getResolution' => array_merge($basicUserSettingsProperties, array(
+ 'translations' => array('label' => Piwik_Translate('UserSettings_ColumnResolution'))
+ )),
+
+ 'UserSettings.getConfiguration' => array_merge($basicUserSettingsProperties, array(
+ 'filter_limit' => 3,
+ 'translations' => array('label' => Piwik_Translate('UserSettings_ColumnConfiguration'))
+ )),
+
+ 'UserSettings.getOS' => array_merge($basicUserSettingsProperties, array(
+ 'translations' => array('label' => Piwik_Translate('UserSettings_ColumnOperatingSystem')),
+ 'title' => Piwik_Translate('UserSettings_OperatingSystems'),
+ 'relatedReports' => $osRelatedReports
+ )),
+
+ 'UserSettings.getOSFamily' => array_merge($basicUserSettingsProperties, array(
+ 'translations' => array('label' => Piwik_Translate('UserSettings_OperatingSystemFamily')),
+ 'title' => Piwik_Translate('UserSettings_OperatingSystemFamily'),
+ 'relatedReports' => $osRelatedReports
+ )),
+
+ 'UserSettings.getBrowserVersion' => array_merge($basicUserSettingsProperties, array(
+ 'translations' => array('label' => Piwik_Translate('UserSettings_ColumnBrowserVersion')),
+ 'graph_limit' => 7,
+ 'title' => Piwik_Translate('UserSettings_ColumnBrowserVersion'),
+ 'relatedReports' => $browserRelatedReports
+ )),
+
+ 'UserSettings.getBrowser' => array_merge($basicUserSettingsProperties, array(
+ 'translations' => array('label' => Piwik_Translate('UserSettings_ColumnBrowser')),
+ 'graph_limit' => 7,
+ 'title' => Piwik_Translate('UserSettings_Browsers'),
+ 'relatedReports' => $browserRelatedReports
+ )),
+
+ 'UserSettings.getBrowserType' => array_merge($basicUserSettingsProperties, array(
+ 'translations' => array('label' => Piwik_Translate('UserSettings_ColumnBrowserFamily')),
+ 'show_offset_information' => false,
+ 'show_pagination_control' => false,
+ 'default_view_type' => 'graphPie',
+ )),
+
+ 'UserSettings.getWideScreen' => array_merge($basicUserSettingsProperties, array(
+ 'translations' => array('label' => Piwik_Translate('UserSettings_ColumnTypeOfScreen')),
+ 'show_offset_information' => false,
+ 'show_pagination_control' => false,
+ 'title' => Piwik_Translate('UserSettings_ColumnTypeOfScreen'),
+ 'relatedReports' => $wideScreenDeviceTypeRelatedReports
+ )),
+
+ 'UserSettings.getMobileVsDesktop' => array_merge($basicUserSettingsProperties, array(
+ 'translations' => array('label' => Piwik_Translate('UserSettings_MobileVsDesktop')),
+ 'title' => Piwik_Translate('UserSettings_MobileVsDesktop'),
+ 'relatedReports' => $wideScreenDeviceTypeRelatedReports
+ )),
+
+ 'UserSettings.getPlugin' => array_merge($basicUserSettingsProperties, array(
+ 'translations' => array(
+ 'label' => Piwik_Translate('UserSettings_ColumnPlugin'),
+ 'nb_visits_percentage' =>
+ str_replace(' ', '&nbsp;', Piwik_Translate('General_ColumnPercentageVisits'))
+ ),
+ 'show_offset_information' => false,
+ 'show_pagination_control' => false,
+ 'show_all_views_icons' => false,
+ 'show_table_all_columns' => false,
+ 'columns_to_display' => array('label', 'nb_visits_percentage', 'nb_visits'),
+ 'filter_sort_column' => 'nb_visits_percentage',
+ 'filter_sort_order' => 'desc',
+ 'filter_limit' => 10,
+ 'show_footer_message' => Piwik_Translate('UserSettings_PluginDetectionDoesNotWorkInIE'),
+ )),
+
+ 'UserSettings.getLanguage' => array(
+ 'translations' => array('label' => Piwik_Translate('General_Language')),
+ 'filter_sort_column' => 'nb_visits',
+ 'filter_sort_order' => 'desc',
+ 'show_search' => false,
+ 'filter_limit' => false,
+ 'columns_to_display' => array('label', 'nb_visits'),
+ 'show_exclude_low_population' => false,
+ ),
+ );
+
+ if (isset($reportViewProperties[$apiAction])) {
+ $properties = $reportViewProperties[$apiAction];
+ }
+ }
/**
* Registers reports metadata
diff --git a/plugins/VisitTime/Controller.php b/plugins/VisitTime/Controller.php
index 769c102761..600262625c 100644
--- a/plugins/VisitTime/Controller.php
+++ b/plugins/VisitTime/Controller.php
@@ -25,83 +25,16 @@ class Piwik_VisitTime_Controller extends Piwik_Controller
public function getVisitInformationPerServerTime($fetch = false)
{
- $view = $this->getGraph(__FUNCTION__, 'VisitTime.getVisitInformationPerServerTime',
- 'VisitTime_ColumnServerTime');
-
- $view->setCustomParameter('hideFutureHoursWhenToday', 1);
- $view->enableShowGoals();
-
- return $this->renderView($view, $fetch);
+ return Piwik_ViewDataTable::render($this->pluginName, __FUNCTION__, $fetch);
}
public function getVisitInformationPerLocalTime($fetch = false)
{
- $view = $this->getGraph(__FUNCTION__, 'VisitTime.getVisitInformationPerLocalTime',
- 'VisitTime_ColumnLocalTime');
-
- // add the visits by day of week as a related report, if the current period is not 'day'
- if (Piwik_Common::getRequestVar('period', 'day') != 'day') {
- $view->addRelatedReports(Piwik_Translate('VisitTime_LocalTime'), array(
- 'VisitTime.getByDayOfWeek' => Piwik_Translate('VisitTime_VisitsByDayOfWeek')
- ));
- }
-
- return $this->renderView($view, $fetch);
+ return Piwik_ViewDataTable::render($this->pluginName, __FUNCTION__, $fetch);
}
public function getByDayOfWeek($fetch = false)
{
- $view = $this->getGraph(
- __FUNCTION__, 'VisitTime.getByDayOfWeek', 'VisitTime_DayOfWeek', $limit = 7, $sort = false);
- $view->disableSort();
-
- if ($view instanceof Piwik_ViewDataTable_GenerateGraphHTML) {
- $view->showAllTicks();
- }
- $dateRange = $this->getRangeDate();
-
- $view->setFooterMessage(Piwik_Translate('General_ReportGeneratedFrom', $dateRange));
-
- return $this->renderView($view, $fetch);
- }
-
- protected function getRangeDate()
- {
- // get query params
- $idSite = Piwik_Common::getRequestVar('idSite');
- $date = Piwik_Common::getRequestVar('date');
- $period = Piwik_Common::getRequestVar('period');
-
- // create a period instance
- $oPeriod = Piwik_Period::makePeriodFromQueryParams(Piwik_Site::getTimezoneFor($idSite), $period, $date);
-
- // set the footer message using the period start & end date
- $start = $oPeriod->getDateStart()->toString();
- $end = $oPeriod->getDateEnd()->toString();
- if ($start == $end) {
- $dateRange = $start;
- } else {
- $dateRange = $start . " &ndash; " . $end;
- }
- return $dateRange;
- }
-
- private function getGraph($controllerMethod, $apiMethod, $labelTranslation, $limit = 24)
- {
- $view = Piwik_ViewDataTable::factory('graphVerticalBar');
- $view->init($this->pluginName, $controllerMethod, $apiMethod);
-
-
- $view->setColumnTranslation('label', Piwik_Translate($labelTranslation));
- $view->setSortedColumn('label', 'asc');
-
- $view->setLimit($limit);
- $view->setGraphLimit($limit);
- $view->disableSearchBox();
- $view->disableExcludeLowPopulation();
- $view->disableOffsetInformationAndPaginationControls();
- $this->setMetricsVariablesView($view);
-
- return $view;
+ return Piwik_ViewDataTable::render($this->pluginName, __FUNCTION__, $fetch);
}
}
diff --git a/plugins/VisitTime/VisitTime.php b/plugins/VisitTime/VisitTime.php
index 36ecd86f65..39934563e5 100644
--- a/plugins/VisitTime/VisitTime.php
+++ b/plugins/VisitTime/VisitTime.php
@@ -29,13 +29,14 @@ class Piwik_VisitTime extends Piwik_Plugin
function getListHooksRegistered()
{
$hooks = array(
- 'ArchiveProcessing_Day.compute' => 'archiveDay',
- 'ArchiveProcessing_Period.compute' => 'archivePeriod',
- 'WidgetsList.add' => 'addWidgets',
- 'Menu.add' => 'addMenu',
- 'Goals.getReportsWithGoalMetrics' => 'getReportsWithGoalMetrics',
- 'API.getReportMetadata' => 'getReportMetadata',
- 'API.getSegmentsMetadata' => 'getSegmentsMetadata',
+ 'ArchiveProcessing_Day.compute' => 'archiveDay',
+ 'ArchiveProcessing_Period.compute' => 'archivePeriod',
+ 'WidgetsList.add' => 'addWidgets',
+ 'Menu.add' => 'addMenu',
+ 'Goals.getReportsWithGoalMetrics' => 'getReportsWithGoalMetrics',
+ 'API.getReportMetadata' => 'getReportMetadata',
+ 'API.getSegmentsMetadata' => 'getSegmentsMetadata',
+ 'ViewDataTable.getReportDisplayProperties' => 'getReportDisplayProperties',
);
return $hooks;
}
@@ -117,6 +118,59 @@ class Piwik_VisitTime extends Piwik_Plugin
'acceptedValues' => $acceptedValues
);
}
+
+ public function getReportDisplayProperties(&$properties, $apiAction)
+ {
+ $commonProperties = array(
+ 'filter_sort_column' => 'label',
+ 'filter_sort_order' => 'asc',
+ 'show_search' => false,
+ 'show_exclude_low_population' => false,
+ 'show_offset_information' => false,
+ 'show_pagination_control' => false,
+ 'default_view_type' => 'graphVerticalBar'
+ );
+
+ $reportViewProperties = array(
+ 'VisitTime.getVisitInformationPerServerTime' => array_merge($commonProperties, array(
+ 'filter_limit' => 24,
+ 'graph_limit' => 24,
+ 'show_goals' => true,
+ 'translations' => array('label' => Piwik_Translate('VisitTime_ColumnServerTime')),
+
+ // custom parameter
+ 'hideFutureHoursWhenToday' => 1,
+ )),
+
+ 'VisitTime.getVisitInformationPerLocalTime' => array_merge($commonProperties, array(
+ 'filter_limit' => 24,
+ 'graph_limit' => 24,
+ 'title' => Piwik_Translate('VisitTime_ColumnLocalTime'),
+ 'translations' => array('label' => Piwik_Translate('VisitTime_LocalTime')),
+ )),
+
+ 'VisitTime.getByDayOfWeek' => array_merge($commonProperties, array(
+ 'filter_limit' => 7,
+ 'graph_limit' => 7,
+ 'enable_sort' => false,
+ 'show_all_ticks' => true,
+ 'show_footer_message' =>
+ Piwik_Translate('General_ReportGeneratedFrom', self::getDateRangeForFooterMessage()),
+ 'translations' => array('label' => Piwik_Translate('VisitTime_DayOfWeek')),
+ )),
+ );
+
+ // add the visits by day of week as a related report, if the current period is not 'day'
+ if (Piwik_Common::getRequestVar('period', 'day') != 'day') {
+ $reportViewProperties['VisitTime.getVisitInformationPerLocalTime']['relatedReports'] = array(
+ 'VisitTime.getByDayOfWeek' => Piwik_Translate('VisitTime_VisitsByDayOfWeek')
+ );
+ }
+
+ if (isset($reportViewProperties[$apiAction])) {
+ $properties = $reportViewProperties[$apiAction];
+ }
+ }
public function archivePeriod(Piwik_ArchiveProcessor_Period $archiveProcessor)
{
@@ -134,4 +188,25 @@ class Piwik_VisitTime extends Piwik_Plugin
$archiving->archiveDay();
}
}
+
+ private static function getDateRangeForFooterMessage()
+ {
+ // get query params
+ $idSite = Piwik_Common::getRequestVar('idSite');
+ $date = Piwik_Common::getRequestVar('date');
+ $period = Piwik_Common::getRequestVar('period');
+
+ // create a period instance
+ $oPeriod = Piwik_Period::makePeriodFromQueryParams(Piwik_Site::getTimezoneFor($idSite), $period, $date);
+
+ // set the footer message using the period start & end date
+ $start = $oPeriod->getDateStart()->toString();
+ $end = $oPeriod->getDateEnd()->toString();
+ if ($start == $end) {
+ $dateRange = $start;
+ } else {
+ $dateRange = $start . " &ndash; " . $end;
+ }
+ return $dateRange;
+ }
}