* @param $templateType The current template's type
* @return void
*/
- private final function setTemplateType ($templateType) {
+ protected final function setTemplateType ($templateType) {
$this->templateType = (string) $templateType;
}
return $this->templateBasePath;
}
+ /**
+ * Getter for generic base path
+ *
+ * @return $templateBasePath The relative base path for all templates
+ */
+ public final function getGenericBasePath () {
+ // And set it
+ return $this->genericBasePath;
+ }
+
/**
* Setter for template extension
*
*
* @param $template The template we shall load
* @return void
+ * @throws FileNotFoundException If the template was not found
*/
- private function loadTemplate ($template) {
- // Get extension for the template
- $ext = $this->getRawTemplateExtension();
-
- // If we shall load a code-template we need to switch the file extension
- if ($this->getTemplateType() == $this->getConfigInstance()->readConfig('code_template_type')) {
- // Switch over to the code-template extension
- $ext = $this->getCodeTemplateExtension();
+ protected function loadTemplate ($template, $ext = '') {
+ // Get extension for the template if empty
+ if (empty($ext)) {
+ // None provided, so get the raw one
+ $ext = $this->getRawTemplateExtension();
} // END - if
// Construct the FQFN for the template by honoring the current language
$fqfn = sprintf("%s%s%s%s/%s/%s%s",
$this->getConfigInstance()->readConfig('base_path'),
$this->getTemplateBasePath(),
- $this->genericBasePath,
+ $this->getGenericBasePath(),
$this->getLanguageInstance()->getLanguageCode(),
$this->getTemplateType(),
(string) $template,
$ext
);
- // Load the raw template data
- $this->loadRawTemplateData($fqfn);
+ // First try this
+ try {
+ // Load the raw template data
+ $this->loadRawTemplateData($fqfn);
+ } catch (FileNotFoundException $e) {
+ // If we shall load a code-template we need to switch the file extension
+ if ($this->getTemplateType() != $this->getConfigInstance()->readConfig('web_template_type')) {
+ // Switch over to the code-template extension and try it again
+ $ext = $this->getCodeTemplateExtension();
+
+ // Try it again...
+ $this->loadTemplate($template, $ext);
+ } else {
+ // Throw it again
+ throw new FileNotFoundException($fqfn, FrameworkFileInputPointer::EXCEPTION_FILE_NOT_FOUND);
+ }
+ }
+
}
/**
*/
public function getImageCacheFqfn () {
// Get the FQFN ready
- $fqfn = $this->getTemplateBasePath().'_cache/' . md5($this->imageInstance->getImageName().':'.$this->__toString().':'.$this->imageInstance->__toString()) . '.' . $this->imageInstance->getImageType();
+ $fqfn = sprintf("%s%s%s/%s.%s",
+ $this->getConfigInstance()->readConfig('base_path'),
+ $this->getGenericBasePath(),
+ 'images/_cache',
+ md5(
+ $this->imageInstance->getImageName().':'.$this->__toString().':'.$this->imageInstance->__toString()
+ ),
+ $this->imageInstance->getImageType()
+ );
// Return it
return $fqfn;
// Set the image instance
$responseInstance->setImageInstance($this->imageInstance);
}
+
+ /**
+ * Load a specified image template into the engine
+ *
+ * @param $template The image template we shall load which is
+ * located in 'image' by default
+ * @return void
+ */
+ public function loadImageTemplate ($template) {
+ // Set template type
+ $this->setTemplateType($this->getConfigInstance()->readConfig('image_template_type'));
+
+ // Load the special template
+ $this->loadTemplate($template);
+ }
}
// [EOF]