b2evolution PHP Cross Reference Blogging Systems

Source: /inc/comments/views/_comment.form.php - 312 lines - 10032 bytes - Text - Print

Description: This file implements the Comment form. This file is part of the b2evolution/evocms project - {@link http://b2evolution.net/}. See also {@link http://sourceforge.net/projects/evocms/}.

   1  <?php
   2  /**
   3   * This file implements the Comment form.
   4   *
   5   * This file is part of the b2evolution/evocms project - {@link http://b2evolution.net/}.
   6   * See also {@link http://sourceforge.net/projects/evocms/}.
   7   *
   8   * @copyright (c)2003-2014 by Francois Planque - {@link http://fplanque.com/}.
   9   *
  10   * @license http://b2evolution.net/about/license.html GNU General Public License (GPL)
  11   *
  12   * @package admin
  13   *
  14   * {@internal Below is a list of authors who have contributed to design/coding of this file: }}
  15   * @author fplanque: Francois PLANQUE
  16   *
  17   * @version $Id: _comment.form.php 6136 2014-03-08 07:59:48Z manuel $
  18   */
  19  if( !defined('EVO_MAIN_INIT') ) die( 'Please, do not access this page directly.' );
  20  
  21  /**
  22   * @var Blog
  23   */
  24  global $Blog;
  25  /**
  26   * @var Comment
  27   */
  28  global $edited_Comment;
  29  /**
  30   *
  31   */
  32  global $Plugins;
  33  
  34  global $mode, $month, $tab, $redirect_to, $comment_content;
  35  
  36  $Form = new Form( NULL, 'comment_checkchanges', 'post' );
  37  
  38  $link_attribs = array( 'style' => 'margin-right: 3ex;' ); // Avoid misclicks by all means!
  39  if( $current_User->check_perm( 'blog_post!draft', 'edit', false, $Blog->ID ) )
  40  {
  41      $Form->global_icon( T_( 'Elevate this comment into a post' ), '', '?ctrl=comments&amp;action=elevate&amp;comment_ID='.$edited_Comment->ID.'&amp;'.url_crumb('comment'),
  42                  T_( 'Elevate into a post' ), 4, 3, $link_attribs );
  43  }
  44  
  45  $delete_url = '?ctrl=comments&amp;action=delete&amp;comment_ID='.$edited_Comment->ID.'&amp;'.url_crumb('comment');
  46  if( $edited_Comment->status == 'trash' )
  47  {
  48      $delete_title = T_('Delete this comment');
  49      $delete_text = T_('delete');
  50      $link_attribs['onclick'] = 'return confirm(\''.TS_('You are about to delete this comment!\\nThis cannot be undone!').'\')';
  51  }
  52  else
  53  {
  54      $delete_title = T_('Recycle this comment');
  55      $delete_text = T_('recycle');
  56  }
  57  $Form->global_icon( $delete_title, 'delete', $delete_url, $delete_text, 4, 3, $link_attribs );
  58  
  59  $Form->global_icon( T_('Cancel editing!'), 'close', str_replace( '&', '&amp;', $redirect_to), T_('cancel'), 4, 1 );
  60  
  61  $Form->begin_form( 'eform' );
  62  
  63  $Form->add_crumb( 'comment' );
  64  $Form->hidden( 'ctrl', 'comments' );
  65  $Form->hidden( 'redirect_to', $redirect_to );
  66  $Form->hidden( 'comment_ID', $edited_Comment->ID );
  67  ?>
  68  
  69  <div class="clear"></div>
  70  
  71  <div class="left_col">
  72  
  73  
  74      <?php
  75      $Form->begin_fieldset( T_('Comment contents') );
  76  
  77      echo '<table cellspacing="0" class="compose_layout">';
  78  
  79      echo '<tr><td width="1%"><strong>'.T_('In response to').':</strong></td>';
  80      echo '<td>';
  81      $comment_Item = & $edited_Comment->get_Item();
  82      $comment_Item->title( array(
  83              'link_type' => 'admin_view',
  84              'max_length' => '30'
  85          ) );
  86      echo '</td>';
  87  
  88      $Blog_owner_User = & $Blog->get_owner_User();
  89      if( ( $Blog_owner_User->ID == $current_User->ID ) || $current_User->check_perm( 'blog_admin', 'edit', false, $Blog->ID ) )
  90      { // User has prmission to change comment's post, because user is the owner of the current blog, or user has admin full access permission for current blog
  91          $Form->switch_layout( 'none' );
  92  
  93          // Move to another post
  94          echo '<td width="1%">&nbsp;&nbsp;<strong>'.T_('Move to post ID').':</strong></td>';
  95          echo '<td class="input">';
  96          $Form->text_input( 'moveto_post', $comment_Item->ID, 20, '', '', array('maxlength'=>100, 'style'=>'width:25%;') );
  97          echo '</td>';
  98  
  99          $Form->switch_layout( NULL );
 100      }
 101  
 102      echo '</tr></table>';
 103      echo '<table cellspacing="0" class="compose_layout">';
 104  
 105      if( ! $edited_Comment->get_author_User() )
 106      { // This is not a member comment
 107          $Form->switch_layout( 'none' );
 108  
 109          echo '<tr><td width="1%"><strong>'.T_('Author').':</strong></td>';
 110          echo '<td class="input">';
 111          $Form->text_input( 'newcomment_author', $edited_Comment->author, 20, '', '', array('maxlength'=>100, 'style'=>'width: 100%;' ) );
 112          echo '</td></tr>';
 113  
 114          echo '<tr><td width="1%"><strong>'.T_('Email').':</strong></td>';
 115          echo '<td class="input">';
 116          $Form->text_input( 'newcomment_author_email', $edited_Comment->author_email, 20, '', '', array('maxlength'=>100, 'style'=>'width: 100%;') );
 117          echo '</td></tr>';
 118  
 119          echo '<tr><td width="1%"><strong>'.T_('Website URL').':</strong></td>';
 120          echo '<td class="input">';
 121          $Form->text_input( 'newcomment_author_url', $edited_Comment->author_url, 20, '', '', array('maxlength'=>100, 'style'=>'width: 100%;') );
 122          echo '</td></tr>';
 123  
 124          $Form->switch_layout( NULL );
 125      }
 126      else
 127      {
 128          echo '<tr><td width="1%"><strong>'.T_('Author').':</strong></td>';
 129          echo '<td class="input">';
 130          $edited_Comment->author();
 131          echo '</td></tr>';
 132      }
 133  
 134      echo '</table>';
 135      ?>
 136  
 137      <div class="edit_toolbars">
 138      <?php // --------------------------- TOOLBARS ------------------------------------
 139          // CALL PLUGINS NOW:
 140          $Plugins->trigger_event( 'AdminDisplayToolbar', array(
 141                  'target_type' => 'Comment',
 142                  'edit_layout' => NULL,
 143                  'Comment' => $edited_Comment,
 144              ) );
 145      ?>
 146      </div>
 147  
 148      <?php // ---------------------------- TEXTAREA -------------------------------------
 149      $content = $comment_content;
 150      $Form->fieldstart = '<div class="edit_area">';
 151      $Form->fieldend = "</div>\n";
 152      $Form->textarea_input( 'content', $content, 16, '', array( 'cols' => 40 , 'id' => 'commentform_post_content' ) );
 153      $Form->fieldstart = '<div class="tile">';
 154      $Form->fieldend = '</div>';
 155      ?>
 156      <script type="text/javascript">
 157          <!--
 158          // This is for toolbar plugins
 159          var b2evoCanvas = document.getElementById('commentform_post_content');
 160          //-->
 161      </script>
 162  
 163      <div class="edit_actions">
 164  
 165      <?php
 166      // ---------- DELETE ----------
 167      if( $action == 'editcomment' )
 168      {    // Editing comment
 169          // Display delete button if user has permission to:
 170          $edited_Comment->delete_link( ' ', ' ', '#', '#', 'DeleteButton', true );
 171      }
 172  
 173      // CALL PLUGINS NOW:
 174      $Plugins->trigger_event( 'AdminDisplayEditorButton', array( 'target_type' => 'Comment', 'edit_layout' => NULL ) );
 175  
 176      echo_comment_buttons( $Form, $edited_Comment );
 177  
 178      ?>
 179      </div>
 180  
 181      <?php
 182      $Form->end_fieldset();
 183  
 184      // -------------------------- ATTACHMENTS/LINKS --------------------------
 185      if( isset($GLOBALS['files_Module']) )
 186      {
 187          load_class( 'links/model/_linkcomment.class.php', 'LinkComment' );
 188          $LinkOwner = new LinkComment( $edited_Comment );
 189          attachment_iframe( $Form, $LinkOwner );
 190      }
 191  
 192      $Form->begin_fieldset( T_('Advanced properties') );
 193  
 194       $Form->switch_layout( 'linespan' );
 195  
 196      if( $current_User->check_perm( 'blog_edit_ts', 'edit', false, $Blog->ID ) )
 197      {    // ------------------------------------ TIME STAMP -------------------------------------
 198          echo '<div id="itemform_edit_timestamp">';
 199          $Form->date( 'comment_issue_date', $edited_Comment->date, T_('Comment date') );
 200          echo ' '; // allow wrapping!
 201          $Form->time( 'comment_issue_time', $edited_Comment->date, '' );
 202          echo '</div>';
 203      }
 204  
 205      // --------------------------- ALLOW MESSAGE FORM ---------------------------
 206      if( ! $edited_Comment->get_author_User() )
 207      {    // Not a member comment
 208          // TODO: move next to email address
 209          ?>
 210          <input type="checkbox" class="checkbox" name="comment_allow_msgform" value="1"
 211          <?php
 212          if( $edited_Comment->allow_msgform )
 213          {
 214              echo ' checked="checked"';
 215          }
 216          ?>
 217              id="comment_allow_msgform" tabindex="7" />
 218          <label for="comment_allow_msgform"><strong><?php echo T_('Allow message form'); ?></strong></label>
 219          <span class="note"><?php echo T_( 'Comment author can be contacted directly via email' ); ?></span>
 220          <?php
 221      }
 222  
 223      $Form->switch_layout( NULL );
 224  
 225      $Form->end_fieldset();
 226  
 227      // ####################### PLUGIN FIELDSETS #########################
 228  
 229      $Plugins->trigger_event( 'AdminDisplayCommentFormFieldset', array( 'Form' => & $Form, 'Comment' => & $edited_Comment, 'edit_layout' => NULL ) );
 230      ?>
 231  
 232  </div>
 233  
 234  <div class="right_col">
 235  
 236  <?php
 237      if( $comment_Item->can_rate()
 238          || !empty( $edited_Comment->rating ) )
 239      {    // Rating is editable
 240          $Form->begin_fieldset( T_('Rating') );
 241  
 242          echo '<p>';
 243          $edited_Comment->rating_input( array( 'reset' => true ) );
 244          echo '</p>';
 245  
 246           $Form->end_fieldset();
 247      }
 248      else
 249      {
 250          $Form->hidden( 'comment_rating', 0 );
 251      }
 252  
 253          /*
 254          $Form->begin_fieldset( T_('Properties') );
 255              echo '<p>';
 256              $Form->checkbox_basic_input( 'comment_featured', $edited_Comment->featured, T_('Featured') );
 257              echo '</p>';
 258          $Form->end_fieldset();
 259          */
 260  
 261          $Form->begin_fieldset( T_('Visibility'), array( 'id' => 'commentform_visibility' ) );
 262  
 263          $Form->switch_layout( 'linespan' );
 264  
 265          // Get those statuses which are not allowed for the current User to create comments in this blog
 266          $exclude_statuses = array_merge( get_restricted_statuses( $Blog->ID, 'blog_comment!', 'edit' ), array( 'redirected', 'trash' ) );
 267          // Get allowed visibility statuses
 268          $sharing_options = get_visibility_statuses( 'radio-options', $exclude_statuses );
 269          $Form->radio( 'comment_status', $edited_Comment->status, $sharing_options, '', true );
 270  
 271          $Form->switch_layout( NULL );
 272  
 273          $Form->end_fieldset();
 274  
 275          $Form->begin_fieldset( T_('Links') );
 276              echo '<p>';
 277              $Form->checkbox_basic_input( 'comment_nofollow', $edited_Comment->nofollow, T_('Nofollow website URL') );
 278              // TODO: apply to all links  -- note: see basic antispam plugin that does this for x hours
 279              echo '</p>';
 280          $Form->end_fieldset();
 281  
 282          $Form->begin_fieldset( T_('Feedback info') );
 283      ?>
 284  
 285      <p><strong><?php echo T_('Type') ?>:</strong> <?php echo $edited_Comment->type; ?></p>
 286      <p><strong><?php echo T_('IP address') ?>:</strong> <?php
 287          // Display IP address and allow plugins to filter it, e.g. the DNSBL plugin will add a link to check the IP:
 288          echo $Plugins->get_trigger_event( 'FilterIpAddress', array('format'=>'htmlbody', 'data'=>$edited_Comment->author_IP), 'data' ); ?>
 289          <?php $edited_Comment->ip_country(); ?>
 290      </p>
 291      <p><strong><?php echo T_('Spam Karma') ?>:</strong> <?php $edited_Comment->spam_karma(); ?></p>
 292  
 293      <?php
 294          $Form->end_fieldset();
 295  
 296          // ####################### TEXT RENDERERS #########################
 297          global $Plugins;
 298          $Form->begin_fieldset( T_('Text Renderers'), array( 'id' => 'itemform_renderers' ) );
 299          $edited_Comment->renderer_checkboxes();
 300          $Form->end_fieldset();
 301      ?>
 302  </div>
 303  
 304  <div class="clear"></div>
 305  
 306  <?php
 307  $Form->end_form();
 308  
 309  // ####################### JS BEHAVIORS #########################
 310  echo_comment_publishbt_js();
 311  
 312  ?>

title

Description

title

Description

title

Description

title

title

Body