00001 <?php 00002 00008 class oxcmp_lang extends oxView 00009 { 00014 public $aLanguages = null; 00015 00020 protected $_blIsComponent = true; 00021 00032 public function init() 00033 { 00034 $myConfig = $this->getConfig(); 00035 00036 // Performance 00037 if ( !$myConfig->getConfigParam( 'bl_perfLoadLanguages' ) ) { 00038 return; 00039 } 00040 00041 $iLang = oxLang::getInstance()->getBaseLanguage(); 00042 $iChangeLang = oxConfig::getParameter( 'lang' ); 00043 00044 if ( oxConfig::getParameter( 'changelang' ) ) { 00045 $iChangeLang = oxConfig::getParameter("changelang"); 00046 } 00047 00048 if ( isset( $iChangeLang ) ) { 00049 // set new language 00050 $iChangeLang = oxLang::getInstance()->validateLanguage( $iChangeLang ); 00051 oxLang::getInstance()->setTplLanguage( $iChangeLang ); 00052 oxLang::getInstance()->setBaseLanguage( $iChangeLang ); 00053 00054 // recalc basket 00055 $oBasket = $this->getSession()->getBasket(); 00056 $oBasket->onUpdate(); 00057 } 00058 00059 $this->aLanguages = oxLang::getInstance()->getLanguageArray(); 00060 00061 parent::init(); 00062 } 00063 00069 public function render() 00070 { 00071 parent::render(); 00072 $myConfig = $this->getConfig(); 00073 00074 // Performance 00075 if ( !$myConfig->getConfigParam( 'bl_perfLoadLanguages' ) ) { 00076 return; 00077 } 00078 00079 reset($this->aLanguages); 00080 $aLanguageURLs = $myConfig->getConfigParam( 'aLanguageURLs' ); 00081 00082 while ( list( $sKey, $oVal ) = each( $this->aLanguages ) ) { 00083 $this->aLanguages[$sKey]->link = $this->getParent()->getLink($oVal->id); 00084 } 00085 return $this->aLanguages; 00086 } 00087 }