Event.class.php 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. <?php
  2. /*
  3. @nom: Event
  4. @auteur: Idleman (idleman@idleman.fr)
  5. @description: Classe de gestion des évenements/news liés a chaques flux RSS/ATOM
  6. */
  7. class Event extends MysqlEntity{
  8. protected $id,$title,$guid,$content,$description,$pudate,$link,$feed,$category,$creator,$unread,$favorite;
  9. protected $TABLE_NAME = 'event';
  10. protected $CLASS_NAME = 'Event';
  11. protected $object_fields =
  12. array(
  13. 'id'=>'key',
  14. 'guid'=>'longstring',
  15. 'title'=>'string',
  16. 'creator'=>'string',
  17. 'content'=>'longstring',
  18. 'description'=>'longstring',
  19. 'link'=>'longstring',
  20. 'unread'=>'integer',
  21. 'feed'=>'integer',
  22. 'unread'=>'integer',
  23. 'favorite'=>'integer',
  24. 'pubdate'=>'integer',
  25. 'syncId'=>'integer',
  26. );
  27. protected $object_fields_index =
  28. array(
  29. 'feed'=>'index',
  30. 'unread'=>'index',
  31. 'favorite'=>'index'
  32. );
  33. function __construct($guid=null,$title=null,$description=null,$content=null,$pubdate=null,$link=null,$category=null,$creator=null){
  34. $this->guid = $guid;
  35. $this->title = $title;
  36. $this->creator = $creator;
  37. $this->content = $content;
  38. $this->description = $description;
  39. $this->pubdate = $pubdate;
  40. $this->link = $link;
  41. $this->category = $category;
  42. parent::__construct();
  43. }
  44. function getEventCountPerFolder(){
  45. $events = array();
  46. $results = $this->customQuery('SELECT COUNT('.MYSQL_PREFIX.$this->TABLE_NAME.'.id),'.MYSQL_PREFIX.'feed.folder FROM '.MYSQL_PREFIX.$this->TABLE_NAME.' INNER JOIN '.MYSQL_PREFIX.'feed ON ('.MYSQL_PREFIX.'event.feed = '.MYSQL_PREFIX.'feed.id) WHERE '.MYSQL_PREFIX.$this->TABLE_NAME.'.unread=1 GROUP BY '.MYSQL_PREFIX.'feed.folder');
  47. while($item = mysql_fetch_array($results)){
  48. $events[$item[1]] = $item[0];
  49. }
  50. return $events;
  51. }
  52. function setId($id){
  53. $this->id = $id;
  54. }
  55. function getCreator(){
  56. return $this->creator;
  57. }
  58. function setCreator($creator){
  59. $this->creator = $creator;
  60. }
  61. function getCategory(){
  62. return $this->category;
  63. }
  64. function setCategory($category){
  65. $this->category = $category;
  66. }
  67. function getDescription(){
  68. return $this->description;
  69. }
  70. function setDescription($description,$encoding = true){
  71. $this->description = $description;
  72. }
  73. function getPubdate($format=false){
  74. if($this->pubdate!=0){
  75. return ($format!=false?date($format,$this->pubdate):$this->pubdate);
  76. }else{
  77. return '';
  78. }
  79. }
  80. function getPubdateWithInstant($instant){
  81. $alpha = $instant - $this->pubdate;
  82. if ($alpha < 86400 ){
  83. $hour = floor($alpha/3600);
  84. $alpha = ($hour!=0?$alpha-($hour*3600):$alpha);
  85. $minuts = floor($alpha/60);
  86. return 'il y a '.($hour!=0?$hour.'h et':'').' '.$minuts.'min';
  87. }else{
  88. return 'le '.$this->getPubdate('d/m/Y à H:i:s');
  89. }
  90. }
  91. function setPubdate($pubdate){
  92. $this->pubdate = (is_numeric($pubdate)?$pubdate:strtotime($pubdate));
  93. }
  94. function getLink(){
  95. return $this->link;
  96. }
  97. function setLink($link){
  98. $this->link = $link;
  99. }
  100. function getId(){
  101. return $this->id;
  102. }
  103. function getTitle(){
  104. return $this->title;
  105. }
  106. function setTitle($title){
  107. $this->title = $title;
  108. }
  109. function getContent(){
  110. return $this->content;
  111. }
  112. function setContent($content,$encoding=true){
  113. $this->content = $content;
  114. }
  115. function getGuid(){
  116. return $this->guid;
  117. }
  118. function setGuid($guid){
  119. $this->guid = $guid;
  120. }
  121. function getSyncId(){
  122. return $this->syncId;
  123. }
  124. function setSyncId($syncId){
  125. $this->syncId = $syncId;
  126. }
  127. function getUnread(){
  128. return $this->unread;
  129. }
  130. function setUnread($unread){
  131. $this->unread = $unread;
  132. }
  133. function setFeed($feed){
  134. $this->feed = $feed;
  135. }
  136. function getFeed(){
  137. return $this->feed;
  138. }
  139. function setFavorite($favorite){
  140. $this->favorite = $favorite;
  141. }
  142. function getFavorite(){
  143. return $this->favorite;
  144. }
  145. }
  146. ?>