Advertisement
Guest User

Untitled

a guest
Oct 17th, 2019
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.29 KB | None | 0 0
  1. <?php
  2.  
  3. /**
  4. * 1 replace mark processing for exception view
  5. */
  6.  
  7. namespace news2\views;
  8.  
  9. use framework2\lib\html_view\CreateHtml;
  10.  
  11. class CreateException extends CreateHtml
  12. {
  13. //replacement mark
  14. const REPLACE1 = "#contents#";
  15. const REPLACE2 = "#url#";
  16.  
  17. /**
  18. * display html page
  19. * @param string $contents
  20. * @return void
  21. */
  22. public function view (array $contents=null) :void
  23. {
  24. $temp = $this->retTempFilePath();
  25.  
  26. //create filename for rendering use template file path
  27. $cache = $this->createCacheFilename($temp);
  28.  
  29. if (!is_file($cache)) {
  30. $temp_php = file_get_contents($temp);
  31. if (empty($contents)) {
  32. $contents = $this->getCreatehtmls();
  33. }
  34.  
  35. $search = array( parent::TITLE,
  36. parent::PAGE,
  37. self::REPLACE1,
  38. self::REPLACE2,
  39. );
  40.  
  41. $replace = array($this->title, $this->id_name, $contents[0], $contents[1]);
  42. $new = str_replace($search, $replace, $temp_php);
  43.  
  44. file_put_contents($cache, $new,LOCK_EX);
  45. }
  46. require $cache;
  47.  
  48. }
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement