From 5f02dc0d0e4a26181e656ae996b769f7165acbf9 Mon Sep 17 00:00:00 2001 From: mDeflotte Date: Thu, 29 Sep 2011 08:59:11 +0000 Subject: [PATCH] //StoresController : Refacto done git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@8865 b9a71923-0436-4b27-9f14-aed3839534dd --- controllers/front/StoresController.php | 31 ++++++++++++++++---------- 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/controllers/front/StoresController.php b/controllers/front/StoresController.php index 9a8fe0020..e6f403651 100644 --- a/controllers/front/StoresController.php +++ b/controllers/front/StoresController.php @@ -107,10 +107,7 @@ class StoresControllerCore extends FrontController )); } - /** - * Assign template vars for classical stores - */ - protected function assignStores() + public function getStores() { $distanceUnit = Configuration::get('PS_DISTANCE_UNIT'); if (!in_array($distanceUnit, array('km', 'mi'))) @@ -152,25 +149,35 @@ class StoresControllerCore extends FrontController ORDER BY distance ASC LIMIT 0,20'); } + + return $stores; + } + + /** + * Assign template vars for classical stores + */ + protected function assignStores() + { + $this->context->smarty->assign('hasStoreIcon', file_exists(dirname(__FILE__).'/../img/logo_stores.gif')); - if ($this->ajax) - $this->displayXmlMaps($stores); - else - $this->context->smarty->assign('hasStoreIcon', file_exists(dirname(__FILE__).'/../img/logo_stores.gif')); - - + $distanceUnit = Configuration::get('PS_DISTANCE_UNIT'); + if (!in_array($distanceUnit, array('km', 'mi'))) + $distanceUnit = 'km'; + $this->context->smarty->assign(array( 'distance_unit' => $distanceUnit, 'simplifiedStoresDiplay' => false, - 'stores' => $stores + 'stores' => $this->getStores() )); } /** * Display the Xml for showing the nodes in the google map */ - protected function displayXmlMaps($stores) + protected function displayAjax() { + $stores = $this->getStores(); + $dom = new DOMDocument('1.0'); $node = $dom->createElement('markers'); $parnode = $dom->appendChild($node);