class.xblogpost.php 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. <?php
  2. # ***** BEGIN LICENSE BLOCK *****
  3. # This file is part of DotClear.
  4. # Copyright (c) 2004 Olivier Meunier and contributors. All rights
  5. # reserved.
  6. #
  7. # DotClear is free software; you can redistribute it and/or modify
  8. # it under the terms of the GNU General Public License as published by
  9. # the Free Software Foundation; either version 2 of the License, or
  10. # (at your option) any later version.
  11. #
  12. # DotClear is distributed in the hope that it will be useful,
  13. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. # GNU General Public License for more details.
  16. #
  17. # You should have received a copy of the GNU General Public License
  18. # along with DotClear; if not, write to the Free Software
  19. # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  20. #
  21. # ***** END LICENSE BLOCK *****
  22. #
  23. # Extension de la classe blogpost
  24. #
  25. class xblogpost extends blogpost
  26. {
  27. # Contenu (avec ou sans smilies)
  28. function getContent()
  29. {
  30. if ($this->blog->use_smilies) {
  31. return $this->blog->addSmilies($this->f('post_content'));
  32. } else {
  33. return $this->f('post_content');
  34. }
  35. }
  36. function getChapo()
  37. {
  38. if ($this->blog->use_smilies) {
  39. return $this->blog->addSmilies($this->f('post_chapo'));
  40. } else {
  41. return $this->f('post_chapo');
  42. }
  43. }
  44. function openComment()
  45. {
  46. return (
  47. dc_allow_comments && $this->f('post_open_comment') &&
  48. (dc_comments_ttl == 0 ||
  49. time()-(dc_comments_ttl*86400) < $this->getTS())
  50. );
  51. }
  52. function openTb()
  53. {
  54. return (
  55. dc_allow_trackbacks && $this->f('post_open_tb') &&
  56. (dc_comments_ttl == 0 ||
  57. time()-(dc_comments_ttl*86400) < $this->getTS())
  58. );
  59. }
  60. # Liens vers tous les billets pour l'en tête
  61. function getHeadLinks()
  62. {
  63. $res = '';
  64. $index = $this->int_index;
  65. $this->moveStart();
  66. while (!$this->EOF())
  67. {
  68. $res .= '<link rel="chapter" href="'.$this->getPermURL().'" '.
  69. 'title="'.$this->f('post_titre').'" />'."\n";
  70. $this->moveNext();
  71. }
  72. $this->move($index);
  73. return $res;
  74. }
  75. function nbComments($zero,$one,$more)
  76. {
  77. $nb = $this->f('nb_comment');
  78. if($nb == 0) {
  79. return $zero;
  80. } elseif($nb == 1) {
  81. return $one;
  82. } elseif($nb > 1) {
  83. return sprintf($more,$nb);
  84. }
  85. }
  86. function firstPostOfDay()
  87. {
  88. $prev_dt = NULL;
  89. if($this->movePrev()) {
  90. $prev_dt = $this->getLDate();
  91. $this->moveNext();
  92. }
  93. if($prev_dt == NULL || $prev_dt != $this->getLDate()) {
  94. return true;
  95. } else {
  96. return false;
  97. }
  98. }
  99. function getRSSSeq()
  100. {
  101. return ' <rdf:li rdf:resource="'.$this->getPermURL().'" />'."\n";
  102. }
  103. function getRSSItem($short=false)
  104. {
  105. if ($this->f('post_chapo') != '') {
  106. $desc = strip_tags($this->f('post_chapo'));
  107. } else {
  108. $desc = util::cutString(strip_tags($this->f('post_content')),300).'...';
  109. }
  110. if ($short) {
  111. $content = $desc;
  112. } else {
  113. $content = $this->f('post_chapo').' '.$this->f('post_content');
  114. }
  115. return
  116. '<item rdf:about="'.$this->getPermURL().'">'."\n".
  117. ' <title>'.$this->blog->toXML($this->f('post_titre'))."</title>\n".
  118. ' <link>'.$this->getPermURL()."</link>\n".
  119. ' <dc:date>'.$this->getIsoDate()."</dc:date>\n".
  120. (($this->f('post_lang')) ? ' <dc:language>'.$this->f('post_lang')."</dc:language>\n" : '').
  121. ' <dc:creator>'.htmlspecialchars($this->getUserCN())."</dc:creator>\n".
  122. ' <dc:subject>'.htmlspecialchars($this->f('cat_libelle'))."</dc:subject>\n".
  123. ' <description>'.$this->blog->toXML($desc)."</description>\n".
  124. ' <content:encoded><![CDATA['.$content."]]></content:encoded>\n".
  125. '</item>'."\n";
  126. }
  127. function getAtomEntry($short=false)
  128. {
  129. if ($this->f('post_chapo') != '') {
  130. $desc = strip_tags($this->f('post_chapo'));
  131. } else {
  132. $desc = util::cutString(strip_tags($this->f('post_content')),300).'...';
  133. }
  134. if ($short) {
  135. $content = $desc;
  136. } else {
  137. $content = $this->f('post_chapo').' '.$this->f('post_content');
  138. }
  139. return
  140. '<entry' .
  141. (($this->f('post_lang')) ? ' xml:lang="'.$this->f('post_lang').'"' : '').
  142. '>'."\n".
  143. ' <title>'.$this->blog->toXML($this->f('post_titre'))."</title>\n".
  144. ' <link rel="alternate" type="text/html" href="'.$this->getPermURL().'" />'."\n".
  145. ' <issued>'.$this->getIsoDate()."</issued>\n".
  146. ' <modified>'.$this->getIsoDate()."</modified>\n".
  147. ' <id>'.$this->getPermURL()."</id>\n".
  148. ' <author><name>'.htmlspecialchars($this->getUserCN())."</name></author>\n".
  149. ' <dc:subject>'.htmlspecialchars($this->f('cat_libelle'))."</dc:subject>\n".
  150. ' <summary>'.$this->blog->toXML($desc)."</summary>\n".
  151. ' <content type="text/html" mode="escaped">'.htmlspecialchars($content)."</content>\n".
  152. '</entry>'."\n";
  153. }
  154. }
  155. ?>