b2evolution PHP Cross Reference Blogging Systems

Source: /inc/collections/views/_coll_features.form.php - 286 lines - 15029 bytes - Summary - Text - Print

Description: This file implements the UI view for the Collection features properties. 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 UI view for the Collection features properties.
   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   * {@internal Open Source relicensing agreement:
  13   * }}
  14   *
  15   * {@internal Below is a list of authors who have contributed to design/coding of this file: }}
  16   *
  17   * @package admin
  18   *
  19   * @version $Id: _coll_features.form.php 6136 2014-03-08 07:59:48Z manuel $
  20   */
  21  if( !defined('EVO_MAIN_INIT') ) die( 'Please, do not access this page directly.' );
  22  
  23  /**
  24   * @var Blog
  25   */
  26  global $edited_Blog;
  27  
  28  
  29  $Form = new Form( NULL, 'coll_features_checkchanges' );
  30  
  31  $Form->begin_form( 'fform' );
  32  
  33  $Form->add_crumb( 'collection' );
  34  $Form->hidden_ctrl();
  35  $Form->hidden( 'action', 'update' );
  36  $Form->hidden( 'tab', 'features' );
  37  $Form->hidden( 'blog', $edited_Blog->ID );
  38  
  39  $Form->begin_fieldset( T_('Post list').get_manual_link('item-list-features') );
  40    $Form->select_input_array( 'orderby', $edited_Blog->get_setting('orderby'), get_available_sort_options(), T_('Order by'), T_('Default ordering of posts.') );
  41    $Form->select_input_array( 'orderdir', $edited_Blog->get_setting('orderdir'), array(
  42                          'ASC'  => T_('Ascending'),
  43                          'DESC' => T_('Descending'), ), T_('Direction') );
  44    $Form->radio( 'what_to_show', $edited_Blog->get_setting('what_to_show'),
  45                  array(  array( 'days', T_('days') ),
  46                          array( 'posts', T_('posts') ),
  47                        ), T_('Display unit'), false,  T_('Do you want to restrict on the number of days or the number of posts?') );
  48    $Form->text( 'posts_per_page', $edited_Blog->get_setting('posts_per_page'), 4, T_('Posts/Days per page'), T_('How many days or posts do you want to display on the home page?'), 4 );
  49  
  50    $Form->radio( 'timestamp_min', $edited_Blog->get_setting('timestamp_min'),
  51                  array(  array( 'yes', T_('yes') ),
  52                          array( 'no', T_('no') ),
  53                          array( 'duration', T_('only the last') ),
  54                        ), T_('Show past posts'), true );
  55    $Form->duration_input( 'timestamp_min_duration', $edited_Blog->get_setting('timestamp_min_duration'), '' );
  56  
  57    $Form->radio( 'timestamp_max', $edited_Blog->get_setting('timestamp_max'),
  58                  array(  array( 'yes', T_('yes') ),
  59                          array( 'no', T_('no') ),
  60                          array( 'duration', T_('only the next') ),
  61                        ), T_('Show future posts'), true );
  62    $Form->duration_input( 'timestamp_max_duration', $edited_Blog->get_setting('timestamp_max_duration'), '' );
  63  
  64  $Form->end_fieldset();
  65  
  66  
  67  $Form->begin_fieldset( T_('Post options').get_manual_link('blog_features_settings') );
  68      $Form->select_input_array( 'default_post_status', $edited_Blog->get_setting('default_post_status'), get_visibility_statuses('notes-string'), T_('Default status'), T_('Default status for new posts') );
  69  
  70      $Form->radio( 'require_title', $edited_Blog->get_setting('require_title'),
  71                                  array(  array( 'required', T_('Always'), T_('The blogger must provide a title') ),
  72                                                  array( 'optional', T_('Optional'), T_('The blogger can leave the title field empty') ),
  73                                                  array( 'none', T_('Never'), T_('No title field') ),
  74                                              ), T_('Post titles'), true );
  75  
  76      $Form->checkbox( 'allow_html_post', $edited_Blog->get_setting( 'allow_html_post' ),
  77                          T_( 'Allow HTML' ), T_( 'Check to allow HTML in posts.' ).' ('.T_('HTML code will pass several sanitization filters.').')' );
  78  
  79      $Form->radio( 'enable_goto_blog', $edited_Blog->get_setting( 'enable_goto_blog' ),
  80          array( array( 'no', T_( 'No' ), T_( 'Check this to view list of the posts.' ) ),
  81              array( 'blog', T_( 'View home page' ), T_( 'Check this to automatically view the blog after publishing a post.' ) ),
  82              array( 'post', T_( 'View new post' ), T_( 'Check this to automatically view the post page.' ) ), ),
  83              T_( 'View blog after publishing' ), true );
  84  
  85      $Form->radio( 'editing_goto_blog', $edited_Blog->get_setting( 'editing_goto_blog' ),
  86          array( array( 'no', T_( 'No' ), T_( 'Check this to view list of the posts.' ) ),
  87              array( 'blog', T_( 'View home page' ), T_( 'Check this to automatically view the blog after editing a post.' ) ),
  88              array( 'post', T_( 'View edited post' ), T_( 'Check this to automatically view the post page.' ) ), ),
  89              T_( 'View blog after editing' ), true );
  90  
  91      // FP> TODO:
  92      // -post_url  always('required')|optional|never
  93      // -multilingual:  true|false   or better yet: provide a list to narrow down the active locales
  94      // -tags  always('required')|optional|never
  95  
  96      $Form->radio( 'post_categories', $edited_Blog->get_setting('post_categories'),
  97          array( array( 'one_cat_post', T_('Allow only one category per post') ),
  98              array( 'multiple_cat_post', T_('Allow multiple categories per post') ),
  99              array( 'main_extra_cat_post', T_('Allow one main + several extra categories') ),
 100              array( 'no_cat_post', T_('Don\'t allow category selections'), T_('(Main cat will be assigned automatically)') ) ),
 101              T_('Post category options'), true );
 102  
 103      $Form->radio( 'post_navigation', $edited_Blog->get_setting('post_navigation'),
 104          array( array( 'same_blog', T_('same blog') ),
 105              array( 'same_category', T_('same category') ),
 106              array( 'same_author', T_('same author') ) ),
 107              T_('Default post by post navigation should stay in'), true, T_( 'Skins may override this setting!') );
 108  
 109      $location_options = array(
 110              array( 'optional', T_('Optional') ),
 111              array( 'required', T_('Required') ),
 112              array( 'hidden', T_('Hidden') )
 113          );
 114  
 115      $Form->radio( 'location_country', $edited_Blog->get_setting( 'location_country' ), $location_options, T_('Country') );
 116  
 117      $Form->radio( 'location_region', $edited_Blog->get_setting( 'location_region' ), $location_options, T_('Region') );
 118  
 119      $Form->radio( 'location_subregion', $edited_Blog->get_setting( 'location_subregion' ), $location_options, T_('Sub-region') );
 120  
 121      $Form->radio( 'location_city', $edited_Blog->get_setting( 'location_city' ), $location_options, T_('City') );
 122  
 123      $Form->checkbox( 'show_location_coordinates', $edited_Blog->get_setting( 'show_location_coordinates' ),
 124                          T_( 'Show location coordinates' ), T_( 'Check this to be able to set the location coordinates and view on map.' ) );
 125  
 126  $Form->end_fieldset();
 127  
 128  // display features settings provided by optional modules:
 129  // echo 'modules';
 130  modules_call_method( 'display_collection_features', array( 'Form' => & $Form, 'edited_Blog' => & $edited_Blog ) );
 131  
 132  $Form->begin_fieldset( T_('RSS/Atom feeds').get_manual_link('item-feeds-features') );
 133      $Form->radio( 'feed_content', $edited_Blog->get_setting('feed_content'),
 134                                  array(  array( 'none', T_('No feeds') ),
 135                                                  array( 'title', T_('Titles only') ),
 136                                                  array( 'excerpt', T_('Post excerpts') ),
 137                                                  array( 'normal', T_('Standard post contents (stopping at "&lt;!-- more -->")') ),
 138                                                  array( 'full', T_('Full post contents (including after "&lt;!-- more -->")') ),
 139                                              ), T_('Post feed contents'), true, T_('How much content do you want to make available in post feeds?') );
 140  
 141      $Form->text( 'posts_per_feed', $edited_Blog->get_setting('posts_per_feed'), 4, T_('Posts in feeds'),  T_('How many of the latest posts do you want to include in RSS & Atom feeds?'), 4 );
 142  
 143      if( isset($GLOBALS['files_Module']) )
 144      {
 145          load_funcs( 'files/model/_image.funcs.php' );
 146          $params['force_keys_as_values'] = true;
 147          $Form->select_input_array( 'image_size', $edited_Blog->get_setting('image_size') , get_available_thumb_sizes(), T_('Image size'), '', $params );
 148      }
 149  $Form->end_fieldset();
 150  
 151  
 152  $Form->begin_fieldset( T_('Custom fields').get_manual_link('item-custom-fields') );
 153      $custom_field_types = array(
 154              'double' => array( 'label' => T_('Numeric'), 'title' => T_('Add new numeric custom field'), 'note' => T_('Ex: Price, Weight, Length... &ndash; will be stored as a double floating point number.'), 'size' => 20, 'maxlength' => 40 ),
 155              'varchar' => array( 'label' => T_('String'), 'title' => T_('Add new text custom field'), 'note' => T_('Ex: Color, Fabric... &ndash; will be stored as a varchar(2000) field.'), 'size' => 30, 'maxlength' => 60 )
 156      );
 157  
 158      foreach( $custom_field_types as $type => $data )
 159      {
 160          echo '<div id="custom_'.$type.'_field_list">';
 161          // dispaly hidden count_custom_type value and increase after a new field was added
 162          $count_custom_field = $edited_Blog->get_setting( 'count_custom_'.$type );
 163          echo '<input type="hidden" name="count_custom_'.$type.'" value='.$count_custom_field.' />';
 164          $deleted_custom_fields = param( 'deleted_custom_'.$type, 'string', '' );
 165          echo '<input type="hidden" name="deleted_custom_'.$type.'" value="'.$deleted_custom_fields.'" />';
 166          for( $i = 1 ; $i <= $count_custom_field; $i++ )
 167          { // dispaly all existing custom field name
 168              $field_id_suffix = 'custom_'.$type.'_'.$i;
 169              $custom_guid = $edited_Blog->get_setting( 'custom_'.$type.$i );
 170              if( !empty( $deleted_custom_fields ) && ( strpos( $deleted_custom_fields, $custom_guid ) !== false ) )
 171              {
 172                  continue;
 173              }
 174              $action_delete = get_icon( 'xross', 'imgtag', array( 'id' => 'delete_'.$field_id_suffix, 'style' => 'cursor:pointer', 'title' => T_('Delete custom field') ) );
 175              $custom_field_name = $edited_Blog->get_setting( 'custom_fname_'.$custom_guid );
 176              $custom_field_value = $edited_Blog->get_setting( 'custom_'.$type.'_'.$custom_guid );
 177              $custom_field_value_class = '';
 178              $custom_field_name_class = '';
 179              if( empty( $custom_field_value ) )
 180              { // When user saves new field without name
 181                  $custom_field_value = get_param( $field_id_suffix );
 182                  $custom_field_value_class = 'new_custom_field_title';
 183                  $custom_field_name_class = 'field_error';
 184              }
 185              echo '<input type="hidden" name="custom_'.$type.'_guid'.$i.'" value="'.$custom_guid.'" />';
 186              $custom_field_name = ' '.T_('Name').' <input type="text" name="custom_'.$type.'_fname'.$i.'" value="'.$custom_field_name.'" class="form_text_input custom_field_name '.$custom_field_name_class.'" maxlength="36" />';
 187              $Form->text_input( $field_id_suffix, $custom_field_value, $data[ 'size' ], $data[ 'label' ], $action_delete, array(
 188                      'maxlength'    => $data[ 'maxlength' ],
 189                      'input_prefix' => T_('Title').' ',
 190                      'input_suffix' => $custom_field_name,
 191                      'class'        => $custom_field_value_class,
 192                  ) );
 193          }
 194          echo '</div>';
 195          // display link to create new custom field
 196          echo '<div class="input">';
 197          echo '<a onclick="return false;" href="#" id="add_new_'.$type.'_custom_field">'.$data[ 'title' ].'</a>';
 198          echo '<span class="notes"> ( '.$data[ 'note' ].' )</span>';
 199          echo '</div>';
 200      }
 201  $Form->end_fieldset();
 202  
 203  
 204  $Form->end_form( array(
 205      array( 'submit', 'submit', T_('Save !'), 'SaveButton' ),
 206      array( 'reset', '', T_('Reset'), 'ResetButton' ) ) );
 207  
 208  
 209  load_funcs( 'regional/model/_regional.funcs.php' );
 210  echo_regional_required_js( 'location_' );
 211  
 212  ?>
 213  
 214  <script type="text/javascript">
 215  	function guidGenerator() {
 216          var S4 = function() {
 217              return (((1+Math.random())*0x10000)|0).toString(16).substring(1);
 218          };
 219          return (S4()+S4()+"-"+S4()+"-"+S4()+"-"+S4()+"-"+S4()+S4());
 220      }
 221  
 222      jQuery( '#add_new_double_custom_field' ).click( function()
 223      {
 224          var count_custom_double = jQuery( 'input[name=count_custom_double]' ).attr( 'value' );
 225          count_custom_double++;
 226          var custom_guid = guidGenerator();
 227          jQuery( '#custom_double_field_list' ).append( '<fieldset id="ffield_custom_double_' + count_custom_double + '">' +
 228                  '<input type="hidden" name="custom_double_guid' + count_custom_double + '" value="' + custom_guid + '" />' +
 229                  '<div class="label"><label for="custom_double_' + count_custom_double + '"><?php echo TS_('Numeric'); ?>:</label></div>' +
 230                  '<div class="input">' +
 231                      'Title <input type="text" id="custom_double_' + count_custom_double + '" name="custom_double_' + count_custom_double + '" class="form_text_input new_custom_field_title" size="20" maxlength="60" />' +
 232                      ' Name <input type="text" name="custom_double_fname' + count_custom_double + '" value="" class="form_text_input custom_field_name" maxlength="36" />' +
 233                  '</div></fieldset>' );
 234          jQuery( 'input[name=count_custom_double]' ).attr( 'value', count_custom_double );
 235      } );
 236  
 237      jQuery( '#add_new_varchar_custom_field' ).click( function()
 238      {
 239          var count_custom_varchar = jQuery( 'input[name=count_custom_varchar]' ).attr( 'value' );
 240          count_custom_varchar++;
 241          var custom_guid = guidGenerator();
 242          jQuery( '#custom_varchar_field_list' ).append( '<fieldset id="ffield_custom_string' + count_custom_varchar + '">' +
 243                  '<input type="hidden" name="custom_varchar_guid' + count_custom_varchar + '" value="' + custom_guid + '" />' +
 244                  '<div class="label"><label for="custom_varchar_' + count_custom_varchar + '"><?php echo TS_('String'); ?>:</label></div>' +
 245                  '<div class="input">' +
 246                      'Title <input type="text" id="custom_varchar_' + count_custom_varchar + '" name="custom_varchar_' + count_custom_varchar + '" class="form_text_input new_custom_field_title" size="30" maxlength="40" />' +
 247                      ' Name <input type="text" name="custom_varchar_fname' + count_custom_varchar + '" value="" class="form_text_input custom_field_name" maxlength="36" />' +
 248                  '</div></fieldset>' );
 249          jQuery( 'input[name=count_custom_varchar]' ).attr( 'value', count_custom_varchar );
 250      } );
 251  
 252      jQuery( '[id^="delete_custom_"]' ).click( function()
 253      {
 254          if( confirm( '<?php echo TS_('Are you sure want to delete this custom field?\nThe update will be performed when you will click on the \'Save changes!\' button.'); ?>' ) )
 255          { // Delete custom field only from html form, This field will be removed after saving of changes
 256              var delete_action_id = jQuery( this ).attr('id');
 257              var field_parts = delete_action_id.split( '_' );
 258              var field_type = field_parts[2];
 259              var field_index = field_parts[3];
 260              var field_guid = jQuery( '[name="custom_' + field_type + '_guid' + field_index + '"]' ).val();
 261              var deleted_fields = '[name="deleted_custom_' + field_type + '"]';
 262              var deleted_fields_value = jQuery( deleted_fields ).val();
 263              if( deleted_fields_value )
 264              {
 265                  deleted_fields_value = deleted_fields_value + ',';
 266              }
 267              jQuery( deleted_fields ).val( deleted_fields_value + field_guid );
 268              jQuery( '#ffield_custom_' + field_type + '_' + field_index ).remove();
 269          }
 270      } );
 271  
 272      jQuery( document ).on( 'keyup', '.new_custom_field_title', function()
 273      { // Prefill new field name
 274          jQuery( this ).parent().find( '.custom_field_name' ).val( parse_custom_field_name( jQuery( this ).val() ) );
 275      } );
 276  
 277      jQuery( document ).on( 'blur', '.custom_field_name', function()
 278      { // Remove incorrect chars from field name on blur event
 279          jQuery( this ).val( parse_custom_field_name( jQuery( this ).val() ) );
 280      } );
 281  
 282  	function parse_custom_field_name( field_name )
 283      {
 284          return field_name.substr( 0, 36 ).replace( /[^a-z0-9\-_]/ig, '_' ).toLowerCase();
 285      }
 286  </script>

title

Description

title

Description

title

Description

title

title

Body