diff options
author | Thomas Steur <thomas.steur@googlemail.com> | 2014-09-30 09:37:32 +0400 |
---|---|---|
committer | Thomas Steur <thomas.steur@googlemail.com> | 2014-09-30 09:37:32 +0400 |
commit | a00487b0b841c4b15463b591c7f62176c4b84d15 (patch) | |
tree | 6eb893ce356a4740e044c9cdadaf84ffb2095b9d /core/ViewDataTable | |
parent | 0edef3332289a7cbe54b58084b967907d1086d29 (diff) |
coding style fixes, some PHPStorm inspection fixes, improved readability of code, few refactorings, all as part of our code cleanup strategy
Diffstat (limited to 'core/ViewDataTable')
-rw-r--r-- | core/ViewDataTable/Config.php | 2 | ||||
-rw-r--r-- | core/ViewDataTable/Manager.php | 132 | ||||
-rw-r--r-- | core/ViewDataTable/Request.php | 4 |
3 files changed, 76 insertions, 62 deletions
diff --git a/core/ViewDataTable/Config.php b/core/ViewDataTable/Config.php index 2bd748d3e4..1706e4b15f 100644 --- a/core/ViewDataTable/Config.php +++ b/core/ViewDataTable/Config.php @@ -598,7 +598,7 @@ class Config // don't add the related report if it references this report if ($this->controllerName == $module && $this->controllerAction == $action) { - if(empty($queryParams)) { + if (empty($queryParams)) { return; } } diff --git a/core/ViewDataTable/Manager.php b/core/ViewDataTable/Manager.php index 19e2335ce1..5d05650657 100644 --- a/core/ViewDataTable/Manager.php +++ b/core/ViewDataTable/Manager.php @@ -156,46 +156,7 @@ class Manager { $result = array(); - // add normal view icons (eg, normal table, all columns, goals) - $normalViewIcons = array( - 'class' => 'tableAllColumnsSwitch', - 'buttons' => array(), - ); - - if ($view->config->show_table) { - $normalViewIcons['buttons'][] = static::getFooterIconFor(HtmlTable::ID); - } - - if ($view->config->show_table_all_columns) { - $normalViewIcons['buttons'][] = static::getFooterIconFor(HtmlTable\AllColumns::ID); - } - - if ($view->config->show_goals) { - $goalButton = static::getFooterIconFor(Goals::ID); - if (Common::getRequestVar('idGoal', false) == 'ecommerceOrder') { - $goalButton['icon'] = 'plugins/Morpheus/images/ecommerceOrder.gif'; - } - - $normalViewIcons['buttons'][] = $goalButton; - } - - if ($view->config->show_ecommerce) { - $normalViewIcons['buttons'][] = array( - 'id' => 'ecommerceOrder', - 'title' => Piwik::translate('General_EcommerceOrders'), - 'icon' => 'plugins/Morpheus/images/ecommerceOrder.gif', - 'text' => Piwik::translate('General_EcommerceOrders') - ); - - $normalViewIcons['buttons'][] = array( - 'id' => 'ecommerceAbandonedCart', - 'title' => Piwik::translate('General_AbandonedCarts'), - 'icon' => 'plugins/Morpheus/images/ecommerceAbandonedCart.gif', - 'text' => Piwik::translate('General_AbandonedCarts') - ); - } - - $normalViewIcons['buttons'] = array_filter($normalViewIcons['buttons']); + $normalViewIcons = self::getNormalViewIcons($view); if (!empty($normalViewIcons['buttons'])) { $result[] = $normalViewIcons; @@ -207,25 +168,7 @@ class Manager 'buttons' => array(), ); - // add graph views - $graphViewIcons = array( - 'class' => 'tableGraphViews tableGraphCollapsed', - 'buttons' => array(), - ); - - if ($view->config->show_all_views_icons) { - if ($view->config->show_bar_chart) { - $graphViewIcons['buttons'][] = static::getFooterIconFor(Bar::ID); - } - - if ($view->config->show_pie_chart) { - $graphViewIcons['buttons'][] = static::getFooterIconFor(Pie::ID); - } - - if ($view->config->show_tag_cloud) { - $graphViewIcons['buttons'][] = static::getFooterIconFor(Cloud::ID); - } - } + $graphViewIcons = self::getGraphViewIcons($view); $nonCoreVisualizations = static::getNonCoreViewDataTables(); @@ -331,4 +274,75 @@ class Manager { return sprintf('viewDataTableParameters_%s_%s', $login, $controllerAction); } + + private static function getNormalViewIcons(ViewDataTable $view) + { + // add normal view icons (eg, normal table, all columns, goals) + $normalViewIcons = array( + 'class' => 'tableAllColumnsSwitch', + 'buttons' => array(), + ); + + if ($view->config->show_table) { + $normalViewIcons['buttons'][] = static::getFooterIconFor(HtmlTable::ID); + } + + if ($view->config->show_table_all_columns) { + $normalViewIcons['buttons'][] = static::getFooterIconFor(HtmlTable\AllColumns::ID); + } + + if ($view->config->show_goals) { + $goalButton = static::getFooterIconFor(Goals::ID); + if (Common::getRequestVar('idGoal', false) == 'ecommerceOrder') { + $goalButton['icon'] = 'plugins/Morpheus/images/ecommerceOrder.gif'; + } + + $normalViewIcons['buttons'][] = $goalButton; + } + + if ($view->config->show_ecommerce) { + $normalViewIcons['buttons'][] = array( + 'id' => 'ecommerceOrder', + 'title' => Piwik::translate('General_EcommerceOrders'), + 'icon' => 'plugins/Morpheus/images/ecommerceOrder.gif', + 'text' => Piwik::translate('General_EcommerceOrders') + ); + + $normalViewIcons['buttons'][] = array( + 'id' => 'ecommerceAbandonedCart', + 'title' => Piwik::translate('General_AbandonedCarts'), + 'icon' => 'plugins/Morpheus/images/ecommerceAbandonedCart.gif', + 'text' => Piwik::translate('General_AbandonedCarts') + ); + } + + $normalViewIcons['buttons'] = array_filter($normalViewIcons['buttons']); + + return $normalViewIcons; + } + + private static function getGraphViewIcons(ViewDataTable $view) + { + // add graph views + $graphViewIcons = array( + 'class' => 'tableGraphViews tableGraphCollapsed', + 'buttons' => array(), + ); + + if ($view->config->show_all_views_icons) { + if ($view->config->show_bar_chart) { + $graphViewIcons['buttons'][] = static::getFooterIconFor(Bar::ID); + } + + if ($view->config->show_pie_chart) { + $graphViewIcons['buttons'][] = static::getFooterIconFor(Pie::ID); + } + + if ($view->config->show_tag_cloud) { + $graphViewIcons['buttons'][] = static::getFooterIconFor(Cloud::ID); + } + } + + return $graphViewIcons; + } } diff --git a/core/ViewDataTable/Request.php b/core/ViewDataTable/Request.php index 9493889944..352ce25899 100644 --- a/core/ViewDataTable/Request.php +++ b/core/ViewDataTable/Request.php @@ -119,8 +119,8 @@ class Request if (isset($_GET[$nameVar])) { return Common::sanitizeInputValue($_GET[$nameVar]); } - $default = $this->getDefault($nameVar); - return $default; + + return $this->getDefault($nameVar); } /** |