b2evolution PHP Cross Reference Blogging Systems

Source: /skins/forums/_edit.disp.php - 386 lines - 14581 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, $advanced_edit_link;
  43  
  44  // Determine if we are creating or updating...

  45  $creating = is_create_action( $action );
  46  
  47  // Default params:

  48  $disp_params = array_merge( array(
  49          'disp_edit_categories' => true,
  50          'edit_form_params' => array(
  51              'formstart'      => '<table class="bForums" width="100%" cellspacing="1" cellpadding="2" border="0"><tr><th colspan="2">'.( $creating ? T_('Post a new topic') : T_('Edit post') ).'</th></tr>',
  52              'formend'        => '</table>',
  53              'fieldset_begin' => '<tr class="top"><td colspan="2">',
  54              'fieldset_end'   => '</td></tr>',
  55              'fieldstart'     => '<tr>',
  56              'fieldend'       => '</tr>',
  57              'labelstart'     => '<td class="left"><strong>',
  58              'labelend'       => '</strong></td>',
  59              'inputstart'     => '<td class="row2 left">',
  60              'inputend'       => '</td>',
  61              'infostart'      => '<td class="row2 left">',
  62              'infoend'        => '</td>',
  63              'buttonsstart'   => '<tr><td colspan="2">',
  64              'buttonsend'     => '</td></tr>',
  65              'output'         => true
  66          ),
  67          'categories_name'  => T_('Appears in'),
  68          'category_name'    => T_('Forum'),
  69          'category_main_title'  => T_('Main forum'),
  70          'category_extra_title' => T_('Additional forum'),
  71      ), $params );
  72  
  73  // BREADCRUMBS

  74  echo '<div class="post_panel">';
  75  
  76  $chapter_ID = 0;
  77  if( !empty( $edited_Item->ID ) )
  78  {    // Get ID of main chapter
  79      $main_Chapter = & $edited_Item->get_main_Chapter();
  80      $chapter_ID = $main_Chapter->ID;
  81  }
  82  elseif( param( 'cat', 'integer', 0 ) > 0 )
  83  {    // Get chapter ID from request when we create a new topic
  84      $chapter_ID = get_param( 'cat' );
  85  }
  86  $Skin->display_breadcrumbs( $chapter_ID );
  87  echo '</div><div class="clear"></div>';
  88  
  89  $Form = new Form( $form_action, 'item_checkchanges', 'post' );
  90  
  91  $Form->switch_template_parts( $disp_params['edit_form_params'] );
  92  
  93  // ================================ START OF EDIT FORM ================================

  94  
  95  $iframe_name = NULL;
  96  if( !empty( $bozo_start_modified ) )
  97  {
  98      $params['bozo_start_modified'] = true;
  99  }
 100  
 101  $Form->begin_form( 'inskin', '', $params );
 102  
 103      $Form->add_crumb( 'item' );
 104      $Form->hidden( 'ctrl', 'items' );
 105      $Form->hidden( 'blog', $Blog->ID );
 106      if( isset( $edited_Item ) )
 107      {
 108          $Form->hidden( 'post_ID', $edited_Item->ID );
 109  
 110          // Here we add js code for attaching file popup window: (Yury)

 111          if( !empty( $edited_Item->ID ) && ( $Session->get('create_edit_attachment') === true ) )
 112          {    // item also created => we have $edited_Item->ID for popup window:
 113              echo_attaching_files_button_js( $iframe_name );
 114              // clear session variable:

 115              $Session->delete('create_edit_attachment');
 116          }
 117      }
 118      $Form->hidden( 'redirect_to', $redirect_to );
 119  
 120      // In case we send this to the blog for a preview :

 121      $Form->hidden( 'preview', 1 );
 122      $Form->hidden( 'more', 1 );
 123      $Form->hidden( 'preview_userid', $current_User->ID );
 124  
 125      // Add hidden required fields or fields that were set in the init_inskin_editing() function

 126      $Form->hidden( 'item_typ_ID', $edited_Item->ptyp_ID );
 127  
 128      // These fields are required on preview mode

 129      $Form->hidden( 'titletag', $edited_Item->get( 'titletag' ) );
 130      $Form->hidden( 'post_excerpt', $edited_Item->get( 'excerpt' ) );
 131      $Form->hidden( 'metadesc', $edited_Item->get_setting( 'post_metadesc' ) );
 132      $Form->hidden( 'custom_headers', $edited_Item->get_setting( 'post_custom_headers' ) );
 133  
 134      if( $edited_Item->get( 'urltitle' ) != '' )
 135      {    // post_urltitle can be defined from request param
 136          $Form->hidden( 'post_urltitle', $edited_Item->get( 'urltitle' ) );
 137      }
 138  
 139      if( $action != 'new' )
 140      {    // DO NOT ADD HIDDEN FIELDS IF THEY ARE NOT SET
 141          // These fields will be set only in case when switch tab from admin editing to in-skin editing

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

 143          $Form->hidden( 'post_locale', $edited_Item->get( 'locale' ) );
 144          $Form->hidden( 'post_url', $edited_Item->get( 'url' ) );
 145  
 146          if( $Blog->get_setting( 'use_workflow' ) )
 147          {    // We want to use workflow properties for this blog:
 148              $Form->hidden( 'item_priority', $edited_Item->priority );
 149              $Form->hidden( 'item_assigned_user_ID', $edited_Item->assigned_user_ID );
 150              $Form->hidden( 'item_st_ID', $edited_Item->pst_ID );
 151              $Form->hidden( 'item_deadline', $edited_Item->datedeadline );
 152          }
 153          $Form->hidden( 'trackback_url', $trackback_url );
 154          $Form->hidden( 'item_hideteaser', $edited_Item->get_setting( 'hide_teaser' ) );
 155          $Form->hidden( 'expiry_delay', $edited_Item->get_setting( 'post_expiry_delay' ) );
 156          $Form->hidden( 'item_order', $edited_Item->order );
 157  
 158          $creator_User = $edited_Item->get_creator_User();
 159          $Form->hidden( 'item_owner_login', $creator_User->login );
 160          $Form->hidden( 'item_owner_login_displayed', 1 );
 161  
 162          if( $Blog->get_setting( 'show_location_coordinates' ) )
 163          {
 164              $Form->hidden( 'item_latitude', $edited_Item->get_setting( 'latitude' ) );
 165              $Form->hidden( 'item_longitude', $edited_Item->get_setting( 'longitude' ) );
 166              $Form->hidden( 'google_map_zoom', $edited_Item->get_setting( 'map_zoom' ) );
 167              $Form->hidden( 'google_map_type', $edited_Item->get_setting( 'map_type' ) );
 168          }
 169  
 170          display_hidden_custom_fields( $Form, $edited_Item );
 171      }
 172      else if( $edited_Item->ID == 0 )
 173      {    // If new item - add these hidden fields (on the edit mode the checkbox and radio buttons are used)
 174          $Form->hidden( 'item_featured', $edited_Item->featured );
 175          $Form->hidden( 'post_comment_status', $edited_Item->get( 'comment_status' ) );
 176          if( !isset( $edited_Item->status ) )
 177          {
 178              $highest_publish_status = get_highest_publish_status( 'post', $Blog->ID, false );
 179              $edited_Item->set( 'status', $highest_publish_status );
 180          }
 181      }
 182  
 183      $disp_edit_categories = true;
 184      if( ! $disp_params['disp_edit_categories'] )
 185      {    // When categories are hidden, we store a cat_ID in the hidden input
 186          if( $edited_Item->ID > 0 )
 187          {    // Get cat_ID from existing Item
 188              $cat = $edited_Item->get_main_Chapter()->ID;
 189          }
 190          else
 191          {    // Forums skin get cat_ID from $_GET
 192              $cat = param( 'cat', 'integer', 0 );
 193          }
 194  
 195          if( $cat > 0 && $edited_Item->ID == 0 )
 196          {    // Store a cat_ID
 197              $Form->hidden( 'post_category', $cat );
 198              $Form->hidden( 'cat', $cat );
 199              $disp_edit_categories = false;
 200          }
 201      }
 202  
 203  ?>
 204  
 205  
 206      <?php
 207      // ############################ POST CONTENTS #############################

 208      // Title input:

 209      $require_title = $Blog->get_setting('require_title');
 210      if( $require_title != 'none' )
 211      {
 212          $Form->text_input( 'post_title', $item_title, 20, T_('Subject'), '', array('maxlength'=>255, 'style'=>'width: 98%;', 'required'=>($require_title=='required')) );
 213      }
 214  
 215      // --------------------------- TOOLBARS ------------------------------------

 216      ob_start();
 217      echo '<div class="edit_toolbars">';
 218      // CALL PLUGINS NOW:

 219      $Plugins->trigger_event( 'AdminDisplayToolbar', array(
 220              'target_type' => 'Item',
 221              'edit_layout' => 'expert',
 222              'Item' => $edited_Item,
 223          ) );
 224      echo '</div>';
 225      $plugins_toolbar = ob_get_clean();
 226      
 227      // CALL PLUGINS NOW:

 228      ob_start();
 229      $Plugins->trigger_event( 'DisplayEditorButton', array( 'target_type' => 'Item', 'edit_layout' => 'inskin' ) );
 230      $plugins_editor_button = ob_get_clean();
 231  
 232      $Form->switch_template_parts( array(
 233              'inputstart' => '<td class="row2 left">'.$plugins_toolbar,
 234              'inputend' => $plugins_editor_button.'</td>',
 235          ) );
 236      // ---------------------------- TEXTAREA -------------------------------------

 237      $Form->textarea_input( 'content', $item_content, 16, T_('Message body'), array( 'cols' => 60 , 'id' => 'itemform_post_content', 'style' => 'width:99%' ) );
 238      ?>
 239      <script type="text/javascript" language="JavaScript">
 240          <!--
 241          // This is for toolbar plugins

 242          var b2evoCanvas = document.getElementById('itemform_post_content');
 243          //-->

 244      </script>
 245  
 246      <?php
 247      $Form->switch_template_parts( $disp_params['edit_form_params'] );
 248  
 249  $Form->end_fieldset();
 250  
 251      if( $current_User->check_perm( 'blog_edit_ts', 'edit', false, $Blog->ID ) )
 252      {    // ------------------------------------ TIME STAMP -------------------------------------
 253          echo $Form->fieldstart;
 254  
 255          $Form->switch_template_parts( array(
 256              'fieldstart' => '',
 257              'fieldend'   => '',
 258              'labelstart' => '',
 259              'labelend'   => '',
 260              'labelempty' => '',
 261              'inputstart' => '',
 262              'inputend'   => '',
 263              'output'     => false
 264          ) );
 265          $note = $Form->date( 'item_issue_date', $edited_Item->get('issue_date'), '' ).' ';
 266          $note .= $Form->time( 'item_issue_time', $edited_Item->get('issue_date'), '', 'hh:mm:ss', '' );
 267  
 268          $Form->switch_template_parts( $disp_params['edit_form_params'] );
 269          $values = array(
 270              array( 'value' => '0', 'label' => T_('Update to NOW') ),
 271              array( 'value' => '1', 'label' => T_('Set to') ),
 272          );
 273          $Form->radio_input( 'item_dateset', $edited_Item->dateset, $values, T_('Issue date'), array( 'note' => $note ) );
 274          echo $Form->fieldend;
 275  
 276          // Autoselect "change date" is the date is changed.

 277          ?>
 278          <script>
 279          jQuery( function()
 280                  {
 281                      jQuery('#item_issue_date, #item_issue_time').change(function()
 282                      {
 283                          jQuery('#item_dateset_radio_2').attr("checked", "checked")
 284                      })
 285                  }
 286              )
 287          </script>
 288          <?php
 289      }
 290  
 291      modules_call_method( 'display_item_settings', array( 'Form' => & $Form, 'Blog' => & $Blog, 'edited_Item' => & $edited_Item ) );
 292  
 293      if( $disp_edit_categories )
 294      {    // Display categories
 295          $Form->switch_template_parts( array(
 296                  'fieldset_begin' => '<tr><td class="left" valign="top"><strong>$fieldset_title$:</strong></td><td>',
 297              ) );
 298          cat_select( $Form, true, false, $disp_params );
 299          $Form->switch_template_parts( $disp_params['edit_form_params'] );
 300      }
 301  
 302      if( $edited_Item->ID > 0 )
 303      {    // If item is editing
 304          $Form->checkbox_input( 'item_featured', $edited_Item->featured, T_('Sticky'), array( 'note' => T_('Make this topic sticky (featured at the top of the list)') ) );
 305  
 306          if( ( $Blog->get_setting( 'allow_comments' ) != 'never' ) && ( $Blog->get_setting( 'disable_comments_bypost' ) ) )
 307          {    // Display radio inputs to change the comments status
 308              $Form->radio_input( 'post_comment_status', $edited_Item->get( 'comment_status' ), array(
 309                      array( 'value' => 'open', 'label' => T_('Open'), 'note' => T_('Visitors can leave comments on this post.') ),
 310                      array( 'value' => 'closed', 'label' => T_('Closed'), 'note' => T_('Visitors can NOT leave comments on this post.') ),
 311                      array( 'value' => 'disabled', 'label' => T_('Disabled'), 'note' => T_('Visitors cannot see nor leave comments on this post.') ),
 312                  ), T_('Allow replies'), array( 'lines' => true ) );
 313          }
 314          else
 315          {
 316              $Form->hidden( 'post_comment_status', $edited_Item->get( 'comment_status' ) );
 317          }
 318      }
 319  
 320      // ################### VISIBILITY / SHARING ###################

 321      $Form->switch_template_parts( array(
 322              'inputstart'     => '<td class="row2 left" id="itemform_visibility">',
 323          ) );
 324      visibility_select( $Form, $edited_Item->status, false, array(), T_('Visibility / Sharing') );
 325      $Form->switch_template_parts( $disp_params['edit_form_params'] );
 326  
 327      // ################### TEXT RENDERERS ###################

 328      $item_renderer_checkboxes = $edited_Item->get_renderer_checkboxes();
 329      if( !empty( $item_renderer_checkboxes ) )
 330      {
 331          $Form->switch_template_parts( array(
 332                  'fieldset_begin' => '<tr><td class="left" valign="top"><strong>$fieldset_title$:</strong></td><td class="row2 left">',
 333              ) );
 334          $Form->begin_fieldset( T_('Text Renderers'), array( 'id' => 'itemform_renderers' ) );
 335          echo $item_renderer_checkboxes;
 336          $Form->end_fieldset();
 337          $Form->switch_template_parts( $disp_params['edit_form_params'] );
 338      }
 339  
 340      // ################### TAGS ###################

 341      $Form->text_input( 'item_tags', $item_tags, 40, T_('Tags'), '', array('maxlength'=>255, 'style'=>'width: 99%;') );
 342  
 343  // ####################### ATTACHMENTS FIELDSETS #########################

 344  $LinkOwner = new LinkItem( $edited_Item );
 345  if( $LinkOwner->count_links() )
 346  {
 347      $Form->switch_template_parts( array(
 348              'fieldset_begin' => '<tr><td class="left" valign="top"><strong>$fieldset_title$:</strong></td><td class="row2 left">',
 349          ) );
 350      $Form->begin_fieldset( T_('Attachments') );
 351      if( $current_User->check_perm( 'files', 'view' ) && $current_User->check_perm( 'admin', 'restricted' ) )
 352      {
 353          display_attachments( $LinkOwner );
 354      }
 355      else
 356      {
 357          echo T_('You do not have permission to edit file attachments for this post');
 358      }
 359      $Form->end_fieldset();
 360      $Form->switch_template_parts( $disp_params['edit_form_params'] );
 361  }
 362  
 363  // ####################### PLUGIN FIELDSETS #########################

 364  $Form->switch_template_parts( array(
 365      'fieldset_begin' => '<tr><td colspan="2" class="left row2">',
 366      'fieldend'       => '</tr><tr><td colspan="2">',
 367      ) );
 368  $Plugins->trigger_event( 'DisplayItemFormFieldset', array( 'Form' => & $Form, 'Item' => & $edited_Item ) );
 369  $Form->switch_template_parts( $disp_params['edit_form_params'] );
 370  
 371  $Form->begin_fieldset();
 372      // ------------------------------- ACTIONS ----------------------------------

 373      echo '<div class="edit_actions">';
 374      echo_publish_buttons( $Form, $creating, $edited_Item, true, true );
 375      echo '</div>';
 376  $Form->end_fieldset();
 377  // ================================== END OF EDIT FORM ==================================

 378  $Form->end_form();
 379  
 380  // ####################### JS BEHAVIORS #########################

 381  echo_publishnowbutton_js();
 382  // New category input box:

 383  echo_onchange_newcat();
 384  echo_autocomplete_tags( $edited_Item->get_tags() );
 385  
 386  ?>

title

Description

title

Description

title

Description

title

title

Body