From b9020ee321e20820ebc58a47c29a4e9c98a53c49 Mon Sep 17 00:00:00 2001
From: Benaka Moorthi <benaka.moorthi@gmail.com>
Date: Wed, 10 Jul 2013 20:25:13 -0400
Subject: [PATCH] Rename
 ViewDataTable::setDataTableType/getDefaultDataTableType to
 setDataTableCssClass/getDefaultDataTableCssClass and move newly added view
 data to viewProperties member.

---
 core/ViewDataTable/HtmlTable.php            | 18 ++++++------------
 core/ViewDataTable/HtmlTable/AllColumns.php |  2 +-
 core/ViewDataTable/HtmlTable/Goals.php      |  2 +-
 plugins/Actions/Controller.php              |  2 +-
 plugins/CoreHome/templates/_dataTable.twig  |  4 ++--
 5 files changed, 11 insertions(+), 17 deletions(-)

diff --git a/core/ViewDataTable/HtmlTable.php b/core/ViewDataTable/HtmlTable.php
index adf4a13ad1..ae24ec692a 100644
--- a/core/ViewDataTable/HtmlTable.php
+++ b/core/ViewDataTable/HtmlTable.php
@@ -56,6 +56,8 @@ class Piwik_ViewDataTable_HtmlTable extends Piwik_ViewDataTable
         $this->setLimit(Piwik_Config::getInstance()->General['datatable_default_limit']);
         $this->handleLowPopulation();
         $this->setSubtableTemplate("@CoreHome/_dataTable.twig");
+        $this->viewProperties['datatable_js_type'] = 'dataTable';
+        $this->viewProperties['datatable_css_class'] = $this->getDefaultDataTableCssClass();
     }
 
     protected function getViewDataTableId()
@@ -91,19 +93,19 @@ class Piwik_ViewDataTable_HtmlTable extends Piwik_ViewDataTable
         $this->view = $this->buildView();
     }
     
-    public function getDefaultDataTableType()
+    public function getDefaultDataTableCssClass()
     {
         return 'dataTableNormal';
     }
     
-    public function setDataTableType($type)
+    public function setDataTableCssClass($type)
     {
-        $this->viewProperties['dataTableType'] = $type;
+        $this->viewProperties['datatable_css_class'] = $type;
     }
     
     public function setJsType($type)
     {
-        $this->dataTableJsType = $type;
+        $this->viewProperties['datatable_js_type'] = $type;
     }
     
     public function setSubtableTemplate($subtableTemplate)
@@ -121,16 +123,8 @@ class Piwik_ViewDataTable_HtmlTable extends Piwik_ViewDataTable
      */
     protected function buildView()
     {
-        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;
-        }
 
         if (!empty($this->loadingError)) {
             $view->error = $this->loadingError;
diff --git a/core/ViewDataTable/HtmlTable/AllColumns.php b/core/ViewDataTable/HtmlTable/AllColumns.php
index d486fcfc51..3381c85891 100644
--- a/core/ViewDataTable/HtmlTable/AllColumns.php
+++ b/core/ViewDataTable/HtmlTable/AllColumns.php
@@ -63,7 +63,7 @@ class Piwik_ViewDataTable_HtmlTable_AllColumns extends Piwik_ViewDataTable_HtmlT
         return true;
     }
 
-    public function getDefaultDataTableType()
+    public function getDefaultDataTableCssClass()
     {
         return 'dataTableAllColumns';
     }
diff --git a/core/ViewDataTable/HtmlTable/Goals.php b/core/ViewDataTable/HtmlTable/Goals.php
index e938771d60..7b407e8d17 100644
--- a/core/ViewDataTable/HtmlTable/Goals.php
+++ b/core/ViewDataTable/HtmlTable/Goals.php
@@ -257,7 +257,7 @@ class Piwik_ViewDataTable_HtmlTable_Goals extends Piwik_ViewDataTable_HtmlTable
         return true;
     }
 
-    public function getDefaultDataTableType()
+    public function getDefaultDataTableCssClass()
     {
         return 'dataTableGoals';
     }
diff --git a/plugins/Actions/Controller.php b/plugins/Actions/Controller.php
index 4980cd7764..1b0cd2b155 100644
--- a/plugins/Actions/Controller.php
+++ b/plugins/Actions/Controller.php
@@ -452,7 +452,7 @@ class Piwik_Actions_Controller extends Piwik_Controller
      */
     protected function configureGenericViewActions($view)
     {
-        $view->setDataTableType('dataTableActions');
+        $view->setDataTableCssClass('dataTableActions');
         $view->setJsType('actionDataTable');
         $view->setSubtableTemplate('@CoreHome/_dataTableActions_subDataTable.twig');
         
diff --git a/plugins/CoreHome/templates/_dataTable.twig b/plugins/CoreHome/templates/_dataTable.twig
index 27ace4d782..d6b51d34f1 100644
--- a/plugins/CoreHome/templates/_dataTable.twig
+++ b/plugins/CoreHome/templates/_dataTable.twig
@@ -1,6 +1,6 @@
 {% set isSubtable = javascriptVariablesToSet.idSubtable is defined and javascriptVariablesToSet.idSubtable != 0 %}
-<div class="dataTable {{ properties.dataTableType }} {% if isSubtable %}subDataTable{% endif %}"
-     data-table-type="{{ dataTableJsType|default('dataTable') }}"
+<div class="dataTable {{ properties.datatable_css_class }} {% if isSubtable %}subDataTable{% endif %}"
+     data-table-type="{{ properties.datatable_js_type|default('dataTable') }}"
      data-report="{{ properties.report_id }}"
      data-params="{{ javascriptVariablesToSet|json_encode }}">
     <div class="reportDocumentation">
-- 
GitLab