63 public function load( $sModuleId )
65 if ( $this->
loadModule($sModuleId) )
return true;
86 if ( is_array($aModulePaths) ) {
87 $sModuleId = array_search( $sModuleDir, $aModulePaths);
92 $sModuleId = $sModuleDir;
95 return $this->
load( $sModuleId );
108 $sMetadataPath = $sModulePath .
"/metadata.php";
110 if ( $sModulePath && file_exists( $sMetadataPath ) && is_readable( $sMetadataPath ) ) {
112 include $sMetadataPath;
114 $this->_blLegacy =
false;
115 $this->_blRegistered =
true;
116 $this->_blMetadata =
true;
117 $this->_blFile =
false;
118 $this->_aModule[
'active'] = $this->
isActive();
137 if ( isset( $aLegacyModules[$sModuleId] ) ) {
138 $this->_aModule = $aLegacyModules[$sModuleId];
139 $this->_blLegacy =
true;
140 $this->_blRegistered =
true;
141 $this->_blMetadata =
false;
142 $this->_blFile = empty( $sModuleDir );
143 $this->_aModule[
'active'] = $this->
isActive();
160 if ( !$sModulePath ) {
161 $sModulePath = $this->
getConfig()->getModulesDir() . $sModuleId;
164 if ( file_exists( $sModulePath ) && is_readable( $sModulePath ) ) {
167 $this->_aModule = array();
168 $this->_aModule[
'id'] = $sModuleId;
169 $this->_aModule[
'title'] = $sModuleId;
171 $this->_blLegacy =
true;
172 $this->_blRegistered =
false;
173 $this->_blMetadata =
false;
174 $this->_blFile = !is_dir($this->
getConfig()->getModulesDir() . $sModuleId );
175 $this->_aModule[
'active'] = $this->
isActive();
190 return $this->
getInfo(
"description", $iLang );
202 return $this->
getInfo(
"title", $iLang );
212 return $this->_aModule[
'id'];
222 return isset( $this->_aModule[
'extend'] ) ? $this->_aModule[
'extend'] : array();
235 $aModulePaths =
$myConfig->getConfigParam(
'aModulePaths' );
237 if (is_array( $aModulePaths )) {
238 foreach ($aModulePaths as $sId => $sPath) {
239 if (strpos($sModule, $sPath.
"/") === 0 ) {
245 $sModuleId = substr( $sModule, 0, strpos( $sModule,
"/" ) );
248 $sModuleId = $sModule;
262 public function getInfo( $sName, $iLang = null )
264 if (isset($this->_aModule[$sName])) {
266 if ( $iLang !== null && is_array($this->_aModule[$sName]) ) {
271 if ( !empty($this->_aModule[$sName]) ) {
272 if ( !empty( $this->_aModule[$sName][$sLang] ) ) {
273 $sValue = $this->_aModule[$sName][$sLang];
274 } elseif ( !empty( $this->_aModule[
'lang'] ) ) {
276 $sValue = $this->_aModule[$sName][$this->_aModule[
'lang']];
279 $sValue = reset( $this->_aModule[$sName] );
285 return $this->_aModule[$sName];
298 $sId = $this->
getId();
299 if ( !is_null( $sId ) ) {
307 if ( is_array( $aDisabledModules ) && !in_array( $sId, $aDisabledModules ) ) {
340 return isset( $aExtensions )
341 && is_array( $aExtensions )
342 && !empty( $aExtensions );
438 if ( is_null( $sModuleId ) ) {
439 $sModuleId = $this->
getId();
441 if ( isset( $sModuleId ) ) {
443 $this->
_callEvent(
'onDeactivate', $sModuleId );
470 if ( isset( $aModuleEvents[$sModuleId], $aModuleEvents[$sModuleId][$sEvent] ) ) {
471 $mEvent = $aModuleEvents[$sModuleId][$sEvent];
473 if ( is_callable( $mEvent ) ) {
474 call_user_func($mEvent);
490 $sShopId = $this->
getConfig()->getShopId();
491 $oDb->execute(
"UPDATE oxtplblocks SET oxactive = '".(
int) $iStatus.
"' WHERE oxmodule =". $oDb->quote( $sModule ).
"AND oxshopid = '$sShopId'" );
504 $sShopId = $this->
getConfig()->getShopId();
505 $oDb->execute(
"DELETE FROM `oxtplblocks` WHERE `oxmodule` =" . $oDb->quote( $sModule ) .
" AND `oxshopid` = " . $oDb->quote( $sShopId ) );
518 $oUtils->resetTemplateCache($aTemplates);
519 $oUtils->resetLanguageCache();
520 $oUtils->resetMenuCache();
523 $oUtilsObject->resetModuleVars();
539 if (is_array($aModuleArray)) {
540 foreach ($aModuleArray as $sClass => $aModuleChain) {
541 $aModules[$sClass] = implode(
'&', $aModuleChain);
558 if ( is_array( $aAllModuleArray ) && is_array( $aAddModuleArray ) ) {
559 foreach ( $aAddModuleArray as $sClass => $aModuleChain ) {
560 if ( !is_array( $aModuleChain ) ) {
561 $aModuleChain = array( $aModuleChain );
563 if ( isset( $aAllModuleArray[$sClass] ) ) {
564 foreach ( $aModuleChain as $sModule ) {
565 if ( !in_array( $sModule, $aAllModuleArray[$sClass] ) ) {
566 $aAllModuleArray[$sClass][] = $sModule;
570 $aAllModuleArray[$sClass] = $aModuleChain;
575 return $aAllModuleArray;
588 $aFilteredModules = array();
589 foreach ($aModules as $sClass => $aExtend) {
590 foreach ($aExtend as $sExtendPath) {
591 if (strstr($sExtendPath, $sModuleId.
'/')) {
592 $aFilteredModules[$sClass][] = $sExtendPath;
596 return $aFilteredModules;
609 $sModuleId = $this->
getId();
613 $sModulePath = $aModulePaths[$sModuleId];
616 if ( !$sModulePath && is_dir($this->
getConfig()->getModulesDir().$sModuleId) ) {
617 $sModulePath = $sModuleId;
633 return $this->
getConfig()->getModulesDir() . $sModuleDir;
645 return $this->
getConfig()->getAllModules();
655 return $this->
getConfig()->getConfigParam(
'aLegacyModules');
665 return $this->
getConfig()->getConfigParam(
'aDisabledModules');
675 return $this->
getConfig()->getConfigParam(
'aModulePaths');
685 return (array) $this->
getConfig()->getConfigParam(
'aModuleTemplates');
695 return (array) $this->
getConfig()->getConfigParam(
'aModuleFiles');
705 return (array) $this->
getConfig()->getConfigParam(
'aModuleVersions');
715 return (array) $this->
getConfig()->getConfigParam(
'aModuleEvents');
727 $sShopId = $this->
getConfig()->getShopId();
729 $blRes = $oDb->getOne(
"SELECT 1 FROM oxtplblocks WHERE oxmodule = ".$oDb->quote($sModuleId).
" AND oxshopid = '$sShopId' LIMIT 1" );
730 return (
bool) $blRes;
743 if (is_null($sModuleId)) {
744 $sModuleId = $this->
getId();
747 $sShopId = $this->
getConfig()->getShopId();
750 if ( is_array($aModuleBlocks) ) {
752 foreach ( $aModuleBlocks as $aValue ) {
755 $sTemplate = $aValue[
"template"];
756 $iPosition = $aValue[
"position"]?$aValue[
"position"]:1;
757 $sBlock = $aValue[
"block"];
758 $sFile = $aValue[
"file"];
760 $sSql =
"INSERT INTO `oxtplblocks` (`OXID`, `OXACTIVE`, `OXSHOPID`, `OXTEMPLATE`, `OXBLOCKNAME`, `OXPOS`, `OXFILE`, `OXMODULE`)
761 VALUES ('{$sOxId}', 1, '{$sShopId}', ".$oDb->quote($sTemplate).
", ".$oDb->quote($sBlock).
", ".$oDb->quote($iPosition).
", ".$oDb->quote($sFile).
", '{$sModuleId}')";
763 $oDb->execute( $sSql );
778 if (is_null($sModuleId)) {
779 $sModuleId = $this->
getId();
784 if ( is_array($aModuleTemplates) ) {
785 $aTemplates[$sModuleId] = $aModuleTemplates;
788 $oConfig->setConfigParam(
'aModuleTemplates', $aTemplates);
789 $oConfig->saveShopConfVar(
'aarr',
'aModuleTemplates', $aTemplates);
802 if (is_null($sModuleId)) {
803 $sModuleId = $this->
getId();
808 if ( is_array($aVersions) ) {
809 $aVersions[$sModuleId] = $sModuleVersion;
812 $oConfig->setConfigParam(
'aModuleVersions', $aVersions);
813 $oConfig->saveShopConfVar(
'aarr',
'aModuleVersions', $aVersions);
826 if (is_null($sModuleId)) {
827 $sModuleId = $this->
getId();
832 if ( is_array($aEvents) ) {
833 $aEvents[$sModuleId] = $aModuleEvents;
836 $oConfig->setConfigParam(
'aModuleEvents', $aEvents);
837 $oConfig->saveShopConfVar(
'aarr',
'aModuleEvents', $aEvents);
850 if (is_null($sModuleId)) {
851 $sModuleId = $this->
getId();
856 if ( is_array($aModuleFiles) ) {
857 $aFiles[$sModuleId] = array_change_key_case($aModuleFiles, CASE_LOWER);
860 $oConfig->setConfigParam(
'aModuleFiles', $aFiles);
861 $oConfig->saveShopConfVar(
'aarr',
'aModuleFiles', $aFiles);
874 if (is_null($sModuleId)) {
875 $sModuleId = $this->
getId();
878 $sShopId = $oConfig->getShopId();
881 if ( is_array($aModuleSettings) ) {
883 foreach ( $aModuleSettings as $aValue ) {
886 $sModule =
'module:'.$sModuleId;
887 $sName = $aValue[
"name"];
888 $sType = $aValue[
"type"];
889 $sValue = is_null($oConfig->getConfigParam($sName))?$aValue[
"value"]:$oConfig->getConfigParam($sName);
890 $sGroup = $aValue[
"group"];
893 if ( $aValue[
"constraints"] ) {
894 $sConstraints = $aValue[
"constraints"];
895 } elseif ( $aValue[
"constrains"] ) {
896 $sConstraints = $aValue[
"constrains"];
899 $iPosition = $aValue[
"position"]?$aValue[
"position"]:1;
901 $oConfig->setConfigParam($sName, $sValue);
902 $oConfig->saveShopConfVar($sType, $sName, $sValue, $sShopId, $sModule);
904 $sDeleteSql =
"DELETE FROM `oxconfigdisplay` WHERE OXCFGMODULE=".$oDb->quote($sModule).
" AND OXCFGVARNAME=".$oDb->quote($sName);
905 $sInsertSql =
"INSERT INTO `oxconfigdisplay` (`OXID`, `OXCFGMODULE`, `OXCFGVARNAME`, `OXGROUPING`, `OXVARCONSTRAINT`, `OXPOS`) ".
906 "VALUES ('{$sOxId}', ".$oDb->quote($sModule).
", ".$oDb->quote($sName).
", ".$oDb->quote($sGroup).
", ".$oDb->quote($sConstraints).
", ".$oDb->quote($iPosition).
")";
908 $oDb->execute( $sDeleteSql );
909 $oDb->execute( $sInsertSql );
923 if (is_null($sModuleId)) {
924 $sModuleId = $this->
getId();
931 $sShopId = $this->
getConfig()->getShopId();
933 $aTemplates =
oxDb::getDb()->getCol(
"SELECT oxtemplate FROM oxtplblocks WHERE oxmodule = '$sModuleId' AND oxshopid = '$sShopId'" );
953 if ( !empty( $aModuleInfo ) && is_array($aModuleInfo)) {
954 $aLegacyModules[$sModuleId][
"id"] = $sModuleId;
955 $aLegacyModules[$sModuleId][
"title"] = ( $sModuleName ) ? $sModuleName : $sModuleId;
956 $aLegacyModules[$sModuleId][
'extend'] = array();
958 foreach ( $aModuleInfo as $sKey => $sValue ) {
959 if ( strpos( $sValue,
"=>" ) > 1 ) {
960 $aClassInfo = explode(
"=>", $sValue );
961 $sClassName = trim( $aClassInfo[0] );
962 $sExtendString = trim( $aClassInfo[1] );
963 $aLegacyModules[$sModuleId][
'extend'][$sClassName] = $sExtendString;
968 if ( !empty( $aLegacyModules[$sModuleId][
'extend'] ) ) {
969 $this->
getConfig()->saveShopConfVar(
"aarr",
"aLegacyModules", $aLegacyModules );
987 $aModulePaths = $oConfig->getConfigParam(
'aModulePaths' );
988 $aModulePaths[$sModuleId] = $aModulePaths[$sModuleLegacyId];
989 unset( $aModulePaths[$sModuleLegacyId] );
991 $oConfig->saveShopConfVar(
'aarr',
'aModulePaths', $aModulePaths );
993 if ( isset($aModulePaths[$sModuleLegacyId]) ) {
994 $aModulePaths[$sModuleId] = $aModulePaths[$sModuleLegacyId];
995 unset( $aModulePaths[$sModuleLegacyId] );
996 $oConfig->saveShopConfVar(
'aarr',
'aModulePaths', $aModulePaths );
1000 $aDisabledModules = $oConfig->getConfigParam(
'aDisabledModules' );
1002 if ( is_array($aDisabledModules) ) {
1003 $iOldKey = array_search( $sModuleLegacyId, $aDisabledModules );
1004 if ( $iOldKey !==
false ) {
1005 unset( $aDisabledModules[$iOldKey] );
1006 $aDisabledModules[$iOldKey] = $sModuleId;
1007 $oConfig->saveShopConfVar(
'arr',
'aDisabledModules', $aDisabledModules );
1017 if ( extension_loaded(
'apc' ) && ini_get(
'apc.enabled' ) ) {
1029 $sModuleId = $this->
getId();
1031 if ( isset( $aDisabledModules ) && is_array( $aDisabledModules ) ) {
1032 $aDisabledModules = array_diff( $aDisabledModules, array($sModuleId) );
1033 $oConfig->setConfigParam(
'aDisabledModules', $aDisabledModules );
1034 $oConfig->saveShopConfVar(
'arr',
'aDisabledModules', $aDisabledModules );
1052 $oConfig->setConfigParam(
'aModules', $aModules );
1053 $oConfig->saveShopConfVar(
'aarr',
'aModules', $aModules );
1064 if ( !is_array( $aDisabledModules ) ) {
1065 $aDisabledModules = array();
1067 $aModules = array_merge( $aDisabledModules, array( $sModuleId ) );
1068 $aModules = array_unique( $aModules );
1070 $oConfig->saveShopConfVar(
'arr',
'aDisabledModules', $aModules );
1071 $oConfig->setConfigParam(
'aDisabledModules', $aModules );
1087 if ( count( $aInstalledModuleExtensions ) ) {
1090 if ( count( $aGarbage ) ) {
1091 $aInstalledExtensions = $this->
_removeGarbage( $aInstalledExtensions, $aGarbage );
1095 return $aInstalledExtensions;
1108 $aGarbage = $aModuleInstalledExtensions;
1110 foreach ( $aModuleMetaDataExtensions as $sClassName => $sClassPath ) {
1111 if ( isset( $aGarbage[$sClassName] ) ) {
1112 unset( $aGarbage[$sClassName][ array_search( $sClassPath, $aGarbage[$sClassName] )] );
1113 if ( count( $aGarbage[$sClassName] ) == 0 ) {
1114 unset( $aGarbage[$sClassName] );
1132 foreach ( $aGarbage as $sClassName => $aClassPaths ) {
1133 foreach ( $aClassPaths as $sClassPath ) {
1134 if ( isset( $aInstalledExtensions[$sClassName] ) ) {
1135 unset( $aInstalledExtensions[$sClassName][ array_search( $sClassPath, $aInstalledExtensions[$sClassName] )] );
1136 if ( count( $aInstalledExtensions[$sClassName] ) == 0 ) {
1137 unset( $aInstalledExtensions[$sClassName] );
1143 return $aInstalledExtensions;
1156 foreach ( $aModuleExtensions as $sClass => $mExtension ) {
1157 if ( is_array( $mExtension ) ) {
1158 foreach ( $mExtension as $sExtension ) {
1159 if ( ( isset( $aInstalledExtensions[$sClass] ) && in_array( $sExtension, $aInstalledExtensions[$sClass] ) ) ) {
1163 } elseif ( ( isset( $aInstalledExtensions[$sClass] ) && in_array( $mExtension, $aInstalledExtensions[$sClass] ) ) ) {
1180 foreach ( $aModuleExtensions as $mExtensions ) {
1181 if ( is_array( $mExtensions ) ) {
1182 $iCount += count( $mExtensions );
1202 $blActive = $iModuleExtensionsCount > 0 && $iActivatedModuleExtensionsCount == $iModuleExtensionsCount;
1215 $blInDisabledList =
false;
1218 if ( is_array( $aDisabledModules ) && in_array( $sId, $aDisabledModules ) ) {
1219 $blInDisabledList =
true;
1222 return $blInDisabledList;