Projects_Page.php 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <?php
  2. require_once($path["model"] . "Page.php");
  3. require_once($path["model"] . "Project.php");
  4. require_once($path["helper"] . "text.php");
  5. /**
  6. * Projects list page model.
  7. */
  8. class Projects_Page extends Page{
  9. /**
  10. * Array with the {@see Project}.
  11. */
  12. public $project = [];
  13. /**
  14. * Constructor.
  15. *
  16. * Retrieves the data and initializes the variables.
  17. *
  18. * @param MySQL_connection $db Connection to the database.
  19. * @param string $lang Lowercase, two-letter language code.
  20. * @param string $id Project id or permalink.
  21. */
  22. public function __construct($db, $lang){
  23. global $path;
  24. global $root;
  25. parent:: __construct($db, $lang);
  26. $this->view = $path["view"] . "projects.php";
  27. $s =
  28. "SELECT id " .
  29. "FROM project " .
  30. "WHERE " .
  31. " project.id = ( " .
  32. " SELECT project " .
  33. " FROM " .
  34. " ( " .
  35. " SELECT " .
  36. " project, " .
  37. " max(dtime) " .
  38. " FROM project_version " .
  39. " GROUP BY project " .
  40. " ORDER BY dtime DESC " .
  41. " ) lp " .
  42. " WHERE lp.project = project.id " .
  43. " ) AND " .
  44. " visible = 1;";
  45. $q = mysqli_query($this->db, $s);
  46. while($r = mysqli_fetch_array($q)){
  47. array_push($this->project, new Project($this->db, $this->lang, $r["id"]));
  48. }
  49. $this->title = text($this, "PROJECT_TITLE") . " - " . text($this, "USER_NAME");
  50. $this->name = text($this, "USER_NAME");
  51. $this->description = text($this, "PROJECT_DESCRIPTION");
  52. $this->favicon = $path["img"]["layout"] . "logo/logo.svg";
  53. $this->icon = $path["img"]["layout"] . "logo/logo.svg";
  54. $this->canonical = $root . $lang . "/project/";
  55. $this->author = $root . $lang . "/";
  56. }
  57. }
  58. ?>