diff --git a/core/ViewDataTable.php b/core/ViewDataTable.php index e6b466399f9d26cb203461746cb0f428cb816ffd..81aefb762c542cf255a8cdfb1bb047f2c9be4761 100644 --- a/core/ViewDataTable.php +++ b/core/ViewDataTable.php @@ -49,14 +49,6 @@ abstract class Piwik_ViewDataTable */ public static $reportPropertiesCache = null; - /** - * Template file that will be loaded for this view. - * Usually set in the Piwik_ViewDataTable_* - * - * @var string eg. 'CoreHome/templates/cloud.twig' - */ - protected $dataTableTemplate = null; - /** * Flag used to make sure the main() is only executed once * @@ -126,6 +118,7 @@ abstract class Piwik_ViewDataTable */ public function __construct() { + $this->viewProperties['datatable_template'] = '@CoreHome/_dataTable'; $this->viewProperties['show_goals'] = false; $this->viewProperties['show_ecommerce'] = false; $this->viewProperties['show_search'] = true; @@ -390,11 +383,13 @@ abstract class Piwik_ViewDataTable * eg. 'CoreHome/templates/cloud' * But some users may want to force this template to some other value * + * TODO: after visualization refactor, should remove this. + * * @param string $tpl eg .'@MyPlugin/templateToUse' */ public function setTemplate($tpl) { - $this->dataTableTemplate = $tpl; + $this->viewProperties['datatable_template'] = $tpl; } /** @@ -1635,7 +1630,7 @@ abstract class Piwik_ViewDataTable protected function buildView($visualization, $template = false) { if ($template === false) { - $template = $this->dataTableTemplate; + $template = $this->viewProperties['datatable_template']; } $view = new Piwik_View($template); diff --git a/core/ViewDataTable/Cloud.php b/core/ViewDataTable/Cloud.php index 5fe275c841a4ed7258d3d8e2158a834b497fcd96..02fed10119d27b6a9992297cc3bb22f9f4d79e2b 100644 --- a/core/ViewDataTable/Cloud.php +++ b/core/ViewDataTable/Cloud.php @@ -32,7 +32,6 @@ class Piwik_ViewDataTable_Cloud extends Piwik_ViewDataTable { parent::__construct(); - $this->dataTableTemplate = '@CoreHome/_dataTable'; $this->disableOffsetInformation(); $this->disableExcludeLowPopulation(); $this->viewProperties['display_logo_instead_of_label'] = false; diff --git a/core/ViewDataTable/GenerateGraphHTML.php b/core/ViewDataTable/GenerateGraphHTML.php index 7823d2cb0031916a7f50c9badf680e2633b5e408..cd6e25284756d5950fcd7b5efb951daf999dc58e 100644 --- a/core/ViewDataTable/GenerateGraphHTML.php +++ b/core/ViewDataTable/GenerateGraphHTML.php @@ -26,7 +26,6 @@ abstract class Piwik_ViewDataTable_GenerateGraphHTML extends Piwik_ViewDataTable { parent::__construct(); - $this->dataTableTemplate = '@CoreHome/_dataTable'; $this->disableOffsetInformationAndPaginationControls(); $this->disableExcludeLowPopulation(); $this->disableSearchBox(); diff --git a/core/ViewDataTable/HtmlTable.php b/core/ViewDataTable/HtmlTable.php index fa014e8521900e58bfc4606a49d06441aab47288..0d5bb7e3ec7f91807d2b88493fe820437489e54b 100644 --- a/core/ViewDataTable/HtmlTable.php +++ b/core/ViewDataTable/HtmlTable.php @@ -30,7 +30,6 @@ class Piwik_ViewDataTable_HtmlTable extends Piwik_ViewDataTable { parent::__construct(); - $this->dataTableTemplate = '@CoreHome/_dataTable'; $this->viewProperties['enable_sort'] = '1'; $this->viewProperties['disable_row_evolution'] = false; $this->viewProperties['disable_row_actions'] = false; @@ -80,7 +79,7 @@ class Piwik_ViewDataTable_HtmlTable extends Piwik_ViewDataTable $this->postDataTableLoadedFromAPI(); - $template = $this->idSubtable ? $this->viewProperties['subtable_template'] : $this->dataTableTemplate; + $template = $this->idSubtable ? $this->viewProperties['subtable_template'] : $this->viewProperties['datatable_template']; $this->view = $this->buildView(new Piwik_Visualization_HtmlTable(), $template); } diff --git a/plugins/Live/Controller.php b/plugins/Live/Controller.php index 6b88ea7b57533669767f7b10335d96d094523fcc..2c7b9c036ee7a49b498100a036bb4bc632dc6224 100644 --- a/plugins/Live/Controller.php +++ b/plugins/Live/Controller.php @@ -78,47 +78,21 @@ class Piwik_Live_Controller extends Piwik_Controller { $view = new Piwik_View('@Live/indexVisitorLog.twig'); $view->filterEcommerce = Piwik_Common::getRequestVar('filterEcommerce', 0, 'int'); - $view->visitorLog = $this->getVisitorLog($fetch = true); + $view->visitorLog = $this->getLastVisitsDetails($fetch = true); echo $view->render(); } - public function getVisitorLog($fetch = false) + public function getLastVisitsDetails($fetch = false) { - $view = Piwik_ViewDataTable::factory(); - $view->init($this->pluginName, - __FUNCTION__, - 'Live.getLastVisitsDetails' - ); - $view->disableGenericFilters(); - $view->disableSort(); - $view->setTemplate("@Live/getVisitorLog.twig"); - $view->setSortedColumn('idVisit', 'ASC'); - $view->disableSearchBox(); - $view->setLimit(20); - $view->disableOffsetInformation(); - $view->disableExcludeLowPopulation(); - - // disable the tag cloud, pie charts, bar chart icons - $view->disableShowAllViewsIcons(); - // disable the button "show more datas" - $view->disableShowAllColumns(); - // disable the RSS feed - $view->disableShowExportAsRssFeed(); - - // disable all row actions - if ($view instanceof Piwik_ViewDataTable_HtmlTable) { - $view->disableRowActions(); - } - - $view->setReportDocumentation(Piwik_Translate('Live_VisitorLogDocumentation', array('<br />', '<br />'))); - - // set a very high row count so that the next link in the footer of the data table is always shown - $view->setCustomParameter('totalRows', 10000000); - - $view->setCustomParameter('filterEcommerce', Piwik_Common::getRequestVar('filterEcommerce', 0, 'int')); - $view->setCustomParameter('pageUrlNotDefined', Piwik_Translate('General_NotDefined', Piwik_Translate('Actions_ColumnPageURL'))); + return Piwik_ViewDataTable::render($this->pluginName, __FUNCTION__, $fetch); + } - return $this->renderView($view, $fetch); + /** + * @deprecated + */ + public function getVisitorLog($fetch = false) + { + return $this->getLastVisitsDetails($fetch); } public function getLastVisitsStart($fetch = false) diff --git a/plugins/Live/Live.php b/plugins/Live/Live.php index d4bd5042041fe6e90658ca24b7da72d5a7b71518..68d3a86e3e274af4e80ea81eeadb49a2195a084d 100644 --- a/plugins/Live/Live.php +++ b/plugins/Live/Live.php @@ -25,6 +25,7 @@ class Piwik_Live extends Piwik_Plugin 'AssetManager.getCssFiles' => 'getCssFiles', 'WidgetsList.add' => 'addWidget', 'Menu.add' => 'addMenu', + 'ViewDataTable.getReportDisplayProperties' => 'getReportDisplayProperties', ); } @@ -50,4 +51,35 @@ class Piwik_Live extends Piwik_Plugin Piwik_AddWidget('Live!', 'Live_RealTimeVisitorCount', 'Live', 'getSimpleLastVisitCount'); } -} + public function getReportDisplayProperties(&$properties) + { + $properties['Live.getLastVisitsDetails'] = $this->getDisplayPropertiesForGetLastVisitsDetails(); + } + + private function getDisplayPropertiesForGetLastVisitsDetails() + { + return array( + 'datatable_template' => "@Live/getVisitorLog.twig", + 'disable_generic_filters' => true, + 'enable_sort' => false, + 'filter_sort_column' => 'idVisit', + 'filter_sort_order' => 'asc', + 'show_search' => false, + 'filter_limit' => 20, + 'show_offset_information' => false, + 'show_exclude_low_population' => false, + 'show_all_views_icons' => false, + 'show_table_all_columns' => false, + 'show_export_as_rss_feed' => false, + 'disable_row_actions' => true, + 'documentation' => Piwik_Translate('Live_VisitorLogDocumentation', array('<br />', '<br />')), + 'custom_parameters' => array( + // set a very high row count so that the next link in the footer of the data table is always shown + 'totalRows' => 10000000, + + 'filterEcommerce' => Piwik_Common::getRequestVar('filterEcommerce', 0, 'int'), + 'pageUrlNotDefined' => Piwik_Translate('General_NotDefined', Piwik_Translate('Actions_ColumnPageURL')) + ), + ); + } +} \ No newline at end of file