theme_config.php

Go to the documentation of this file.
00001 <?php
00002 
00009 class Theme_Config extends Shop_Config
00010 {
00011     protected $_sTheme = 'shop_config.tpl';
00012 
00019     public function render()
00020     {
00021         $myConfig  = $this->getConfig();
00022 
00023         $sTheme  = $this->_sTheme = $this->getEditObjectId();
00024         $sShopId = $myConfig->getShopId();
00025 
00026         if (!isset( $sTheme ) ) {
00027             $sTheme = $this->_sTheme = $this->getConfig()->getConfigParam('sTheme');
00028         }
00029 
00030         $oTheme = oxNew('oxTheme');
00031         if ($oTheme->load($sTheme)) {
00032             $this->_aViewData["oTheme"] =  $oTheme;
00033 
00034             try {
00035                 oxLang::getInstance()->registerAdditionalLangFile(
00036                     $this->_getTemplateOptionsLanguageFile()
00037                 );
00038 
00039                 $aDbVariables = $this->_loadConfVars($sShopId, $this->_getModuleForConfigVars());
00040                 $this->_aViewData["var_constraints"] = $aDbVariables['constraints'];
00041                 $this->_aViewData["var_grouping"]    = $aDbVariables['grouping'];
00042                 foreach ($this->_aConfParams as $sType => $sParam) {
00043                     $this->_aViewData[$sParam] = $aDbVariables['vars'][$sType];
00044                 }
00045             } catch (oxException $oEx) {
00046                 oxUtilsView::getInstance()->addErrorToDisplay( $oEx );
00047                 $oEx->debugOut();
00048             }
00049         } else {
00050             oxUtilsView::getInstance()->addErrorToDisplay( new oxException('EXCEPTION_THEME_NOT_LOADED') );
00051         }
00052         return 'theme_config.tpl';
00053     }
00054 
00055 
00061     public function setTheme()
00062     {
00063         $sTheme = $this->getEditObjectId();
00064         $oTheme = oxNew('oxtheme');
00065         $oTheme->setTheme($sTheme);
00066     }
00067 
00073     protected function _getModuleForConfigVars()
00074     {
00075         return oxConfig::OXMODULE_THEME_PREFIX.$this->_sTheme;
00076     }
00077 
00083     protected function _getTemplateOptionsLanguageFile()
00084     {
00085         $iLang = oxLang::getInstance()->getTplLanguage();
00086         $sFile = $this->getConfig()->getDir(
00087                 "theme_options.php",
00088                 oxLang::getInstance()->getLanguageAbbr( $iLang ),
00089                 false,
00090                 $iLang,
00091                 null,
00092                 $this->_sTheme,
00093                 true,
00094                 true
00095         );
00096         if (!$sFile) {
00097             $oErr = new oxFileException('EXCEPTION_FILENOTFOUND');
00098             $oErr->setFileName('theme_options.php for the theme "'.$this->_sTheme.'"');
00099             throw $oErr;
00100         }
00101         return $sFile;
00102     }
00103 
00109     public function saveConfVars()
00110     {
00111         $myConfig = $this->getConfig();
00112 
00113         oxAdminDetails::save();
00114 
00115         $sTheme  = $this->_sTheme = $this->getEditObjectId();
00116         $sShopId = $myConfig->getShopId();
00117 
00118         $sModule = $this->_getModuleForConfigVars();
00119 
00120         foreach ($this->_aConfParams as $sType => $sParam) {
00121             $aConfVars = oxConfig::getParameter($sParam);
00122             if (is_array($aConfVars)) {
00123                 foreach ( $aConfVars as $sName => $sValue ) {
00124                     $myConfig->saveShopConfVar(
00125                             $sType,
00126                             $sName,
00127                             $this->_serializeConfVar($sType, $sName, $sValue),
00128                             $sShopId,
00129                             $sModule
00130                     );
00131                 }
00132             }
00133         }
00134     }
00135 }