diff options
-rw-r--r-- | core/Plugin/Controller.php | 6 | ||||
-rw-r--r-- | core/ViewDataTable/Manager.php | 7 | ||||
-rw-r--r-- | plugins/CoreVisualizations/javascripts/seriesPicker.js | 2 | ||||
-rw-r--r-- | plugins/ExampleUI/Controller.php | 14 | ||||
-rw-r--r-- | plugins/Goals/Controller.php | 26 | ||||
-rw-r--r-- | plugins/VisitFrequency/Controller.php | 14 | ||||
-rw-r--r-- | plugins/VisitsSummary/Controller.php | 14 |
7 files changed, 59 insertions, 24 deletions
diff --git a/core/Plugin/Controller.php b/core/Plugin/Controller.php index 7284dedda6..1d9f01302b 100644 --- a/core/Plugin/Controller.php +++ b/core/Plugin/Controller.php @@ -26,6 +26,7 @@ use Piwik\Period; use Piwik\Period\Range; use Piwik\Piwik; use Piwik\Plugins\CoreAdminHome\CustomLogo; +use Piwik\Plugins\CoreVisualizations\Visualizations\JqplotGraph\Evolution; use Piwik\Plugins\LanguagesManager\LanguagesManager; use Piwik\Plugins\SitesManager\API as APISitesManager; use Piwik\Plugins\UsersManager\API as APIUsersManager; @@ -297,7 +298,7 @@ abstract class Controller protected function getLastUnitGraph($currentModuleName, $currentControllerAction, $apiMethod) { $view = ViewDataTableFactory::build( - 'graphEvolution', $apiMethod, $currentModuleName . '.' . $currentControllerAction, $forceDefault = true); + Evolution::ID, $apiMethod, $currentModuleName . '.' . $currentControllerAction, $forceDefault = true); $view->config->show_goals = false; return $view; } @@ -329,7 +330,7 @@ abstract class Controller $date = Common::getRequestVar('date'); $meta = \Piwik\Plugins\API\API::getInstance()->getReportMetadata($idSite, $period, $date); - $columns = array_merge($columnsToDisplay, $selectableColumns); + $columns = array_merge($columnsToDisplay ? $columnsToDisplay : array(), $selectableColumns); $translations = array_combine($columns, $columns); foreach ($meta as $reportMeta) { if ($reportMeta['action'] == 'get' && !isset($reportMeta['parameters'])) { @@ -343,6 +344,7 @@ abstract class Controller // initialize the graph and load the data $view = $this->getLastUnitGraph($currentModuleName, $currentControllerAction, $apiMethod); + if ($columnsToDisplay !== false) { $view->config->columns_to_display = $columnsToDisplay; } diff --git a/core/ViewDataTable/Manager.php b/core/ViewDataTable/Manager.php index 0f745932b1..75d4e303ad 100644 --- a/core/ViewDataTable/Manager.php +++ b/core/ViewDataTable/Manager.php @@ -272,6 +272,11 @@ class Manager ); } + public static function clearAllViewDataTableParameters() + { + Option::deleteLike('viewDataTableParameters_%'); + } + public static function getViewDataTableParameters($login, $controllerAction) { $paramsKey = self::buildViewDataTableParametersOptionKey($login, $controllerAction); @@ -301,6 +306,6 @@ class Manager private static function buildViewDataTableParametersOptionKey($login, $controllerAction) { - return sprintf('ReportConfig_%s_%s', $login, $controllerAction); + return sprintf('viewDataTableParameters_%s_%s', $login, $controllerAction); } } diff --git a/plugins/CoreVisualizations/javascripts/seriesPicker.js b/plugins/CoreVisualizations/javascripts/seriesPicker.js index 04bec3d6a9..a4a1f3ddb4 100644 --- a/plugins/CoreVisualizations/javascripts/seriesPicker.js +++ b/plugins/CoreVisualizations/javascripts/seriesPicker.js @@ -273,7 +273,7 @@ // inform dashboard widget about changed parameters (to be restored on reload) var UI = require('piwik/UI') - var params = {columns: columns, rows: rows}; + var params = {columns: columns, rows: rows, columns_to_display: columns}; var tableNode = $('#' + this.dataTableId); UI.DataTable.prototype.notifyWidgetParametersChange(tableNode, params); } diff --git a/plugins/ExampleUI/Controller.php b/plugins/ExampleUI/Controller.php index d4dd15c3b3..5dd0e9bb52 100644 --- a/plugins/ExampleUI/Controller.php +++ b/plugins/ExampleUI/Controller.php @@ -46,7 +46,7 @@ class Controller extends \Piwik\Plugin\Controller $view = new View('@ExampleUI/evolutiongraph'); $this->setPeriodVariablesView($view); - $view->evolutionGraph = $this->getEvolutionGraph(array('server1', 'server2')); + $view->evolutionGraph = $this->getEvolutionGraph(array(), array('server1', 'server2')); return $view->render(); } @@ -78,17 +78,23 @@ class Controller extends \Piwik\Plugin\Controller return $view->render(); } - public function getEvolutionGraph(array $columns = array()) + public function getEvolutionGraph(array $columns = array(), array $defaultColumns = array()) { if (empty($columns)) { - $columns = Common::getRequestVar('columns'); - $columns = Piwik::getArrayFromApiParameter($columns); + $columns = Common::getRequestVar('columns', false); + if (false !== $columns) { + $columns = Piwik::getArrayFromApiParameter($columns); + } } $view = $this->getLastUnitGraphAcrossPlugins($this->pluginName, __FUNCTION__, $columns, $selectableColumns = array('server1', 'server2'), 'My documentation', 'ExampleUI.getTemperaturesEvolution'); $view->requestConfig->filter_sort_column = 'label'; + if (empty($view->config->columns_to_display) && !empty($defaultColumns)) { + $view->config->columns_to_display = $defaultColumns; + } + return $this->renderView($view); } diff --git a/plugins/Goals/Controller.php b/plugins/Goals/Controller.php index 2d64135948..47ed50ac43 100644 --- a/plugins/Goals/Controller.php +++ b/plugins/Goals/Controller.php @@ -140,7 +140,7 @@ class Controller extends \Piwik\Plugin\Controller $view->idGoal = $idGoal; $view->goalName = $goalDefinition['name']; $view->goalAllowMultipleConversionsPerVisit = $goalDefinition['allow_multiple']; - $view->graphEvolution = $this->getEvolutionGraph(array('nb_conversions'), $idGoal); + $view->graphEvolution = $this->getEvolutionGraph(array(), $idGoal, array('nb_conversions')); $view->nameGraphEvolution = 'Goals.getEvolutionGraph' . $idGoal; $view->topDimensions = $this->getTopDimensions($idGoal); @@ -189,7 +189,7 @@ class Controller extends \Piwik\Plugin\Controller $view = new View('@Goals/getOverviewView'); $this->setGeneralVariablesView($view); - $view->graphEvolution = $this->getEvolutionGraph(array('nb_conversions')); + $view->graphEvolution = $this->getEvolutionGraph(array(), false, array('nb_conversions')); $view->nameGraphEvolution = 'GoalsgetEvolutionGraph'; // sparkline for the historical data of the above values @@ -247,14 +247,18 @@ class Controller extends \Piwik\Plugin\Controller return $view->render(); } - public function getEvolutionGraph(array $columns = array(), $idGoal = false) + public function getEvolutionGraph(array $columns = array(), $idGoal = false, array $defaultColumns = array()) { if (empty($columns)) { - $columns = Common::getRequestVar('columns'); - $columns = Piwik::getArrayFromApiParameter($columns); + $columns = Common::getRequestVar('columns', false); + if (false !== $columns) { + $columns = Piwik::getArrayFromApiParameter($columns); + } } - $columns = !is_array($columns) ? array($columns) : $columns; + if (false !== $columns) { + $columns = !is_array($columns) ? array($columns) : $columns; + } if (empty($idGoal)) { $idGoal = Common::getRequestVar('idGoal', false, 'string'); @@ -278,7 +282,7 @@ class Controller extends \Piwik\Plugin\Controller $selectableColumns[] = 'avg_order_revenue'; } - foreach (array_merge($columns, $selectableColumns) as $columnName) { + foreach (array_merge($columns ? $columns : array(), $selectableColumns) as $columnName) { $columnTranslation = ''; // find the right translation for this column, eg. find 'revenue' if column is Goal_1_revenue foreach ($nameToLabel as $metric => $metricTranslation) { @@ -294,7 +298,13 @@ class Controller extends \Piwik\Plugin\Controller } $view->config->translations[$columnName] = $columnTranslation; } - $view->config->columns_to_display = $columns; + + if (!empty($columns)) { + $view->config->columns_to_display = $columns; + } elseif (empty($view->config->columns_to_display) && !empty($defaultColumns)) { + $view->config->columns_to_display = $defaultColumns; + } + $view->config->selectable_columns = $selectableColumns; $langString = $idGoal ? 'Goals_SingleGoalOverviewDocumentation' : 'Goals_GoalsOverviewDocumentation'; diff --git a/plugins/VisitFrequency/Controller.php b/plugins/VisitFrequency/Controller.php index 5ddfd1b6ad..e3ba12abb1 100644 --- a/plugins/VisitFrequency/Controller.php +++ b/plugins/VisitFrequency/Controller.php @@ -21,7 +21,7 @@ class Controller extends \Piwik\Plugin\Controller function index() { $view = new View('@VisitFrequency/index'); - $view->graphEvolutionVisitFrequency = $this->getEvolutionGraph(array('nb_visits_returning')); + $view->graphEvolutionVisitFrequency = $this->getEvolutionGraph(array(), array('nb_visits_returning')); $this->setSparklinesAndNumbers($view); return $view->render(); } @@ -33,11 +33,13 @@ class Controller extends \Piwik\Plugin\Controller return $view->render(); } - public function getEvolutionGraph(array $columns = array()) + public function getEvolutionGraph(array $columns = array(), array $defaultColumns = array()) { if (empty($columns)) { - $columns = Common::getRequestVar('columns'); - $columns = Piwik::getArrayFromApiParameter($columns); + $columns = Common::getRequestVar('columns', false); + if (false !== $columns) { + $columns = Piwik::getArrayFromApiParameter($columns); + } } $documentation = Piwik::translate('VisitFrequency_ReturningVisitsDocumentation') . '<br />' @@ -74,6 +76,10 @@ class Controller extends \Piwik\Plugin\Controller $view = $this->getLastUnitGraphAcrossPlugins($this->pluginName, __FUNCTION__, $columns, $selectableColumns, $documentation); + if (empty($view->config->columns_to_display) && !empty($defaultColumns)) { + $view->config->columns_to_display = $defaultColumns; + } + return $this->renderView($view); } diff --git a/plugins/VisitsSummary/Controller.php b/plugins/VisitsSummary/Controller.php index 0bcae74281..638f5feee2 100644 --- a/plugins/VisitsSummary/Controller.php +++ b/plugins/VisitsSummary/Controller.php @@ -26,7 +26,7 @@ class Controller extends \Piwik\Plugin\Controller { $view = new View('@VisitsSummary/index'); $this->setPeriodVariablesView($view); - $view->graphEvolutionVisitsSummary = $this->getEvolutionGraph(array('nb_visits')); + $view->graphEvolutionVisitsSummary = $this->getEvolutionGraph(array(), array('nb_visits')); $this->setSparklinesAndNumbers($view); return $view->render(); } @@ -39,11 +39,13 @@ class Controller extends \Piwik\Plugin\Controller return $view->render(); } - public function getEvolutionGraph(array $columns = array()) + public function getEvolutionGraph(array $columns = array(), array $defaultColumns = array()) { if (empty($columns)) { - $columns = Common::getRequestVar('columns'); - $columns = Piwik::getArrayFromApiParameter($columns); + $columns = Common::getRequestVar('columns', false); + if (false !== $columns) { + $columns = Piwik::getArrayFromApiParameter($columns); + } } $documentation = Piwik::translate('VisitsSummary_VisitsSummaryDocumentation') . '<br />' @@ -91,6 +93,10 @@ class Controller extends \Piwik\Plugin\Controller $view = $this->getLastUnitGraphAcrossPlugins($this->pluginName, __FUNCTION__, $columns, $selectableColumns, $documentation); + if (empty($view->config->columns_to_display) && !empty($defaultColumns)) { + $view->config->columns_to_display = $defaultColumns; + } + return $this->renderView($view); } |