/** * Loads and initializes zendfox module system * * @param Zend_Controller_Front $front * @return array */ private static function loadNamespacesAndModules(Zend_Controller_Front $front, $bootS) { if (null == self::$modules) { self::$modules = array(); $loader = Zend_Loader_Autoloader::getInstance(); if ((self::$modules = self::$cache->load('fox_modules')) === false) { $dbConf = $bootS->db->getConfig(); if (self::$modeRun) { $mData = self::$dbAdapter->fetchAll("SELECT * FROM {$dbConf['prefix']}core_module"); foreach ($mData as $mInfo) { $name = trim($mInfo['name']); $enabled = trim($mInfo['status']); $package = trim($mInfo['package']); $nameSpc = trim($mInfo['namespace']); if ($name != '' && $enabled == 1 && $package != '' && $nameSpc != '') { $moduleDir = APPLICATION_PATH . DIRECTORY_SEPARATOR . 'modules' . DIRECTORY_SEPARATOR . $package . DIRECTORY_SEPARATOR . $nameSpc . DIRECTORY_SEPARATOR . $name; self::$modules[$name]['path'] = $moduleDir; self::$modules[$name]['namespace'] = $nameSpc; } } //Caching module info self::$cache->save(self::$modules, 'fox_modules'); } else { // ********Reading Module info from XML files**********************/ $doc = new DOMDocument(); if (is_dir(MODULE_CONFIG_DIR)) { $dp = opendir(MODULE_CONFIG_DIR); while ($file = readdir($dp)) { if (!($file == '.' || $file == '..')) { $fPath = MODULE_CONFIG_DIR . DIRECTORY_SEPARATOR . $file; if (is_readable($fPath) && is_file($fPath)) { $doc->load($fPath); if ($doc->documentElement->childNodes) { $nList = $doc->documentElement->childNodes; foreach ($nList as $n) { if ($n->nodeName == 'module' && ($name = $n->getAttribute('name')) && ($enabled = $n->getAttribute('enabled') === 'true') && ($package = $n->getAttribute('package')) && ($nameSpc = $n->getAttribute('namespace'))) { if ($enabled) { $moduleDir = APPLICATION_PATH . DIRECTORY_SEPARATOR . 'modules' . DIRECTORY_SEPARATOR . $package . DIRECTORY_SEPARATOR . $nameSpc . DIRECTORY_SEPARATOR . $name; self::$modules[$name]['path'] = $moduleDir; self::$modules[$name]['namespace'] = $nameSpc; } } } } } } } } /* * ****End Reading module info from XML files************** */ } } $ns = array(); foreach (self::$modules as $name => $module) { $moduleDir = $module['path']; $nameSpc = $module['namespace']; if (!in_array($nameSpc, $ns)) { $loader->registerNamespace($nameSpc . '_'); $ns[] = $nameSpc; } $front->addControllerDirectory($moduleDir . DIRECTORY_SEPARATOR . 'controllers', $name); //Translation loading if (NULL == self::$translator) { self::$translator = new Zend_Translate(array('adapter' => 'csv', 'locale' => 'auto')); Zend_Registry::set('translator', self::$translator); // self::$translator->setLocale(Zend_Registry::get('Zend_Locale')); } $langDir = $moduleDir . DIRECTORY_SEPARATOR . 'lang' . DIRECTORY_SEPARATOR; if (file_exists($langDir)) { self::$translator->addTranslation(array('content' => $langDir, 'scan' => Zend_Translate::LOCALE_FILENAME)); } } unset($ns); } }