diff --git a/core/ViewDataTable/HtmlTable.php b/core/ViewDataTable/HtmlTable.php index 9b951f392fe..adf4a13ad1d 100644 --- a/core/ViewDataTable/HtmlTable.php +++ b/core/ViewDataTable/HtmlTable.php @@ -55,6 +55,7 @@ function init($currentControllerName, $this->setSortedColumn('nb_visits', 'desc'); $this->setLimit(Piwik_Config::getInstance()->General['datatable_default_limit']); $this->handleLowPopulation(); + $this->setSubtableTemplate("@CoreHome/_dataTable.twig"); } protected function getViewDataTableId() @@ -105,12 +106,14 @@ public function setJsType($type) $this->dataTableJsType = $type; } - public function showExpanded($subtableTemplate = false) + public function setSubtableTemplate($subtableTemplate) + { + $this->viewProperties['subtable_template'] = $subtableTemplate; + } + + public function showExpanded() { $this->viewProperties['show_expanded'] = true; - if ($subtableTemplate !== false) { - $this->viewProperties['subtable_template'] = $subtableTemplate; - } } /** @@ -118,12 +121,13 @@ public function showExpanded($subtableTemplate = false) */ protected function buildView() { - $view = new Piwik_View($this->dataTableTemplate); - if (empty($this->viewProperties['dataTableType'])) { $this->viewProperties['dataTableType'] = $this->getDefaultDataTableType(); } + $template = $this->idSubtable ? $this->viewProperties['subtable_template'] : $this->dataTableTemplate; + $view = new Piwik_View($template); + if (!empty($this->dataTableJsType)) { $view->dataTableJsType = $this->dataTableJsType; } @@ -206,13 +210,16 @@ public function addColumnToDisplay($columnName) /** * Sets the search on a table to be recursive (also searches in subtables) * Works only on Actions/Downloads/Outlinks tables. - * - * @return bool If the pattern for a recursive search was set in the URL */ public function setSearchRecursive() { $this->variablesDefault['search_recursive'] = true; - return $this->setRecursiveLoadDataTableIfSearchingForPattern(); + $this->setRecursiveLoadDataTableIfSearchingForPattern(); + } + + public function isLoadingExpandedDataTable() + { + return $this->recursiveDataTableLoad; } protected function getRequestString() @@ -228,23 +235,14 @@ protected function getRequestString() /** * Set the flag to load the datatable recursively so we can search on subtables as well - * - * @return bool if recursive search is enabled */ protected function setRecursiveLoadDataTableIfSearchingForPattern() { - try { - $requestValue = Piwik_Common::getRequestVar('filter_column_recursive'); - $requestValue = Piwik_Common::getRequestVar('filter_pattern_recursive'); - // if the 2 variables are set we are searching for something. - // we have to load all the children subtables in this case - - $this->recursiveDataTableLoad = true; - return true; - } catch (Exception $e) { - $this->recursiveDataTableLoad = false; - return false; - } + // if the 2 variables are set we are searching for something. + // we have to load all the children subtables in this case + $this->recursiveDataTableLoad = Piwik_Common::getRequestVar('filter_column_recursive', false) !== false + && Piwik_Common::getRequestVar('filter_pattern_recursive', false) !== false; + return $this->recursiveDataTableLoad; } /** diff --git a/plugins/Actions/Controller.php b/plugins/Actions/Controller.php index d8bf8a12c61..4980cd7764c 100644 --- a/plugins/Actions/Controller.php +++ b/plugins/Actions/Controller.php @@ -454,14 +454,11 @@ protected function configureGenericViewActions($view) { $view->setDataTableType('dataTableActions'); $view->setJsType('actionDataTable'); + $view->setSubtableTemplate('@CoreHome/_dataTableActions_subDataTable.twig'); - - if (Piwik_Common::getRequestVar('idSubtable', -1) != -1) { - $view->setTemplate('@CoreHome/_dataTableActions_subDataTable'); - } - $currentlySearching = $view->setSearchRecursive(); - if ($currentlySearching) { - $view->showExpanded($subtableTemplate = '@CoreHome/_dataTableActions_subDataTable.twig'); + $view->setSearchRecursive(); + if ($view->isLoadingExpandedDataTable()) { + $view->showExpanded(); // set levelN css class for each row $self = $this; diff --git a/plugins/CoreHome/templates/_dataTable.twig b/plugins/CoreHome/templates/_dataTable.twig index 3bfe563aa0f..27ace4d782b 100644 --- a/plugins/CoreHome/templates/_dataTable.twig +++ b/plugins/CoreHome/templates/_dataTable.twig @@ -42,7 +42,7 @@ {# display subtable if present and showing expanded datatable #} {% if properties.show_expanded|default(false) and rowHasSubtable %} - {% include properties.subtable_template|default("@CoreHome/_dataTable.twig") with {'dataTable': row.getSubtable()} %} + {% include properties.subtable_template with {'dataTable': row.getSubtable()} %} {% endif %} {% endfor %} diff --git a/plugins/CoreHome/templates/_dataTableActions_subDataTable.twig b/plugins/CoreHome/templates/_dataTableActions_subDataTable.twig index cdd0bc603f5..4f4789d49e9 100644 --- a/plugins/CoreHome/templates/_dataTableActions_subDataTable.twig +++ b/plugins/CoreHome/templates/_dataTableActions_subDataTable.twig @@ -1,5 +1,5 @@ -{% if arrayDataTable.result is defined and arrayDataTable.result == 'error' %} - {{ arrayDataTable.message }} +{% if error is defined %} + {{ error.message }} {% else %} {% if (dataTable is empty or dataTable.getRowsCount() == 0) and not properties.show_expanded|default(false) %}