/** * First function called to begin loading template * @param string $template The template file to be loaded * @param array $vars Array of variables to be used in template * @param boolean $ajax If true then echo the rendered template * @throws Exception * @return void */ public static function load($template, $vars, $ajax = false) { //Get the location of the templates folder $setup['templates'] = file_get_contents(__DIR__ . '/setup.json'); $setup['templates'] = json_decode($setup['templates']); $setup['templates'] = $setup['templates']->templates; $dir = explode('/', __DIR__); if ($dir[sizeof($dir) - 1] == "templator" && $dir[sizeof($dir) - 2] == "drroach" && $dir[sizeof($dir) - 3] == "vendor") { self::$templateLocation = dirname(dirname(dirname(__DIR__))) . $setup['templates'] . 'templates/' . $template . '.tpl'; } else { self::$templateLocation = dirname(__DIR__) . '/templates/' . $template . '.tpl'; } self::$definedVars = $vars; //Check to see if a cached file already exists if (Cache::cacheExists($template)) { $timedOut = Cache::cacheTimedOut($template); if (!$timedOut) { Cache::loadCacheFile($template, $vars); return; } } self::checkTemplateExists($template); $templateHtml = self::getTemplateHtml($template); if ($vars === null) { $vars = []; } extract($vars); include Generate::parse($templateHtml, $template); }