b2evolution PHP Cross Reference Blogging Systems

Source: /inc/items/views/_item_expert.form.php - 509 lines - 18539 bytes - Text - Print

Description: This file implements the Post 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 Post 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   * @version $Id: _item_expert.form.php 6136 2014-03-08 07:59:48Z manuel $
  15   */
  16  if( !defined('EVO_MAIN_INIT') ) die( 'Please, do not access this page directly.' );
  17  
  18  /**
  19   * @var User
  20   */
  21  global $current_User;
  22  /**
  23   * @var Item
  24   */
  25  global $edited_Item;
  26  /**
  27   * @var Blog
  28   */
  29  global $Blog;
  30  /**
  31   * @var Plugins
  32   */
  33  global $Plugins;
  34  /**
  35   * @var GeneralSettings
  36   */
  37  global $Settings;
  38  
  39  global $pagenow;
  40  
  41  global $Session;
  42  
  43  global $mode, $admin_url, $rsc_url;
  44  global $post_comment_status, $trackback_url, $item_tags;
  45  global $bozo_start_modified, $creating;
  46  global $item_title, $item_content;
  47  global $redirect_to;
  48  
  49  // Determine if we are creating or updating...
  50  $creating = is_create_action( $action );
  51  
  52  $Form = new Form( NULL, 'item_checkchanges', 'post' );
  53  $Form->labelstart = '<strong>';
  54  $Form->labelend = "</strong>\n";
  55  
  56  
  57  // ================================ START OF EDIT FORM ================================
  58  
  59  $iframe_name = NULL;
  60  $params = array();
  61  if( !empty( $bozo_start_modified ) )
  62  {
  63      $params['bozo_start_modified'] = true;
  64  }
  65  
  66  $Form->begin_form( '', '', $params );
  67  
  68      $Form->add_crumb( 'item' );
  69      $Form->hidden( 'ctrl', 'items' );
  70      $Form->hidden( 'blog', $Blog->ID );
  71      $Form->hidden( 'mode_editing', 'expert' ); // used by in-skin mode when we want back in a last editing mode
  72      if( isset( $mode ) )   $Form->hidden( 'mode', $mode );    // used by bookmarklet
  73      if( isset( $edited_Item ) )
  74      {
  75          if( $action == 'copy' )
  76          {    // Copy post
  77              $Form->hidden( 'post_ID', 0 );
  78          }
  79          else
  80          {    // Edit post
  81              $Form->hidden( 'post_ID', $edited_Item->ID );
  82          }
  83  
  84          // Here we add js code for attaching file popup window: (Yury)
  85          if( !empty( $edited_Item->ID ) && ( $Session->get('create_edit_attachment') === true ) )
  86          {    // item also created => we have $edited_Item->ID for popup window
  87              echo_attaching_files_button_js( $iframe_name );
  88              // clear session variable
  89              $Session->delete('create_edit_attachment');
  90          }
  91      }
  92      $Form->hidden( 'redirect_to', $redirect_to );
  93  
  94      // In case we send this to the blog for a preview :
  95      $Form->hidden( 'preview', 1 );
  96      $Form->hidden( 'more', 1 );
  97      $Form->hidden( 'preview_userid', $current_User->ID );
  98  
  99  ?>
 100  <div class="left_col">
 101  
 102      <?php
 103      // ############################ POST CONTENTS #############################
 104  
 105      $Form->begin_fieldset( T_('Post contents').get_manual_link('post_contents_fieldset') );
 106  
 107      $Form->switch_layout( 'none' );
 108  
 109      echo '<table cellspacing="0" class="compose_layout"><tr>';
 110      $display_title_field = $Blog->get_setting('require_title') != 'none';
 111      if( $display_title_field )
 112      {
 113          echo '<td width="1%"><strong>'.T_('Title').':</strong></td>';
 114          echo '<td width="97%" class="input">';
 115          $Form->text_input( 'post_title', $item_title, 20, '', '', array('maxlength'=>255, 'style'=>'width: 100%;', 'required' => $Blog->get_setting('require_title') == 'required') );
 116          echo '</td>';
 117      }
 118  
 119      // -- Language chooser BEGIN --
 120      $locale_options = locale_options( $edited_Item->get( 'locale' ), false, true );
 121  
 122      if ( is_array( $locale_options ) )
 123      {    // We've only one enabled locale.
 124          // Tblue> The locale name is not really needed here, but maybe we
 125          //        want to display the name of the only locale?
 126          $Form->hidden( 'post_locale', $locale_options[0] );
 127          //pre_dump( $locale_options );
 128      }
 129      else
 130      {    // More than one locale => select field.
 131          echo '<td width="1%">';
 132          if( $display_title_field )
 133          {
 134              echo '&nbsp;&nbsp;';
 135          }
 136          echo '<strong>'.T_('Language').':</strong></td>';
 137          echo '<td width="1%" class="select">';
 138          $Form->select_options( 'post_locale', $locale_options, '' );
 139          echo '</td>';
 140      }
 141      // -- Language chooser END --
 142      echo '</tr></table>';
 143  
 144      echo '<table cellspacing="0" class="compose_layout"><tr>';
 145      echo '<td width="1%"><strong>'.T_('Link to url').':</strong></td>';
 146      echo '<td class="input">';
 147      $Form->text_input( 'post_url', $edited_Item->get( 'url' ), 20, '', '', array('maxlength'=>255, 'style'=>'width: 100%;') );
 148      echo '</td>';
 149      echo '<td width="1%">&nbsp;&nbsp;<strong>'.T_('Type').':</strong></td>';
 150      echo '<td width="1%" class="select">';
 151      $ItemTypeCache = & get_ItemTypeCache();
 152      $Form->select_object( 'item_typ_ID', $edited_Item->ptyp_ID, $ItemTypeCache,
 153                                  '', '', false, '', 'get_option_list_usable_only' );
 154      echo '</td>';
 155  
 156      echo '</tr></table>';
 157  
 158       $Form->switch_layout( NULL );
 159  
 160      // --------------------------- TOOLBARS ------------------------------------
 161      echo '<div class="edit_toolbars">';
 162      // CALL PLUGINS NOW:
 163      $Plugins->trigger_event( 'AdminDisplayToolbar', array(
 164              'target_type' => 'Item',
 165              'edit_layout' => 'expert',
 166              'Item' => $edited_Item,
 167          ) );
 168      echo '</div>';
 169  
 170      // ---------------------------- TEXTAREA -------------------------------------
 171      $Form->fieldstart = '<div class="edit_area">';
 172      $Form->fieldend = "</div>\n";
 173      $Form->textarea_input( 'content', $item_content, 16, '', array( 'cols' => 40 , 'id' => 'itemform_post_content' ) );
 174      $Form->fieldstart = '<div class="tile">';
 175      $Form->fieldend = '</div>';
 176      ?>
 177      <script type="text/javascript" language="JavaScript">
 178          <!--
 179          // This is for toolbar plugins
 180          var b2evoCanvas = document.getElementById('itemform_post_content');
 181          // -->
 182      </script>
 183  
 184      <?php // ------------------------------- ACTIONS ----------------------------------
 185      echo '<div class="edit_actions">';
 186  
 187      // CALL PLUGINS NOW:
 188      $Plugins->trigger_event( 'AdminDisplayEditorButton', array( 'target_type' => 'Item', 'edit_layout' => 'expert' ) );
 189  
 190      echo_publish_buttons( $Form, $creating, $edited_Item );
 191  
 192      echo '</div>';
 193  
 194      $Form->end_fieldset();
 195  
 196  
 197      // ####################### ATTACHMENTS/LINKS #########################
 198      if( isset($GLOBALS['files_Module']) && ( !$creating ||
 199          ( $current_User->check_perm( 'item_post!CURSTATUS', 'edit', false, $edited_Item )
 200          && $current_User->check_perm( 'files', 'view', false ) ) ) )
 201      { // Files module is enabled, but in case of creating new posts we should show file attachments block only if user has all required permissions to attach files
 202          load_class( 'links/model/_linkitem.class.php', 'LinkItem' );
 203          $LinkOwner = new LinkItem( $edited_Item );
 204          attachment_iframe( $Form, $LinkOwner, $iframe_name, $creating );
 205      }
 206      // ############################ ADVANCED #############################
 207  
 208      $Form->begin_fieldset( T_('Advanced properties').get_manual_link('post_advanced_properties_fieldset'), array( 'id' => 'itemform_adv_props' ) );
 209  
 210      // CUSTOM FIELDS varchar
 211      echo '<table cellspacing="0" class="compose_layout">';
 212      $field_count = $Blog->get_setting( 'count_custom_varchar' );
 213      for( $i = 1 ; $i <= $field_count; $i++ )
 214      { // Loop through custom varchar fields
 215          $field_guid = $Blog->get_setting( 'custom_varchar'.$i );
 216          $field_name = $Blog->get_setting( 'custom_varchar_'.$field_guid );
 217          // Display field
 218          echo '<tr><td class="label"><label for="item_varchar_'.$field_guid.'"><strong>'.$field_name.':</strong></label></td>';
 219          echo '<td class="input" width="97%">';
 220          $Form->text_input( 'item_varchar_'.$field_guid, $edited_Item->get_setting( 'custom_varchar_'.$field_guid ), 20, '', '', array('maxlength'=>255, 'style'=>'width: 100%;') );
 221          echo '</td><td width="1"><!-- for IE7 --></td></tr>';
 222      }
 223  
 224      //add slug_changed field - needed for slug trim, if this field = 0 slug will trimmed
 225      $Form->hidden( 'slug_changed', 0 );
 226  
 227      $edit_slug_link = '';
 228      if( $edited_Item->ID > 0 && $current_User->check_perm( 'slugs', 'view' ) )
 229      {    // user has permission to view slugs:
 230          $edit_slug_link = '&nbsp;'.action_icon( T_('Edit slugs...'), 'edit', $admin_url.'?ctrl=slugs&amp;slug_item_ID='.$edited_Item->ID );
 231      }
 232  
 233      if( empty( $edited_Item->tiny_slug_ID ) )
 234      {
 235          $tiny_slug_info = T_('No Tiny URL yet.');
 236      }
 237      else
 238      {
 239          $tiny_slug_info = $edited_Item->get_tinyurl_link( array(
 240                  'before' => T_('Tiny URL').': ',
 241                  'after'  => ''
 242              ) );
 243      }
 244  
 245      echo '<tr><td class="label" valign="top"><label for="post_urltitle" title="'.T_('&quot;slug&quot; to be used in permalinks').'"><strong>'.T_('URL slugs').$edit_slug_link.':</strong></label></td>';
 246      echo '<td class="input" width="97%">';
 247      $Form->text_input( 'post_urltitle', $edited_Item->get_slugs(), 40, '', '<br />'.$tiny_slug_info, array('maxlength'=>210, 'style'=>'width: 100%;') );
 248      echo '</td><td width="1"><!-- for IE7 --></td></tr>';
 249  
 250      echo '<tr><td class="label"><label for="titletag"><strong>'.T_('&lt;title&gt; tag').':</strong></label></td>';
 251      echo '<td class="input" width="97%">';
 252      $Form->text_input( 'titletag', $edited_Item->get('titletag'), 40, '', '', array('maxlength'=>255, 'style'=>'width: 100%;') );
 253      echo '</td><td width="1"><!-- for IE7 --></td></tr>';
 254  
 255      echo '<tr><td class="label"><label for="metadesc" title="&lt;meta name=&quot;description&quot;&gt;"><strong>'.T_('&lt;meta&gt; desc').':</strong></label></td>';
 256      echo '<td class="input" width="97%">';
 257      $Form->text_input( 'metadesc', $edited_Item->get_setting('post_metadesc'), 40, '', '', array('maxlength'=>255, 'style'=>'width: 100%;') );
 258      echo '</td><td width="1"><!-- for IE7 --></td></tr>';
 259  
 260      echo '<tr><td class="label"><label for="custom_headers" title="&lt;meta name=&quot;keywords&quot;&gt;"><strong>'.T_('&lt;meta&gt; keywds').':</strong></label></td>';
 261      echo '<td class="input" width="97%">';
 262      $Form->text_input( 'custom_headers', $edited_Item->get_setting('post_custom_headers'), 40, '', '', array('maxlength'=>255, 'style'=>'width: 100%;') );
 263      echo '</td><td width="1"><!-- for IE7 --></td></tr>';
 264  
 265      echo '<tr><td class="label"><label for="item_tags"><strong>'.T_('Tags').':</strong></label></td>';
 266      echo '<td class="input" width="97%">';
 267      $Form->text_input( 'item_tags', $item_tags, 40, '', '', array('maxlength'=>255, 'style'=>'width: 100%;') );
 268      echo '</td><td width="1"><!-- for IE7 --></td></tr>';
 269  
 270      echo '</table>';
 271  
 272       $Form->switch_layout( 'linespan' );
 273      echo '<div id="itemform_urltitle" class="edit_fieldgroup">';
 274  
 275      echo '</div>';
 276      $Form->switch_layout( NULL );
 277  
 278      $edited_Item_excerpt = $edited_Item->get('excerpt');
 279      ?>
 280  
 281      <div id="itemform_post_excerpt" class="edit_fieldgroup">
 282          <label for="post_excerpt"><strong><?php echo T_('Excerpt') ?>:</strong>
 283          <span class="notes"><?php echo T_('(for XML feeds)') ?></span></label><br />
 284          <textarea name="post_excerpt" rows="2" cols="25" class="large" id="post_excerpt"><?php echo htmlspecialchars($edited_Item_excerpt) ?></textarea>
 285      </div>
 286  
 287      <?php
 288  
 289      if( $edited_Item->get('excerpt_autogenerated') )
 290      { // store hash of current post_excerpt to detect if it was changed.
 291          $Form->hidden('post_excerpt_previous_md5', md5($edited_Item_excerpt));
 292      }
 293      $Form->end_fieldset();
 294  
 295  
 296      // ############################ WORKFLOW #############################
 297  
 298      if( $Blog->get_setting( 'use_workflow' ) )
 299      {    // We want to use workflow properties for this blog:
 300          $Form->begin_fieldset( T_('Workflow properties'), array( 'id' => 'itemform_workflow_props' ) );
 301  
 302              echo '<div id="itemform_edit_timestamp" class="edit_fieldgroup">';
 303              $Form->switch_layout( 'linespan' );
 304  
 305              $Form->select_object( 'item_priority', NULL, $edited_Item, T_('Priority'), '', true, '', 'priority_options' );
 306  
 307              echo ' '; // allow wrapping!
 308  
 309              $Form->select_object( 'item_assigned_user_ID', NULL, $edited_Item, T_('Assigned to'),
 310                                                          '', true, '', 'get_assigned_user_options' );
 311  
 312              echo ' '; // allow wrapping!
 313  
 314              $ItemStatusCache = & get_ItemStatusCache();
 315              $Form->select_options( 'item_st_ID', $ItemStatusCache->get_option_list( $edited_Item->pst_ID, true ), T_('Task status') );
 316  
 317              echo ' '; // allow wrapping!
 318  
 319              $Form->date( 'item_deadline', $edited_Item->get('datedeadline'), T_('Deadline') );
 320  
 321              $Form->switch_layout( NULL );
 322              echo '</div>';
 323  
 324          $Form->end_fieldset();
 325      }
 326  
 327      // ####################### ADDITIONAL ACTIONS #########################
 328  
 329      if( isset( $Blog ) && $Blog->get('allowtrackbacks') )
 330      {
 331          $Form->begin_fieldset( T_('Additional actions'), array( 'id' => 'itemform_additional_actions' ) );
 332  
 333          // --------------------------- TRACKBACK --------------------------------------
 334          ?>
 335          <div id="itemform_trackbacks">
 336              <label for="trackback_url"><strong><?php echo T_('Trackback URLs') ?>:</strong>
 337              <span class="notes"><?php echo T_('(Separate by space)') ?></span></label><br />
 338              <input type="text" name="trackback_url" class="large form_text_input" id="trackback_url" value="<?php echo format_to_output( $trackback_url, 'formvalue' ); ?>" />
 339          </div>
 340          <?php
 341  
 342          $Form->end_fieldset();
 343      }
 344  
 345  
 346      // ####################### PLUGIN FIELDSETS #########################
 347  
 348      $Plugins->trigger_event( 'AdminDisplayItemFormFieldset', array( 'Form' => & $Form, 'Item' => & $edited_Item, 'edit_layout' => 'expert' ) );
 349  
 350      ?>
 351  
 352  </div>
 353  
 354  <div class="right_col">
 355  
 356      <?php
 357      // ################### MODULES SPECIFIC ITEM SETTINGS ###################
 358  
 359      modules_call_method( 'display_item_settings', array( 'Form' => & $Form, 'Blog' => & $Blog, 'edited_Item' => & $edited_Item ) );
 360  
 361      // ################### CATEGORIES ###################
 362  
 363      cat_select( $Form );
 364  
 365      // ################### LOCATIONS ###################
 366      echo_item_location_form( $Form, $edited_Item );
 367  
 368      // ################### PROPERTIES ###################
 369  
 370      $Form->begin_fieldset( T_('Properties'), array( 'id' => 'itemform_extra' ) );
 371  
 372      $Form->switch_layout( 'linespan' );
 373  
 374      $Form->checkbox_basic_input( 'item_featured', $edited_Item->featured, '<strong>'.T_('Featured post').'</strong>' );
 375      echo "<br/>";
 376  
 377      $Form->checkbox_basic_input( 'item_hideteaser', $edited_Item->get_setting( 'hide_teaser' ), '<strong>'.T_('Hide teaser when displaying -- more --').'</strong>' );
 378      echo "<br/>";
 379  
 380      if( $current_User->check_perm( 'blog_edit_ts', 'edit', false, $Blog->ID ) )
 381      { // ------------------------------------ TIME STAMP -------------------------------------
 382          echo '<div id="itemform_edit_timestamp" class="edit_fieldgroup">';
 383          issue_date_control( $Form, true );
 384          echo '</div>';
 385      }
 386  
 387      echo '<table>';
 388  
 389      echo '<tr><td><strong>'.T_('Order').':</strong></td><td>';
 390      $Form->text( 'item_order', $edited_Item->order, 10, '', T_('can be decimal') );
 391      echo '</td></tr>';
 392  
 393      if( $current_User->check_perm( 'users', 'edit' ) )
 394      {
 395          echo '<tr><td><strong>'.T_('Owner').':</strong></td><td>';
 396          $Form->username( 'item_owner_login', $edited_Item->get_creator_User(), '', T_( 'login of this post\'s owner.').'<br/>' );
 397          $Form->hidden( 'item_owner_login_displayed', 1 );
 398          echo '</td></tr>';
 399      }
 400  
 401      if( $Blog->get_setting( 'show_location_coordinates' ) )
 402      { // Dispaly Latitude & Longitude settings
 403          echo '<tr><td><strong>'.T_('Latitude').':</strong></td><td>';
 404          $Form->text( 'item_latitude', $edited_Item->get_setting( 'latitude' ), 10, '' );
 405          echo '</td></tr>';
 406          echo '<tr><td><strong>'.T_('Longitude').':</strong></td><td>';
 407          $Form->text( 'item_longitude', $edited_Item->get_setting( 'longitude' ), 10, '' );
 408          echo '</td></tr>';
 409      }
 410  
 411      // CUSTOM FIELDS double
 412      $field_count = $Blog->get_setting( 'count_custom_double' );
 413      for( $i = 1 ; $i <= $field_count; $i++ )
 414      { // Loop through custom double fields
 415          $field_guid = $Blog->get_setting( 'custom_double'.$i );
 416          $field_name = $Blog->get_setting( 'custom_double_'.$field_guid );
 417          // Display field
 418          echo '<tr><td><strong>'.$field_name.':</strong></td><td>';
 419          $Form->text( 'item_double_'.$field_guid, $edited_Item->get_setting( 'custom_double_'.$field_guid ), 10, '', T_('can be decimal') );
 420          echo '</td></tr>';
 421      }
 422  
 423      echo '</table>';
 424  
 425      $Form->switch_layout( NULL );
 426  
 427      $Form->end_fieldset();
 428  
 429  
 430      // ################### VISIBILITY / SHARING ###################
 431  
 432      $Form->begin_fieldset( T_('Visibility / Sharing'), array( 'id' => 'itemform_visibility' ) );
 433  
 434      $Form->switch_layout( 'linespan' );
 435      visibility_select( $Form, $edited_Item->status );
 436      $Form->switch_layout( NULL );
 437  
 438      $Form->end_fieldset();
 439  
 440  
 441      // ################### TEXT RENDERERS ###################
 442  
 443      $Form->begin_fieldset( T_('Text Renderers'), array( 'id' => 'itemform_renderers' ) );
 444  
 445      // fp> TODO: there should be no param call here (shld be in controller)
 446      $edited_Item->renderer_checkboxes( param('renderers', 'array/string', NULL) );
 447  
 448      $Form->end_fieldset();
 449  
 450  
 451      // ################### COMMENT STATUS ###################
 452  
 453      if( ( $Blog->get_setting( 'allow_comments' ) != 'never' ) && ( $Blog->get_setting( 'disable_comments_bypost' ) ) )
 454      {
 455          $Form->begin_fieldset( T_('Comments'), array( 'id' => 'itemform_comments' ) );
 456  
 457          ?>
 458              <label title="<?php echo T_('Visitors can leave comments on this post.') ?>"><input type="radio" name="post_comment_status" value="open" class="checkbox" <?php if( $post_comment_status == 'open' ) echo 'checked="checked"'; ?> />
 459              <?php echo T_('Open') ?></label><br />
 460  
 461              <label title="<?php echo T_('Visitors can NOT leave comments on this post.') ?>"><input type="radio" name="post_comment_status" value="closed" class="checkbox" <?php if( $post_comment_status == 'closed' ) echo 'checked="checked"'; ?> />
 462              <?php echo T_('Closed') ?></label><br />
 463  
 464              <label title="<?php echo T_('Visitors cannot see nor leave comments on this post.') ?>"><input type="radio" name="post_comment_status" value="disabled" class="checkbox" <?php if( $post_comment_status == 'disabled' ) echo 'checked="checked"'; ?> />
 465              <?php echo T_('Disabled') ?></label><br />
 466          <?php
 467  
 468          $Form->switch_layout( 'table' );
 469          $Form->duration_input( 'expiry_delay',  $edited_Item->get_setting( 'post_expiry_delay' ), T_('Expiry delay'), 'months', 'hours',
 470                              array( 'minutes_step' => 1, 'required' => false, 'note' => T_( 'Older comments and ratings will no longer be displayed.' ) ) );
 471          $Form->switch_layout( NULL );
 472  
 473          $Form->end_fieldset();
 474      }
 475  
 476      ?>
 477  
 478  </div>
 479  
 480  <div class="clear"></div>
 481  
 482  <?php
 483  // ================================== END OF EDIT FORM ==================================
 484  $Form->end_form();
 485  
 486  // ####################### JS BEHAVIORS #########################
 487  echo_publishnowbutton_js();
 488  echo_set_is_attachments();
 489  echo_link_files_js();
 490  echo_autocomplete_tags( $edited_Item->get_tags() );
 491  if( empty( $edited_Item->ID ) )
 492  { // if we creating new post - we add slug autofiller JS
 493      echo_slug_filler();
 494  }
 495  else
 496  {    // if we are editing the post
 497      echo_set_slug_changed();
 498  }
 499  // New category input box:
 500  echo_onchange_newcat();
 501  $edited_Item->load_Blog();
 502  // Location
 503  echo_regional_js( 'item', $edited_Item->Blog->region_visible() );
 504  // Item type
 505  echo_onchange_item_type_js();
 506  
 507  // require dirname(__FILE__).'/inc/_item_form_behaviors.inc.php';
 508  
 509  ?>

title

Description

title

Description

title

Description

title

title

Body