/**
* processes template
*
* @return void
*/
protected function parse() {
$this->_template = $this->substituteLoops($this->_template, $this->_content);
$this->_template = $this->substituteContentTags($this->_template, $this->_content);
$this->_template = $this->substituteIncludes($this->_template, $this->_content); // NEW LINE
$this->_parsed = TRUE;
}
/**
* substitutes includes in string with content
*
* @return string
* @param string $string
* @param array $content
*/
protected function substituteIncludes($string, $content) {
$this->_tempContent = $content;
return preg_replace_callback('/(include|include_once|require|require_once)[ ]?[\"\'](.*)[\"\'][;]?/i', array($this, 'getContentOfIncludeTag'), $string);
}
/**
* substitutes includes in string with content
*
* @return string
* @param string $string
* @param array $content
*/
protected function getContentOfIncludeTag($includeName) {
$file = $includeName[2];
if(file_exists($file)) {
$fp = fopen($file, "rb");
$returnValue = fread($fp, filesize($file));
fclose($fp);
} else {
$returnValue = '[ERROR: The file "'.$file.'" could not be included!]';
}
return $returnValue;
}
TPL:
include 'einzubinden.txt';