/** * Loads the template from the specified file. * @return ITemplate template parsed from the specified file, null if the file doesn't exist. */ public function getTemplateByFileName($fileName) { if (($fileName = $this->getLocalizedTemplate($fileName)) !== null) { Prado::trace("Loading template {$fileName}", '\\Prado\\Web\\UI\\TTemplateManager'); if (($cache = $this->getApplication()->getCache()) === null) { return new TTemplate(file_get_contents($fileName), dirname($fileName), $fileName); } else { $array = $cache->get(self::TEMPLATE_CACHE_PREFIX . $fileName); if (is_array($array)) { list($template, $timestamps) = $array; if ($this->getApplication()->getMode() === TApplicationMode::Performance) { return $template; } $cacheValid = true; foreach ($timestamps as $tplFile => $timestamp) { if (!is_file($tplFile) || filemtime($tplFile) > $timestamp) { $cacheValid = false; break; } } if ($cacheValid) { return $template; } } $template = new TTemplate(file_get_contents($fileName), dirname($fileName), $fileName); $includedFiles = $template->getIncludedFiles(); $timestamps = array(); $timestamps[$fileName] = filemtime($fileName); foreach ($includedFiles as $includedFile) { $timestamps[$includedFile] = filemtime($includedFile); } $cache->set(self::TEMPLATE_CACHE_PREFIX . $fileName, array($template, $timestamps)); return $template; } } else { return null; } }