Activities_Page.php 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <?php
  2. require_once($path["page"] . "Page.php");
  3. require_once($path["entity"] . "Activity.php");
  4. /**
  5. * Activities page model.
  6. */
  7. class Activities_Page extends Page{
  8. /**
  9. * List of {@see Activity} in the future, sorted with the closest one
  10. * first.
  11. */
  12. public $future = [];
  13. /**
  14. * List of {@see Activity} in the past, sorted with the closest one
  15. * first.
  16. */
  17. public $past = [];
  18. /**
  19. * Constructor.
  20. *
  21. * Retrieves the data and initializes the variables.
  22. *
  23. * @param db Connection to the database.
  24. * @param lang Lowercase, two-letter language code.
  25. */
  26. public function __construct($db, $lang){
  27. global $path;
  28. global $base_url;
  29. global $data;
  30. parent::__construct($db, $lang);
  31. $this->template = $path["template"] . "activities.php";
  32. $s_future =
  33. "SELECT id " .
  34. "FROM activity " .
  35. "WHERE " .
  36. " visible = 1 AND " .
  37. " date > now() " .
  38. "ORDER BY date;";
  39. $q_future = mysqli_query($this->db, $s_future);
  40. while($r_future = mysqli_fetch_array($q_future)){
  41. array_push($this->future, new Activity($this->db, $this->lang, $r_future["id"]));
  42. }
  43. $s_past =
  44. "SELECT id " .
  45. "FROM activity " .
  46. "WHERE " .
  47. " visible = 1 AND " .
  48. " date < now() " .
  49. "ORDER BY date DESC;";
  50. $q_past = mysqli_query($this->db, $s_past);
  51. while($r_past = mysqli_fetch_array($q_past)){
  52. array_push($this->past, new Activity($this->db, $this->lang, $r_past["id"]));
  53. }
  54. $this->title = $this->string["section_activities"] . " - " . $data["name"];
  55. $this->description = $this->string["section_activities"] . " - " . $data["name"];
  56. $this->canonical = $base_url . "/actividades/";
  57. }
  58. }
  59. ?>