/** * * @return Context */ public static function getInstance() { $context = self::traitGetInstance(); //while ($context->_status == 1) # Semaphore --> 1 Setup not finished yet. Wait for it. // sleep(1); if ($context->_status == 0) { $context->_status = 1; # Lock semaphore / Running $context->setupVariables(); ModuleFactory::registerUserLibDir($context); $context->setLocale(); // Adjusts to Run with XMLNukeDB $context->_appNameInMemory = "db_" . strtolower($context->Language()->getName()); $context->_xmlnukedb = new XmlnukeDB($context->XmlHashedDir(), $context->XmlPath(), strtolower($context->Language()->getName())); //$this->_xmlnukedb->loadIndex(); if ($context->get("logout") != "") { UserContext::getInstance()->registerLogout(); } $context->_status = 2; # Release Semaphore / All done. } return $context; }
/** * * @return array() */ public static function registerUserLibDir($context) { if (ModuleFactory::$_phpLibDir == null) { if (!is_array($context->get("xmlnuke.PHPLIBDIR"))) { throw new InvalidArgumentException('Config "xmlnuke.PHPLIBDIR" requires an associative array'); } ModuleFactory::$_phpLibDir = $context->get("xmlnuke.PHPLIBDIR"); $autoLoad = AutoLoad::getInstance(); foreach (ModuleFactory::$_phpLibDir as $lib => $path) { if (!file_exists($path)) { throw new \Exception("Path {$path} in xmlnuke.PHPLIBDIR was not found"); } $autoLoad->registrUserProject($path); } } return ModuleFactory::$_phpLibDir; }
/** * */ function processModule() { $context = Context::getInstance(); //IModule $module = null; $moduleName = $context->getModule(); if ($moduleName == "") { // Experimental... Not finished... $moduleName = $context->getVirtualCommand(); if ($moduleName == 'admin') { $moduleName = 'Xmlnuke.Admin.ControlPanel'; } } $firstError = null; $debug = $context->getDebugStatus(); // Try load modules // Catch errors from permissions and so on. $writeResult = $this->getProcessResult(); try { $module = ModuleFactory::GetModule($moduleName); $engine = $this->createXmlnukeEngine(); $writeResult->SearchAndReplace($engine->TransformDocumentFromModule($module)); } catch (ModuleNotFoundException $ex) { $module = ModuleFactory::GetModule('Xmlnuke.HandleException', array('TYPE' => 'NOTFOUND', 'MESSAGE' => 'The module "' . $moduleName . '" was not found.', 'OBJECT' => $moduleName)); $engine = $this->createXmlnukeEngine(); $writeResult->SearchAndReplace($engine->TransformDocumentFromModule($module)); } catch (NotAuthenticatedException $ex) { $s = XmlnukeManageUrl::encodeParam($_SERVER["REQUEST_URI"]); $url = $context->bindModuleUrl($context->get("xmlnuke.LOGINMODULE")) . "&ReturnUrl=" . $s; // Do not leave empty spaces at begin or end of modules // Não deixe espaços em branco no início ou fim dos módulos $context->redirectUrl($url); } }