function cachedInclude($script, $env = array(), $expire = null) { $this->cacheMembers = array('html'); $this->cacheState = 'include-' . str_replace('\\', '-', str_replace('/', '-', $script)); $this->cacheState .= '-' . abs(crc32(serialize($env))); if (!$this->cacheRestore()) { extract($env); ob_start(); include $script; $this->html = ob_get_flush(); if (!$expire) { $expire = new CacheExpire(); } $expire->filemtimeChanged($script); // The cache is invalid if the included file has changed $this->cacheStore($expire); } else { echo $this->html; } }
private function loadDefinitions($classes) { if ($this->definitions_loaded) { return; } $this->cacheState = $classes; array_unshift($this->cacheState, 'defs'); if (!$this->cacheRestore()) { $exp = new CacheExpire(); foreach ($classes as $class) { $doc = new php_doc($class); $refl = new ReflectionClass($class); $vers = $doc->getTags('version', php_doc::TYPE_GENERIC); if (!$vers[0]) { $vers = $doc->getTags('ver', php_doc::TYPE_GENERIC); } $ver = @$vers[0]['name']; if (!isset($ver)) { $ver = '0'; } $this->versions[$class] = $ver; $historys = $doc->getTags('history', php_doc::TYPE_KEYVALUE); if ($historys[0] && $historys[0]['key']) { $file = $historys[0]['value']; if ($file && $file[0] != '/' && $file[0] != '\\') { $file = dirname($refl->getFileName()) . '/' . $file; } $this->histories[$class] = array($historys[0]['key'], $file); } else { continue; } $exp->filemtimeChanged($refl->getFileName()); } $this->cacheMembers = array('versions', 'histories'); $this->cacheStore($exp); } }