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

Refs #4041, mild refactoring to ViewDataTable, handle max_graph_elements...

Refs #4041, mild refactoring to ViewDataTable, handle max_graph_elements property w/ filter_truncate instead of directly executing filter and fix bug in JqplotGraph's constructor.
parent fc8ae5f1
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -29,14 +29,11 @@ class Limit extends Filter ...@@ -29,14 +29,11 @@ class Limit extends Filter
* @param int $limit Number of rows to keep (specify -1 to keep all rows) * @param int $limit Number of rows to keep (specify -1 to keep all rows)
* @param bool $keepSummaryRow Whether to keep the summary row or not. * @param bool $keepSummaryRow Whether to keep the summary row or not.
*/ */
public function __construct($table, $offset, $limit = null, $keepSummaryRow = false) public function __construct($table, $offset, $limit = -1, $keepSummaryRow = false)
{ {
parent::__construct($table); parent::__construct($table);
$this->offset = $offset; $this->offset = $offset;
if (is_null($limit)) {
$limit = -1;
}
$this->limit = $limit; $this->limit = $limit;
$this->keepSummaryRow = $keepSummaryRow; $this->keepSummaryRow = $keepSummaryRow;
} }
...@@ -48,6 +45,10 @@ class Limit extends Filter ...@@ -48,6 +45,10 @@ class Limit extends Filter
*/ */
public function filter($table) public function filter($table)
{ {
if ($this->limit <= 0) {
return;
}
$table->setRowsCountBeforeLimitFilter(); $table->setRowsCountBeforeLimitFilter();
if ($this->keepSummaryRow) { if ($this->keepSummaryRow) {
......
...@@ -703,7 +703,7 @@ class ViewDataTable ...@@ -703,7 +703,7 @@ class ViewDataTable
$requestArray['expanded'] = 1; $requestArray['expanded'] = 1;
} }
$requestArray = array_merge($requestArray, $this->viewProperties['request_parameters_to_modify']); $requestArray = array_merge($requestArray, $this->request_parameters_to_modify);
return $requestArray; return $requestArray;
} }
...@@ -1057,10 +1057,6 @@ class ViewDataTable ...@@ -1057,10 +1057,6 @@ class ViewDataTable
if (!PluginsManager::getInstance()->isPluginActivated('Goals')) { if (!PluginsManager::getInstance()->isPluginActivated('Goals')) {
$this->viewProperties['show_goals'] = false; $this->viewProperties['show_goals'] = false;
} }
if ($this->viewProperties['filter_limit'] == 0) {
$this->viewProperties['filter_limit'] = false;
}
} }
protected function buildView() protected function buildView()
......
...@@ -79,6 +79,13 @@ abstract class Graph extends DataTableVisualization ...@@ -79,6 +79,13 @@ abstract class Graph extends DataTableVisualization
$view->translations['nb_conversions'] = Piwik_Translate('Goals_ColumnConversions'); $view->translations['nb_conversions'] = Piwik_Translate('Goals_ColumnConversions');
$view->translations['revenue'] = Piwik_Translate('General_TotalRevenue'); $view->translations['revenue'] = Piwik_Translate('General_TotalRevenue');
} }
$view->request_parameters_to_modify['filter_limit'] = false;
$view->request_parameters_to_modify['filter_offset'] = false;
if ($view->visualization_properties->max_graph_elements) {
$view->request_parameters_to_modify['filter_truncate'] = $view->visualization_properties->max_graph_elements - 1;
}
} }
public static function getDefaultPropertyValues() public static function getDefaultPropertyValues()
......
...@@ -83,16 +83,6 @@ class JqplotDataGenerator ...@@ -83,16 +83,6 @@ class JqplotDataGenerator
*/ */
public function generate($dataTable) public function generate($dataTable)
{ {
if (!empty($this->properties['visualization_properties']->max_graph_elements)) {
$offsetStartSummary = $this->properties['visualization_properties']->max_graph_elements - 1;
$sortColumn = !empty($this->properties['filter_sort_column'])
? $this->properties['filter_sort_column']
: Metrics::INDEX_NB_VISITS;
$dataTable->filter(
'AddSummaryRow', array($offsetStartSummary, Piwik_Translate('General_Others'), $sortColumn));
}
if ($dataTable->getRowsCount() > 0) { if ($dataTable->getRowsCount() > 0) {
// if addTotalRow was called in GenerateGraphHTML, add a row containing totals of // if addTotalRow was called in GenerateGraphHTML, add a row containing totals of
// different metrics // different metrics
......
...@@ -46,6 +46,8 @@ class JqplotGraph extends Graph ...@@ -46,6 +46,8 @@ class JqplotGraph extends Graph
*/ */
public function __construct($view) public function __construct($view)
{ {
parent::__construct($view);
// do not sort if sorted column was initially "label" or eg. it would make "Visits by Server time" not pretty // do not sort if sorted column was initially "label" or eg. it would make "Visits by Server time" not pretty
if ($view->filter_sort_column != 'label') { if ($view->filter_sort_column != 'label') {
$columns = $view->columns_to_display; $columns = $view->columns_to_display;
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Veuillez vous inscrire ou vous pour commenter