Profile_Page.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <?php
  2. require_once($path["page"] . "Page.php");
  3. require_once($path["entity"] . "Cv.php");
  4. require_once($path["helper"] . "text.php");
  5. /**
  6. * Profile page model.
  7. */
  8. class Profile_Page extends Page{
  9. /**
  10. * List of available {@see CV}.
  11. */
  12. public $cv = [];
  13. /**
  14. * {@see CV} in the current languages.
  15. */
  16. public $main_cv;
  17. /**
  18. * List {@see CV}s in other languages.
  19. */
  20. public $other_cv = [];
  21. /**
  22. * Constructor.
  23. *
  24. * Retrieves the data and initializes the variables.
  25. *
  26. * @param MySQL_connection $db Connection to the database.
  27. * @param string $lang Lowercase, two-letter language code.
  28. */
  29. public function __construct($db, $lang){
  30. global $path;
  31. global $base_url;
  32. parent::__construct($db, $lang);
  33. $this->view = $path["view"] . "profile.php";
  34. $s =
  35. "SELECT id " .
  36. "FROM cv " .
  37. "WHERE visible = 1 " .
  38. "ORDER BY lang = '" . $this->lang . "' DESC;";
  39. $q = mysqli_query($this->db, $s);
  40. while($r = mysqli_fetch_array($q)){
  41. $c = new Cv($this->db, $r["id"]);
  42. array_push($this->cv, $c);
  43. if ($c->lang == $this->lang){
  44. $this->main_cv = $c;
  45. }
  46. else{
  47. array_push($this->other_cv, $c);
  48. }
  49. }
  50. $this->title = text($this, "USER_NAME");
  51. $this->description = text($this, "SECTION_ME") . " - " . text($this, "USER_NAME");
  52. $this->canonical = $base_url . "/profile/";
  53. }
  54. }
  55. ?>