Blog_Page.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php
  2. require_once($path["page"] . "Page.php");
  3. require_once($path["entity"] . "Post.php");
  4. /**
  5. * Blog page model.
  6. */
  7. class Blog_Page extends Page{
  8. /**
  9. * List of {@see Post}.
  10. */
  11. public $post = [];
  12. /**
  13. * Constructor.
  14. *
  15. * Retrieves the data and initializes the variables.
  16. *
  17. * @param db Connection to the database.
  18. * @param lang Lowercase, two-letter language code.
  19. */
  20. public function __construct($db, $lang){
  21. global $path;
  22. global $base_url;
  23. global $data;
  24. parent::__construct($db, $lang);
  25. $this->template = $path["template"] . "blog.php";
  26. $s =
  27. "SELECT id " .
  28. "FROM post " .
  29. "WHERE visible = 1 " .
  30. "ORDER BY dtime DESC;";
  31. $q = mysqli_query($this->db, $s);
  32. while($r = mysqli_fetch_array($q)){
  33. array_push($this->post, new Post($this->db, $this->lang, $r["id"]));
  34. }
  35. $this->title = $this->string["section_blog"] . " - " . $data["name"];
  36. $this->description = $this->string["section_blog"] . " - " . $data["name"];
  37. $this->canonical = $base_url . "/blog/";
  38. }
  39. }
  40. ?>