b2evolution PHP Cross Reference Blogging Systems

Source: /skins/basic/_item_feedback.inc.php - 199 lines - 6200 bytes - Text - Print

Description: This is the template that displays the feedback for a post (comments, trackback, pingback...)

   1  <?php
   2  /**
   3   * This is the template that displays the feedback for a post
   4   * (comments, trackback, pingback...)
   5   *
   6   * You may want to call this file multiple time in a row with different $c $tb $pb params.
   7   * This allow to seprate different kinds of feedbacks instead of displaying them mixed together
   8   *
   9   * This file is not meant to be called directly.
  10   * It is meant to be called by an include in the main.page.php template.
  11   * To display a feedback, you should call a stub AND pass the right parameters
  12   * For example: /blogs/index.php?p=1&more=1&c=1&tb=1&pb=1
  13   * Note: don't code this URL by hand, use the template functions to generate it!
  14   *
  15   * b2evolution - {@link http://b2evolution.net/}
  16   *
  17   * @package evoskins
  18   * @subpackage basic
  19   */
  20  if( !defined('EVO_MAIN_INIT') ) die( 'Please, do not access this page directly.' );
  21  
  22  // Default params:
  23  $params = array_merge( array(
  24          'comment_start'        => '<div>',
  25          'comment_end'          => '</div>',
  26          'comment_template'     => '_item_comment.inc.php',    // The template used for displaying individual comments (including preview)
  27      ), $params );
  28  
  29  
  30  global $c, $cookie_name, $cookie_email, $cookie_url, $comment_allowed_tags;
  31  
  32  // Display filters:
  33  // You can change these and call this template multiple time if you want to separate comments from trackbacks
  34  $disp_comments = 1;                    // Display the comments if requested
  35  $disp_comment_form = 1;            // Display the comments form if comments requested
  36  $disp_trackbacks = 1;                // Display the trackbacks if requested
  37  $disp_trackback_url = 1;        // Display the trackbal URL if trackbacks requested
  38  $disp_pingbacks = 1;        // pingbacks (deprecated)
  39  
  40  
  41  
  42  if( empty($c) )
  43  {    // Comments not requested
  44      $disp_comments = 0;                    // DO NOT Display the comments if not requested
  45      $disp_comment_form = 0;            // DO NOT Display the comments form if not requested
  46  }
  47  
  48  if( empty($tb) || !$Item->can_receive_pings() )
  49  {    // Trackback not requested or not allowed
  50      $disp_trackbacks = 0;                // DO NOT Display the trackbacks if not requested
  51      $disp_trackback_url = 0;        // DO NOT Display the trackback URL if not requested
  52  }
  53  
  54  if( empty($pb) )
  55  {    // Pingback not requested
  56      $disp_pingbacks = 0;                // DO NOT Display the pingbacks if not requested
  57  }
  58  
  59  ?>
  60  <a id="feedbacks"></a>
  61  <?php
  62  
  63  if( ! ($disp_comments || $disp_comment_form || $disp_trackbacks || $disp_trackback_url || $disp_pingbacks ) )
  64  {    // Nothing more to do....
  65      return false;
  66  }
  67  
  68  $type_list = array();
  69  $disp_title = array();
  70  if(  $disp_comments )
  71  {    // We requested to display comments
  72      if( $Item->can_see_comments( true ) )
  73      { // User can see a comments
  74          $type_list[] = 'comment';
  75          $disp_title[] = T_("Comments");
  76      }
  77      else
  78      { // Use cannot see comments
  79          $disp_comments = false;
  80      }
  81      ?>
  82      <a id="comments"></a>
  83  <?php }
  84  if( $disp_trackbacks ) {
  85      $type_list[] = 'trackback';
  86      $disp_title[] = T_("Trackbacks"); ?>
  87      <a id="trackbacks"></a>
  88  <?php }
  89  if( $disp_pingbacks ) {
  90      $type_list[] = 'pingback';
  91      $disp_title[] = T_("Pingbacks"); ?>
  92      <a id="pingbacks"></a>
  93  <?php } ?>
  94  
  95  <?php
  96  if( $disp_trackback_url )
  97  {    // We want to display the trackback URL:
  98      ?>
  99      <h4><?php echo T_('Trackback address for this post:') ?></h4>
 100      <?php
 101      /*
 102       * Trigger plugin event, which could display a captcha form, before generating a whitelisted URL:
 103       * fp> What's the difference between a "whitelisted" URL and a normal trackback URL ??
 104       */
 105      if( ! $Plugins->trigger_event_first_true( 'DisplayTrackbackAddr', array('Item' => & $Item, 'template' => '<code>%url%</code>') ) )
 106      { // No plugin displayed a payload, so we just display the default:
 107          ?>
 108          <code><?php $Item->trackback_url() ?></code>
 109          <?php
 110      }
 111  }
 112  ?>
 113  
 114  <?php
 115  if( $disp_comments || $disp_trackbacks || $disp_pingbacks )
 116  {
 117      if( $disp_comments )
 118  ?>
 119  
 120  <!-- Title for comments, tbs, pbs... -->
 121  <h4><?php echo implode( ", ", $disp_title) ?>:</h4>
 122  
 123  <?php
 124  $comments_per_page = !$Blog->get_setting( 'threaded_comments' ) ? $Blog->get_setting( 'comments_per_page' ) : 1000;
 125  $CommentList = new CommentList2( $Blog, $comments_per_page );
 126  
 127  // Filter list:
 128  $CommentList->set_filters( array(
 129          'types' => $type_list,
 130          'statuses' => get_inskin_statuses(),
 131          'post_ID' => $Item->ID,
 132          'order' => $Blog->get_setting( 'comments_orderdir' ),
 133          'threaded_comments' => $Blog->get_setting( 'threaded_comments' ),
 134      ) );
 135  
 136  // Get ready for display (runs the query):
 137  $CommentList->display_init();
 138  
 139  $CommentList->display_if_empty( array(
 140          'msg_empty' => sprintf( /* TRANS: NO comments/trackbacks/pingbacks/ FOR THIS POST... */
 141                  T_('No %s for this post yet...'), implode( "/", $disp_title) ),
 142       ) );
 143  
 144  
 145  if( $Blog->get_setting( 'threaded_comments' ) )
 146  {    // Array to store the comment replies
 147      global $CommentReplies;
 148      $CommentReplies = array();
 149  }
 150  
 151  while( $Comment = & $CommentList->get_next() )
 152  {    // Loop through comments:
 153  
 154      if( $Blog->get_setting( 'threaded_comments' ) && $Comment->in_reply_to_cmt_ID > 0 )
 155      {    // Store the replies in a special array
 156          if( !isset( $CommentReplies[ $Comment->in_reply_to_cmt_ID ] ) )
 157          {
 158              $CommentReplies[ $Comment->in_reply_to_cmt_ID ] = array();
 159          }
 160          $CommentReplies[ $Comment->in_reply_to_cmt_ID ][] = $Comment;
 161          continue; // Skip dispay a comment reply here in order to dispay it after parent comment by function display_comment_replies()
 162      }
 163  
 164      // ------------------ COMMENT INCLUDED HERE ------------------
 165      skin_include( $params['comment_template'], array(
 166              'Comment'         => & $Comment,
 167              'comment_start'   => $params['comment_start'],
 168              'comment_end'     => $params['comment_end'],
 169          ) );
 170      // ---------------------- END OF COMMENT ---------------------
 171  
 172      if( $Blog->get_setting( 'threaded_comments' ) )
 173      {    // Display the comment replies
 174          display_comment_replies( $Comment->ID, $params );
 175      }
 176  }
 177  }
 178  
 179  if( $disp_comment_form )
 180  {    // We want to display the comments form:
 181      if( $Item->can_comment( '<p><em>', '</em></p>', '#', '#', '<h4>'.T_('Leave a comment').':</h4>' ) )
 182      { // User can leave a comment
 183          if( $Blog->get_ajax_form_enabled() )
 184          {
 185              $json_params = array( 
 186                  'action' => 'get_comment_form',
 187                  'p' => $Item->ID,
 188                  'blog' => $Blog->ID,
 189                  'disp' => $disp,
 190                  'params' => $params );
 191              display_ajax_form( $json_params );
 192          }
 193          else
 194          {
 195              skin_include( '_item_comment_form.inc.php', $params );
 196          }
 197      }
 198  }
 199  ?>

title

Description

title

Description

title

Description

title

title

Body