theme_main.php

Go to the documentation of this file.
00001 <?php
00002 
00009 class Theme_Main extends oxAdminDetails
00010 {
00011 
00018     public function render()
00019     {
00020         $soxId = $this->getEditObjectId();
00021 
00022         $oTheme = oxNew('oxTheme');
00023 
00024         if (!$soxId) {
00025             $soxId = $oTheme->getActiveThemeId();
00026         }
00027 
00028         if ($oTheme->load($soxId)) {
00029             $this->_aViewData["oTheme"] =  $oTheme;
00030         } else {
00031             oxRegistry::get("oxUtilsView")->addErrorToDisplay( oxNew( "oxException", 'EXCEPTION_THEME_NOT_LOADED') );
00032         }
00033 
00034         parent::render();
00035 
00036         if ( $this->themeInConfigFile() ) {
00037             oxRegistry::get("oxUtilsView")->addErrorToDisplay( 'EXCEPTION_THEME_SHOULD_BE_ONLY_IN_DATABASE' );
00038         }
00039 
00040         return 'theme_main.tpl';
00041     }
00042     
00048     public function themeInConfigFile()
00049     {
00050         $blThemeSet = isset( $this->getConfig()->sTheme );
00051         $blCustomThemeSet = isset( $this->getConfig()->sCustomTheme );
00052         
00053         if ( $blThemeSet || $blCustomThemeSet ) {
00054             return true;
00055         }
00056         return false;
00057     }
00058 
00059 
00065     public function setTheme()
00066     {
00067         $sTheme = $this->getEditObjectId();
00068         $oTheme = oxNew('oxtheme');
00069         if (!$oTheme->load($sTheme)) {
00070             oxRegistry::get("oxUtilsView")->addErrorToDisplay( oxNew( "oxException", 'EXCEPTION_THEME_NOT_LOADED') );
00071             return;
00072         }
00073         try {
00074             $oTheme->activate();
00075             $this->resetContentCache();
00076         } catch (oxException $oEx) {
00077             oxRegistry::get("oxUtilsView")->addErrorToDisplay( $oEx );
00078             $oEx->debugOut();
00079         }
00080     }
00081 }