From 2a65bab40ec17d538a014216be979ccff1031372 Mon Sep 17 00:00:00 2001 From: PrestaEdit Date: Wed, 28 Nov 2012 01:10:42 +0100 Subject: [PATCH 1/7] [+] BO: add posibility to set a Mobile Header logo --- controllers/admin/AdminThemesController.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/controllers/admin/AdminThemesController.php b/controllers/admin/AdminThemesController.php index 029f43503..478d94fac 100644 --- a/controllers/admin/AdminThemesController.php +++ b/controllers/admin/AdminThemesController.php @@ -127,6 +127,14 @@ class AdminThemesControllerCore extends AdminController 'type' => 'file', 'thumb' => _PS_IMG_.Configuration::get('PS_LOGO').'?date='.time() ), + 'PS_LOGO_MOBILE' => array( + 'title' => $this->l('Mobile Header logo'), + 'desc' => + ((Configuration::get('PS_LOGO_MOBILE') === false) ? ''.$this->l('Warning: No mobile logo defined, the header logo is used instead.').'
' : ''). + $this->l('Will appear on mobile main page. If undefined, the Header logo will be used'), + 'type' => 'file', + 'thumb' => (Configuration::get('PS_LOGO_MOBILE') !== false && file_exists(_PS_IMG_DIR_.Configuration::get('PS_LOGO_MOBILE'))) ? _PS_IMG_.Configuration::get('PS_LOGO_MOBILE').'?date='.time() : _PS_IMG_.Configuration::get('PS_LOGO').'?date='.time() + ), 'PS_LOGO_MAIL' => array( 'title' => $this->l('Mail logo'), 'desc' => From bbdef58492343652743f555e0215363ffa0c7370 Mon Sep 17 00:00:00 2001 From: PrestaEdit Date: Wed, 28 Nov 2012 01:19:45 +0100 Subject: [PATCH 2/7] [+] BO: add updateOptionPsLogoMobile() --- controllers/admin/AdminThemesController.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/controllers/admin/AdminThemesController.php b/controllers/admin/AdminThemesController.php index 478d94fac..0ac54ff05 100644 --- a/controllers/admin/AdminThemesController.php +++ b/controllers/admin/AdminThemesController.php @@ -547,6 +547,14 @@ class AdminThemesControllerCore extends AdminController { $this->updateLogo('PS_LOGO', 'logo'); } + + /** + * Update PS_LOGO_MOBILE + */ + public function updateOptionPsLogoMobile() + { + $this->updateLogo('PS_LOGO_MOBILE', 'logo_mobile'); + } /** * Update PS_LOGO_MAIL From 59035bd99af7d6ab90fd02e619e0c6510f0df238 Mon Sep 17 00:00:00 2001 From: PrestaEdit Date: Wed, 28 Nov 2012 01:23:24 +0100 Subject: [PATCH 3/7] [+] BO: modifiy smarty var $logo_url to have the mobile logo image if mobile version --- classes/controller/FrontController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/classes/controller/FrontController.php b/classes/controller/FrontController.php index 1b02797d6..6814fb31a 100755 --- a/classes/controller/FrontController.php +++ b/classes/controller/FrontController.php @@ -608,7 +608,7 @@ class FrontControllerCore extends Controller 'favicon_url' => _PS_IMG_.Configuration::get('PS_FAVICON'), 'logo_image_width' => Configuration::get('SHOP_LOGO_WIDTH'), 'logo_image_height' => Configuration::get('SHOP_LOGO_HEIGHT'), - 'logo_url' => _PS_IMG_.Configuration::get('PS_LOGO').'?'.Configuration::get('PS_IMG_UPDATE_TIME') + 'logo_url' => ($this->context->getMobileDevice() == false ? _PS_IMG_.Configuration::get('PS_LOGO').'?'.Configuration::get('PS_IMG_UPDATE_TIME') : _PS_IMG_.Configuration::get('PS_LOGO_MOBILE').'?'.Configuration::get('PS_IMG_UPDATE_TIME')) )); $template_dir = ($this->context->getMobileDevice() == true ? _PS_THEME_MOBILE_DIR_ : _PS_THEME_DIR_); From a6389cb7ef6477bcff23ac68a591f5bf0bc6a907 Mon Sep 17 00:00:00 2001 From: PrestaEdit Date: Wed, 28 Nov 2012 01:26:53 +0100 Subject: [PATCH 4/7] [+] BO: modifiy width and height configuration for the mobile logo --- controllers/admin/AdminThemesController.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/controllers/admin/AdminThemesController.php b/controllers/admin/AdminThemesController.php index 0ac54ff05..eaa87e60c 100644 --- a/controllers/admin/AdminThemesController.php +++ b/controllers/admin/AdminThemesController.php @@ -408,6 +408,12 @@ class AdminThemesControllerCore extends AdminController Configuration::updateValue('SHOP_LOGO_HEIGHT', (int)round($height)); Configuration::updateValue('SHOP_LOGO_WIDTH', (int)round($width)); } + if (file_exists(_PS_IMG_DIR_.'logo_mobile.jpg')) + { + list($width, $height, $type, $attr) = getimagesize(_PS_IMG_DIR_.Configuration::get('PS_LOGO_MOBILE')); + Configuration::updateValue('SHOP_LOGO_MOBILE_HEIGHT', (int)round($height)); + Configuration::updateValue('SHOP_LOGO_MOBILE_WIDTH', (int)round($width)); + } $this->content .= $content; return parent::initContent(); From 36851aaa5823785a4a4a4ff34ccf90ef902c7f9e Mon Sep 17 00:00:00 2001 From: PrestaEdit Date: Wed, 28 Nov 2012 01:31:43 +0100 Subject: [PATCH 5/7] [+] FO: modifiy width and height smarty vars for the mobile logo --- classes/controller/FrontController.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/classes/controller/FrontController.php b/classes/controller/FrontController.php index 6814fb31a..3a08d7efe 100755 --- a/classes/controller/FrontController.php +++ b/classes/controller/FrontController.php @@ -606,8 +606,8 @@ class FrontControllerCore extends Controller header('HTTP/1.1 503 temporarily overloaded'); $this->context->smarty->assign(array( 'favicon_url' => _PS_IMG_.Configuration::get('PS_FAVICON'), - 'logo_image_width' => Configuration::get('SHOP_LOGO_WIDTH'), - 'logo_image_height' => Configuration::get('SHOP_LOGO_HEIGHT'), + 'logo_image_width' => ($this->context->getMobileDevice() == false ? Configuration::get('SHOP_LOGO_WIDTH') : Configuration::get('SHOP_LOGO_MOBILE_WIDTH')), + 'logo_image_height' => ($this->context->getMobileDevice() == false ? Configuration::get('SHOP_LOGO_HEIGHT') : Configuration::get('SHOP_LOGO_MOBILE_HEIGHT')), 'logo_url' => ($this->context->getMobileDevice() == false ? _PS_IMG_.Configuration::get('PS_LOGO').'?'.Configuration::get('PS_IMG_UPDATE_TIME') : _PS_IMG_.Configuration::get('PS_LOGO_MOBILE').'?'.Configuration::get('PS_IMG_UPDATE_TIME')) )); From f7b40b24b94d4629bdf857ec9bfd1581632c7477 Mon Sep 17 00:00:00 2001 From: PrestaEdit Date: Thu, 29 Nov 2012 21:56:03 +0100 Subject: [PATCH 6/7] [*] FO: add initLogoAndFavicon() --- classes/controller/FrontController.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/classes/controller/FrontController.php b/classes/controller/FrontController.php index 3a08d7efe..2645ac198 100755 --- a/classes/controller/FrontController.php +++ b/classes/controller/FrontController.php @@ -1140,4 +1140,21 @@ class FrontControllerCore extends Controller $this->context->smarty->assign($assign); $this->template = $template; } + + /** + * Return an array with specific logo and favicon, + * if mobile device + * + * @since 1.5 + * @return array + */ + public function initLogoAndFavicon() + { + return array( + 'favicon_url' => _PS_IMG_.Configuration::get('PS_FAVICON'), + 'logo_image_width' => ($this->context->getMobileDevice() == false ? Configuration::get('SHOP_LOGO_WIDTH') : Configuration::get('SHOP_LOGO_MOBILE_WIDTH')), + 'logo_image_height' => ($this->context->getMobileDevice() == false ? Configuration::get('SHOP_LOGO_HEIGHT') : Configuration::get('SHOP_LOGO_MOBILE_HEIGHT')), + 'logo_url' => ($this->context->getMobileDevice() == false ? _PS_IMG_.Configuration::get('PS_LOGO').'?'.Configuration::get('PS_IMG_UPDATE_TIME') : _PS_IMG_.Configuration::get('PS_LOGO_MOBILE').'?'.Configuration::get('PS_IMG_UPDATE_TIME')) + ); + } } From 99b97d9bb766d69a8a087aa3b5ce5c8f6fd48fab Mon Sep 17 00:00:00 2001 From: PrestaEdit Date: Thu, 29 Nov 2012 21:57:04 +0100 Subject: [PATCH 7/7] [*] FO: use initLogoAndFavicon() function --- classes/controller/FrontController.php | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/classes/controller/FrontController.php b/classes/controller/FrontController.php index 2645ac198..ddc6c7970 100755 --- a/classes/controller/FrontController.php +++ b/classes/controller/FrontController.php @@ -604,12 +604,8 @@ class FrontControllerCore extends Controller if (!in_array(Tools::getRemoteAddr(), explode(',', Configuration::get('PS_MAINTENANCE_IP')))) { header('HTTP/1.1 503 temporarily overloaded'); - $this->context->smarty->assign(array( - 'favicon_url' => _PS_IMG_.Configuration::get('PS_FAVICON'), - 'logo_image_width' => ($this->context->getMobileDevice() == false ? Configuration::get('SHOP_LOGO_WIDTH') : Configuration::get('SHOP_LOGO_MOBILE_WIDTH')), - 'logo_image_height' => ($this->context->getMobileDevice() == false ? Configuration::get('SHOP_LOGO_HEIGHT') : Configuration::get('SHOP_LOGO_MOBILE_HEIGHT')), - 'logo_url' => ($this->context->getMobileDevice() == false ? _PS_IMG_.Configuration::get('PS_LOGO').'?'.Configuration::get('PS_IMG_UPDATE_TIME') : _PS_IMG_.Configuration::get('PS_LOGO_MOBILE').'?'.Configuration::get('PS_IMG_UPDATE_TIME')) - )); + + $this->context->smarty->assign($this->initLogoAndFavicon()); $template_dir = ($this->context->getMobileDevice() == true ? _PS_THEME_MOBILE_DIR_ : _PS_THEME_DIR_); $this->smartyOutputContent($template_dir.'maintenance.tpl'); @@ -784,13 +780,11 @@ class FrontControllerCore extends Controller 'img_update_time' => Configuration::get('PS_IMG_UPDATE_TIME'), 'static_token' => Tools::getToken(false), 'token' => Tools::getToken(), - 'logo_image_width' => Configuration::get('SHOP_LOGO_WIDTH'), - 'logo_image_height' => Configuration::get('SHOP_LOGO_HEIGHT'), 'priceDisplayPrecision' => _PS_PRICE_DISPLAY_PRECISION_, 'content_only' => (int)Tools::getValue('content_only'), - 'logo_url' => _PS_IMG_.Configuration::get('PS_LOGO').'?'.Configuration::get('PS_IMG_UPDATE_TIME'), - 'favicon_url' => _PS_IMG_.Configuration::get('PS_FAVICON'), )); + + $this->context->smarty->assign($this->initLogoAndFavicon()); } public function initFooter()