Esempio n. 1
0
 public function registerPlugin($classname)
 {
     if (@constant("OUTLINE_DEBUG")) {
         OutlineDebug("Registering plugin '{$classname}'");
     }
     if (in_array($classname, $this->plugin_registry)) {
         trigger_error("OutlineCompiler::registerPlugin() : plugin '{$classname}' already registered", E_USER_ERROR);
     }
     $this->plugin_registry[] = $classname;
     $this->current_plugin = $classname;
     call_user_func_array(array($classname, "register"), array(&$this));
     $this->current_plugin = null;
 }
Esempio n. 2
0
 public function __construct($tplname, $config = null)
 {
     /*
     $tplname: name of template to load - will be compiled as needed.
     $config: optional configuration settings - see [OutlineEngine] for valid configuration options.
     */
     parent::__construct();
     $this->config['plugins']['OutlineSystem'] = OUTLINE_CLASS_PATH . "/system.php";
     if (is_array($config)) {
         foreach ($config as $name => $value) {
             if (!array_key_exists($name, $this->config)) {
                 throw new OutlineException("Outline::__construct() : invalid configuration option '{$name}'");
             }
             if (is_array($this->config[$name])) {
                 $this->config[$name] += $value;
             } else {
                 $this->config[$name] = $value;
             }
         }
     } else {
         if ($config === null && count(self::$engine_stack)) {
             if (@constant("OUTLINE_DEBUG")) {
                 OutlineDebug("inheriting configuration of parent engine");
             }
             $this->config =& self::$engine_stack[0]->config;
         }
     }
     if ($this->config['bracket_comment'] == null) {
         $this->config['bracket_comment'] = $this->config['bracket_open'] . '*';
     }
     if ($this->config['bracket_end_comment'] == null) {
         $this->config['bracket_end_comment'] = '*' . $this->config['bracket_close'];
     }
     if ($this->config['bracket_ignore'] == null) {
         $this->config['bracket_ignore'] = $this->config['bracket_open'] . 'ignore' . $this->config['bracket_close'];
     }
     if ($this->config['bracket_end_ignore'] == null) {
         $this->config['bracket_end_ignore'] = $this->config['bracket_open'] . '/ignore' . $this->config['bracket_close'];
     }
     $this->tplname = $tplname;
     $this->caching = !$this->build($this->getAbsTplPath(), $this->config["compiled_path"] . '/' . $this->getRelTplPath($tplname) . $this->config["compiled_suffix"], @constant("OUTLINE_ALWAYS_COMPILE"));
     if (!isset($this->config['functions'])) {
         $this->config['functions'] = array();
     }
     if (!is_array($config) || !array_key_exists('default_root', $config)) {
         $bits = explode(':', $tplname, 2);
         if (count($bits) == 2) {
             $this->config['default_root'] = $bits[0];
         }
     }
 }
Esempio n. 3
0
 public function stop()
 {
     /*
     Completes capture of output for caching, and saves
     the output content to the cache.
     */
     if (@constant("OUTLINE_DEBUG")) {
         OutlineDebug("Cache capture finished");
     }
     if (!$this->buffering) {
         throw new OutlineException("OutlineCache::stop() : capture() must be called before stop() can be called");
     }
     if (!@file_put_contents(implode($this->path), $this->valid ? ob_get_contents() : ob_get_clean())) {
         throw new OutlineException("OutlineCache::stop() : unable to write new cache entry " . implode($this->path));
     }
     if ($this->valid) {
         ob_end_flush();
     }
     $this->valid = true;
 }