[ Index ]
 

Code source de Dotclear 2.0-beta6

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/admin/ -> comments.php (source)

   1  <?php
   2  # ***** BEGIN LICENSE BLOCK *****
   3  # This file is part of DotClear.
   4  # Copyright (c) 2005 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  require dirname(__FILE__).'/../inc/admin/prepend.php';
  24  
  25  dcPage::check('usage,contentadmin');
  26  
  27  # Creating filter combo boxes
  28  # Filter form we'll put in html_block
  29  $status_combo = array(
  30  '-' => ''
  31  );
  32  foreach ($core->blog->getAllCommentStatus() as $k => $v) {
  33      $status_combo[$v] = (string) $k;
  34  }
  35  
  36  $type_combo = array(
  37  '-' => '',
  38  __('comment') => 'co',
  39  __('trackback') => 'tb'
  40  );
  41  
  42  $sortby_combo = array(
  43  __('Date') => 'comment_dt',
  44  __('Entry title') => 'post_title',
  45  __('Author') => 'comment_author',
  46  __('Status') => 'comment_status'
  47  );
  48  
  49  $order_combo = array(
  50  __('Descending') => 'desc',
  51  __('Ascending') => 'asc'
  52  );
  53  
  54  
  55  /* Get comments
  56  -------------------------------------------------------- */
  57  $author = !empty($_GET['author']) ?    $_GET['author'] : '';
  58  $status = isset($_GET['status']) ?        $_GET['status'] : '';
  59  $type = !empty($_GET['type']) ?        $_GET['type'] : '';
  60  $sortby = !empty($_GET['sortby']) ?    $_GET['sortby'] : 'comment_dt';
  61  $order = !empty($_GET['order']) ?        $_GET['order'] : 'desc';
  62  $ip = !empty($_GET['ip']) ?            $_GET['ip'] : '';
  63  
  64  $with_spam = $author || $status || $type || $sortby != 'comment_dt' || $order != 'desc' || $ip;
  65  
  66  $show_filters = false;
  67  
  68  $page = !empty($_GET['page']) ? $_GET['page'] : 1;
  69  $nb_per_page =  30;
  70  
  71  if (!empty($_GET['nb']) && (integer) $_GET['nb'] > 0) {
  72      if ($nb_per_page != $_GET['nb']) {
  73          $show_filters = true;
  74      }
  75      $nb_per_page = (integer) $_GET['nb'];
  76  }
  77  
  78  $params['limit'] = array((($page-1)*$nb_per_page),$nb_per_page);
  79  $params['no_content'] = true;
  80  
  81  # Author filter
  82  if ($author !== '') {
  83      $params['q_author'] = $author;
  84      $show_filters = true;
  85  }
  86  
  87  # - Type filter
  88  if ($type == 'tb' || $type == 'co') {
  89      $params['comment_trackback'] = ($type == 'tb');
  90      $show_filters = true;
  91  }
  92  
  93  # - Status filter
  94  if ($status !== '' && in_array($status,$status_combo)) {
  95      $params['comment_status'] = $status;
  96      $show_filters = true;
  97  } elseif (!$with_spam) {
  98      $params['comment_status_not'] = -2;
  99  }
 100  
 101  # - IP filter
 102  if ($ip) {
 103      $params['comment_ip'] = $ip;
 104      $show_filters = true;
 105  }
 106  
 107  # Sortby and order filter
 108  if ($sortby !== '' && in_array($sortby,$sortby_combo)) {
 109      if ($order !== '' && in_array($order,$order_combo)) {
 110          $params['order'] = $sortby.' '.$order;
 111      }
 112      
 113      if ($sortby != 'comment_dt' || $order != 'desc') {
 114          $show_filters = true;
 115      }
 116  }
 117  
 118  # Actions combo box
 119  $combo_action = array();
 120  if ($core->auth->check('publish,contentadmin',$core->blog->id))
 121  {
 122      $combo_action[__('publish')] = 'publish';
 123      $combo_action[__('unpublish')] = 'unpublish';
 124      $combo_action[__('mark as pending')] = 'pending';
 125      $combo_action[__('mark as junk')] = 'junk';
 126  }
 127  if ($core->auth->check('delete,contentadmin',$core->blog->id))
 128  {
 129      $combo_action[__('delete')] = 'delete';
 130  }
 131  
 132  
 133  /* Get comments
 134  -------------------------------------------------------- */
 135  try {
 136      $comments = $core->blog->getComments($params);
 137      $counter = $core->blog->getComments($params,true);
 138      $comment_list = new adminCommentList($core,$comments,$counter->f(0));
 139  } catch (Exception $e) {
 140      $core->error->add($e->getMessage());
 141  }
 142  
 143  /* DISPLAY
 144  -------------------------------------------------------- */
 145  $starting_script = dcPage::jsLoad('js/_comments.js');
 146  if (!$show_filters) {
 147      $starting_script .= dcPage::jsLoad('js/filter-controls.js');
 148  }
 149  
 150  dcPage::open(__('Comment'),$starting_script);
 151  
 152  echo '<h2>'.__('Comments').'</h2>';
 153  
 154  if (!$core->error->flag())
 155  {
 156      # Filters
 157      if (!$show_filters) {
 158          echo '<p><a id="filter-control" class="form-control" href="#">'.
 159          __('Filters').'</a></p>';
 160      }
 161      
 162      echo
 163      '<form action="comments.php" method="get" id="filters-form">'.
 164      '<fieldset><legend>'.__('Filters').'</legend>'.
 165      '<div class="three-cols">'.
 166      '<div class="col">'.
 167      '<label>'.__('Type:').' '.
 168      form::combo('type',$type_combo,$type).
 169      '</label> '.
 170      '<label>'.__('Status:').' '.
 171      form::combo('status',$status_combo,$status).
 172      '</label>'.
 173      '</div>'.
 174      
 175      '<div class="col">'.
 176      '<p><label>'.__('Order by:').' '.
 177      form::combo('sortby',$sortby_combo,$sortby).
 178      '</label> '.
 179      '<label>'.__('Sort:').' '.
 180      form::combo('order',$order_combo,$order).
 181      '</label></p>'.
 182      '<p><label class="classic">'.    form::field('nb',3,3,$nb_per_page).' '.
 183      __('Comments per page').'</label></p>'.
 184      '</div>'.
 185      
 186      '<div class="col">'.
 187      '<p><label>'.__('Comment author:').' '.
 188      form::field('author',20,255,html::escapeHTML($author)).
 189      '</label>'.
 190      '<label>'.__('IP address:').' '.
 191      form::field('ip',20,39,html::escapeHTML($ip)).
 192      '</label></p>'.
 193      '<p><input type="submit" value="'.__('filter').'" /></p>'.
 194      '</div>'.
 195      
 196      '</div>'.
 197      '<br class="clear" />'. //Opera sucks
 198      '</fieldset>'.
 199      '</form>';
 200      
 201      if (!$with_spam) {
 202          $spam_count = $core->blog->getComments(array('comment_status'=>-2),true)->f(0);
 203          if ($spam_count == 1) {
 204              echo '<p>'.sprintf(__('You have one spam comments.'),'<strong>'.$spam_count.'</strong>').' '.
 205              '<a href="comments.php?status=-2">'.__('Show it.').'</a></p>';
 206          } elseif ($spam_count > 1) {
 207              echo '<p>'.sprintf(__('You have %s spam comments.'),'<strong>'.$spam_count.'</strong>').' '.
 208              '<a href="comments.php?status=-2">'.__('Show them.').'</a></p>';
 209          }
 210      }
 211      
 212      # Show comments
 213      $comment_list->display($page,$nb_per_page,
 214      '<form action="comments_actions.php" method="post" id="form-comments">'.
 215      
 216      '%s'.
 217      
 218      '<div class="two-cols">'.
 219      '<p class="col checkboxes-helpers"></p>'.
 220      
 221      '<p class="col right">'.__('Selected comments action:').' '.
 222      form::combo('action',$combo_action).
 223      '<input type="submit" value="'.__('ok').'" /></p>'.
 224      form::hidden(array('type'),$type).
 225      form::hidden(array('sortby'),$sortby).
 226      form::hidden(array('order'),$order).
 227      form::hidden(array('author'),$author).
 228      form::hidden(array('status'),$status).
 229      form::hidden(array('ip'),$ip).
 230      form::hidden(array('page'),$page).
 231      form::hidden(array('nb'),$nb_per_page).
 232      '</div>'.
 233      
 234      '</form>'
 235      );
 236  }
 237  
 238  dcPage::close();
 239  ?>


Généré le : Fri Feb 23 22:16:06 2007 par Balluche grâce à PHPXref 0.7