a_str_OriginalContent = str_replace("\n", "", file_get_contents($l_str_TemplateFile)); $this->a_str_OriginalContent = str_replace("\r", "", $this->a_str_OriginalContent); $this->a_str_OriginalContent = str_replace("\t", " ", $this->a_str_OriginalContent); $this->a_str_OriginalContent = preg_replace('# +#', " ", $this->a_str_OriginalContent); $this->reload(); } /** * Replace all placeholders specified in array. * * @author Stefan Herndler * @since 1.5.0 * @param array $p_arr_Placeholders Placeholders (key = placeholder, value = value). * @return bool True on Success, False if Placeholders invalid. */ public function replace($p_arr_Placeholders) { // no placeholders set if (empty($p_arr_Placeholders)) { return false; } // template content is empty if (empty($this->a_str_ReplacedContent)) { return false; } // iterate through each placeholder and replace it with its value foreach($p_arr_Placeholders as $l_str_Placeholder => $l_str_Value) { $this->a_str_ReplacedContent = str_replace("[[" . $l_str_Placeholder . "]]", $l_str_Value, $this->a_str_ReplacedContent); } // success return true; } /** * Reloads the original content of the template file. * * @author Stefan Herndler * @since 1.5.0 */ public function reload() { $this->a_str_ReplacedContent = $this->a_str_OriginalContent; } /** * Returns the content of the template file with replaced placeholders. * * @author Stefan Herndler * @since 1.5.0 * @return string Template content with replaced placeholders. */ public function getContent() { return $this->a_str_ReplacedContent; } } // end of class