67 if (defined(
'OXID_PHP_UNIT')) {
68 self::$_instance = null;
74 $oUtilsObject =
new oxUtilsObject();
75 self::$_instance = $oUtilsObject->oxNew(
'oxUtilsObject');
90 $sClassName = strtolower($sClassName);
91 self::$_aClassInstances[$sClassName] = $oInstance;
99 self::$_aClassInstances = array();
109 self::$_aModuleVars = array();
111 $sMask =
oxRegistry::get(
"oxConfigFile")->getVar(
"sCompileDir") .
"/" . self::CACHE_FILE_PREFIX .
".*.txt";
112 $aFiles = glob($sMask);
113 if (is_array($aFiles)) {
114 foreach ($aFiles as $sFile) {
115 if (is_file($sFile)) {
134 $aArgs = func_get_args();
136 $iArgCnt = count($aArgs);
137 $blCacheObj = $iArgCnt < 2;
138 $sClassName = strtolower($sClassName);
140 if (isset(self::$_aClassInstances[$sClassName])) {
141 return self::$_aClassInstances[$sClassName];
143 if (!defined(
'OXID_PHP_UNIT') && $blCacheObj) {
144 $sCacheKey = ($iArgCnt) ? $sClassName . md5(serialize($aArgs)) : $sClassName;
145 if (isset(self::$_aInstanceCache[$sCacheKey])) {
146 return clone self::$_aInstanceCache[$sCacheKey];
151 if (!defined(
'OXID_PHP_UNIT') && isset($this->_aClassNameCache[$sClassName])) {
152 $sActionClassName = $this->_aClassNameCache[$sClassName];
156 if (!class_exists($sActionClassName)) {
158 $oEx =
oxNew(
"oxSystemComponentException");
159 $oEx->setMessage(
'EXCEPTION_SYSTEMCOMPONENT_CLASSNOTFOUND');
160 $oEx->setComponent($sClassName);
165 $this->_aClassNameCache[$sClassName] = $sActionClassName;
168 $oActionObject = $this->
_getObject($sActionClassName, $iArgCnt, $aArgs);
169 if ($blCacheObj && $oActionObject instanceof
oxBase) {
170 self::$_aInstanceCache[$sCacheKey] = clone $oActionObject;
173 return $oActionObject;
188 protected function _getObject($sClassName, $iArgCnt, $aParams)
193 $oObj =
new $sClassName();
196 $oObj =
new $sClassName($aParams[0]);
199 $oObj =
new $sClassName($aParams[0], $aParams[1]);
202 $oObj =
new $sClassName($aParams[0], $aParams[1], $aParams[2]);
207 $oRo =
new ReflectionClass($sClassName);
208 $oObj = $oRo->newInstanceArgs($aParams);
209 }
catch (ReflectionException $oRefExcp) {
212 $oEx =
oxNew(
"oxSystemComponentException");
213 $oEx->setMessage($oRefExcp->getMessage());
214 $oEx->setComponent($sClassName);
232 if ($sClassName && isset(self::$_aInstanceCache[$sClassName])) {
233 unset(self::$_aInstanceCache[$sClassName]);
239 if (is_array(self::$_aInstanceCache)) {
240 foreach (self::$_aInstanceCache as $sKey => $oInstance) {
241 unset(self::$_aInstanceCache[$sKey]);
245 self::$_aInstanceCache = array();
256 substr(md5(uniqid(
'',
true) .
'|' . microtime()), 0, 32);
272 $aClassChain = array();
275 if (is_array($aModules)) {
277 $aModules = array_change_key_case($aModules);
279 if (array_key_exists($sClassName, $aModules)) {
283 $aClassChain = explode(
"&", $aModules[$sClassName]);
287 if (count($aClassChain)) {
288 $sParent = $sClassName;
291 $sParent = str_replace(chr(0),
'', $sParent);
299 $sClassName = basename($sClassName);
313 $aDisabledModules = $this->
getModuleVar(
'aDisabledModules');
316 if (is_array($aDisabledModules) && count($aDisabledModules) > 0) {
317 foreach ($aDisabledModules as $sId) {
319 if (is_array($aModulePaths) && array_key_exists($sId, $aModulePaths)) {
320 $sPath = $aModulePaths[$sId];
321 if (!isset($sPath)) {
325 foreach ($aClassChain as $sKey => $sModuleClass) {
326 if (strpos($sModuleClass, $sPath .
"/") === 0) {
327 unset($aClassChain[$sKey]);
328 } elseif (strpos($sPath,
".")) {
330 if (strpos($sPath, strtolower($sModuleClass)) === 0) {
331 unset($aClassChain[$sKey]);
349 $oModule =
oxNew(
"oxModule");
350 $sModuleId = $oModule->getIdByPath($sModule);
351 $oModule->load($sModuleId);
354 $oModuleCache =
oxNew(
'oxModuleCache', $oModule);
356 $oModuleInstaller =
oxNew(
'oxModuleInstaller', $oModuleCache);
358 $oModuleInstaller->deactivate($oModule);
374 $sParent = $sBaseModule;
375 $sClassName = $sBaseModule;
378 foreach ($aClassChain as $sModule) {
385 $sModule = str_replace(chr(0),
'', $sModule);
388 $sModuleClass = basename($sModule);
390 if (!class_exists($sModuleClass,
false)) {
391 $sParentClass = basename($sParent);
392 $sModuleParentClass = $sModuleClass .
"_parent";
395 if (!class_exists($sModuleParentClass,
false)) {
397 if (function_exists(
'class_alias')) {
398 class_alias($sParentClass, $sModuleParentClass);
400 eval(
"abstract class $sModuleParentClass extends $sParentClass {}");
403 $sParentPath =
oxRegistry::get(
"oxConfigFile")->getVar(
"sShopDir") .
"/modules/" . $sModule .
".php";
406 if (file_exists($sParentPath)) {
407 include_once $sParentPath;
408 } elseif (!class_exists($sModuleClass)) {
411 if ($sParentClass ==
"oxconfig") {
412 $oConfig = $this->
_getObject(
"oxconfig", 0, null);
417 $blDisableModuleOnError = !
oxRegistry::get(
"oxConfigFile")->getVar(
"blDoNotDisableModuleOnError");
418 if ($blDisableModuleOnError) {
423 $oEx =
oxNew(
"oxSystemComponentException");
424 $oEx->setMessage(
"EXCEPTION_SYSTEMCOMPONENT_CLASSNOTFOUND");
425 $oEx->setComponent($sModuleClass);
432 $sClassName = $sModule;
461 if (isset(self::$_aModuleVars[$sModuleVarName])) {
462 return self::$_aModuleVars[$sModuleVarName];
469 if (is_null($aValue)) {
475 self::$_aModuleVars[$sModuleVarName] = $aValue;
488 if (is_null($aValues)) {
489 self::$_aModuleVars = null;
491 self::$_aModuleVars[$sModuleVarName] = $aValues;
504 $sFileName = dirname(__FILE__) .
"/oxconfk.php";
505 $sCfgFile =
new oxConfigFile($sFileName);
507 return $sCfgFile->getVar(
"sConfigKey");
519 if (isset(self::$_aModuleVars[
"urlMap"])) {
520 return self::$_aModuleVars[
"urlMap"];
525 if (!is_null($aMap)) {
526 self::$_aModuleVars[
"urlMap"] = $aMap;
536 $sSelect =
"SELECT oxshopid, oxvarname, DECODE( oxvarvalue , " . $oDb->quote($sConfKey) .
" ) as oxvarvalue " .
537 "FROM oxconfig WHERE oxvarname in ('aLanguageURLs','sMallShopURL','sMallSSLShopURL')";
539 $oRs = $oDb->select($sSelect,
false,
false);
541 if ($oRs && $oRs->recordCount() > 0) {
543 $iShp = (int) $oRs->fields[0];
544 $sVar = $oRs->fields[1];
545 $sURL = $oRs->fields[2];
547 if ($sVar ==
'aLanguageURLs') {
548 $aUrls = unserialize($sURL);
549 if (is_array($aUrls) && count($aUrls)) {
550 $aUrls = array_filter($aUrls);
551 $aUrls = array_fill_keys($aUrls, $iShp);
552 $aMap = array_merge($aMap, $aUrls);
555 $aMap[$sURL] = $iShp;
564 self::$_aModuleVars[
"urlMap"] = $aMap;
591 if (is_null($sShopId)) {
596 $sVar = strtolower(basename($sModuleVarName));
597 $sShop = strtolower(basename($sShopId));
599 $sFileName = $sDir .
"/" . self::CACHE_FILE_PREFIX .
"." . $sShop .
'.' . $sVar .
".txt";
618 $sSelect =
"SELECT DECODE( oxvarvalue , " . $oDb->quote($sConfKey) .
" ) FROM oxconfig " .
619 "WHERE oxvarname = " . $oDb->quote($sModuleVarName) .
" AND oxshopid = " . $oDb->quote($sShopId);
621 $sModuleVarName = $oDb->getOne($sSelect,
false,
false);
623 $sModuleVarName = unserialize($sModuleVarName);
625 return $sModuleVarName;
637 protected function _getFromCache($sModuleVarName, $blSubshopSpecific =
true)
640 if (!$blSubshopSpecific) {
646 if (is_readable($sFileName)) {
647 $sValue = file_get_contents($sFileName);
648 if ($sValue == serialize(
false)) {
652 $sValue = unserialize($sValue);
653 if ($sValue ===
false) {
668 protected function _setToCache($sVarName, $sValue, $blSubshopSpecific =
true)
671 if (!$blSubshopSpecific) {
676 file_put_contents($sFileName, serialize($sValue), LOCK_EX);