Projects_Page.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?php
  2. require_once(PATH::PAGE . "Page.php");
  3. require_once(PATH::ENTITY . "Project.php");
  4. /**
  5. * Projects list page model.
  6. */
  7. class Projects_Page extends Page{
  8. /**
  9. * Array with the {@see Project}.
  10. */
  11. private $projects = [];
  12. /**
  13. * Constructor.
  14. *
  15. * Retrieves the data and initializes the variables.
  16. */
  17. public function __construct(){
  18. $this->view = PATH::VIEW . "projects.php";
  19. parent:: __construct();
  20. $this->set_view("projects.php");
  21. $statement = get_context()->get_db()->prepare(
  22. "SELECT id FROM project WHERE user = :user AND visible = 1 ORDER BY idx"
  23. );
  24. $statement->bindValue(':user', get_context()->get_user()->get_id(), PDO::PARAM_INT);
  25. $statement->execute();
  26. while ($r_projects = $statement->fetch(PDO::FETCH_ASSOC))
  27. array_push($this->projects, new Project($r_projects["id"]));
  28. $this->set_title(Text::get("PROJECT_TITLE"));
  29. $this->set_description(Text::get("PROJECT_DESCRIPTION"));
  30. $this->set_canonical(URL::PROJECTS);
  31. $this->add_css("projects.css");
  32. }
  33. /**
  34. * Retrieves the projects to show on the page.
  35. *
  36. * @return Project[] Project list.
  37. */
  38. public function get_projects(){return $this->projects;}
  39. }
  40. ?>