public function load($template, $options = array()) { $options = array_merge(array("master" => "master.php", "path" => null), $options); $path = $options["path"]; $this->template_name = basename($template, '.php'); if (empty($path)) { $path = Ac::path("templates"); } if (!is_dir($path)) { Ac::exception("The templates directory does not exist: " . $path); } // To prevent wrong includes, we do a chdir chdir($path); if (is_readable($template)) { $file = $this->template_file = realpath($template); } else { $file = $this->template_file = $path . $template; } if ($options["master"] != NULL) { if (is_readable($options["master"])) { $file = realpath($options["master"]); } else { $file = $path . $options["master"]; } } set_include_path(get_include_path() . PATH_SEPARATOR . $path . PATH_SEPARATOR); $content = static::process($file, $this->vars()); chdir(AC_PATH); return $content; }