b2evolution PHP Cross Reference Blogging Systems

Source: /skins/_edit.disp.php - 368 lines - 12518 bytes - Text - Print

Description: This is the template that displays the edit item form. It gets POSTed to /htsrv/item_edit.php. Note: don't code this URL by hand, use the template functions to generate it!

   1  <?php
   2  /**

   3   * This is the template that displays the edit item form. It gets POSTed to /htsrv/item_edit.php.

   4   *

   5   * Note: don't code this URL by hand, use the template functions to generate it!

   6   *

   7   * This file is part of the b2evolution/evocms project - {@link http://b2evolution.net/}.

   8   * See also {@link http://sourceforge.net/projects/evocms/}.

   9   *

  10   * @copyright (c)2003-2014 by Francois Planque - {@link http://fplanque.com/}.

  11   *

  12   * @license http://b2evolution.net/about/license.html GNU General Public License (GPL)

  13   *

  14   * @package evoskins

  15   *

  16   * @version $Id: _edit.disp.php 6136 2014-03-08 07:59:48Z manuel $

  17   */
  18  if( !defined('EVO_MAIN_INIT') ) die( 'Please, do not access this page directly.' );
  19  
  20  global $Blog, $Session, $inc_path;
  21  global $action, $form_action;
  22  
  23  /**

  24   * @var User

  25   */
  26  global $current_User;
  27  /**

  28   * @var Plugins

  29   */
  30  global $Plugins;
  31  /**

  32   * @var GeneralSettings

  33   */
  34  global $Settings;
  35  
  36  global $pagenow;
  37  
  38  global $trackback_url;
  39  global $bozo_start_modified, $creating;
  40  global $edited_Item, $item_tags, $item_title, $item_content;
  41  global $post_category, $post_extracats;
  42  global $admin_url, $redirect_to, $form_action;
  43  
  44  
  45  // Default params:

  46  $params = array_merge( array(
  47          'disp_edit_categories' => true,
  48          'edit_form_params' => array(),
  49      ), $params );
  50  
  51  // Determine if we are creating or updating...

  52  $creating = is_create_action( $action );
  53  
  54  $Form = new Form( $form_action, 'item_checkchanges', 'post' );
  55  
  56  $Form->switch_template_parts( $params['edit_form_params'] );
  57  
  58  // ================================ START OF EDIT FORM ================================

  59  
  60  $form_params = array();
  61  $iframe_name = NULL;
  62  if( !empty( $bozo_start_modified ) )
  63  {
  64      $form_params['bozo_start_modified'] = true;
  65  }
  66  
  67  $Form->begin_form( 'inskin', '', $form_params );
  68  
  69      $Form->add_crumb( 'item' );
  70      $Form->hidden( 'ctrl', 'items' );
  71      $Form->hidden( 'blog', $Blog->ID );
  72      if( isset( $edited_Item ) )
  73      {
  74          $copy_post_ID = param( 'cp', 'integer', 0 );
  75          if( $copy_post_ID > 0 )
  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', 0 );
  96      $Form->hidden( 'more', 1 );
  97      $Form->hidden( 'preview_userid', $current_User->ID );
  98  
  99      // Add hidden required fields or fields that were set in the init_inskin_editing() function

 100      $Form->hidden( 'item_typ_ID', $edited_Item->ptyp_ID );
 101  
 102      if( $edited_Item->get( 'urltitle' ) != '' )
 103      {    // post_urltitle can be defined from request param
 104          $Form->hidden( 'post_urltitle', $edited_Item->get( 'urltitle' ) );
 105      }
 106  
 107      if( $action != 'new' )
 108      { // DO NOT ADD HIDDEN FIELDS IF THEY ARE NOT SET
 109          // These fields will be set only in case when switch tab from admin editing to in-skin editing

 110          // Fields used in "advanced" form, but not here:

 111          $Form->hidden( 'post_comment_status', $edited_Item->get( 'comment_status' ) );
 112          $Form->hidden( 'post_locale', $edited_Item->get( 'locale' ) );
 113          $Form->hidden( 'post_url', $edited_Item->get( 'url' ) );
 114          $Form->hidden( 'post_excerpt', $edited_Item->get( 'excerpt' ) );
 115          $Form->hidden( 'titletag', $edited_Item->get( 'titletag' ) );
 116          $Form->hidden( 'metadesc', $edited_Item->get_setting( 'post_metadesc' ) );
 117          $Form->hidden( 'custom_headers', $edited_Item->get_setting( 'post_custom_headers' ) );
 118  
 119          if( $Blog->get_setting( 'use_workflow' ) )
 120          {    // We want to use workflow properties for this blog:
 121              $Form->hidden( 'item_priority', $edited_Item->priority );
 122              $Form->hidden( 'item_assigned_user_ID', $edited_Item->assigned_user_ID );
 123              $Form->hidden( 'item_st_ID', $edited_Item->pst_ID );
 124              $Form->hidden( 'item_deadline', $edited_Item->datedeadline );
 125          }
 126          $Form->hidden( 'trackback_url', $trackback_url );
 127          $Form->hidden( 'item_featured', $edited_Item->featured );
 128          $Form->hidden( 'item_hideteaser', $edited_Item->get_setting( 'hide_teaser' ) );
 129          $Form->hidden( 'expiry_delay', $edited_Item->get_setting( 'post_expiry_delay' ) );
 130          $Form->hidden( 'item_order', $edited_Item->order );
 131  
 132          $creator_User = $edited_Item->get_creator_User();
 133          $Form->hidden( 'item_owner_login', $creator_User->login );
 134          $Form->hidden( 'item_owner_login_displayed', 1 );
 135      }
 136      elseif( !isset( $edited_Item->status ) )
 137      {
 138          $highest_publish_status = get_highest_publish_status( 'post', $Blog->ID, false );
 139          $edited_Item->set( 'status', $highest_publish_status );
 140      }
 141  
 142      $disp_edit_categories = true;
 143      if( ! $params['disp_edit_categories'] )
 144      {    // When categories are hidden, we store a cat_ID in the hidden input
 145          if( $edited_Item->ID > 0 )
 146          {    // Get cat_ID from existing Item
 147              $main_Chapter = $edited_Item->get_main_Chapter();
 148              $cat = $main_Chapter->ID;
 149          }
 150          else
 151          {    // Forums skin get cat_ID from $_GET
 152              $cat = param( 'cat', 'integer', 0 );
 153          }
 154  
 155          if( $cat > 0 )
 156          {    // Store a cat_ID
 157              $Form->hidden( 'post_category', $cat );
 158              $Form->hidden( 'cat', $cat );
 159              $disp_edit_categories = false;
 160          }
 161      }
 162  
 163  ?>
 164  
 165  
 166      <?php
 167      // ############################ POST CONTENTS #############################

 168      // Title input:

 169      $require_title = $Blog->get_setting('require_title');
 170      if( $require_title != 'none' )
 171      {
 172          $Form->switch_layout( 'none' );
 173          echo '<table width="100%"><tr>';
 174          $Form->labelstart = '<th width="10%">';
 175          $Form->labelend = '</th>';
 176          $Form->inputstart = '<td>';
 177          $Form->inputend = '</td>';
 178          $Form->text_input( 'post_title', $item_title, 20, T_('Title'), '', array('maxlength'=>255, 'style'=>'width: 100%;', 'required'=>($require_title=='required')) );
 179          echo '</tr></table>';
 180          $Form->switch_layout( NULL );
 181      }
 182  
 183      // --------------------------- TOOLBARS ------------------------------------

 184      echo '<div class="edit_toolbars">';
 185      // CALL PLUGINS NOW:

 186      $Plugins->trigger_event( 'AdminDisplayToolbar', array(
 187              'target_type' => 'Item',
 188              'edit_layout' => 'expert',
 189              'Item' => $edited_Item,
 190          ) );
 191      echo '</div>';
 192  
 193      // ---------------------------- TEXTAREA -------------------------------------

 194      $Form->switch_layout( 'none' );
 195      $Form->fieldstart = '<div class="edit_area">';
 196      $Form->fieldend = "</div>\n";
 197      $Form->textarea_input( 'content', $item_content, 16, NULL, array( 'cols' => 50 , 'id' => 'itemform_post_content' ) );
 198      $Form->switch_layout( NULL );
 199      ?>
 200      <script type="text/javascript" language="JavaScript">
 201          <!--
 202          // This is for toolbar plugins

 203          var b2evoCanvas = document.getElementById('itemform_post_content');
 204          //-->

 205      </script>
 206  
 207      <?php
 208      // CALL PLUGINS NOW:

 209      $Plugins->trigger_event( 'DisplayEditorButton', array( 'target_type' => 'Item', 'edit_layout' => 'inskin' ) );
 210  
 211  $Form->end_fieldset();
 212  
 213      global $display_item_settings_is_defined;
 214      $display_item_settings_is_defined = false;
 215      modules_call_method( 'display_item_settings', array( 'Form' => & $Form, 'Blog' => & $Blog, 'edited_Item' => & $edited_Item ) );
 216  
 217      if( ! $display_item_settings_is_defined )
 218      {
 219          if( $current_User->check_perm( 'blog_edit_ts', 'edit', false, $Blog->ID ) )
 220          { // ------------------------------------ TIME STAMP -------------------------------------
 221              $Form->begin_fieldset();
 222  
 223              $Form->switch_layout( 'none' );
 224              echo '<div id="itemform_edit_timestamp" class="edit_fieldgroup">';
 225              issue_date_control( $Form, false, '<strong>'.T_('Issue date').'</strong>' );
 226              echo '</div>';
 227              $Form->switch_layout( NULL );
 228  
 229              $Form->end_fieldset();
 230          }
 231  
 232          // ################### VISIBILITY / SHARING ###################

 233          // Get those statuses which are not allowed for the current User to create posts in this blog

 234          $exclude_statuses = array_merge( get_restricted_statuses( $Blog->ID, 'blog_post!', 'create' ), array( 'trash' ) );
 235          // Get allowed visibility statuses

 236          $sharing_options = get_visibility_statuses( 'radio-options', $exclude_statuses );
 237          if( count( $sharing_options ) == 1 )
 238          { // Only one visibility status is available, don't show radio but set hidden field
 239              $Form->hidden( 'post_status', $sharing_options[0][0] );
 240          }
 241          else
 242          { // Display visibiliy options
 243              $Form->begin_fieldset( T_('Visibility / Sharing'), array( 'id' => 'itemform_visibility' ) );
 244              $Form->switch_layout( 'linespan' );
 245              visibility_select( $Form, $edited_Item->status );
 246              $Form->switch_layout( NULL );
 247              $Form->end_fieldset();
 248          }
 249      }
 250  
 251      if( $disp_edit_categories )
 252      {    // Display categories
 253          cat_select( $Form, true, false );
 254          echo '<br />';
 255      }
 256  
 257      // ################### TEXT RENDERERS ###################

 258      $item_renderer_checkboxes = $edited_Item->get_renderer_checkboxes();
 259      if( !empty( $item_renderer_checkboxes ) )
 260      {
 261          $Form->begin_fieldset( T_('Text Renderers'), array( 'id' => 'itemform_renderers' ) );
 262          echo $item_renderer_checkboxes;
 263          $Form->end_fieldset();
 264      }
 265  
 266      $Form->switch_layout( 'none' );
 267      echo '<table cellspacing="0" width="100%">';
 268      echo '<tr><td class="label shrinkwrap"><label for="item_tags"><strong>'.T_('Tags').':</strong></label></td>';
 269      echo '<td class="input">';
 270      $Form->text_input( 'item_tags', $item_tags, 40, '', '', array('maxlength'=>255, 'style'=>'width: 100%;') );
 271      echo '</td><td width="1"><!-- for IE7 --></td></tr>';
 272      echo '</table>';
 273      $Form->switch_layout( NULL );
 274  ?>
 275  
 276  <div class="clear"></div>
 277  
 278  <?php
 279  // ################### LOCATIONS ###################

 280  echo_item_location_form( $Form, $edited_Item );
 281  
 282  if( $Blog->get_setting( 'show_location_coordinates' ) )
 283  {
 284      $Form->hidden( 'item_latitude', $edited_Item->get_setting( 'latitude' ) );
 285      $Form->hidden( 'item_longitude', $edited_Item->get_setting( 'longitude' ) );
 286      $Form->hidden( 'google_map_zoom', $edited_Item->get_setting( 'map_zoom' ) );
 287      $Form->hidden( 'google_map_type', $edited_Item->get_setting( 'map_type' ) );
 288  }
 289  
 290  // ################### PROPERTIES ###################

 291  $custom_fields = get_item_custom_fields();
 292  
 293  if( count( $custom_fields ) > 0 )
 294  {
 295      $Form->begin_fieldset( T_('Properties') );
 296  
 297      $Form->switch_layout( 'table' );
 298      $Form->labelstart = '<td class="right"><strong>';
 299      $Form->labelend = '</strong></td>';
 300  
 301      echo $Form->formstart;
 302  
 303      foreach( $custom_fields as $field )
 304      {    // Display each custom field
 305          if( $field['type'] == 'varchar' )
 306          {
 307              $field_note = '';
 308              $field_params = array( 'maxlength' => 255, 'style' => 'width:100%' );
 309          }
 310          else
 311          {    // type == double
 312              $field_note = T_('can be decimal');
 313              $field_params = array();
 314          }
 315          $Form->text_input( 'item_'.$field['name'], $edited_Item->get_setting( 'custom_'.$field['name'] ), 10, $field['title'], $field_note, $field_params );
 316      }
 317  
 318      echo $Form->formend;
 319  
 320      $Form->switch_layout( NULL );
 321  
 322      $Form->end_fieldset();
 323  }
 324  
 325  // ####################### ATTACHMENTS FIELDSETS #########################

 326  $LinkOwner = new LinkItem( $edited_Item );
 327  if( $LinkOwner->count_links() )
 328  {
 329      $Form->begin_fieldset( T_('Attachments') );
 330      if( $current_User->check_perm( 'files', 'view' ) && $current_User->check_perm( 'admin', 'restricted' ) )
 331      {
 332          display_attachments( $LinkOwner );
 333      }
 334      else
 335      {
 336          $Form->info( '', T_('You do not have permission to edit file attachments for this post') );
 337      }
 338      $Form->end_fieldset();
 339  }
 340  
 341  // ####################### PLUGIN FIELDSETS #########################

 342  $Plugins->trigger_event( 'DisplayItemFormFieldset', array( 'Form' => & $Form, 'Item' => & $edited_Item) );
 343  ?>
 344  
 345  <div class="clear"></div>
 346  
 347  <div class="center margin2ex">
 348  <?php // ------------------------------- ACTIONS ----------------------------------
 349      echo '<div class="edit_actions">';
 350      echo_publish_buttons( $Form, $creating, $edited_Item, true );
 351      echo '</div>';
 352  ?>
 353  </div>
 354  <?php
 355  // ================================== END OF EDIT FORM ==================================

 356  $Form->end_form();
 357  
 358  
 359  // ####################### JS BEHAVIORS #########################

 360  echo_publishnowbutton_js();
 361  // New category input box:

 362  echo_onchange_newcat();
 363  echo_autocomplete_tags( $edited_Item->get_tags() );
 364  
 365  $edited_Item->load_Blog();
 366  // Location

 367  echo_regional_js( 'item', $edited_Item->Blog->region_visible() );
 368  ?>

title

Description

title

Description

title

Description

title

title

Body