/** * Identical to read(), but also stores the result in a temporary file * @return object an object which contains configuration values */ public function readAndCache() { $config = $this->read(false); $tempPath = App::tempPath(); \jFile::createDir($tempPath, $config->chmodDir); $filename = $tempPath . str_replace('/', '~', $this->configFileName); if (BYTECODE_CACHE_EXISTS) { $filename .= '.conf.php'; if ($f = @fopen($filename, 'wb')) { fwrite($f, '<?php $config = ' . var_export(get_object_vars($config), true) . ";\n?>"); fclose($f); chmod($filename, $config->chmodFile); } else { throw new Exception('Error while writing configuration cache file -- ' . $filename); } } else { IniFileMgr::write(get_object_vars($config), $filename . '.resultini.php', ";<?php die('');?>\n", '', $config->chmodFile); } return $config; }
static function checkTempPath() { $tempBasePath = \Jelix\Core\App::tempBasePath(); // we always clean the temp directory. But first, let's check the temp path (see ticket #840)... if ($tempBasePath == DIRECTORY_SEPARATOR || $tempBasePath == '' || $tempBasePath == '/') { throw new Exception("Error: bad path in \\Jelix\\Core\\App::tempBasePath(), it is equals to '" . $tempBasePath . "' !!\n" . " Jelix cannot clear the content of the temp directory.\n" . " Correct the path for the temp directory or create the directory you\n" . " indicated with \\Jelix\\Core\\App in your application.init.php.\n"); } jFile::removeDir(\Jelix\Core\App::tempPath(), false, array('.svn', '.dummy')); }
public static function tempPath($file = '') { return \Jelix\Core\App::tempPath($file); }
protected function _createCachePath() { // don't share the same cache for all the possible dirs // in case of overload removal $this->_cachePath = App::tempPath('compiled/locales/' . $this->_where . $this->module . '~' . $this->resource . $this->_cacheSuffix); }
public function getCompiledFilePath() { return \Jelix\Core\App::tempPath('compiled/urlsig/' . $this->file . '.creationinfos_15.php'); }
/** * Parse some url components. * * @param string $scriptNamePath /path/index.php * @param string $pathinfo the path info part of the url (part between script name and query) * @param array $params url parameters (query part e.g. $_REQUEST) * * @return \jUrlAction */ public function parse($scriptNamePath, $pathinfo, $params) { if ($this->config->enableParser) { if (strpos($scriptNamePath, $this->config->basePath) === 0) { $snp = substr($scriptNamePath, strlen($this->config->basePath)); } else { $snp = $scriptNamePath; } $pos = strrpos($snp, '.php'); if ($pos !== false) { $snp = substr($snp, 0, $pos); } $snp = rawurlencode($snp); $file = App::tempPath('compiled/urlsig/' . $this->xmlfileSelector->file . '.' . $snp . '.entrypoint.php'); if (file_exists($file)) { require $file; $this->dataParseUrl =& $GLOBALS['SIGNIFICANT_PARSEURL'][$snp]; return $this->_parse($scriptNamePath, $pathinfo, $params, false); } } $urlact = new \jUrlAction($params); return $urlact; }
function __construct($sel) { $this->_basePath = \Jelix\Core\App::tempPath(); parent::__construct($sel); }
protected function _createCachePath() { $this->_cachePath = App::tempPath('compiled/' . $this->_dirname . $this->module . '~' . $this->resource . $this->_cacheSuffix); }
/** * initialize the installation * * it reads configurations files of all entry points, and prepare object for * each module, needed to install/upgrade modules. * @param ReporterInterface $reporter object which is responsible to process messages (display, storage or other..) * @param string $lang the language code for messages */ function __construct(ReporterInterface $reporter, $lang = '') { $this->reporter = $reporter; $this->messages = new Checker\Messages($lang); $localConfig = App::configPath('localconfig.ini.php'); if (!file_exists($localConfig)) { $localConfigDist = App::configPath('localconfig.ini.php.dist'); if (file_exists($localConfigDist)) { copy($localConfigDist, $localConfig); } else { file_put_contents($localConfig, ';<' . '?php die(\'\');?' . '>'); } } $this->mainConfig = new \Jelix\IniFile\MultiIniModifier(\Jelix\Core\Config::getDefaultConfigFile(), App::mainConfigFile()); $this->localConfig = new \Jelix\IniFile\MultiIniModifier($this->mainConfig, $localConfig); $this->installerIni = $this->getInstallerIni(); $urlfile = App::appConfigPath($this->localConfig->getValue('significantFile', 'urlengine')); $this->xmlMapFile = new \Jelix\Routing\UrlMapping\XmlMapModifier($urlfile, true); $appInfos = new \Jelix\Core\Infos\AppInfos(); $this->readEntryPointsData($appInfos); $this->installerIni->save(); // be sure temp path is ready $chmod = $this->mainConfig->getValue('chmodDir'); \jFile::createDir(App::tempPath(), intval($chmod, 8)); }
/** * */ 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; }
/** * initialize the installation * * it reads configurations files of all entry points, and prepare object for * each module, needed to install/upgrade modules. * @param ReporterInterface $reporter object which is responsible to process messages (display, storage or other..) * @param string $lang the language code for messages */ function __construct(ReporterInterface $reporter, $lang = '') { $this->reporter = $reporter; $this->messages = new Checker\Messages($lang); $this->mainConfig = new \Jelix\IniFile\IniModifier(App::mainConfigFile()); $localConfig = App::configPath('localconfig.ini.php'); if (!file_exists($localConfig)) { $localConfigDist = App::configPath('localconfig.ini.php.dist'); if (file_exists($localConfigDist)) { copy($localConfigDist, $localConfig); } else { file_put_contents($localConfig, ';<' . '?php die(\'\');?' . '>'); } } $this->localConfig = new \Jelix\IniFile\MultiIniModifier($this->mainConfig, $localConfig); $this->installerIni = $this->getInstallerIni(); $appInfos = new \Jelix\Core\Infos\AppInfos(); $this->readEntryPointsData($appInfos); $this->installerIni->save(); // be sure temp path is ready \jFile::createDir(App::tempPath(), intval($this->mainConfig->getValue('chmodDirValue'), 8)); }