License.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <?php
  2. require_once($path["model"] . "Entity.php");
  3. require_once($path["helper"] . "text.php");
  4. /**
  5. * License.
  6. *
  7. * Represents an object from the table 'license'.
  8. */
  9. class License extends Entity{
  10. /**
  11. * License identifier. Usually an abbreviation.
  12. */
  13. public $id;
  14. /**
  15. * Short, easily readable text summarizing the full text of the
  16. * license.
  17. */
  18. public $summary;
  19. /**
  20. * Full text of the license.
  21. */
  22. public $legal;
  23. /**
  24. * License logo.
  25. */
  26. public $logo;
  27. /**
  28. * License icon, small.
  29. */
  30. public $icon;
  31. /**
  32. * Constructor.
  33. *
  34. * Searches the database and retrieves the information about the
  35. * object, populating it.
  36. *
  37. * @param MySQL_connection $db Connection to the database.
  38. * @param string $lang Lowercase, two-letter language code.
  39. * @param string $id Database identifier of the license.
  40. */
  41. public function __construct($db, $lang, $id){
  42. parent::__construct($db, $lang);
  43. $s =
  44. "SELECT " .
  45. " id, " .
  46. " summary, " .
  47. " legal, " .
  48. " logo, " .
  49. " icon " .
  50. "FROM license " .
  51. "WHERE id = '$id'; ";
  52. $q = mysqli_query($this->db, $s);
  53. if (mysqli_num_rows($q) > 0){
  54. $r = mysqli_fetch_array($q);
  55. $this->id = $r["id"];
  56. $this->summary = text($this, $r["summary"]);
  57. $this->legal = text($this, $r["legal"]);
  58. $this->logo = $r["logo"];
  59. $this->icon = $r["icon"];
  60. }
  61. }
  62. }
  63. ?>