Go to the documentation of this file.00001 <?php
00002
00009 class Module_Config extends Shop_Config
00010 {
00011 protected $_sModule = 'shop_config.tpl';
00012
00019 public function render()
00020 {
00021 $myConfig = $this->getConfig();
00022
00023 $sModuleId = $this->_sModuleId = $this->getEditObjectId();
00024 $sShopId = $myConfig->getShopId();
00025
00026 $oModule = oxNew( 'oxModule' );
00027
00028 if ( $sModuleId && $oModule->load( $sModuleId ) ) {
00029 try {
00030 $aDbVariables = $this->_loadMetadataConfVars($oModule->getInfo("settings"));
00031
00032 $this->_aViewData["var_constraints"] = $aDbVariables['constraints'];
00033 $this->_aViewData["var_grouping"] = $aDbVariables['grouping'];
00034 $iCount = 0;
00035 foreach ($this->_aConfParams as $sType => $sParam) {
00036 $this->_aViewData[$sParam] = $aDbVariables['vars'][$sType];
00037 $iCount += count($aDbVariables['vars'][$sType]);
00038 }
00039 } catch (oxException $oEx) {
00040 oxRegistry::get("oxUtilsView")->addErrorToDisplay( $oEx );
00041 $oEx->debugOut();
00042 }
00043 } else {
00044 oxRegistry::get("oxUtilsView")->addErrorToDisplay( new oxException('EXCEPTION_MODULE_NOT_LOADED') );
00045 }
00046
00047 $this->_aViewData["oModule"] = $oModule;
00048
00049 return 'module_config.tpl';
00050 }
00051
00057 protected function _getModuleForConfigVars()
00058 {
00059 return oxConfig::OXMODULE_MODULE_PREFIX . $this->_sModuleId;
00060 }
00061
00073 public function _loadMetadataConfVars($aModuleSettings)
00074 {
00075 $oConfig = $this->getConfig();
00076
00077 $aConfVars = array(
00078 "bool" => array(),
00079 "str" => array(),
00080 "arr" => array(),
00081 "aarr" => array(),
00082 "select" => array(),
00083 );
00084 $aVarConstraints = array();
00085 $aGrouping = array();
00086
00087 $aDbVariables = $this->_loadConfVars($oConfig->getShopId(), $this->_getModuleForConfigVars());
00088
00089 if ( is_array($aModuleSettings) ) {
00090
00091 foreach ( $aModuleSettings as $aValue ) {
00092
00093 $sName = $aValue["name"];
00094 $sType = $aValue["type"];
00095
00096 if (is_null($oConfig->getConfigParam($sName)) ) {
00097 switch ($aValue["type"]){
00098 case "arr":
00099 $sValue = $this->_arrayToMultiline( unserialize( $aValue["value"] ) );
00100 break;
00101 case "aarr":
00102 $sValue = $this->_aarrayToMultiline( unserialize( $aValue["value"] ) );
00103 break;
00104 }
00105 $sValue = getStr()->htmlentities( $sValue );
00106 } else {
00107 $sValue = $aDbVariables['vars'][$sType][$sName];
00108 }
00109
00110 $sGroup = $aValue["group"];
00111
00112 $sConstraints = "";
00113 if ( $aValue["constraints"] ) {
00114 $sConstraints = $aValue["constraints"];
00115 } elseif ( $aValue["constrains"] ) {
00116 $sConstraints = $aValue["constrains"];
00117 }
00118
00119 $aConfVars[$sType][$sName] = $sValue;
00120 $aVarConstraints[$sName] = $this->_parseConstraint( $sType, $sConstraints );
00121 if ($sGroup) {
00122 if (!isset($aGrouping[$sGroup])) {
00123 $aGrouping[$sGroup] = array($sName=>$sType);
00124 } else {
00125 $aGrouping[$sGroup][$sName] = $sType;
00126 }
00127 }
00128 }
00129 }
00130
00131 return array(
00132 'vars' => $aConfVars,
00133 'constraints' => $aVarConstraints,
00134 'grouping' => $aGrouping,
00135 );
00136 }
00137
00138
00144 public function saveConfVars()
00145 {
00146 $myConfig = $this->getConfig();
00147
00148
00149 $sModuleId = $this->_sModuleId = $this->getEditObjectId();
00150 $sShopId = $myConfig->getShopId();
00151
00152 $sModuleId = $this->_getModuleForConfigVars();
00153
00154 foreach ($this->_aConfParams as $sType => $sParam) {
00155 $aConfVars = oxConfig::getParameter($sParam);
00156 if (is_array($aConfVars)) {
00157 foreach ( $aConfVars as $sName => $sValue ) {
00158 $myConfig->saveShopConfVar(
00159 $sType,
00160 $sName,
00161 $this->_serializeConfVar($sType, $sName, $sValue),
00162 $sShopId,
00163 $sModuleId
00164 );
00165 }
00166 }
00167 }
00168 }
00169
00170 }