Advertisement
Guest User

Untitled

a guest
Sep 26th, 2017
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.45 KB | None | 0 0
  1. protected function showTemplate() {
  2. ob_start('ob_gzhandler');
  3. $templateFileContents = file_get_contents($this->templateFileLocation);
  4. $outputHTML = $this->replaceVariables($templateFileContents);
  5. eval("?>".$outputHTML);
  6. ob_end_flush();
  7. }
  8.  
  9. private function replaceVariables($templateContents) {
  10. if(file_exists(PROJECT."config/templateinfo.php")) {
  11. require_once(PROJECT."config/templateinfo.php");
  12. foreach($templateinfo as $key => $value) {
  13. $requiredVars = "{".$key."}";
  14. $replaceVars = "(".$key.")";
  15. for($i=1;$i<=1;$i++) {
  16. if(strpos($templateContents,$requiredVars) == true) {
  17. $requireContent = file_get_contents($value);
  18. $templateContents = str_replace($requiredVars, $requireContent, $templateContents);
  19. }
  20. }
  21. if(strpos($templateContents,$replaceVars) == true) {
  22. $templateContents = str_replace($replaceVars, $value, $templateContents);
  23. }
  24. }
  25. return $templateContents;
  26. } else {
  27. $this->errors->addFatalError("The template engine could not parse the code provided to it.");
  28. return false;
  29. }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement