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 
00114         $sTheme  = $this->_sTheme = $this->getEditObjectId();
00115         $sShopId = $myConfig->getShopId();
00116 
00117         $sModule = $this->_getModuleForConfigVars();
00118 
00119         foreach ($this->_aConfParams as $sType => $sParam) {
00120             $aConfVars = oxConfig::getParameter($sParam);
00121             if (is_array($aConfVars)) {
00122                 foreach ( $aConfVars as $sName => $sValue ) {
00123                     $myConfig->saveShopConfVar(
00124                             $sType,
00125                             $sName,
00126                             $this->_serializeConfVar($sType, $sName, $sValue),
00127                             $sShopId,
00128                             $sModule
00129                     );
00130                 }
00131             }
00132         }
00133     }
00134 }