[ Index ]

MailPress 7.1

[ Index ]     [ Classes ]     [ Functions ]     [ Variables ]     [ Constants ]     [ Statistics ]    

title

Body

[close]

/mp-includes/class/options/form/field_types/file/ -> file.php (source)

   1  <?php
   2  class MP_Form_field_type_file extends MP_form_field_type_
   3  {
   4      var $file         = __FILE__;
   5  
   6      var $id        = 'file';
   7  
   8      var $category     = 'html';
   9  
  10      var $order        = 60;
  11  
  12  	function get_name( $field )
  13      {
  14          $this->field = $field;
  15  
  16          return $this->prefix . $this->field->form_id . '_' . $this->field->id;
  17      }
  18  
  19  // have file loading ?
  20  	function have_file ( $have_file )            
  21      {
  22          return true;
  23      }
  24  
  25  	function submitted( $field )
  26      {
  27          $this->field = $field;
  28  
  29          $name        = $this->get_name( $this->field );
  30  
  31          $required     = ( isset( $this->field->settings['controls']['required'] ) && $this->field->settings['controls']['required'] );
  32          $empty     = ( !isset( $_FILES[$name] ) || empty( $_FILES[$name]['name'] ) );
  33  
  34          if ( $empty )
  35          {
  36              if ( $required )
  37              {
  38                  $this->field->submitted['on_error'] = true;
  39                  return $this->field;
  40              }
  41              $this->field->submitted['value'] = false;
  42              $this->field->submitted['text']  = __( 'no file', 'MailPress' );
  43              return $this->field;
  44          }
  45          $this->field->submitted['file'] = $name;
  46  
  47          $i = 0;
  48          $this->field->submitted['text']  = '';
  49          $attributes = array( 'name', 'type', 'tmp_name', 'error', 'size' );
  50  
  51          foreach( $attributes as $attribute ) if ( isset( $_FILES[$name][$attribute] ) ) $this->field->submitted['value'][$attribute] = $_FILES[$name][$attribute];
  52          foreach( $this->field->submitted['value'] as $attribute => $v )
  53          {
  54              $i++;
  55              if ( $i == 1 )     $this->field->submitted['text'] .= "$attribute : " . ( ( !empty( $v ) ) ? "$v " : '<small>[<i>' . __( 'empty', 'MailPress' ) . '</i>]</small>' ) . ( ( count( $this->field->submitted['value'] ) > 1 )   ? ', ' : '' );
  56              else            $this->field->submitted['text'] .= "$attribute : " . ( ( !empty( $v ) ) ? "$v " : '<small>[<i>' . __( 'empty', 'MailPress' ) . '</i>]</small>' ) . ( ( count( $this->field->submitted['value'] ) != $i ) ? ', ' : '' );
  57          }
  58          return $this->field;
  59      }
  60  
  61  	function attributes_filter( $no_reset )
  62      {
  63          if ( !$no_reset ) return;
  64  
  65          $this->attributes_filter_css();
  66      }
  67  }
  68  new MP_Form_field_type_file( __( 'File select', 'MailPress' ) );


Generated: Mon Mar 11 18:33:33 2019 Cross-referenced by PHPXref 0.7.1