comments.php 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  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. require dirname(__FILE__).'/inc/prepend.php';
  23. require dirname(__FILE__).'/../inc/classes/class.multipage.php';
  24. $auth->check(1);
  25. include dirname(__FILE__).'/inc/connexion.php';
  26. # Mise hors ligne d'un commentaire
  27. if (!empty($_GET['com_id']) && isset($_GET['cancel']))
  28. {
  29. if ($blog->statusComment($_GET['com_id']) !== false)
  30. {
  31. $redir = 'comments.php';
  32. $redir .= (!empty($_GET['env'])) ? '?env='.$_GET['env'] : '';
  33. header('Location: '.$redir);
  34. exit;
  35. }
  36. }
  37. $nb_per_page = 30;
  38. $nb_comments = $blog->getNbComments();
  39. $max_pages = ceil($nb_comments/$nb_per_page);
  40. $env = (!empty($_GET['env']) && $_GET['env'] <= $max_pages) ? $_GET['env'] : 1;
  41. $comments = $blog->getComments('','DESC',(($env-1)*$nb_per_page).','.$nb_per_page);
  42. # Pour voir ou cacher les commentaires
  43. $js_openCloseAll = $h_script = '';
  44. if (!$comments->isEmpty())
  45. {
  46. $h_script =
  47. '<script type="text/javascript">'."\n".
  48. "js_comments_ids = new Array('".implode("','",$comments->getIDs('comment'))."');\n".
  49. //"window.onload = function() { mOpenClose(js_comments_ids,-1); }\n".
  50. "</script>\n";
  51. $js_openCloseAll =
  52. '<p class="small"><a href="#" onclick="mOpenClose(js_comments_ids,1)">'.__('show all').'</a> - '.
  53. '<a href="#" onclick="mOpenClose(js_comments_ids,-1)">'.__('hide all').'</a></p>';
  54. }
  55. # Ligne pour afficher un commentaire
  56. function ligne_comment($data,$i)
  57. {
  58. $comment_id = $data['comment_id'];
  59. $comment_dt = $data['comment_dt'];
  60. $comment_auteur = $data['comment_auteur'];
  61. $comment_email = $data['comment_email'];
  62. $comment_site = $data['comment_site'];
  63. $comment_content = $data['comment_content'];
  64. $comment_pub = $data['comment_pub'];
  65. $comment_ip = $data['comment_ip'];
  66. $comment_trackback = $data['comment_trackback'];
  67. $post_titre = $data['post_titre'];
  68. $post_id = $data['post_id'];
  69. $comment_date = date('d/m/Y H:i',strtotime($comment_dt));
  70. if($comment_pub)
  71. {
  72. $com_cancel = __('set offline');
  73. $com_style = '';
  74. $com_img = '<img src="images/check_on.png" '.
  75. 'alt="'.__('This comment is online').'" class="status" /> ';
  76. }
  77. else
  78. {
  79. $com_cancel = __('set online');
  80. $com_style = ' cancel';
  81. $com_img = '<img src="images/check_off.png" '.
  82. 'alt="'.__('This comment is offline').'" class="status" /> ';
  83. }
  84. $str_tb = ($comment_trackback == 1) ? ' - <strong>trackback</strong>' : '';
  85. $cancel_url = $_SERVER['REQUEST_URI'];
  86. $cancel_url .= (strpos($cancel_url,'?') !== false) ? '&amp;' : '?';
  87. $cancel_url .= 'com_id='.$comment_id.'&amp;cancel=1';
  88. $res = '<div class="ligne'.$com_style.'">'.
  89. '<h3 class="ligneTitre">'.$com_img.
  90. '<a href="#" onclick="openClose(\'comment'.$comment_id.'\',0); return false;">'.
  91. '<img src="images/plus.png" id="img_comment'.$comment_id.'" '.
  92. 'alt="'.__('show/hide').'" title="'.__('show/hide').'" /></a>&nbsp;&nbsp;'.
  93. '<a href="poster.php?post_id='.$post_id.'#c'.$comment_id.'">'.
  94. $post_titre.'</a>'.$str_tb.
  95. ' - <a style="font-weight: normal;" href="'.$cancel_url.'">'.$com_cancel.'</a>'.
  96. '</h3>'.
  97. '<p class="ligneInfo">'.$comment_date.' - '.$comment_auteur.'</p>';
  98. $res .= '<div id="comment'.$comment_id.'" class="comment" style="display:none">'.
  99. $comment_content.'</div>';
  100. $res .= '</div>';
  101. return $res;
  102. }
  103. # Affichage
  104. openPage(__('Comments'),$h_script);
  105. echo '<h2>'.__('Comments').'</h2>';
  106. echo '<p>'.__('Comments listed from most recent to oldest').'</p>';
  107. $lum = new multipage($env,'ligne_comment',$comments->getData(),$nb_comments,$nb_per_page);
  108. $lum->setOption('html_block','%s');
  109. $lum->setOption('html_row','%s');
  110. $lum->setOption('html_cell','%s');
  111. $lum->setOption('html_links','<p>'.__('Page(s)').' : %s</p>');
  112. $lum->setOption('html_cur_page','<strong>%s</strong>');
  113. $lum->setOption('html_prev','&lt;'.__('prev. page'));
  114. $lum->setOption('html_next',__('next page').'&gt;');
  115. $lum->setOption('html_prev_grp','...');
  116. $lum->setOption('html_next_grp','...');
  117. $lum->setOption('html_empty','<p><strong>'.__('No comment yet').'</strong></p>');
  118. echo $lum->getLinks();
  119. echo $js_openCloseAll;
  120. echo $lum->getPage();
  121. echo $lum->getLinks();
  122. closePage();
  123. ?>