b2evolution PHP Cross Reference Blogging Systems

Source: /inc/files/views/_file_settings.form.php - 262 lines - 11128 bytes - Summary - Text - Print

Description: This file implements the UI view for the file settings. This file is part of the evoCore framework - {@link http://evocore.net/} See also {@link http://sourceforge.net/projects/evocms/}.

   1  <?php
   2  /**
   3   * This file implements the UI view for the file settings.
   4   *
   5   * This file is part of the evoCore framework - {@link http://evocore.net/}
   6   * See also {@link http://sourceforge.net/projects/evocms/}.
   7   *
   8   * @copyright (c)2003-2014 by Francois Planque - {@link http://fplanque.com/}
   9   * Parts of this file are copyright (c)2005-2006 by PROGIDISTRI - {@link http://progidistri.com/}.
  10   *
  11   * {@internal License choice
  12   * - If you have received this file as part of a package, please find the license.txt file in
  13   *   the same folder or the closest folder above for complete license terms.
  14   * - If you have received this file individually (e-g: from http://evocms.cvs.sourceforge.net/)
  15   *   then you must choose one of the following licenses before using the file:
  16   *   - GNU General Public License 2 (GPL) - http://www.opensource.org/licenses/gpl-license.php
  17   *   - Mozilla Public License 1.1 (MPL) - http://www.opensource.org/licenses/mozilla1.1.php
  18   * }}
  19   *
  20   * {@internal Open Source relicensing agreement:
  21   * PROGIDISTRI S.A.S. grants Francois PLANQUE the right to license
  22   * PROGIDISTRI S.A.S.'s contributions to this file and the b2evolution project
  23   * under any OSI approved OSS license (http://www.opensource.org/licenses/).
  24   * }}
  25   *
  26   * @package admin
  27   *
  28   * {@internal Below is a list of authors who have contributed to design/coding of this file: }}
  29   * @author fplanque: Francois PLANQUE.
  30   * @author mbruneau: Marc BRUNEAU / PROGIDISTRI
  31   * @author fsaya: Fabrice SAYA-GASNIER / PROGIDISTRI
  32   *
  33   * @version $Id: _file_settings.form.php 6136 2014-03-08 07:59:48Z manuel $
  34   */
  35  if( !defined('EVO_MAIN_INIT') ) die( 'Please, do not access this page directly.' );
  36  
  37  
  38  /**
  39   * @var GeneralSettings
  40   */
  41  global $Settings;
  42  
  43  global $upload_maxmaxkb;
  44  
  45  /**
  46   * Javascript to init hidden/shown state of something (like a DIV) based on a checkbox
  47   *
  48   * EXPERIMENTAL
  49   * Will be moved to another file, I'm leaving it here for a short period, in order to provide context
  50   *
  51   * PROBLEM: jQuery is not necessarily loaded at the moment we use this :(
  52   *
  53   * @param string DOM class
  54   * @param string DOM id
  55   */
  56  function JS_showhide_class_on_checkbox( $class, $checkbox_id )
  57  {
  58      return '<script type="text/javascript">
  59      if( document.getElementById("'.$checkbox_id.'").checked )
  60          {
  61               jQuery(".'.$class.'").show();
  62          }
  63          else
  64          {
  65               jQuery(".'.$class.'").hide();
  66          }
  67      </script>';
  68  }
  69  
  70  /**
  71   * Javascript to init hidden/shown state of something (like a DIV) based on a checkbox
  72   *
  73   * EXPERIMENTAL
  74   * Will be moved to another file, I'm leaving it here for a short period, in order to provide context
  75   *
  76   * @param array|string DOM id
  77   * @param string DOM id
  78   */
  79  function JS_showhide_ids_on_checkbox( $div_ids, $checkbox_id )
  80  {
  81      if( !is_array($div_ids) )
  82      {
  83          $div_ids = array( $div_ids );
  84      }
  85      $r = '<script type="text/javascript">
  86          var display = document.getElementById("'.$checkbox_id.'").checked ? "" : "none";'."\n";
  87      foreach( $div_ids as $div_id )
  88      {
  89          $r .= 'document.getElementById("'.$div_id.'").style.display = display;'."\n";
  90      }
  91      $r .= '</script>';
  92      return $r;
  93  }
  94  
  95  /**
  96   * Javascript to init hidden/shown state of a fastform field based on a checkbox
  97   *
  98   * EXPERIMENTAL
  99   * Will be moved to another file, I'm leaving it here for a short period, in order to provide context
 100   *
 101   * @param string form field id as used when creating it with the Form class
 102   * @param string DOM id
 103   */
 104  function JS_showhide_ffield_on_checkbox( $field_id, $checkbox_id )
 105  {
 106      return '<script type="text/javascript">
 107          document.getElementById("ffield_'.$field_id.'").style.display = (document.getElementById("'.$checkbox_id.'").checked ? "" : "none")
 108      </script>';
 109  }
 110  
 111  /**
 112   * Javascript hide/show all DOM elements with a particular class based on current checkbox
 113   *
 114   * EXPERIMENTAL
 115   * Will be moved to another file, I'm leaving it here for a short period, in order to provide context
 116   *
 117   * @param string DOM class name
 118   */
 119  function JS_showhide_class_on_this( $class )
 120  {
 121      return 'if( this.checked )
 122          {
 123               jQuery(".'.$class.'").show();
 124          }
 125          else
 126          {
 127               jQuery(".'.$class.'").hide();
 128          }';
 129  }
 130  
 131  /**
 132   * Javascript hide/show something (like a DIV) based on current checkbox
 133   *
 134   * EXPERIMENTAL
 135   * Will be moved to another file, I'm leaving it here for a short period, in order to provide context
 136   *
 137   * @param array|string DOM ids
 138   */
 139  function JS_showhide_ids_on_this( $div_ids )
 140  {
 141      if( !is_array($div_ids) )
 142      {
 143          $div_ids = array( $div_ids );
 144      }
 145      $r = 'var display = this.checked ? "" : "none";'."\n";
 146      foreach( $div_ids as $div_id )
 147      {
 148          $r .= 'document.getElementById("'.$div_id.'").style.display = display;'."\n";
 149      }
 150      return $r;
 151  }
 152  
 153  /**
 154   * Javascript hide/show a fastform field based on current checkbox
 155   *
 156   * EXPERIMENTAL
 157   * Will be moved to another file, I'm leaving it here for a short period, in order to provide context
 158   *
 159   * @param string DOM id
 160   */
 161  function JS_showhide_ffield_on_this( $field_id )
 162  {
 163      return 'document.getElementById("ffield_'.$field_id.'").style.display = (this.checked ? "" : "none")';
 164  }
 165  
 166  
 167  $Form = new Form( NULL, 'files_checkchanges' );
 168  
 169  $Form->begin_form( 'fform', T_('File manager settings') );
 170  
 171  $Form->add_crumb( 'file' );
 172  $Form->hidden( 'ctrl', 'fileset' );
 173  $Form->hidden( 'action', 'update' );
 174  
 175  $Form->begin_fieldset( T_('Accessible file roots').get_manual_link('accessible_file_roots'), array( 'id' => 'ffset_fileroots', 'class' => 'additional_file_settings' ) );
 176      $Form->checkbox( 'fm_enable_roots_blog', $Settings->get('fm_enable_roots_blog'), T_('Enable blog directories'), T_('Check to enable root directories for blogs.' ) );
 177      $Form->checkbox( 'fm_enable_roots_user', $Settings->get('fm_enable_roots_user'), T_('Enable user directories'), T_('Check to enable root directories for users.' ) );
 178      $Form->checkbox( 'fm_enable_roots_shared', $Settings->get('fm_enable_roots_shared'), T_('Enable shared directory'), T_('Check to enable shared root directory.' ) );
 179      $Form->checkbox( 'fm_enable_roots_skins', $Settings->get('fm_enable_roots_skins'), T_('Enable skins directory'), T_('Check to enable root directory for skins.' ) );    // fp> note: meaning may change to 1 dir per (installed) skin
 180  $Form->end_fieldset();
 181  
 182  $Form->begin_fieldset( T_('File creation options'), array( 'id' => 'ffset_filecreate', 'class' => 'additional_file_settings' ) );
 183      $Form->checkbox( 'fm_enable_create_dir', $Settings->get('fm_enable_create_dir'), T_('Enable creation of folders'), T_('Check to enable creation of directories.' ) );
 184      $Form->checkbox( 'fm_enable_create_file', $Settings->get('fm_enable_create_file'), T_('Enable creation of files'), T_('Check to enable creation of files.' ) );
 185      $Form->checkbox_input( 'upload_enabled', $Settings->get( 'upload_enabled', true ), T_('Enable upload of files'), array(
 186          'note' => T_('Check to allow uploading files in general.' ), 'onclick' => JS_showhide_ffield_on_this('upload_maxkb') ) );
 187      $Form->text_input( 'upload_maxkb', $Settings->get('upload_maxkb'), 6, T_('Maximum upload filesize'), sprintf( /* TRANS: first %s is php.ini limit, second is setting/var name, third is file name, 4th is limit in b2evo conf */ T_('KB. This cannot be higher than your PHP/Webserver setting (PHP: %s) and the limit of %s (in %s), which is currently %s!'), ini_get('upload_max_filesize').'/'.ini_get('post_max_size').' (upload_max_filesize/post_max_size)', '$upload_maxmaxkb', '/conf/_advanced.php', $upload_maxmaxkb.' '.T_('KB') ), array( 'maxlength'=>7, 'required'=>true ) );
 188      // Javascript to init hidden/shown state:
 189      echo JS_showhide_ffield_on_checkbox( 'upload_maxkb', 'upload_enabled' );
 190  $Form->end_fieldset();
 191  
 192  $Form->begin_fieldset( T_('Advanced options'), array( 'id' => 'ffset_fileadvanced', 'class' => 'additional_file_settings' ) );
 193  
 194      $Form->text_input( 'fm_default_chmod_dir', $Settings->get('fm_default_chmod_dir'), 4, T_('Default folder permissions'), T_('Default CHMOD (UNIX permissions) for new directories created by the file manager.' ) );
 195  
 196      // fp> Does the following also applu to *uploaded* files? (It should)
 197       $Form->text_input( 'fm_default_chmod_file', $Settings->get('fm_default_chmod_file'), 4, T_('Default file permissions'), T_('Default CHMOD (UNIX permissions) for new files created by the file manager.' ) );
 198  
 199      if( empty( $force_regexp_filename ) || empty( $force_regexp_dirname ) )
 200      { // At least one of these strings can be configured in the UI:
 201  
 202          // Do not display regexp for filename if the force_regexp_filename var is set
 203          if( empty($force_regexp_filename) )
 204          {
 205              $Form->text( 'regexp_filename',
 206                                              $Settings->get('regexp_filename'),
 207                                              40,
 208                                              T_('Valid filename'),
 209                                              T_('Regular expression'),
 210                                              255 );
 211          }
 212          // Do not display regexp for dirname if the force_regexp_dirname var is set
 213          if( empty( $force_regexp_dirname ) )
 214          {
 215              $Form->text( 'regexp_dirname',
 216                                              $Settings->get('regexp_dirname'),
 217                                              40,
 218                                              T_('Valid dirname'),
 219                                              T_('Regular expression'),
 220                                              255 );
 221          }
 222      }
 223  
 224      $Form->radio_input( 'evocache_foldername', $Settings->get( 'evocache_foldername' ), array(
 225                          array( 'value' => '.evocache', 'label' => T_('Use .evocache folders (system hidden folders)') ),
 226                          array( 'value' => '_evocache', 'label' => T_('Use _evocache folders (compatible with all webservers)') ) ), T_('Cache folder names'), array( 'lines' => 2 ) );
 227  
 228  $Form->end_fieldset();
 229  
 230  $Form->begin_fieldset( T_('Image options').get_manual_link( 'image-options' ) );
 231  
 232      $Form->checkbox( 'exif_orientation', $Settings->get( 'exif_orientation' ), T_('Use EXIF info in photos'), T_('Use orientation tag to automatically rotate thumbnails to upright position.') );
 233  
 234      $resize_input_suffix = ' '.T_('Fit to').' ';
 235      $resize_input_suffix .= '<input type="text" id="fm_resize_width" name="fm_resize_width" class="form_text_input" size="4" maxlength="4" value="'.$Settings->get( 'fm_resize_width' ).'" />';
 236      $resize_input_suffix .= ' x ';
 237      $resize_input_suffix .= '<input type="text" id="fm_resize_height" name="fm_resize_height" class="form_text_input" size="4" maxlength="4" value="'.$Settings->get( 'fm_resize_height' ).'" />';
 238      $resize_input_suffix .= ' '.T_('pixels').' ';
 239      $resize_input_suffix .= '<input type="text" id="fm_resize_quality" name="fm_resize_quality" class="form_text_input" size="3" maxlength="3" style="margin-left:10px" value="'.$Settings->get( 'fm_resize_quality' ).'" />';
 240      $resize_input_suffix .= ' % '.T_('quality').' ';
 241      $Form->checkbox_input( 'fm_resize_enable', $Settings->get( 'fm_resize_enable' ), T_('Resize large images after upload'), array( 'input_suffix' => $resize_input_suffix ) );
 242  
 243  $Form->end_fieldset();
 244  
 245  if( $current_User->check_perm( 'options', 'edit', false ) )
 246  { // We have permission to modify:
 247      $Form->buttons( array(
 248              array( 'submit', 'submit[update]', T_('Update'), 'SaveButton' ),
 249              array( 'reset', '', T_('Reset'), 'ResetButton' ),
 250              array( 'submit', 'submit[restore_defaults]', T_('Restore defaults'), 'ResetButton' ),
 251          ) );
 252  }
 253  
 254  $Form->end_form();
 255  
 256  if( $current_User->check_perm( 'options', 'edit', false ) )
 257  {    // TODO: better perm check
 258      echo '<p class="note">'.T_('See also:').' ';
 259      echo T_('Blog Settings').' &gt; '.T_('Advanced').' &gt; '.T_('Media directory location');
 260  }
 261  
 262  ?>

title

Description

title

Description

title

Description

title

title

Body