OXID eShop CE  4.8.12
 All Classes Files Functions Variables Pages
theme_main.php
Go to the documentation of this file.
1 <?php
2 
10 {
11 
18  public function render()
19  {
20  $soxId = $this->getEditObjectId();
21 
22  $oTheme = oxNew('oxTheme');
23 
24  if (!$soxId) {
25  $soxId = $oTheme->getActiveThemeId();
26  }
27 
28  if ($oTheme->load($soxId)) {
29  $this->_aViewData["oTheme"] = $oTheme;
30  } else {
31  oxRegistry::get("oxUtilsView")->addErrorToDisplay( oxNew( "oxException", 'EXCEPTION_THEME_NOT_LOADED') );
32  }
33 
35 
36  if ( $this->themeInConfigFile() ) {
37  oxRegistry::get("oxUtilsView")->addErrorToDisplay( 'EXCEPTION_THEME_SHOULD_BE_ONLY_IN_DATABASE' );
38  }
39 
40  return 'theme_main.tpl';
41  }
42 
48  public function themeInConfigFile()
49  {
50  $blThemeSet = isset( $this->getConfig()->sTheme );
51  $blCustomThemeSet = isset( $this->getConfig()->sCustomTheme );
52 
53  if ( $blThemeSet || $blCustomThemeSet ) {
54  return true;
55  }
56  return false;
57  }
58 
59 
65  public function setTheme()
66  {
67  $sTheme = $this->getEditObjectId();
68  $oTheme = oxNew('oxtheme');
69  if (!$oTheme->load($sTheme)) {
70  oxRegistry::get("oxUtilsView")->addErrorToDisplay( oxNew( "oxException", 'EXCEPTION_THEME_NOT_LOADED') );
71  return;
72  }
73  try {
74  $oTheme->activate();
75  $this->resetContentCache();
76  } catch (oxException $oEx) {
77  oxRegistry::get("oxUtilsView")->addErrorToDisplay( $oEx );
78  $oEx->debugOut();
79  }
80  }
81 }