b2evolution PHP Cross Reference Blogging Systems

Source: /skins/glossyblue/_item_feedback.inc.php - 335 lines - 11396 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   * Released under GNU GPL License - {@link http://b2evolution.net/about/license.html}
  17   * @copyright (c)2003-2007 by Francois PLANQUE - {@link http://fplanque.net/}
  18   *
  19   * @package evoskins
  20   * @subpackage glossyblue
  21   */
  22  if( !defined('EVO_MAIN_INIT') ) die( 'Please, do not access this page directly.' );
  23  
  24  ?>
  25  <!-- ===================== START OF FEEDBACK ===================== -->
  26  <?php
  27  
  28  // Default params:
  29  $params = array_merge( array(
  30          'disp_comments'      =>    true,
  31          'disp_comment_form'     =>    true,
  32          'disp_trackbacks'       =>    true,
  33          'disp_trackback_url' =>    true,
  34          'disp_pingbacks'       =>    true,
  35          'before_section_title' => '<h3>',
  36          'after_section_title'  => '</h3>',
  37          'form_title_start' => '<h3>',
  38          'form_title_end'  => '</h3>',
  39          'before_comment_error' => '<p><em>',
  40          'after_comment_error'  => '</em></p>',
  41          'before_comment_form'  => '',
  42          'after_comment_form'   => '',
  43          'comment_template'     => '_item_comment.inc.php',    // The template used for displaying individual comments (including preview)
  44          'comment_start'        => '<li>',
  45          'comment_end'          => '</li>',
  46          'notification_before'  => '<div class="comment_notification">',
  47          'notification_text'    => T_( 'This is your post. You are receiving notifications when anyone comments on your posts.' ),
  48          'notification_text2'   => T_( 'You will be notified by email when someone comments here.' ),
  49          'notification_text3'   => T_( 'Notify me by email when someone comments here.' ),
  50          'notification_after'   => '</div>',
  51          'feed_title'           => '#',
  52      ), $params );
  53  
  54  
  55  global $c, $tb, $pb, $redir, $comment_allowed_tags;
  56  
  57  global $cookie_name, $cookie_email, $cookie_url;
  58  
  59  
  60  if( $Item->can_see_comments( true ) )
  61  {
  62      if( empty($c) )
  63      {    // Comments not requested
  64          $params['disp_comments'] = false;                    // DO NOT Display the comments if not requested
  65          $params['disp_comment_form'] = false;            // DO NOT Display the comments form if not requested
  66      }
  67  
  68      if( empty($tb) || !$Item->can_receive_pings() )
  69      {    // Trackback not requested or not allowed
  70          $params['disp_trackbacks'] = false;                // DO NOT Display the trackbacks if not requested
  71          $params['disp_trackback_url'] = false;        // DO NOT Display the trackback URL if not requested
  72      }
  73  
  74      if( empty($pb) )
  75      {    // Pingback not requested
  76          $params['disp_pingbacks'] = false;                // DO NOT Display the pingbacks if not requested
  77      }
  78  
  79      if( ! ($params['disp_comments'] || $params['disp_comment_form'] || $params['disp_trackbacks'] || $params['disp_trackback_url'] || $params['disp_pingbacks'] ) )
  80      {    // Nothing more to do....
  81          return false;
  82      }
  83  
  84      echo '<a id="feedbacks"></a>';
  85  
  86      $type_list = array();
  87      $disp_title = array();
  88  
  89      if( $params['disp_comments'] )
  90      {    // We requested to display comments
  91          if( $Item->can_see_comments() )
  92          { // User can see a comments
  93              $type_list[] = 'comment';
  94              if( $title = $Item->get_feedback_title( 'comments' ) )
  95              {
  96                  $disp_title[] = $title;
  97              }
  98          }
  99          else
 100          { // Use cannot see comments
 101              $params['disp_comments'] = false;
 102          }
 103          echo '<a id="comments"></a>';
 104      }
 105  
 106      if( $params['disp_trackbacks'] )
 107      {
 108          $type_list[] = 'trackback';
 109          if( $title = $Item->get_feedback_title( 'trackbacks' ) )
 110          {
 111              $disp_title[] = $title;
 112          }
 113          echo '<a id="trackbacks"></a>';
 114      }
 115  
 116      if( $params['disp_pingbacks'] )
 117      {
 118          $type_list[] = 'pingback';
 119          if( $title = $Item->get_feedback_title( 'pingbacks' ) )
 120          {
 121              $disp_title[] = $title;
 122          }
 123          echo '<a id="pingbacks"></a>';
 124      }
 125  
 126      if( $params['disp_trackback_url'] )
 127      { // We want to display the trackback URL:
 128  
 129          echo $params['before_section_title'];
 130          echo T_('Trackback address for this post');
 131          echo $params['after_section_title'];
 132  
 133          /*
 134           * Trigger plugin event, which could display a captcha form, before generating a whitelisted URL:
 135           */
 136          if( ! $Plugins->trigger_event_first_true( 'DisplayTrackbackAddr', array('Item' => & $Item, 'template' => '<code>%url%</code>') ) )
 137          { // No plugin displayed a payload, so we just display the default:
 138              echo '<p class="trackback_url"><a href="'.$Item->get_trackback_url().'">'.T_('Trackback URL (right click and copy shortcut/link location)').'</a></p>';
 139          }
 140      }
 141  
 142  
 143      if( $params['disp_comments'] || $params['disp_trackbacks'] || $params['disp_pingbacks']  )
 144      {
 145          if( empty($disp_title) )
 146          {    // No title yet
 147              if( $title = $Item->get_feedback_title( 'feedbacks', '', T_('Feedback awaiting moderation'), T_('Feedback awaiting moderation'), array( 'review', 'draft' ), false ) )
 148              { // We have some feedback awaiting moderation: we'll want to show that in the title
 149                  $disp_title[] = $title;
 150              }
 151          }
 152  
 153          if( empty($disp_title) )
 154          {    // Still no title
 155              $disp_title[] = T_('No feedback yet');
 156          }
 157  
 158          echo $params['before_section_title'];
 159          echo implode( ', ', $disp_title);
 160          echo $params['after_section_title'];
 161  
 162          $comments_per_page = !$Blog->get_setting( 'threaded_comments' ) ? $Blog->get_setting( 'comments_per_page' ) : 1000;
 163          $CommentList = new CommentList2( $Blog, $comments_per_page, 'CommentCache', 'c_' );
 164  
 165          // Filter list:
 166          $CommentList->set_default_filters( array(
 167                  'types' => $type_list,
 168                  'statuses' => NULL,
 169                  'post_ID' => $Item->ID,
 170                  'order' => $Blog->get_setting( 'comments_orderdir' ),
 171                  'threaded_comments' => $Blog->get_setting( 'threaded_comments' ),
 172              ) );
 173  
 174          $CommentList->load_from_Request();
 175  
 176          // Get ready for display (runs the query):
 177          $CommentList->display_init();
 178  
 179          // Set redir=no in order to open comment pages
 180          memorize_param( 'redir', 'string', '', 'no' );
 181  
 182          if( $Blog->get_setting( 'paged_comments' ) )
 183          { // Prev/Next page navigation
 184              $CommentList->page_links( array(
 185                      'page_url' => url_add_tail( $Item->get_permanent_url(), '#comments' ),
 186                  ) );
 187          }
 188  
 189  
 190          if( $Blog->get_setting( 'threaded_comments' ) )
 191          {    // Array to store the comment replies
 192              global $CommentReplies;
 193              $CommentReplies = array();
 194  
 195              if( $Comment = $Session->get('core.preview_Comment') )
 196              {    // Init PREVIEW comment
 197                  if( $Comment->item_ID == $Item->ID )
 198                  {
 199                      $CommentReplies[ $Comment->in_reply_to_cmt_ID ] = array( $Comment );
 200                  }
 201              }
 202          }
 203      ?>
 204  
 205      <ol class="commentlist">
 206      <?php
 207          /* This variable is for alternating comment background */
 208          global $glossyblue_oddcomment;
 209          $glossyblue_oddcomment = 'alt';
 210          /**
 211           * @var Comment
 212           */
 213          while( $Comment = & $CommentList->get_next() )
 214          {    // Loop through comments:
 215  
 216              if( $Blog->get_setting( 'threaded_comments' ) && $Comment->in_reply_to_cmt_ID > 0 )
 217              {    // Store the replies in a special array
 218                  if( !isset( $CommentReplies[ $Comment->in_reply_to_cmt_ID ] ) )
 219                  {
 220                      $CommentReplies[ $Comment->in_reply_to_cmt_ID ] = array();
 221                  }
 222                  $CommentReplies[ $Comment->in_reply_to_cmt_ID ][] = $Comment;
 223                  continue; // Skip dispay a comment reply here in order to dispay it after parent comment by function display_comment_replies()
 224              }
 225  
 226              // ------------------ COMMENT INCLUDED HERE ------------------
 227              skin_include( $params['comment_template'], array(
 228                      'Comment'         => & $Comment,
 229                      'comment_start'   => '<li id="comment-'.$Comment->ID.'" class="">',
 230                      'comment_end'     => $params['comment_end'],
 231                  ) );
 232              // ---------------------- END OF COMMENT ---------------------
 233  
 234              if( $Blog->get_setting( 'threaded_comments' ) )
 235              {    // Display the comment replies
 236                  $params['comment_start'] = '<li id="comment-'.$Comment->ID.'" class="">';
 237                  display_comment_replies( $Comment->ID, $params );
 238              }
 239  
 240          }    // End of comment list loop.
 241      ?>
 242      </ol><?php
 243  
 244          if( $Blog->get_setting( 'paged_comments' ) )
 245          { // Prev/Next page navigation
 246              $CommentList->page_links( array(
 247                      'page_url' => url_add_tail( $Item->get_permanent_url(), '#comments' ),
 248                  ) );
 249          }
 250  
 251          // Restore "redir" param
 252          forget_param('redir');
 253  
 254          // Display count of comments to be moderated:
 255          $Item->feedback_moderation( 'feedbacks', '<div class="moderation_msg"><p>', '</p></div>', '',
 256                  T_('This post has 1 feedback awaiting moderation... %s'),
 257                  T_('This post has %d feedbacks awaiting moderation... %s') );
 258      }
 259  
 260          // _______________________________________________________________
 261  
 262  }
 263  
 264  // ------------------ COMMENT FORM INCLUDED HERE ------------------
 265  if( $Blog->get_ajax_form_enabled() )
 266  {
 267      $json_params = array( 
 268          'action' => 'get_comment_form',
 269          'p' => $Item->ID,
 270          'blog' => $Blog->ID,
 271          'disp' => $disp,
 272          'params' => $params );
 273      display_ajax_form( $json_params );
 274  }
 275  else
 276  {
 277      skin_include( '_item_comment_form.inc.php', $params );
 278  }
 279  // ---------------------- END OF COMMENT FORM ---------------------
 280  
 281  
 282  // ----------- Register for item's comment notification -----------
 283  if( is_logged_in() && $Item->can_comment( NULL ) )
 284  {
 285      global $DB, $htsrv_url;
 286      global $UserSettings;
 287  
 288      $not_subscribed = true;
 289      $creator_User = $Item->get_creator_User();
 290  
 291      if( $Blog->get_setting( 'allow_subscriptions' ) )
 292      {
 293          $sql = 'SELECT count( sub_user_ID ) FROM T_subscriptions
 294                      WHERE sub_user_ID = '.$current_User->ID.' AND sub_coll_ID = '.$Blog->ID.' AND sub_comments <> 0';
 295          if( $DB->get_var( $sql ) > 0 )
 296          {
 297              echo '<p>'.T_( 'You are receiving notifications when anyone comments on any post.' );
 298              echo ' <a href="'.$Blog->get('subsurl').'">'.T_( 'Click here to manage your subscriptions.' ).'</a></p>';
 299              $not_subscribed = false;
 300          }
 301      }
 302  
 303      echo $params['notification_before'];
 304  
 305      $notification_icon = get_icon( 'notification' );
 306  
 307      if( $not_subscribed && ( $creator_User->ID == $current_User->ID ) && ( $UserSettings->get( 'notify_published_comments', $current_User->ID ) != 0 ) )
 308      {
 309          echo '<p>'.$notification_icon.' <span>'.$params['notification_text'];
 310          echo ' <a href="'.$Blog->get('subsurl').'">'.T_( 'Click here to manage your subscriptions.' ).'</a></span></p>';
 311          $not_subscribed = false;
 312      }
 313      if( $not_subscribed && $Blog->get_setting( 'allow_item_subscriptions' ) )
 314      {
 315          if( get_user_isubscription( $current_User->ID, $Item->ID ) )
 316          {
 317              echo '<p>'.$notification_icon.' <span>'.$params['notification_text2'];
 318              echo ' <a href="'.$samedomain_htsrv_url.'action.php?mname=collections&action=isubs_update&p='.$Item->ID.'&amp;notify=0&amp;'.url_crumb( 'collections_isubs_update' ).'">'.T_( 'Click here to unsubscribe.' ).'</a></span></p>';
 319          }
 320          else
 321          {
 322              echo '<p>'.$notification_icon.' <span><a href="'.$samedomain_htsrv_url.'action.php?mname=collections&action=isubs_update&p='.$Item->ID.'&amp;notify=1&amp;'.url_crumb( 'collections_isubs_update' ).'">'.$params['notification_text3'].'</a></span></p>';
 323          }
 324      }
 325  
 326      echo $params['notification_after'];
 327  }
 328  
 329  
 330  if( $Item->can_see_comments( false ) && ( $params['disp_comments'] || $params['disp_trackbacks'] || $params['disp_pingbacks'] ) )
 331  {    // user is allowed to see comments
 332      // Display link for comments feed:
 333      $Item->feedback_feed_link( '_rss2', '<div class="feedback_feed_msg"><p>', '</p></div>', $params['feed_title'] );
 334  }
 335  ?>

title

Description

title

Description

title

Description

title

title

Body