public function build($template, $compiled, $force = false) { /* Builds $template and writes the resulting compiled script to $compiled. Returns true if the template was built, false if the compiled template was already up-to-date. */ $this->template = $template; $this->compiled = $compiled; if (!file_exists($this->template)) { throw new OutlineException("OutlineEngine::build(): template not found: " . $this->template); } if ($force || !file_exists($this->compiled) || filemtime($this->template) > @filemtime($this->compiled)) { if (!@constant("OUTLINE_COMPILER")) { if (@constant("OUTLINE_DEBUG")) { OutlineDebug("loading OutlineCompiler"); } require OUTLINE_CLASS_PATH . "/compiler.php"; } if (@constant("OUTLINE_DEBUG")) { OutlineDebug("compiling template '{$template}' to '{$compiled}'"); } try { $compiler = new OutlineCompiler($this); @mkdir(dirname($compiled), OUTLINE_DIR_MODE, true); OutlineUtil::write_file($compiled, $compiler->compile(file_get_contents($template))); $compiler->__destruct(); unset($compiler); } catch (OutlineCompilerException $e) { throw new OutlineException("error compiling template '{$template}', line " . $e->getLineNum() . " - " . $e->getMessage()); } return true; } return false; }
public function user_block_name($keyword) { return OUTLINE_USERBLOCK_PREFIX . OutlineUtil::clean($this->compiler->engine->getTplName()) . '_' . $keyword; }
public function clear($path) { /* Recursively clears cached content for the given path. $path: an array of cache names - as a minimum, this must contain one name, e.g. the template name. */ if (!is_array($path)) { $path = array($path); } $dir = $this->config['cache_path']; $last = count($path); for ($n = 0; $n < $last; $n++) { $dir .= '/' . OutlineUtil::clean($path[$n]); } $file = $dir . $this->config['cache_suffix']; if (is_dir($dir)) { OutlineUtil::delete($dir, $this->config['cache_suffix']); } if (is_file($file)) { unlink($file); } }