Last active
August 29, 2015 14:20
-
-
Save seansan/fe1945722c7b257ab55f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Magento | |
* | |
* NOTICE OF LICENSE | |
* | |
* This source file is subject to the Academic Free License (AFL 3.0) | |
* that is bundled with this package in the file LICENSE_AFL.txt. | |
* It is also available through the world-wide-web at this URL: | |
* http://opensource.org/licenses/afl-3.0.php | |
* If you did not receive a copy of the license and are unable to | |
* obtain it through the world-wide-web, please send an email | |
* to [email protected] so we can send you a copy immediately. | |
* | |
* DISCLAIMER | |
* | |
* Do not edit or add to this file if you wish to upgrade Magento to newer | |
* versions in the future. If you wish to customize Magento for your | |
* needs please refer to http://www.magentocommerce.com for more information. | |
* | |
* @category design | |
* @package base_default | |
* @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com) | |
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) | |
*/ | |
?> | |
<?php | |
/** | |
* Language switcher template | |
* | |
* CUSTOM: changed language switcher foreach/inchoo | |
* Also manually added $_lang->getCurrentUrl() => false to remove from store code | |
* | |
* @see Mage_Page_Block_Switch | |
*/ | |
?> | |
<!-- LANGUAGES BOF --> | |
<?php if(count($this->getStores())>1): ?> | |
<?php | |
$stores = array(); | |
$_current = null; | |
$languages = Zend_Locale::getTranslationList('language', Mage::app()->getLocale()->getLocaleCode()); | |
/** CUSTOM **/ | |
$router = Mage::app()->getRequest()->getRouteName(); | |
foreach ($this->getStores() as $_lang) { | |
$_selected = $_selected_option = $_language_name = ''; | |
$_language_code = substr(Mage::getStoreConfig('general/locale/code', $_lang->getId()),0,2); | |
if (isset($languages[$_language_code])) {$_language_name = $languages[$_language_code];} | |
$parts = explode('(', $_language_name); | |
$_language_name = trim($parts[0]); | |
if ( ($_lang->getId() == $this->getCurrentStoreId()) ) { | |
$_current = $_lang; | |
$_current_lang = $_language_name; | |
$_current_bg = $this->getSkinUrl('images/flags/'.$_language_code.'.png'); | |
$_selected = ' class="selected"'; | |
$_selected_option = ' selected="selected"'; | |
} | |
Mage::log($router.'/'., null, 'languages.log'); | |
$_setCurrentUrl = false; | |
$url = ''; | |
if (($router == 'cms') && ($controller != 'index')) { | |
$cms_id = Mage::getBlockSingleton('cms/page')->getPage()->getId(); | |
if (class_exists('Magmodules_Alternatelang_Helper_Data') && function_exists('getAlternateCategory')) { | |
$cms_category = Mage::getBlockSingleton('cms/page')->getPage()->getAlternateCategory(); | |
$cat = Mage::getModel('cms/page')->setStoreId($_lang->getId())->load($cms_category, 'alternate_category'); | |
$cms_uri = $cat->getIdentifier(); | |
$cms_id = $cat->getId(); | |
$url = $store->getBaseUrl() . $cms_uri; | |
} | |
$_setCurrentUrl = Mage::getModel('cms/page') | |
->setStoreId($_lang->getId()) | |
->load($cms_id) | |
->getIsActive(); | |
} | |
if ($product = Mage::registry('current_product')) { | |
$_setCurrentUrl = Mage::getModel('catalog/product') | |
->setStoreId($_lang->getId()) | |
->load($product->getId()) | |
->getStatus(); | |
} | |
if (($category = Mage::registry('current_category')) && !Mage::registry('current_product')) { | |
$_setCurrentUrl = Mage::getModel('catalog/category') | |
->setStoreId($_lang->getId()) | |
->load($category) | |
->getIsActive(); | |
} | |
if ($_setCurrentUrl) { | |
if (empty($_url)) { $_url = $_lang->getCurrentUrl(); } | |
} else { | |
$_url = Mage::app()->getStore($_lang->getId())->getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK); | |
} | |
// $stores[] = '<li'. $_selected .'><a style="background-image:url(\''. $this->getSkinUrl('images/flags/'.$_lang->getCode().'.png') .'\');" href="'. $_lang->getCurrentUrl() .'">'. $this->htmlEscape($_lang->getName()) .'</a></li>'; | |
$stores[] = '<li'. $_selected .'><a style="background-image:url(\''. $this->getSkinUrl('images/flags/'.$_language_code.'.png') .'\');" href="'. $_lang->getCurrentUrl() .'">'. $this->htmlEscape($_language_name) .'</a></li>'; | |
$select_stores[] = '<option '.$_selected_option.' value="'. $_url .'">'. $this->htmlEscape($_lang->getName()) .'</option>'; | |
} | |
?> | |
<div class="header-switch language-switch"> | |
<span><?php echo $this->__('Your Language:') ?> | |
<span class="current" style="background-image:url('<?php echo $_current_bg ?>');"><?php echo $this->htmlEscape($_current_lang); ?></span> | |
</span> | |
<div class="header-dropdown"> | |
<ul><?php echo implode('', $stores); ?></ul> | |
</div> | |
</div> | |
<!-- | |
<div class="language-select"> | |
<span><?php echo $this->__('Your Language:') ?></span> | |
<select name="language_switch" onchange="window.location=this.value"><?php echo implode('', $select_stores); ?></select> | |
</div> | |
--> | |
<?php endif; ?> | |
<!-- LANGUAGES EOF --> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment