b2evolution PHP Cross Reference Blogging Systems

Source: /skins/touch/_item_feedback.inc.php - 354 lines - 13575 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-2014 by Francois Planque - {@link http://fplanque.com/}

  18   *

  19   * @package evoskins

  20   * @subpackage touch

  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          'disp_section_title'   => true,
  36          'disp_rating_summary'  => true,
  37          'before_section_title' => '<h3 id="com-head" onclick="bnc_showhide_coms_toggle();"><img alt="arrow" src="'.$Skin->get_url().'img/com_arrow.png" id="com-arrow">',
  38          'after_section_title'  => '</h3>',
  39          'comment_list_start'   => '<ol id="commentlist" class="commentlist">',
  40          'comment_list_end'     => '</ol>',
  41          'comment_start'        => '<li><div class="comwrap">',
  42          'comment_end'          => '</div></li>',
  43          'preview_start'        => '<h3 id="com-head-preview" class="comhead-open">'.T_('Preview comment').'</h3><ol id="commentlist" class="commentlist" style="display:block"><li id="comment_preview"><div class="comwrap">',
  44          'preview_end'          => '</div></li></ol>',
  45          'comment_error_start'  => '<div class="bComment" id="comment_error">',
  46          'comment_error_end'    => '</div>',
  47          'comment_template'     => '_item_comment.inc.php',    // The template used for displaying individual comments (including preview)
  48          'author_link_text'     => 'login', // avatar | only_avatar | login | nickname | firstname | lastname | fullname | preferredname
  49          'link_to'              => 'userurl>userpage',            // 'userpage' or 'userurl' or 'userurl>userpage' or 'userpage>userurl'
  50          'form_title_start'     => '<h3 id="respond">',
  51          'form_title_end'       => '</h3>',
  52          'notification_text'    => T_( 'This is your post. You are receiving notifications when anyone comments on your posts.' ),
  53      ), $params );
  54  
  55  global $c, $tb, $pb, $redir;
  56  
  57  echo '<div id="comment_wrapper">';
  58  
  59  // ----------------- MODULES "Before Comments" EVENT -----------------

  60  modules_call_method( 'before_comments', $params );
  61  // -------------------- END OF MODULES EVENT ---------------------

  62  
  63  // Check if user is allowed to see comments, display corresponding message if not allowed

  64  if( $Item->can_see_comments( true ) )
  65  { // user is allowed to see comments
  66      if( empty($c) )
  67      {    // Comments not requested
  68          $params['disp_comments'] = false;                    // DO NOT Display the comments if not requested

  69          $params['disp_comment_form'] = false;            // DO NOT Display the comments form if not requested

  70      }
  71  
  72      if( empty($tb) || !$Item->can_receive_pings() )
  73      {    // Trackback not requested or not allowed
  74          $params['disp_trackbacks'] = false;                // DO NOT Display the trackbacks if not requested

  75          $params['disp_trackback_url'] = false;        // DO NOT Display the trackback URL if not requested

  76      }
  77  
  78      if( empty($pb) )
  79      {    // Pingback not requested
  80          $params['disp_pingbacks'] = false;                // DO NOT Display the pingbacks if not requested

  81      }
  82  
  83      if( ! ($params['disp_comments'] || $params['disp_comment_form'] || $params['disp_trackbacks'] || $params['disp_trackback_url'] || $params['disp_pingbacks'] ) )
  84      {    // Nothing more to do....
  85          return false;
  86      }
  87  
  88      echo '<a id="feedbacks"></a>';
  89  
  90      $type_list = array();
  91      $disp_title = array();
  92      $rating_summary = '';
  93  
  94      if( $params['disp_comments'] )
  95      {    // We requested to display comments
  96          if( $Item->can_see_comments() )
  97          {    // User can see a comments
  98              $type_list[] = 'comment';
  99              if( $title = $Item->get_feedback_title( 'comments' ) )
 100              {
 101                  $disp_title[] = $title;
 102              }
 103  
 104              if( $params['disp_rating_summary'] )
 105              {    // We requested to display rating summary
 106                  $rating_summary = $Item->get_rating_summary( $params );
 107              }
 108          }
 109          else
 110          {    // User cannot see comments
 111              $params['disp_comments'] = false;
 112          }
 113          echo '<a id="comments"></a>';
 114      }
 115  
 116      if( $params['disp_trackbacks'] )
 117      {
 118          $type_list[] = 'trackback';
 119          if( $title = $Item->get_feedback_title( 'trackbacks' ) )
 120          {
 121              $disp_title[] = $title;
 122          }
 123          echo '<a id="trackbacks"></a>';
 124      }
 125  
 126      if( $params['disp_pingbacks'] )
 127      {
 128          $type_list[] = 'pingback';
 129          if( $title = $Item->get_feedback_title( 'pingbacks' ) )
 130          {
 131              $disp_title[] = $title;
 132          }
 133          echo '<a id="pingbacks"></a>';
 134      }
 135  
 136      if( $params['disp_trackback_url'] )
 137      { // We want to display the trackback URL:
 138  
 139          echo $params['before_section_title'];
 140          echo T_('Trackback address for this post');
 141          echo $params['after_section_title'];
 142  
 143          /*

 144           * Trigger plugin event, which could display a captcha form, before generating a whitelisted URL:

 145           */
 146          if( ! $Plugins->trigger_event_first_true( 'DisplayTrackbackAddr', array('Item' => & $Item, 'template' => '<code>%url%</code>') ) )
 147          { // No plugin displayed a payload, so we just display the default:
 148              echo '<p class="trackback_url"><a href="'.$Item->get_trackback_url().'">'.T_('Trackback URL (right click and copy shortcut/link location)').'</a></p>';
 149          }
 150      }
 151  
 152  
 153      if( $params['disp_comments'] || $params['disp_trackbacks'] || $params['disp_pingbacks']  )
 154      {
 155          if( empty($disp_title) )
 156          {    // No title yet
 157              if( $title = $Item->get_feedback_title( 'feedbacks', '', T_('Feedback awaiting moderation'), T_('Feedback awaiting moderation'), array( 'review', 'draft' ), false ) )
 158              { // We have some feedback awaiting moderation: we'll want to show that in the title
 159                  $disp_title[] = $title;
 160              }
 161          }
 162  
 163          if( empty($disp_title) )
 164          {    // Still no title
 165              $disp_title[] = T_('No feedback yet');
 166          }
 167  
 168          $comments_per_page = !$Blog->get_setting( 'threaded_comments' ) ? $Blog->get_setting( 'comments_per_page' ) : 1000;
 169          $CommentList = new CommentList2( $Blog, $comments_per_page, 'CommentCache', 'c_' );
 170  
 171          // Filter list:

 172          $CommentList->set_default_filters( array(
 173                  'types' => $type_list,
 174                  'statuses' => NULL,
 175                  'post_ID' => $Item->ID,
 176                  'order' => $Blog->get_setting( 'comments_orderdir' ),
 177                  'threaded_comments' => $Blog->get_setting( 'threaded_comments' ),
 178              ) );
 179  
 180          $CommentList->load_from_Request();
 181  
 182          // Get ready for display (runs the query):

 183          $CommentList->display_init();
 184  
 185          // Set redir=no in order to open comment pages

 186          memorize_param( 'redir', 'string', '', 'no' );
 187  
 188          if( $Blog->get_setting( 'paged_comments' ) )
 189          { // Prev/Next page navigation
 190              $CommentList->page_links( array(
 191                      'page_url' => url_add_tail( $Item->get_permanent_url(), '#comments' ),
 192                  ) );
 193          }
 194  
 195  
 196          if( $Blog->get_setting( 'threaded_comments' ) )
 197          {    // Array to store the comment replies
 198              global $CommentReplies;
 199              $CommentReplies = array();
 200  
 201              if( $Comment = $Session->get('core.preview_Comment') )
 202              {    // Init PREVIEW comment
 203                  if( $Comment->item_ID == $Item->ID )
 204                  {
 205                      $CommentReplies[ $Comment->in_reply_to_cmt_ID ] = array( $Comment );
 206  
 207                      // Change the styles for preview comment

 208                      $params['before_section_title'] = '<h3 id="com-head" onclick="bnc_showhide_coms_toggle();" class="comhead-open"><img alt="arrow" src="'.$Skin->get_url().'img/com_arrow.png" id="com-arrow" class="com-arrow-down" />';
 209                      $params['comment_list_start'] = '<ol id="commentlist" class="commentlist" style="display:block">';
 210                      $params['preview_start'] = '<li id="comment_preview"><div class="comwrap">';
 211                      $params['preview_end'] = '</div></li>';
 212                  }
 213              }
 214          }
 215  
 216          echo $rating_summary;
 217  
 218          if( $params['disp_section_title'] )
 219          {    // Display title
 220              echo $params['before_section_title'];
 221              echo implode( ', ', $disp_title);
 222              echo $params['after_section_title'];
 223          }
 224  
 225          echo $params['comment_list_start'];
 226          /**

 227           * @var Comment

 228           */
 229          while( $Comment = & $CommentList->get_next() )
 230          {    // Loop through comments:
 231  
 232              if( $Blog->get_setting( 'threaded_comments' ) && $Comment->in_reply_to_cmt_ID > 0 )
 233              {    // Store the replies in a special array
 234                  if( !isset( $CommentReplies[ $Comment->in_reply_to_cmt_ID ] ) )
 235                  {
 236                      $CommentReplies[ $Comment->in_reply_to_cmt_ID ] = array();
 237                  }
 238                  $CommentReplies[ $Comment->in_reply_to_cmt_ID ][] = $Comment;
 239                  continue; // Skip dispay a comment reply here in order to dispay it after parent comment by function display_comment_replies()

 240              }
 241  
 242              // ------------------ COMMENT INCLUDED HERE ------------------

 243              skin_include( $params['comment_template'], array(
 244                      'Comment'         => & $Comment,
 245                      'comment_start'   => $params['comment_start'],
 246                      'comment_end'     => $params['comment_end'],
 247                      'author_link_text' => $params['author_link_text'],
 248                      'link_to'         => $params['link_to'],        // 'userpage' or 'userurl' or 'userurl>userpage' or 'userpage>userurl'
 249                  ) );
 250              // Note: You can customize the default item comment by copying the generic

 251              // /skins/_item_comment.inc.php file into the current skin folder.

 252              // ---------------------- END OF COMMENT ---------------------

 253  
 254              if( $Blog->get_setting( 'threaded_comments' ) )
 255              {    // Display the comment replies
 256                  display_comment_replies( $Comment->ID, $params );
 257              }
 258          }    // End of comment list loop.

 259          echo $params['comment_list_end'];
 260  
 261  
 262          if( $Blog->get_setting( 'paged_comments' ) )
 263          { // Prev/Next page navigation
 264              $CommentList->page_links( array(
 265                      'page_url' => url_add_tail( $Item->get_permanent_url(), '#comments' ),
 266                  ) );
 267          }
 268  
 269          // Restore "redir" param

 270          forget_param('redir');
 271  
 272          // _______________________________________________________________

 273          // Display count of comments to be moderated:

 274          $Item->feedback_moderation( 'feedbacks', '<div class="moderation_msg"><p>', '</p></div>', '',
 275                  T_('This post has 1 feedback awaiting moderation... %s'),
 276                  T_('This post has %d feedbacks awaiting moderation... %s') );
 277          // _______________________________________________________________

 278      }
 279  }
 280  
 281  // ------------------ COMMENT FORM INCLUDED HERE ------------------

 282  if( $Blog->get_ajax_form_enabled() )
 283  {
 284      $json_params = array(
 285          'action' => 'get_comment_form',
 286          'p' => $Item->ID,
 287          'blog' => $Blog->ID,
 288          'disp' => $disp,
 289          'params' => $params );
 290      display_ajax_form( $json_params );
 291  }
 292  else
 293  {
 294      skin_include( '_item_comment_form.inc.php', $params );
 295  }
 296  // Note: You can customize the default item comment form by copying the generic

 297  // /skins/_item_comment_form.inc.php file into the current skin folder.

 298  // ---------------------- END OF COMMENT FORM ---------------------

 299  
 300  // ----------- Register for item's comment notification -----------

 301  if( is_logged_in() && $Item->can_comment( NULL ) )
 302  {
 303      global $DB, $htsrv_url;
 304      global $UserSettings;
 305  
 306      echo '<div class="comment_notification">';
 307  
 308      $not_subscribed = true;
 309      $creator_User = $Item->get_creator_User();
 310  
 311      if( $Blog->get_setting( 'allow_subscriptions' ) )
 312      {
 313          $sql = 'SELECT count( sub_user_ID ) FROM T_subscriptions
 314                      WHERE sub_user_ID = '.$current_User->ID.' AND sub_coll_ID = '.$Blog->ID.' AND sub_comments <> 0';
 315          if( $DB->get_var( $sql ) > 0 )
 316          {
 317              echo '<p>'.T_( 'You are receiving notifications when anyone comments on any post.' );
 318              echo ' <a href="'.$Blog->get('subsurl').'">'.T_( 'Click here to manage your subscriptions.' ).'</a></p>';
 319              $not_subscribed = false;
 320          }
 321      }
 322  
 323      if( $not_subscribed && ( $creator_User->ID == $current_User->ID ) && ( $UserSettings->get( 'notify_published_comments', $current_User->ID ) != 0 ) )
 324      {
 325          echo '<p>'.$params['notification_text'];
 326          echo ' <a href="'.$Blog->get('subsurl').'">'.T_( 'Click here to manage your subscriptions.' ).'</a></p>';
 327          $not_subscribed = false;
 328      }
 329      if( $not_subscribed && $Blog->get_setting( 'allow_item_subscriptions' ) )
 330      {
 331          if( get_user_isubscription( $current_User->ID, $Item->ID ) )
 332          {
 333              echo '<p>'.T_( 'You will be notified by email when someone comments here.' );
 334              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></p>';
 335          }
 336          else
 337          {
 338              echo '<p><a href="'.$samedomain_htsrv_url.'action.php?mname=collections&action=isubs_update&p='.$Item->ID.'&amp;notify=1&amp;'.url_crumb( 'collections_isubs_update' ).'">'.T_( 'Notify me by email when someone comments here.' ).'</a></p>';
 339          }
 340      }
 341  
 342      echo '</div>';
 343  }
 344  
 345  
 346  if( $Item->can_see_comments( false ) && ( $params['disp_comments'] || $params['disp_trackbacks'] || $params['disp_pingbacks'] ) )
 347  {    // user is allowed to see comments
 348      // Display link for comments feed:

 349      $Item->feedback_feed_link( '_rss2', '<div class="feedback_feed_msg"><p>', '</p></div>' );
 350  }
 351  
 352  echo '</div>';// End of <div id="comment_wrapper">

 353  
 354  ?>

title

Description

title

Description

title

Description

title

title

Body