OXID eShop CE  4.10.4
 All Classes Namespaces 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 
57  return false;
58  }
59 
60 
66  public function setTheme()
67  {
68  $sTheme = $this->getEditObjectId();
70  $oTheme = oxNew('oxtheme');
71  if (!$oTheme->load($sTheme)) {
72  oxRegistry::get("oxUtilsView")->addErrorToDisplay(oxNew("oxException", 'EXCEPTION_THEME_NOT_LOADED'));
73 
74  return;
75  }
76  try {
77  $oTheme->activate();
78  $this->resetContentCache();
79  } catch (oxException $oEx) {
80  oxRegistry::get("oxUtilsView")->addErrorToDisplay($oEx);
81  $oEx->debugOut();
82  }
83  }
84 }