License.php 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. <?php
  2. require_once(PATH::ENTITY . "Entity.php");
  3. /**
  4. * License.
  5. *
  6. * Represents an object from the table 'license'.
  7. */
  8. class License extends Entity{
  9. /**
  10. * @var string License identifier. Usually an abbreviation.
  11. */
  12. private $id;
  13. /**
  14. * @var string Short, easily readable text summarizing the full text of
  15. * the license.
  16. */
  17. private $summary;
  18. /**
  19. * @var string Full text of the license.
  20. */
  21. private $legal;
  22. /**
  23. * @var string License logo.
  24. */
  25. private $logo;
  26. /**
  27. * @var string License icon, small.
  28. */
  29. private $icon;
  30. /**
  31. * Constructor.
  32. *
  33. * Searches the database and retrieves the information about the
  34. * object, populating it.
  35. *
  36. * @param string $id Identifier of the license.
  37. */
  38. public function __construct($id){
  39. $statement = get_context()->get_db()->prepare("
  40. SELECT id, summary, legal, logo, icon
  41. FROM license
  42. WHERE id = :id
  43. ");
  44. $statement->bindValue(':id', $id, PDO::PARAM_STR);
  45. $statement->execute();
  46. $r_license = $statement->fetch(PDO::FETCH_ASSOC);
  47. if ($r_license !== false){
  48. $this->id = $r_license["id"];
  49. $this->summary = TEXT::get($r_license["summary"]);
  50. $this->legal = TEXT::get($r_license["legal"]);
  51. $this->logo = $r_license["logo"];
  52. $this->icon = $r_license["icon"];
  53. }
  54. else{
  55. Log::warn("License with id '$id' doesn't exist");
  56. }
  57. }
  58. /**
  59. * Retrieves the license identifier
  60. *
  61. * @return string License ID.
  62. */
  63. public function get_id(){
  64. return $this->id;
  65. }
  66. /**
  67. * Retrieves a short, easily readable text summarizing the full text of
  68. * the license.
  69. *
  70. * @return string License summary.
  71. */
  72. public function get_summary(){
  73. return $this->summary;
  74. }
  75. /**
  76. * Retrieves the full text of the license
  77. *
  78. * @return string License legal text.
  79. */
  80. public function get_legal(){
  81. return $this->legal;
  82. }
  83. /**
  84. * Retrieves the license logo.
  85. *
  86. * @return string The logo filename.
  87. */
  88. public function get_logo(){
  89. return $this->logo;
  90. }
  91. /**
  92. * Retrieves the license icon.
  93. *
  94. * @return string The icon filename.
  95. */
  96. public function get_icon(){
  97. return $this->icon;
  98. }
  99. }