Profile_Page.php 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. <?php
  2. require_once(PATH::PAGE . "Page.php");
  3. require_once(PATH::ENTITY . "Cv.php");
  4. /**
  5. * Profile page model.
  6. */
  7. class Profile_Page extends Page{
  8. /**
  9. * List of available {@see CV}.
  10. */
  11. private $cv = [];
  12. /**
  13. * {@see CV} in the current languages.
  14. */
  15. private $main_cv;
  16. /**
  17. * List {@see CV}s in other languages.
  18. */
  19. private $other_cv = [];
  20. /**
  21. * Constructor.
  22. *
  23. * Retrieves the data and initializes the variables.
  24. */
  25. public function __construct(){
  26. $this->view = PATH::VIEW . "profile.php";
  27. parent::__construct();
  28. $this->set_view("profile.php");
  29. $statement = get_context()->get_db()->prepare(
  30. "SELECT id FROM cv WHERE user = :user AND visible = 1 ORDER BY lang = :lang DESC"
  31. );
  32. $statement->bindValue(':user', get_context()->get_user()->get_id(), PDO::PARAM_INT);
  33. $statement->bindValue(':lang', get_context()->get_lang(), PDO::PARAM_STR);
  34. $statement->execute();
  35. while ($r_cv = $statement->fetch(PDO::FETCH_ASSOC)){
  36. $c = new Cv($r_cv["id"]);
  37. array_push($this->cv, $c);
  38. if ($c->get_lang()->get_code() == get_context()->get_lang()) $this->main_cv = $c;
  39. array_push($this->other_cv, $c);
  40. }
  41. $this->set_title(Text::get("USER_NAME"));
  42. $this->set_description(Text::get("SECTION_ME") . " - " . Text::get("USER_NAME"));
  43. $this->set_canonical(URL::PROFILE);
  44. $this->add_css("profile.css");
  45. }
  46. /**
  47. * Retrieves the list of CVs.
  48. *
  49. * @return CV[] CV list.
  50. */
  51. public function get_cvs(){return $this->cv;}
  52. /**
  53. * Retrieves the main CV.
  54. *
  55. * @return Main CV.
  56. */
  57. public function get_main_cv(){return $this->main_cv;}
  58. /**
  59. * Retrieves the list of CVs excluding the main one.
  60. *
  61. * @return CV[] CV list, excluding the main one.
  62. */
  63. public function get_other_cvs(){return $this->other_cv;}
  64. }
  65. ?>