32 protected $_aSkipFiles = array(
'functions.php',
'vendormetadata.php');
51 return $this->
getConfig()->getModulesWithExtendedClass();
64 if (!is_array($aModulePaths) || count($aModulePaths) < 1) {
69 if (is_array($aDisabledModules) && count($aDisabledModules) > 0 && count($aModulePaths) > 0) {
70 $aModulePaths = array_diff_key($aModulePaths, array_flip($aDisabledModules));
84 $aModulePaths = array();
86 if (is_array($aDisabledModules) && count($aDisabledModules) > 0) {
90 if (!is_array($aModulePaths) || count($aModulePaths) < 1) {
94 if (is_array($aModulePaths) || count($aModulePaths) > 0) {
95 $aModulePaths = array_intersect_key($aModulePaths, array_flip($aDisabledModules));
109 return $this->
getConfig()->getConfigParam(
'aModuleVersions');
119 return $this->
getConfig()->getConfigParam(
'aModules');
129 return (array) $this->
getConfig()->getConfigParam(
'aDisabledModules');
139 return $this->
getConfig()->getConfigParam(
'aModulePaths');
149 return (array) $this->
getConfig()->getConfigParam(
'aModuleEvents');
160 $aModulePaths = array();
162 if (is_array($aModules) && count($aModules) > 0) {
163 foreach ($aModules as $aModuleClasses) {
164 foreach ($aModuleClasses as $sModule) {
165 $sModuleId = substr($sModule, 0, strpos($sModule,
"/"));
166 $aModulePaths[$sModuleId] = $sModuleId;
171 return $aModulePaths;
181 return (array) $this->
getConfig()->getConfigParam(
'aModuleFiles');
191 return $this->
getConfig()->getConfigParam(
'aModuleTemplates');
208 $aDisabledModuleClasses = array();
209 if (isset($aDisabledModules) && is_array($aDisabledModules)) {
211 foreach ($aDisabledModules as $sId) {
212 $sPath = $aModulePaths[$sId];
213 if (!isset($sPath)) {
216 foreach ($aModules as $aModuleClasses) {
217 foreach ($aModuleClasses as $sModuleClass) {
218 if (strpos($sModuleClass, $sPath .
"/") === 0) {
219 $aDisabledModuleClasses[] = $sModuleClass;
226 return $aDisabledModuleClasses;
237 $aDeletedModuleIds = array_keys($aDeletedModules);
272 $oModuleMetadataValidator = $oModuleValidatorFactory->getModuleMetadataValidator();
275 $aDeletedExt = array();
277 foreach ($aModulesIds as $sModuleId) {
278 $oModule->setModuleData(array(
'id' => $sModuleId));
279 if (!$oModuleMetadataValidator->validate($oModule)) {
280 $aDeletedExt[$sModuleId][
'files'] = array($sModuleId .
'/metadata.php');
283 if ($aInvalidExtensions) {
284 $aDeletedExt[$sModuleId][
'extensions'] = $aInvalidExtensions;
303 if (is_array($aAllModuleArray) && is_array($aRemModuleArray)) {
304 foreach ($aAllModuleArray as $sClass => $aModuleChain) {
305 if (!is_array($aModuleChain)) {
306 $aModuleChain = array($aModuleChain);
308 if (isset($aRemModuleArray[$sClass])) {
309 if (!is_array($aRemModuleArray[$sClass])) {
310 $aRemModuleArray[$sClass] = array($aRemModuleArray[$sClass]);
312 $aAllModuleArray[$sClass] = array();
313 foreach ($aModuleChain as $sModule) {
314 if (!in_array($sModule, $aRemModuleArray[$sClass])) {
315 $aAllModuleArray[$sClass][] = $sModule;
318 if (!count($aAllModuleArray[$sClass])) {
319 unset ($aAllModuleArray[$sClass]);
322 $aAllModuleArray[$sClass] = $aModuleChain;
327 return $aAllModuleArray;
340 if (is_array($aModuleArray)) {
341 foreach ($aModuleArray as $sClass => $aModuleChain) {
342 $aModules[$sClass] = implode(
'&', $aModuleChain);
356 return oxNew(
'oxModule');
367 $aExtensionsToDelete = array();
368 foreach ($aModuleIds as $sModuleId) {
369 $aExtensionsToDelete = array_merge_recursive($aExtensionsToDelete, $this->
getModuleExtensions($sModuleId));
372 $aUpdatedExtensions = $this->
diffModuleArrays($aModuleExtensions, $aExtensionsToDelete);
375 $this->
getConfig()->saveShopConfVar(
'aarr',
'aModules', $aUpdatedExtensionsChains);
387 $aDisabledExtensionIds = array_diff($aDisabledExtensionIds, $aDeletedExtIds);
388 $oConfig->saveShopConfVar(
'arr',
'aDisabledModules', $aDisabledExtensionIds);
400 foreach ($aDeletedModule as $sDeletedModuleId) {
401 if (isset($aModulePaths[$sDeletedModuleId])) {
402 unset($aModulePaths[$sDeletedModuleId]);
406 $this->
getConfig()->saveShopConfVar(
'aarr',
'aModulePaths', $aModulePaths);
418 foreach ($aDeletedModule as $sDeletedModuleId) {
419 if (isset($aModuleVersions[$sDeletedModuleId])) {
420 unset($aModuleVersions[$sDeletedModuleId]);
424 $this->
getConfig()->saveShopConfVar(
'aarr',
'aModuleVersions', $aModuleVersions);
436 foreach ($aDeletedModule as $sDeletedModuleId) {
437 if (isset($aModuleEvents[$sDeletedModuleId])) {
438 unset($aModuleEvents[$sDeletedModuleId]);
442 $this->
getConfig()->saveShopConfVar(
'aarr',
'aModuleEvents', $aModuleEvents);
454 foreach ($aDeletedModule as $sDeletedModuleId) {
455 if (isset($aModuleFiles[$sDeletedModuleId])) {
456 unset($aModuleFiles[$sDeletedModuleId]);
460 $this->
getConfig()->saveShopConfVar(
'aarr',
'aModuleFiles', $aModuleFiles);
472 foreach ($aDeletedModule as $sDeletedModuleId) {
473 if (isset($aModuleTemplates[$sDeletedModuleId])) {
474 unset($aModuleTemplates[$sDeletedModuleId]);
478 $this->
getConfig()->saveShopConfVar(
'aarr',
'aModuleTemplates', $aModuleTemplates);
490 if (!is_array($aDeletedExtIds) || !count($aDeletedExtIds)) {
496 $aConfigIds = $sDelExtIds = array();
497 foreach ($aDeletedExtIds as $sDeletedExtId) {
498 $aConfigIds[] = $oDb->quote(
'module:' . $sDeletedExtId);
499 $sDelExtIds[] = $oDb->quote($sDeletedExtId);
502 $sConfigIds = implode(
', ', $aConfigIds);
503 $sDelExtIds = implode(
', ', $sDelExtIds);
505 $aSql[] =
"DELETE FROM oxconfig where oxmodule IN ($sConfigIds)";
506 $aSql[] =
"DELETE FROM oxconfigdisplay where oxcfgmodule IN ($sConfigIds)";
507 $aSql[] =
"DELETE FROM oxtplblocks where oxmodule IN ($sDelExtIds)";
509 foreach ($aSql as $sQuery) {
510 $oDb->execute($sQuery);
523 public function getModulesFromDir($sModulesDir, $sVendorDir = null)
525 $sModulesDir =
oxRegistry::get(
'oxUtilsFile')->normalizeDir($sModulesDir);
527 foreach (glob($sModulesDir .
'*') as $sModuleDirPath) {
529 $sModuleDirPath .= (is_dir($sModuleDirPath)) ?
'/' :
'';
530 $sModuleDirName = basename($sModuleDirPath);
533 if (in_array($sModuleDirName, $this->_aSkipFiles) || (!is_dir($sModuleDirPath) && substr($sModuleDirName, -4) !=
".php")) {
539 $this->getModulesFromDir($sModuleDirPath, basename($sModuleDirPath));
543 $sModuleDirName = (!empty($sVendorDir)) ? $sVendorDir .
'/' . $sModuleDirName : $sModuleDirName;
544 if ($oModule->loadByDir($sModuleDirName)) {
545 $sModuleId = $oModule->getId();
546 $this->_aModules[$sModuleId] = $oModule;
550 if (!is_array($aModulePaths) || !array_key_exists($sModuleId, $aModulePaths)) {
559 $oModuleCache =
oxNew(
'oxModuleCache', $oModule);
561 $oModuleInstaller =
oxNew(
'oxModuleInstaller', $oModuleCache);
563 $oModuleInstaller->deactivate($oModule);
570 if ($this->_aModules !== null) {
571 uasort($this->_aModules, array($this,
'_sortModules'));
584 return oxNew(
'oxModuleValidatorFactory');
597 return array_unique(array_merge($aModuleIdsFromExtensions, $aModuleIdsFromFiles));
609 if (!isset($this->_aModuleExtensions)) {
610 $aModuleExtension = $this->
getConfig()->getModulesWithExtendedClass();
612 $aExtension = array();
613 foreach ($aModuleExtension as $sOxClass => $aFiles) {
614 foreach ($aFiles as $sFilePath) {
615 $sId = $oModule->getIdByPath($sFilePath);
616 $aExtension[$sId][$sOxClass][] = $sFilePath;
620 $this->_aModuleExtensions = $aExtension;
623 return $this->_aModuleExtensions[$sModuleId] ? $this->_aModuleExtensions[$sModuleId] : array();
636 return strcasecmp($oModule1->getTitle(), $oModule2->getTitle());
648 if (is_dir($sModuleDir) && file_exists($sModuleDir .
'vendormetadata.php')) {
664 $aModules = $this->
getConfig()->getConfigParam(
'aModules');
665 if (is_array($aModules)) {
666 $sModules = implode(
'&', $aModules);
668 if (preg_match(
"@(^|&+)" . $sModuleDir .
"\b@", $sModules)) {
686 $aModulePaths[$sModuleId] = $sModulePath;
687 $this->
getConfig()->saveShopConfVar(
'aarr',
'aModulePaths', $aModulePaths);
699 $aModuleIds = array();
702 foreach ($aModule as $sFilePath) {
703 $sModuleId = $oModule->getIdByPath($sFilePath);
704 $aModuleIds[] = $sModuleId;
721 $aDeletedExt = array();
723 foreach ($aModules as $sOxClass => $aModulesList) {
724 foreach ($aModulesList as $sModulePath) {
725 $sExtPath = $this->
getConfig()->getModulesDir() . $sModulePath .
'.php';
726 if (!file_exists($sExtPath)) {
727 $aDeletedExt[$sOxClass][] = $sModulePath;