public static function getAllModulesPath() { return \Jelix\Core\App::getAllModulesPath(); }
/** * Find all activated modules and check their status * @param object $config the config object * @param boolean $allModuleInfo may be true for the installer, which needs all informations * else should be false, these extra informations are * not needed to run the application * @return \Jelix\Core\Infos\ModuleInfos[] */ protected function _loadModulesInfo($config, $allModuleInfo) { $installerFile = App::configPath('installer.ini.php'); if ($config->disableInstallers) { $installation = array(); } else { if (file_exists($installerFile)) { $installation = parse_ini_file($installerFile, true); } else { if ($allModuleInfo) { $installation = array(); } else { throw new Exception("The application is not installed -- installer.ini.php doesn't exist!\n", 9); } } } $section = $config->urlengine['urlScriptId']; if (!isset($installation[$section])) { $installation[$section] = array(); } if ($config->compilation['checkCacheFiletime']) { $config->_allBasePath = App::getDeclaredModulesDir(); } else { $config->_allBasePath = array(); } $modules = array(); $list = App::getAllModulesPath(); foreach ($list as $k => $path) { $module = $this->_readModuleInfo($config, $allModuleInfo, $path, $installation, $section); if ($module !== null) { $modules[$module->name] = $module; } } return $modules; }
/** * */ public function compile($aSelector) { $sourceFile = $aSelector->getPath(); $cachefile = $aSelector->getCompiledFilePath(); $this->xmlfile = $aSelector->file; $xml = simplexml_load_file($sourceFile); if (!$xml) { return false; } /* <urls> <classicentrypoint name="index" default="true"> <url pathinfo="/test/:mois/:annee" module="" action=""> <param name="mois" escape="true" regexp="\d{4}"/> <param name="annee" escape="false" /> <static name="bla" value="cequejeveux" /> </url> <url handler="" module="" action="" /> </classicentrypoint> </urls> The compiler generates two files. It generates a php file for each entrypoint. A file contains a $PARSE_URL array: $PARSE_URL = array($isDefault, $infoparser, $infoparser, ... ) where: $isDefault: true if it is the default entry point. In this case and where the url parser doesn't find a corresponding action, it will ignore else it will generate an error $infoparser = array('module','action', 'regexp_pathinfo', 'handler selector', array('secondaries','actions'), false // needs https or not ) or $infoparser = array('module','action','regexp_pathinfo', array('year','month'), // list of dynamic value included in the url, // alphabetical ascendant order array(true, false), // list of boolean which indicates for each // dynamic value, if it is an escaped value or not array('bla'=>'whatIWant' ), // list of static values array('secondaries','actions'), false // need https or not ) It generates an other file common to all entry point. It contains an array which contains informations to create urls $CREATE_URL = array( 'news~show@classic' => // the action selector array(0,'entrypoint', https true/false, 'handler selector') or array(1,'entrypoint', https true/false, array('year','month',), // list of dynamic values included in the url array(0, 1..), // list of integer which indicates for each // dynamic value: 0: urlencode, 1:urlencode except '/', 2:escape, 4: lang, 8: locale "/news/%1/%2/", // the url array('bla'=>'whatIWant' ) // list of static values ) or When there are several urls to the same action, it is an array of this kind of the previous array: array(4, array(1,...), array(1,...)...) or array(2,'entrypoint', https true/false), // for the patterns "@request" or array(3,'entrypoint', https true/false, pathinfobase), // for the patterns "module~@request" */ $this->createUrlInfos = array(); $this->createUrlContent = "<?php \nif (\\Jelix\\Core\\App::config()->compilation['checkCacheFiletime'] &&( \n"; $this->createUrlContent .= "filemtime('" . $sourceFile . '\') > ' . filemtime($sourceFile); $this->createUrlContentInc = ''; $this->modulesPath = App::getAllModulesPath(); $this->parseXml($xml); // write cache files containing parsing informations foreach ($this->entrypoints as $epName => $epInfos) { list($urlModel, $parseInfos, $createUrlInfosDedicatedModules) = $epInfos; $parseContent = "<?php \n"; $parseContent .= '$GLOBALS[\'SIGNIFICANT_PARSEURL\'][\'' . rawurlencode($urlModel->entryPoint) . '\'] = ' . var_export($parseInfos, true) . ";\n?>"; \jFile::write(App::tempPath('compiled/urlsig/' . $aSelector->file . '.' . rawurlencode($urlModel->entryPoint) . '.entrypoint.php'), $parseContent); } // write cache file containing url creation informations $this->createUrlContent .= ")) { return false; } else {\n"; $this->createUrlContent .= $this->createUrlContentInc; $this->createUrlContent .= '$GLOBALS[\'SIGNIFICANT_CREATEURL\'] =' . var_export($this->createUrlInfos, true) . ";\nreturn true;"; $this->createUrlContent .= "\n}\n"; \jFile::write(App::tempPath('compiled/urlsig/' . $aSelector->file . '.creationinfos_15.php'), $this->createUrlContent); return true; }