artefact.class.php 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. <?php
  2. namespace Portfolio;
  3. /**
  4. * An artefact is any object the user can display in its portfolio.
  5. *
  6. * The artefact point either to a local file or to a url from which the object's content
  7. * can be fetched.
  8. *
  9. * Usage
  10. *
  11. * $artefact = new artefact();
  12. * $artefact->set_path('...');
  13. *
  14. * or
  15. *
  16. *
  17. * $artefact = new artefact();
  18. * $artefact->set_url('...');
  19. *
  20. * @copyright (c) 2012 University of Geneva
  21. * @license GNU General Public License - http://www.gnu.org/copyleft/gpl.html
  22. * @author Laurent Opprecht <laurent@opprecht.info>
  23. */
  24. class Artefact
  25. {
  26. protected $id = '';
  27. protected $mime_type = '';
  28. protected $name = '';
  29. protected $description = '';
  30. protected $path = '';
  31. protected $url = '';
  32. protected $creation_date = '';
  33. protected $modification_date = '';
  34. protected $metadata = null;
  35. /**
  36. *
  37. * @param string $file Either url or file path
  38. */
  39. public function __construct($file = '')
  40. {
  41. if ($file) {
  42. if (strpos($file, 'http') !== false) {
  43. $this->url = $file;
  44. } else {
  45. $this->path = $file;
  46. }
  47. }
  48. $this->id = uniqid('', true);
  49. $this->mime_type = '';
  50. $time = time();
  51. $this->creation_date = $time;
  52. $this->modification_date = $time;
  53. }
  54. public function get_id()
  55. {
  56. return $this->id;
  57. }
  58. public function set_id($value)
  59. {
  60. $this->id = $value;
  61. }
  62. public function get_name()
  63. {
  64. return $this->name;
  65. }
  66. public function set_name($value)
  67. {
  68. $this->name = $value;
  69. }
  70. public function get_mime_type()
  71. {
  72. return $this->mime_type;
  73. }
  74. public function set_mime_type($value)
  75. {
  76. $this->mime_type = $value;
  77. }
  78. public function get_description()
  79. {
  80. return $this->description;
  81. }
  82. public function set_description($value)
  83. {
  84. $this->description = $value;
  85. }
  86. public function get_path()
  87. {
  88. return $this->path;
  89. }
  90. public function set_path($value)
  91. {
  92. $this->path = $value;
  93. }
  94. public function get_url()
  95. {
  96. return $this->url;
  97. }
  98. public function set_url($value)
  99. {
  100. $this->url = $value;
  101. }
  102. public function get_creation_date()
  103. {
  104. return $this->creation_date;
  105. }
  106. public function set_creation_date($value)
  107. {
  108. $this->creation_date = $value;
  109. }
  110. public function get_modification_date()
  111. {
  112. return $this->modification_date;
  113. }
  114. public function set_modification_date($value)
  115. {
  116. $this->modification_date = $value;
  117. }
  118. public function get_metadata()
  119. {
  120. return $this->metadata;
  121. }
  122. public function set_metadata($value)
  123. {
  124. $this->metadata = $value;
  125. }
  126. }