class.xblogcomment.php 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  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 blogcomment
  24. class xblogcomment extends blogcomment
  25. {
  26. # Extraction des trackbacks dans un autre recordset
  27. function extractTrackbacks()
  28. {
  29. $res = array();
  30. foreach ($this->arry_data as $k => $v)
  31. {
  32. if ($v['comment_trackback'] == 1) {
  33. $res[] = $v;
  34. unset($this->arry_data[$k]);
  35. }
  36. }
  37. $this->recordSet(array_values($this->arry_data));
  38. $rs = new xblogcomment($res);
  39. $rs->setBlog($this->blog);
  40. return $rs;
  41. }
  42. function auteurLink()
  43. {
  44. if($this->f('comment_email') != '') {
  45. return $this->getEncodMail();
  46. } else {
  47. return false;
  48. }
  49. }
  50. function auteurSite()
  51. {
  52. if($this->f('comment_site') != '') {
  53. return 'http://'.$this->f('comment_site');
  54. } else {
  55. return false;
  56. }
  57. }
  58. function xGetContent()
  59. {
  60. if ($this->blog->use_smilies) {
  61. return $this->blog->addSmilies($this->getContent());
  62. } else {
  63. return $this->getContent();
  64. }
  65. }
  66. function getRSSSeq()
  67. {
  68. return ' <rdf:li rdf:resource="'.$this->getPermURL().'" />'."\n";
  69. }
  70. function getRSSItem($short=false)
  71. {
  72. $tb = (boolean) $this->f('comment_trackback');
  73. $desc = util::cutString(strip_tags($this->getContent()),300).'...';
  74. $content = ($short) ? $desc : $this->getContent();
  75. return
  76. '<item rdf:about="'.$this->getPermURL().'">'."\n".
  77. ' <title>'.($tb ? 'trackback - ' : '').
  78. $this->blog->toXML($this->f('post_titre')).' - '.
  79. $this->blog->toXML($this->f('comment_auteur'))."</title>\n".
  80. ' <link>'.$this->getPermURL()."</link>\n".
  81. ' <dc:date>'.$this->getIsoDate()."</dc:date>\n".
  82. ' <dc:creator>'.htmlspecialchars($this->f('comment_auteur'))."</dc:creator>\n".
  83. ' <description>'.$this->blog->toXML($desc)."</description>\n".
  84. ' <content:encoded><![CDATA['.$content."]]></content:encoded>\n".
  85. '</item>'."\n";
  86. }
  87. function getAtomEntry($short=false)
  88. {
  89. $tb = (boolean) $this->f('comment_trackback');
  90. if ($short) {
  91. $content = util::cutString(strip_tags($this->getContent()),300).'...';
  92. } else {
  93. $content = $this->getContent();
  94. }
  95. return
  96. '<entry>'."\n".
  97. ' <title>'.($tb ? 'trackback - ' : '').
  98. $this->blog->toXML($this->f('post_titre')).' - '.
  99. $this->blog->toXML($this->f('comment_auteur'))."</title>\n".
  100. ' <link rel="alternate" type="text/html" href="'.$this->getPermURL().'"/>'."\n".
  101. ' <issued>'.$this->getIsoDate()."</issued>\n".
  102. ' <modified>'.$this->getIsoDate()."</modified>\n".
  103. ' <id>'.$this->getPermURL()."</id>\n".
  104. ' <author><name>'.htmlspecialchars($this->f('comment_auteur'))."</name></author>\n".
  105. ' <content type="text/html" mode="escaped">'.htmlspecialchars($content)."</content>\n".
  106. '</entry>'."\n";
  107. }
  108. }
  109. ?>