[ Index ]

MailPress 544

[ 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      var $order    = 99;
  10  
  11  	function get_name($field) { return $this->prefix . $field->form_id . '_' . $field->id; }
  12  	function have_file($have_file) { return true; } // have file loading ?
  13  
  14  	function submitted($field)
  15      {
  16          $name        = $this->get_name($field);
  17  
  18          $required     = (isset($field->settings['controls']['required']) && $field->settings['controls']['required']);
  19          $empty     = (!isset($_FILES[$name]) || empty($_FILES[$name]['name']) );
  20  
  21          if ($empty)
  22          {
  23              if ($required)
  24              {
  25                  $field->submitted['on_error'] = true;
  26                  return $field;
  27              }
  28              $field->submitted['value'] = false;
  29              $field->submitted['text']  = __('no file', MP_TXTDOM);
  30              return $field;
  31          }
  32          $field->submitted['file'] = $name;
  33  
  34          $i = 0;
  35          $field->submitted['text']  = '';
  36          $attributes = array('name', 'type', 'tmp_name', 'error', 'size');
  37  
  38          foreach($attributes as $attribute) if (isset($_FILES[$name][$attribute])) $field->submitted['value'][$attribute] = $_FILES[$name][$attribute];
  39          foreach($field->submitted['value'] as $attribute => $v)
  40          {
  41              $i++;
  42              if ($i == 1)     $field->submitted['text'] .= "$attribute : " . ( (!empty($v)) ? "$v " : '<small>[<i>' . __('empty', MP_TXTDOM) . '</i>]</small>' ) . ( (count($field->submitted['value']) > 1)   ? ', ' : '' );
  43              else            $field->submitted['text'] .= "$attribute : " . ( (!empty($v)) ? "$v " : '<small>[<i>' . __('empty', MP_TXTDOM) . '</i>]</small>' ) . ( (count($field->submitted['value']) != $i) ? ', ' : '' );
  44          }
  45          return $field;
  46      }
  47  
  48  	function attributes_filter($no_reset)
  49      {
  50          if (!$no_reset) return;
  51  
  52          $this->attributes_filter_css();
  53      }
  54  }
  55  new MP_Form_field_type_file(__('File select', MP_TXTDOM));


Generated: Thu Apr 28 18:38:52 2016 Cross-referenced by PHPXref 0.7.1