[ Index ]
 

Code source de Dotclear 1.2.5

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

title

Body

[fermer]

/ecrire/ -> comments.php (source)

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


Généré le : Fri Feb 23 21:40:15 2007 par Balluche grâce à PHPXref 0.7