Home_Page.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. require_once($path["page"] . "Page.php");
  3. require_once($path["entity"] . "Project.php");
  4. require_once($path["helper"] . "text.php");
  5. /**
  6. * Home page model.
  7. */
  8. class Home_Page extends Page{
  9. private $max_projects = 3;
  10. /**
  11. * List of recent projects.
  12. */
  13. public $project = [];
  14. /**
  15. * Constructor.
  16. *
  17. * Retrieves the data and initializes the variables.
  18. *
  19. * @param MySQL_connection $db Connection to the database.
  20. * @param string $lang Lowercase, two-letter language code.
  21. */
  22. public function __construct($db, $lang){
  23. global $path;
  24. global $base_url;
  25. parent::__construct($db, $lang);
  26. $this->view = $path["view"] . "home.php";
  27. $s_project =
  28. "SELECT id " .
  29. "FROM project " .
  30. "WHERE visible = 1 " .
  31. "ORDER BY idx DESC " .
  32. "LIMIT " . $this->max_projects . ";";
  33. $q_project = mysqli_query($this->db, $s_project);
  34. while($r_project = mysqli_fetch_array($q_project)){
  35. array_push($this->project, new Project($this->db, $this->lang, $r_project["id"]));
  36. }
  37. $this->title = text($this, "USER_NAME");
  38. $this->description = text($this, "USER_NAME") . " - " . text($this, "USER_TAGLINE");
  39. $this->canonical = $base_url . "/";
  40. }
  41. }
  42. ?>