file = $tpl_file_path;
}
// reading template file and store it into result properties
if ($tpl_str = file_get_contents($this->file)) {
$this->result = $tpl_str;
} else {
die('
Template file '.$this->file.' cant be opened!
');
}
}
/**
* Method assign content to template marker
*
* @param string $str_maker
* @param string $str_replacement
* @param boolean $bool_show_error
* @return void
*/
public function assign($str_maker, $str_replacement, $bool_show_error = false)
{
if (!preg_match("/".preg_quote($str_maker)."/i", $this->result)) {
if ($bool_show_error) {
$str_maker = str_ireplace(array(''), '', $str_maker);
echo "Marker : ".htmlentities($str_maker)." doesnt exist in ".$this->file;
}
return;
}
$this->result = str_ireplace($str_maker, $str_replacement, $this->result);
// get any gettext marker
preg_match_all('@@i', $this->result, $_gettext);
if (count($_gettext[0]) > 0) {
foreach ($_gettext[0] as $_trans_mark) {
$_trans_text = str_replace(array(''), '', $_trans_mark);
$this->result = str_ireplace($_trans_mark, __($_trans_text), $this->result);
}
}
}
/**
* Method to print out the template
*
* @return void
*/
public function printOut()
{
echo $this->result;
}
}
?>