Home_Page.php 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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. * Array with profile data.
  12. */
  13. public $profile = [
  14. "role" => "",
  15. "company" => "",
  16. "city" => "",
  17. "days" => "",
  18. "summary" => ""
  19. ];
  20. /**
  21. * List of recent projects.
  22. */
  23. public $project = [];
  24. /**
  25. * Constructor.
  26. *
  27. * Retrieves the data and initializes the variables.
  28. *
  29. * @param MySQL_connection $db Connection to the database.
  30. * @param string $lang Lowercase, two-letter language code.
  31. */
  32. public function __construct($db, $lang){
  33. global $path;
  34. global $root;
  35. parent::__construct($db, $lang);
  36. $this->view = $path["view"] . "home.php";
  37. $s_profile =
  38. "SELECT " .
  39. " role, " .
  40. " company, " .
  41. " city, " .
  42. " datediff(now(), start) AS days, " .
  43. " summary " .
  44. "FROM cv_entry " .
  45. "WHERE " .
  46. " category = 1 AND " .
  47. " visible = 1 AND " .
  48. " end IS NULL " .
  49. "ORDER BY start " .
  50. "DESC LIMIT 1;";
  51. $q_profile = mysqli_query($this->db, $s_profile);
  52. if (mysqli_num_rows($q_profile) > 0){
  53. $r_profile = mysqli_fetch_array($q_profile);
  54. $this->profile["role"] = text($this, $r_profile["role"]);
  55. $this->profile["company"] = $r_profile["company"];
  56. $this->profile["city"] = $r_profile["city"];
  57. $this->profile["days"] = $r_profile["days"];
  58. $this->profile["summary"] = text($this, $r_profile["summary"]);
  59. }
  60. $s_project =
  61. "SELECT id " .
  62. "FROM project " .
  63. "WHERE visible = 1;";
  64. $q_project = mysqli_query($this->db, $s_project);
  65. while($r_project = mysqli_fetch_array($q_project)){
  66. array_push($this->project, new Project($this->db, $this->lang, $r_project["id"]));
  67. }
  68. $this->title = text($this, "USER_NAME");
  69. $this->name = text($this, "USER_NAME");
  70. $this->description = text($this, "USER_NAME") . " - " . text($this, "USER_TAGLINE");
  71. $this->favicon = $path["img"]["layout"] . "logo/logo.svg";
  72. $this->icon = $path["img"]["layout"] . "logo/logo.svg";
  73. $this->canonical = $root . $lang . "/";
  74. $this->author = $root . $lang . "/";
  75. }
  76. }
  77. ?>