Cv.php 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. <?php
  2. require_once($path["entity"] . "Entity.php");
  3. require_once($path["entity"] . "Cv_Category.php");
  4. require_once($path["helper"] . "text.php");
  5. /**
  6. * Entry on the CV.
  7. *
  8. * Represents an object from the table 'cv'.
  9. */
  10. class Cv extends Entity{
  11. /**
  12. * Project identifier.
  13. */
  14. public $id;
  15. /**
  16. * {@see Cv_Category} of the entry.
  17. */
  18. public $category;
  19. /**
  20. * Role of the entry in the defined language.
  21. */
  22. public $role;
  23. /**
  24. * Company or center of the entry in the defined language.
  25. */
  26. public $company;
  27. /**
  28. * City.
  29. */
  30. public $city;
  31. /**
  32. * Start date of the activity.
  33. */
  34. public $start;
  35. /**
  36. * End date of the activity, or null if it's a current one.
  37. */
  38. public $end;
  39. /**
  40. * Date precission to show ("M" for months, "Y for years").
  41. */
  42. public $date_precission;
  43. /**
  44. * Description of the role in the defined language.
  45. */
  46. public $summary;
  47. /**
  48. * Indicates wether the activity must or mustn's be displayed.
  49. */
  50. public $visible;
  51. /**
  52. * Constructor.
  53. *
  54. * Searches the database and retrieves the information about the
  55. * entry, populating it and it's items.
  56. *
  57. * @param MySQL_connection $db Connection to the database.
  58. * @param string $lang Lowercase, two-letter language code.
  59. * @param int $id Identifier of the cv entry.
  60. */
  61. public function __construct($db, $lang, $id){
  62. parent::__construct($db, $lang);
  63. $s =
  64. "SELECT " .
  65. " id, " .
  66. " category, " .
  67. " role, " .
  68. " company, " .
  69. " city, " .
  70. " start, " .
  71. " end, " .
  72. " date_precission, " .
  73. " summary, " .
  74. " visible " .
  75. "FROM cv " .
  76. "WHERE " .
  77. " visible = 1 AND " .
  78. " id = $id ; ";
  79. $q = mysqli_query($this->db, $s);
  80. if (mysqli_num_rows($q) > 0){
  81. $r = mysqli_fetch_array($q);
  82. $this->id = $r["id"];
  83. $this->role = text($this, $r["role"]);
  84. $this->company = $r["company"];
  85. $this->city = text($this, $r["city"]);
  86. $this->start = $r["start"];
  87. $this->end = $r["end"];
  88. $this->date_precission = $r["date_precission"];
  89. $this->summary = text($this, $r["summary"]);
  90. $this->visible = $r["visible"];
  91. $this->category = new Cv_Category($this->db, $this->lang, $r["category"]);
  92. }
  93. }
  94. }
  95. ?>