OXID eShop CE  4.8.12
 All Classes Files Functions Variables Pages
module_main.php
Go to the documentation of this file.
1 <?php
2 
10 {
11 
18  public function render()
19  {
20  if ( oxConfig::getParameter("moduleId") ) {
21  $sModuleId = oxConfig::getParameter("moduleId");
22  } else {
23  $sModuleId = $this->getEditObjectId();
24  }
25 
26  $oModule = oxNew('oxModule');
27 
28  if ( $sModuleId ) {
29  if ( $oModule->load( $sModuleId ) ) {
30  $iLang = oxRegistry::getLang()->getTplLanguage();
31 
32  $this->_aViewData["oModule"] = $oModule;
33  $this->_aViewData["sModuleName"] = basename( $oModule->getInfo( "title", $iLang ) );
34  $this->_aViewData["sModuleId"] = str_replace( "/", "_", $oModule->getModulePath() );
35  } else {
36  oxRegistry::get("oxUtilsView")->addErrorToDisplay( new oxException('EXCEPTION_MODULE_NOT_LOADED') );
37  }
38  }
39 
41 
42  return 'module_main.tpl';
43  }
44 
50  public function activateModule()
51  {
52  $sModule = $this->getEditObjectId();
53  $oModule = oxNew('oxModule');
54  if (!$oModule->load($sModule)) {
55  oxRegistry::get("oxUtilsView")->addErrorToDisplay( new oxException('EXCEPTION_MODULE_NOT_LOADED') );
56  return;
57  }
58  try {
59  if ( $oModule->activate() ) {
60  $this->_aViewData["updatenav"] = "1";
61  }
62  } catch (oxException $oEx) {
63  oxRegistry::get("oxUtilsView")->addErrorToDisplay( $oEx );
64  $oEx->debugOut();
65  }
66  }
67 
73  public function deactivateModule()
74  {
75  $sModule = $this->getEditObjectId();
76  $oModule = oxNew('oxModule');
77  if (!$oModule->load($sModule)) {
78  oxRegistry::get("oxUtilsView")->addErrorToDisplay( new oxException('EXCEPTION_MODULE_NOT_LOADED') );
79  return;
80  }
81  try {
82  if ( $oModule->deactivate() ) {
83  $this->_aViewData["updatenav"] = "1";
84  }
85  } catch (oxException $oEx) {
86  oxRegistry::get("oxUtilsView")->addErrorToDisplay( $oEx );
87  $oEx->debugOut();
88  }
89  }
90 
98  public function saveLegacyModule()
99  {
100  $aModuleInfo = explode( "\n", trim( oxConfig::getParameter("aExtendedClasses") ) );
101  $sModuleLegacyId = trim( $this->getEditObjectId() );
102  $sModuleId = trim( oxConfig::getParameter("moduleId") );
103  $sModuleName = trim( oxConfig::getParameter("moduleName") );
104 
105  $oModule = oxNew('oxModule');
106  $sModuleId = $oModule->saveLegacyModule($sModuleId, $sModuleName, $aModuleInfo);
107 
108  if ( $sModuleLegacyId != $sModuleId ) {
109  $oModule->updateModuleIds( $sModuleLegacyId, $sModuleId );
110  $this->setEditObjectId($sModuleId);
111  }
112  }
113 }