Skip to content
Extraits de code Groupes Projets
Valider f1dcb45b rédigé par Benaka Moorthi's avatar Benaka Moorthi
Parcourir les fichiers

Refs #4040, converted Live plugin to use display properties instead of ViewDataTable methods.

parent 9b02615d
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -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);
......
......@@ -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;
......
......@@ -26,7 +26,6 @@ abstract class Piwik_ViewDataTable_GenerateGraphHTML extends Piwik_ViewDataTable
{
parent::__construct();
$this->dataTableTemplate = '@CoreHome/_dataTable';
$this->disableOffsetInformationAndPaginationControls();
$this->disableExcludeLowPopulation();
$this->disableSearchBox();
......
......@@ -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);
}
......
......@@ -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)
......
......@@ -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
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter