Advertisement
Guest User

Untitled

a guest
Oct 17th, 2019
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.28 KB | None | 0 0
  1. <?php
  2.  
  3. /**
  4. * 2mark replace processing for table tag
  5. */
  6.  
  7. namespace news2\views;
  8.  
  9. use framework2\lib\html_view\CreateHtml;
  10. //use function framework2\hs;
  11.  
  12. class CreateTablesec1 extends CreateHtml
  13. {
  14. //replacement mark
  15. const REPLACE1 = "#h2-1#";
  16. const REPLACE2 = "#table1#";
  17.  
  18. /**
  19. * display html page
  20. * @param string $contents
  21. * @return void
  22. */
  23. public function view (array $contents=null) :void
  24. {
  25. $tempfile_path = $this->retTempFilePath();
  26.  
  27. $cache = $this->createCacheFilename($tempfile_path);
  28.  
  29. if (!is_file($cache)) {
  30. $temp_html = file_get_contents($tempfile_path);
  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. $replace = array($this->title, $this->id_name, $contents[0], $contents[1]);
  41. $new = str_replace($search, $replace, $temp_html);
  42.  
  43. file_put_contents($cache, $new,LOCK_EX);
  44.  
  45. }
  46. require $cache;
  47.  
  48. }
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement