Merge pull request #55 from PrestaEdit/mobile_logo

[+] FO: Mobile logo
This commit is contained in:
Vincent Augagneur committed 2012-11-30 02:06:19 -08:00
commit 539011c057
2 files changed
+43 -10

No files matched your search

+21 -10
View File
@@ -605,12 +605,8 @@ class FrontControllerCore extends Controller
if (!in_array(Tools::getRemoteAddr(), explode(',', Configuration::get('PS_MAINTENANCE_IP')))) if (!in_array(Tools::getRemoteAddr(), explode(',', Configuration::get('PS_MAINTENANCE_IP'))))
{ {
header('HTTP/1.1 503 temporarily overloaded'); header('HTTP/1.1 503 temporarily overloaded');
$this->context->smarty->assign(array(
'favicon_url' => _PS_IMG_.Configuration::get('PS_FAVICON'), $this->context->smarty->assign($this->initLogoAndFavicon());
'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')
));
$template_dir = ($this->context->getMobileDevice() == true ? _PS_THEME_MOBILE_DIR_ : _PS_THEME_DIR_); $template_dir = ($this->context->getMobileDevice() == true ? _PS_THEME_MOBILE_DIR_ : _PS_THEME_DIR_);
$this->smartyOutputContent($template_dir.'maintenance.tpl'); $this->smartyOutputContent($template_dir.'maintenance.tpl');
@@ -785,13 +781,11 @@ class FrontControllerCore extends Controller
'img_update_time' => Configuration::get('PS_IMG_UPDATE_TIME'), 'img_update_time' => Configuration::get('PS_IMG_UPDATE_TIME'),
'static_token' => Tools::getToken(false), 'static_token' => Tools::getToken(false),
'token' => Tools::getToken(), 'token' => Tools::getToken(),
'logo_image_width' => Configuration::get('SHOP_LOGO_WIDTH'),
'logo_image_height' => Configuration::get('SHOP_LOGO_HEIGHT'),
'priceDisplayPrecision' => _PS_PRICE_DISPLAY_PRECISION_, 'priceDisplayPrecision' => _PS_PRICE_DISPLAY_PRECISION_,
'content_only' => (int)Tools::getValue('content_only'), '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() public function initFooter()
@@ -1141,4 +1135,21 @@ class FrontControllerCore extends Controller
$this->context->smarty->assign($assign); $this->context->smarty->assign($assign);
$this->template = $template; $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'))
);
}
} }
@@ -127,6 +127,14 @@ class AdminThemesControllerCore extends AdminController
'type' => 'file', 'type' => 'file',
'thumb' => _PS_IMG_.Configuration::get('PS_LOGO').'?date='.time() '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) ? '<span class="light-warning">'.$this->l('Warning: No mobile logo defined, the header logo is used instead.').'</span><br />' : '').
$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( 'PS_LOGO_MAIL' => array(
'title' => $this->l('Mail logo'), 'title' => $this->l('Mail logo'),
'desc' => 'desc' =>
@@ -400,6 +408,12 @@ class AdminThemesControllerCore extends AdminController
Configuration::updateValue('SHOP_LOGO_HEIGHT', (int)round($height)); Configuration::updateValue('SHOP_LOGO_HEIGHT', (int)round($height));
Configuration::updateValue('SHOP_LOGO_WIDTH', (int)round($width)); 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; $this->content .= $content;
return parent::initContent(); return parent::initContent();
@@ -540,6 +554,14 @@ class AdminThemesControllerCore extends AdminController
$this->updateLogo('PS_LOGO', 'logo'); $this->updateLogo('PS_LOGO', 'logo');
} }
/**
* Update PS_LOGO_MOBILE
*/
public function updateOptionPsLogoMobile()
{
$this->updateLogo('PS_LOGO_MOBILE', 'logo_mobile');
}
/** /**
* Update PS_LOGO_MAIL * Update PS_LOGO_MAIL
*/ */