diff --git a/classes/Page.php b/classes/Page.php index f63641032..6f456d810 100644 --- a/classes/Page.php +++ b/classes/Page.php @@ -128,4 +128,20 @@ class PageCore extends ObjectModel )); } } + + public static function getPageTypeAlias($pageName) + { + $pageTypeAlias = array( + 'index' => 'home', + 'category' => 'hotel', + 'product' => 'room-type', + 'orderopc' => 'checkout' + ); + + if (isset($pageTypeAlias[$pageName])) { + return $pageTypeAlias[$pageName]; + } else { + return $pageName; + } + } } diff --git a/modules/statslive/statslive.php b/modules/statslive/statslive.php index 7ddd1e70c..afce68a5b 100644 --- a/modules/statslive/statslive.php +++ b/modules/statslive/statslive.php @@ -45,12 +45,6 @@ class StatsLive extends Module $this->displayName = $this->l('Visitors online'); $this->description = $this->l('Adds a list of customers and visitors who are currently online to the Stats dashboard.'); $this->ps_versions_compliancy = array('min' => '1.6', 'max' => '1.7.0.99'); - $this->page_map = array( - 'index' => 'home', - 'category' => 'hotel', - 'product' => 'room-type', - 'orderopc' => 'checkout' - ); } public function install() @@ -95,7 +89,7 @@ class StatsLive extends Module ORDER BY u.firstname, u.lastname'; } $results = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql); - $this->updatePageName($results); + $this->updatePageTypeAlias($results); return array($results, Db::getInstance()->NumRows()); } @@ -137,18 +131,16 @@ class StatsLive extends Module } $results = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql); - $this->updatePageName($results); + $this->updatePageTypeAlias($results); return array($results, Db::getInstance()->NumRows()); } - public function updatePageName(&$result) + public function updatePageTypeAlias(&$result) { if (count($result)) { foreach ($result as &$customer) { - if (isset($this->page_map[$customer['page']])) { - $customer['page'] = $this->page_map[$customer['page']]; - } + $customer['page'] = Page::getPageTypeAlias($customer['page']); } } }