[ Index ]
 

Code source de b2evolution 2.1.0-beta

Accédez au Source d'autres logiciels libres

Classes | Fonctions | Variables | Constantes | Tables

title

Body

[fermer]

/blogs/skins/ -> _item_feedback.inc.php (source)

   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   */
  21  if( !defined('EVO_MAIN_INIT') ) die( 'Please, do not access this page directly.' );
  22  
  23  ?>
  24  <!-- ===================== START OF FEEDBACK ===================== -->
  25  <?php
  26  
  27  // Default params:

  28  $params = array_merge( array(
  29          'disp_comments'      =>    true,
  30          'disp_comment_form'     =>    true,
  31          'disp_trackbacks'       =>    true,
  32          'disp_trackback_url' =>    true,
  33          'disp_pingbacks'       =>    true,
  34          'before_section_title' => '<h3>',
  35          'after_section_title'  => '</h3>',
  36          'form_title_start' => '<h3>',
  37          'form_title_end'  => '</h3>',
  38      ), $params );
  39  
  40  
  41  global $c, $tb, $pb, $comment_allowed_tags, $comments_use_autobr;
  42  
  43  global $cookie_name, $cookie_email, $cookie_url;
  44  
  45  
  46  if( empty($c) )
  47  {    // Comments not requested
  48      $params['disp_comments'] = false;                    // DO NOT Display the comments if not requested

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

  50  }
  51  
  52  if( empty($tb) || !$Blog->get( 'allowtrackbacks' ) )
  53  {    // Trackback not requested or not allowed
  54      $params['disp_trackbacks'] = false;                // DO NOT Display the trackbacks if not requested

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

  56  }
  57  
  58  if( empty($pb) )
  59  {    // Pingback not requested
  60      $params['disp_pingbacks'] = false;                // DO NOT Display the pingbacks if not requested

  61  }
  62  
  63  if( ! ($params['disp_comments'] || $params['disp_comment_form'] || $params['disp_trackbacks'] || $params['disp_trackback_url'] || $params['disp_pingbacks'] ) )
  64  {    // Nothing more to do....
  65      return false;
  66  }
  67  
  68  echo '<a id="feedbacks"></a>';
  69  
  70  $type_list = array();
  71  $disp_title = array();
  72  
  73  if( $params['disp_comments'] )
  74  {    // We requested to display comments
  75      if( $Item->can_see_comments() )
  76      { // User can see a comments
  77          $type_list[] = "'comment'";
  78          if( $title = $Item->get_feedback_title( 'comments' ) )
  79          {
  80              $disp_title[] = $title;
  81          }
  82      }
  83      else
  84      { // Use cannot see comments
  85          $params['disp_comments'] = false;
  86      }
  87      echo '<a id="comments"></a>';
  88  }
  89  
  90  if( $params['disp_trackbacks'] )
  91  {
  92      $type_list[] = "'trackback'";
  93      if( $title = $Item->get_feedback_title( 'trackbacks' ) )
  94      {
  95          $disp_title[] = $title;
  96      }
  97      echo '<a id="trackbacks"></a>';
  98  }
  99  
 100  if( $params['disp_pingbacks'] )
 101  {
 102      $type_list[] = "'pingback'";
 103      if( $title = $Item->get_feedback_title( 'pingbacks' ) )
 104      {
 105          $disp_title[] = $title;
 106      }
 107      echo '<a id="pingbacks"></a>';
 108  }
 109  
 110  if( $params['disp_trackback_url'] )
 111  { // We want to display the trackback URL:
 112  
 113      echo $params['before_section_title'];
 114      echo T_('Trackback address for this post');
 115      echo $params['after_section_title'];
 116  
 117      /*

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

 119       */
 120      if( ! $Plugins->trigger_event_first_true( 'DisplayTrackbackAddr', array('Item' => & $Item, 'template' => '<code>%url%</code>') ) )
 121      { // No plugin displayed a payload, so we just display the default:
 122          echo '<p class="trackback_url"><a href="'.$Item->get_trackback_url().'">'.T_('Trackback URL (right click and copy shortcut/link location)').'</a></p>';
 123      }
 124  }
 125  
 126  
 127  if( $params['disp_comments'] || $params['disp_trackbacks'] || $params['disp_pingbacks']  )
 128  {
 129      if( empty($disp_title) )
 130      {    // No title yet
 131          if( $title = $Item->get_feedback_title( 'feedbacks', '', T_('Feedback awaiting moderation'), T_('Feedback awaiting moderation'), 'draft' ) )
 132          { // We have some feedback awaiting moderation: we'll want to show that in the title
 133              $disp_title[] = $title;
 134          }
 135      }
 136  
 137      if( empty($disp_title) )
 138      {    // Still no title
 139          $disp_title[] = T_('No feedback yet');
 140      }
 141  
 142      echo $params['before_section_title'];
 143      echo implode( ', ', $disp_title);
 144      echo $params['after_section_title'];
 145  
 146      $CommentList = & new CommentList( NULL, implode(',', $type_list), array('published'), $Item->ID, '', 'ASC' );
 147  
 148      /**

 149       * @var Comment

 150       */
 151      while( $Comment = & $CommentList->get_next() )
 152      {    // Loop through comments:
 153          ?>
 154          <!-- ========== START of a COMMENT/TB/PB ========== -->
 155          <?php $Comment->anchor() ?>
 156          <div class="bComment">
 157              <div class="bCommentTitle">
 158              <?php
 159                  switch( $Comment->get( 'type' ) )
 160                  {
 161                      case 'comment': // Display a comment:
 162                          $Comment->permanent_link( T_('Comment') );
 163                          echo ' '.T_('from:').' ';
 164                          $Comment->author();
 165                          $Comment->msgform_link( $Blog->get('msgformurl') );
 166                          $Comment->author_url( '', ' &middot; ', '' );
 167                          break;
 168  
 169                      case 'trackback': // Display a trackback:
 170                          $Comment->permanent_link( T_('Trackback') );
 171                          echo ' '.T_('from:').' ';
 172                          $Comment->author( '', '#', '', '#', 'htmlbody', true );
 173                          break;
 174  
 175                      case 'pingback': // Display a pingback:
 176                          $Comment->permanent_link( T_('Pingback') );
 177                          echo ' '.T_('from:').' ';
 178                          $Comment->author( '', '#', '', '#', 'htmlbody', true );
 179                          break;
 180                  }
 181              ?>
 182              </div>
 183              <?php $Comment->rating(); ?>
 184              <div class="bCommentText">
 185                  <?php $Comment->content() ?>
 186              </div>
 187              <div class="bCommentSmallPrint">
 188                  <?php $Comment->edit_link( '', '', '#', '#', 'permalink_right' ); /* Link to backoffice for editing */ ?>
 189                  <?php $Comment->delete_link( '', '', '#', '#', 'permalink_right' ); /* Link to backoffice for deleting */ ?>
 190  
 191                  <?php $Comment->date() ?> @ <?php $Comment->time( 'H:i' ) ?>
 192              </div>
 193          </div>
 194          <!-- ========== END of a COMMENT/TB/PB ========== -->
 195          <?php
 196      }    // End of comment list loop.

 197  
 198  
 199      // _______________________________________________________________

 200  
 201      // Display count of comments to be moderated:

 202      $Item->feedback_moderation( 'feedbacks', '<div class="moderation_msg"><p>', '</p></div>', '',
 203              T_('This post has 1 feedback awaiting moderation... %s'),
 204              T_('This post has %d feedbacks awaiting moderation... %s') );
 205  
 206      // _______________________________________________________________

 207  
 208      // Display link for comments feed:

 209      $Item->feedback_feed_link( '_rss2', '<div class="feedback_feed_msg"><p>', '</p></div>' );
 210  
 211      // _______________________________________________________________

 212  
 213  }
 214  
 215  
 216  
 217  /*

 218   * Comment form:

 219   */
 220  if( $params['disp_comment_form'] && $Item->can_comment() )
 221  { // We want to display the comments form and the item can be commented on:
 222  
 223  
 224  
 225      if( $Comment = $Session->get('core.preview_Comment') )
 226      {    // We have a comment to preview
 227          if( $Comment->item_ID == $Item->ID )
 228          { // display PREVIEW:
 229              ?>
 230              <div class="bComment" id="comment_preview">
 231                  <div class="bCommentTitle">
 232                  <?php
 233                      echo T_('PREVIEW Comment from:').' ';
 234                      $Comment->author();
 235                      $Comment->msgform_link( $Blog->get('msgformurl') );
 236                      $Comment->author_url( '', ' &middot; ', '' );
 237                  ?>
 238                  </div>
 239                  <div class="bCommentText">
 240                      <?php $Comment->content() ?>
 241                  </div>
 242                  <div class="bCommentSmallPrint">
 243                      <?php $Comment->date() ?> @ <?php $Comment->time( 'H:i' ) ?>
 244                  </div>
 245              </div>
 246  
 247              <?php
 248              // Form fields:

 249              $comment_content = $Comment->original_content;
 250              // for visitors:

 251              $comment_author = $Comment->author;
 252              $comment_author_email = $Comment->author_email;
 253              $comment_author_url = $Comment->author_url;
 254          }
 255  
 256          // delete any preview comment from session data:

 257          $Session->delete( 'core.preview_Comment' );
 258      }
 259      else
 260      { // New comment:
 261          $Comment = & new Comment();
 262          $comment_author = isset($_COOKIE[$cookie_name]) ? trim($_COOKIE[$cookie_name]) : '';
 263          $comment_author_email = isset($_COOKIE[$cookie_email]) ? trim($_COOKIE[$cookie_email]) : '';
 264          $comment_author_url = isset($_COOKIE[$cookie_url]) ? trim($_COOKIE[$cookie_url]) : '';
 265          if( empty($comment_author_url) )
 266          {    // Even if we have a blank cookie, let's reset this to remind the bozos what it's for
 267              $comment_author_url = 'http://';
 268          }
 269          $comment_content = '';
 270      }
 271  
 272  
 273      echo $params['form_title_start'];
 274      echo T_('Leave a comment');
 275      echo $params['form_title_end'];
 276  
 277  
 278      $Form = & new Form( $htsrv_url.'comment_post.php', 'bComment_form_id_'.$Item->ID, 'post' );
 279      $Form->begin_form( 'bComment', '', array( 'target' => '_self' ) );
 280  
 281      // TODO: dh> a plugin hook would be useful here to add something to the top of the Form.

 282      //           Actually, the best would be, if the $Form object could be changed by a plugin

 283      //           before display!

 284  
 285      $Form->hidden( 'comment_post_ID', $Item->ID );
 286      $Form->hidden( 'redirect_to',
 287              // Make sure we get back to the right page (on the right domain)

 288              // fplanque>> TODO: check if we can use the permalink instead but we must check that application wide,

 289              // that is to say: check with the comments in a pop-up etc...

 290              url_rel_to_same_host(regenerate_url( '', '', $Blog->get('blogurl'), '&' ), $htsrv_url) );
 291  
 292      if( is_logged_in() )
 293      { // User is logged in:
 294          $Form->begin_fieldset();
 295          $Form->info_field( T_('User'), '<strong>'.$current_User->get_preferred_name().'</strong>'
 296              .' '.get_user_profile_link( ' [', ']', T_('Edit profile') ) );
 297          $Form->end_fieldset();
 298      }
 299      else
 300      { // User is not logged in:
 301          // Note: we use funky field names to defeat the most basic guestbook spam bots

 302          $Form->text( 'u', $comment_author, 40, T_('Name'), '', 100, 'bComment' );
 303          $Form->text( 'i', $comment_author_email, 40, T_('Email'), '<br />'.T_('Your email address will <strong>not</strong> be revealed on this site.'), 100, 'bComment' );
 304          $Form->text( 'o', $comment_author_url, 40, T_('Website'), '<br />'.T_('Your URL will be displayed.'), 100, 'bComment' );
 305      }
 306  
 307      if( $Item->can_rate() )
 308      {    // Comment rating:
 309          $Form->begin_fieldset();
 310              echo $Form->begin_field( NULL, T_('Your vote'), true );
 311              $Comment->rating_input();
 312              echo $Form->end_field();
 313          $Form->end_fieldset();
 314      }
 315  
 316      echo '<div class="comment_toolbars">';
 317      // CALL PLUGINS NOW:

 318      $Plugins->trigger_event( 'DisplayCommentToolbar', array() );
 319      echo '</div>';
 320  
 321      // Message field:

 322      $note = '';
 323      // $note = T_('Allowed XHTML tags').': '.htmlspecialchars(str_replace( '><',', ', $comment_allowed_tags));

 324      $Form->textarea( 'p', $comment_content, 10, T_('Comment text'), $note, 40, 'bComment' );
 325  
 326      // set b2evoCanvas for plugins

 327      echo '<script type="text/javascript">var b2evoCanvas = document.getElementById( "p" );</script>';
 328  
 329      $comment_options = array();
 330  
 331      if( substr($comments_use_autobr,0,4) == 'opt-')
 332      {
 333          $comment_options[] = '<label><input type="checkbox" class="checkbox" name="comment_autobr" tabindex="6"'
 334                                                      .( ($comments_use_autobr == 'opt-out') ? ' checked="checked"' : '' )
 335                                                      .' value="1" /> '.T_('Auto-BR').'</label>'
 336                                                      .' <span class="note">('.T_('Line breaks become &lt;br /&gt;').')</span>';
 337      }
 338  
 339      if( ! is_logged_in() )
 340      { // User is not logged in:
 341          $comment_options[] = '<label><input type="checkbox" class="checkbox" name="comment_cookies" tabindex="7"'
 342                                                      .' checked="checked" value="1" /> '.T_('Remember me').'</label>'
 343                                                      .' <span class="note">('.T_('Name, email &amp; website').')</span>';
 344          // TODO: If we got info from cookies, Add a link called "Forget me now!" (without posting a comment).

 345  
 346          $comment_options[] = '<label><input type="checkbox" class="checkbox" name="comment_allow_msgform" tabindex="8"'
 347                                                      .' checked="checked" value="1" /> '.T_('Allow message form').'</label>'
 348                                                      .' <span class="note">('.T_('Allow users to contact you through a message form (your email will <strong>not</strong> be revealed.').')</span>';
 349          // TODO: If we have an email in a cookie, Add links called "Add a contact icon to all my previous comments" and "Remove contact icon from all my previous comments".

 350      }
 351  
 352      if( ! empty($comment_options) )
 353      {
 354          $Form->begin_fieldset();
 355              echo $Form->begin_field( NULL, T_('Options'), true );
 356              echo implode( '<br />', $comment_options );
 357              echo $Form->end_field();
 358          $Form->end_fieldset();
 359      }
 360  
 361      $Plugins->trigger_event( 'DisplayCommentFormFieldset', array( 'Form' => & $Form, 'Item' => & $Item ) );
 362  
 363      $Form->begin_fieldset();
 364          echo '<div class="input">';
 365  
 366          $Form->button_input( array( 'name' => 'submit_comment_post_'.$Item->ID.'[save]', 'class' => 'submit', 'value' => T_('Send comment'), 'tabindex' => 10 ) );
 367          $Form->button_input( array( 'name' => 'submit_comment_post_'.$Item->ID.'[preview]', 'class' => 'preview', 'value' => T_('Preview'), 'tabindex' => 9 ) );
 368  
 369          $Plugins->trigger_event( 'DisplayCommentFormButton', array( 'Form' => & $Form, 'Item' => & $Item ) );
 370  
 371          echo '</div>';
 372      $Form->end_fieldset();
 373      ?>
 374  
 375      <div class="clear"></div>
 376  
 377      <?php
 378      $Form->end_form();
 379  }
 380  
 381  
 382  /*

 383   * $Log: _item_feedback.inc.php,v $

 384   * Revision 1.10  2007/11/03 21:04:28  fplanque

 385   * skin cleanup

 386   *

 387   * Revision 1.9  2007/11/02 01:55:57  fplanque

 388   * comment ratings

 389   *

 390   * Revision 1.8  2007/11/01 19:52:46  fplanque

 391   * better comment forms

 392   *

 393   * Revision 1.7  2007/09/28 02:18:10  fplanque

 394   * minor

 395   *

 396   * Revision 1.6  2007/09/26 21:54:00  fplanque

 397   * minor

 398   *

 399   * Revision 1.5  2007/09/16 22:07:06  fplanque

 400   * cleaned up feedback form

 401   *

 402   * Revision 1.4  2007/09/08 19:31:28  fplanque

 403   * cleanup of XML feeds for comments on individual posts.

 404   *

 405   * Revision 1.3  2007/06/24 22:26:34  fplanque

 406   * improved feedback template

 407   *

 408   * Revision 1.2  2007/06/24 01:05:31  fplanque

 409   * skin_include() now does all the template magic for skins 2.0.

 410   * .disp.php templates still need to be cleaned up.

 411   *

 412   * Revision 1.1  2007/06/23 22:09:30  fplanque

 413   * feedback and item content templates.

 414   * Interim check-in before massive changes ahead.

 415   *

 416   * Revision 1.91  2007/04/26 00:11:04  fplanque

 417   * (c) 2007

 418   *

 419   * Revision 1.90  2007/04/03 19:22:22  blueyed

 420   * Fixed WhiteSpace

 421   *

 422   * Revision 1.89  2007/03/18 01:39:55  fplanque

 423   * renamed _main.php to main.page.php to comply with 2.0 naming scheme.

 424   * (more to come)

 425   *

 426   * Revision 1.88  2007/01/26 04:49:17  fplanque

 427   * cleanup

 428   *

 429   * Revision 1.87  2007/01/18 22:28:53  fplanque

 430   * no unnecessary complexity

 431   *

 432   * Revision 1.86  2007/01/16 22:53:38  blueyed

 433   * TODOs

 434   *

 435   * Revision 1.85  2006/12/28 23:20:40  fplanque

 436   * added plugin event for displaying comment form toolbars

 437   * used by smilies plugin

 438   *

 439   * Revision 1.84  2006/12/17 23:42:39  fplanque

 440   * Removed special behavior of blog #1. Any blog can now aggregate any other combination of blogs.

 441   * Look into Advanced Settings for the aggregating blog.

 442   * There may be side effects and new bugs created by this. Please report them :]

 443   *

 444   * Revision 1.83  2006/11/20 22:15:30  blueyed

 445   * whitespace

 446   *

 447   * Revision 1.82  2006/10/23 22:19:03  blueyed

 448   * Fixed/unified encoding of redirect_to param. Use just rawurlencode() and no funky &amp; replacements

 449   *

 450   * Revision 1.81  2006/10/15 21:30:46  blueyed

 451   * Use url_rel_to_same_host() for redirect_to params.

 452   */
 453  ?>


Généré le : Thu Nov 29 23:58:50 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics