language_list.php

Go to the documentation of this file.
00001 <?php
00002 
00006 class Language_List extends oxAdminList
00007 {
00008 
00014     protected $_sDefSort = 'sort';
00015 
00021     protected $_sDefSortOrder = 'asc';
00022 
00029     public function deleteEntry()
00030     {
00031 
00032         $myConfig = $this->getConfig();
00033 
00034         $sOxId = oxConfig::getParameter( 'oxid' );
00035 
00036         $aLangData['params']  = $myConfig->getConfigParam( 'aLanguageParams' );
00037         $aLangData['lang']    = $myConfig->getConfigParam( 'aLanguages' );
00038         $aLangData['urls']    = $myConfig->getConfigParam( 'aLanguageURLs' );
00039         $aLangData['sslUrls'] = $myConfig->getConfigParam( 'aLanguageSSLURLs' );
00040 
00041         $iBaseId = (int)$aLangData['params'][$sOxId]['baseId'];
00042 
00043         // unsetting selected lang from languages arrays
00044         unset( $aLangData['params'][$sOxId] );
00045         unset( $aLangData['lang'][$sOxId] );
00046         unset( $aLangData['urls'][$iBaseId] );
00047         unset( $aLangData['sslUrls'][$iBaseId] );
00048 
00049         //saving languages info back to DB
00050         $myConfig->saveShopConfVar( 'aarr', 'aLanguageParams', serialize($aLangData['params']) );
00051         $myConfig->saveShopConfVar( 'aarr', 'aLanguages', serialize($aLangData['lang']) );
00052         $myConfig->saveShopConfVar( 'arr',  'aLanguageURLs', serialize($aLangData['urls']) );
00053         $myConfig->saveShopConfVar( 'arr',  'aLanguageSSLURLs', serialize($aLangData['sslUrls']) );
00054 
00055         //updating oConfig object
00056         $myConfig->setConfigParam( 'aLanguageParams', $aLangData['params'] );
00057         $myConfig->setConfigParam( 'aLanguages', $aLangData['lang'] );
00058         $myConfig->setConfigParam( 'aLanguageURLs', $aLangData['urls'] );
00059         $myConfig->setConfigParam( 'aLanguageSSLURLs', $aLangData['sslUrls'] );
00060 
00061         //if deleted language was default, setting defalt lang to 0
00062         if ( $iBaseId == $myConfig->getConfigParam( 'sDefaultLang' ) ) {
00063             $myConfig->saveShopConfVar( 'str',  'sDefaultLang', 0 );
00064             $myConfig->setConfigParam( 'sDefaultLang', 0 );
00065         }
00066     }
00067 
00074     public function render()
00075     {
00076 
00077         parent::render();
00078         $this->_aViewData['mylist'] = $this->_getLanguagesList();
00079 
00080         return "language_list.tpl";
00081     }
00082 
00088     protected function _getLanguagesList()
00089     {
00090         $aLangParams  = $this->getConfig()->getConfigParam( 'aLanguageParams' );
00091         $aLanguages   = oxLang::getInstance()->getLanguageArray();
00092         $sDefaultLang = $this->getConfig()->getConfigParam( 'sDefaultLang' );
00093 
00094         foreach( $aLanguages as $sKey => $sValue ) {
00095             $sOxId = $sValue->oxid;
00096             $aLanguages[$sKey]->active  = $aLangParams[$sOxId]["active"];
00097             $aLanguages[$sKey]->default = ($aLangParams[$sOxId]["baseId"] == $sDefaultLang) ? true : false;
00098             $aLanguages[$sKey]->sort   = $aLangParams[$sOxId]["sort"];
00099         }
00100 
00101         if ( is_array($aLangParams) ) {
00102             $sSrotParam = $this->getConfig()->getParameter( 'sort' );
00103 
00104             if ( !empty($sSrotParam) ) {
00105                 $this->_sDefSort = $sSrotParam;
00106 
00107                 if ( $sSrotParam == 'active' ) {
00108                     //reverting sort order for field 'active'
00109                     $this->_sDefSortOrder = 'desc';
00110                 }
00111             }
00112 
00113             uasort( $aLanguages, array($this, '_sortLanguagesCallback') );
00114         }
00115 
00116         return $aLanguages;
00117     }
00118 
00128     protected function _sortLanguagesCallback( $oLang1, $oLang2 )
00129     {
00130         $sSortParam = $this->_sDefSort;
00131         $sVal1 = is_string($oLang1->$sSortParam) ? strtolower( $oLang1->$sSortParam ) : $oLang1->$sSortParam;
00132         $sVal2 = is_string($oLang2->$sSortParam) ? strtolower( $oLang2->$sSortParam ) : $oLang2->$sSortParam;
00133 
00134         if ( $this->_sDefSortOrder == 'asc' ) {
00135             return ($sVal1 < $sVal2) ? -1 : 1;
00136         } else {
00137             return ($sVal1 > $sVal2) ? -1 : 1;
00138         }
00139     }
00140 }

Generated on Wed Apr 22 12:26:29 2009 for OXID eShop CE by  doxygen 1.5.5