[ Index ]

MailPress 544

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

title

Body

[close]

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

   1  <?php
   2  class MP_Form_field_type_text extends MP_form_field_type_
   3  {
   4      var $file    = __FILE__;
   5  
   6      var $id    = 'text';
   7  
   8      var $category = 'html';
   9      var $order    = 10;
  10  
  11  	function submitted($field)
  12      {
  13          $value    = trim($_POST[$this->prefix][$field->form_id][$field->id]);
  14  
  15          $required     = (isset($field->settings['controls']['required']) && $field->settings['controls']['required']);
  16          $numeric     = (isset($field->settings['controls']['numeric'])  && $field->settings['controls']['numeric']);
  17          $empty     = empty($value);
  18          $is_numeric    = ($value == (string)(float)$value);
  19  
  20          if ($required)
  21          {
  22              if ($empty)
  23              {
  24                  $field->submitted['on_error'] = 1;
  25                  return $field;
  26              }
  27              if ($numeric && !$is_numeric)
  28              {
  29                  $field->submitted['on_error'] = 2;
  30                  return $field;
  31              }
  32          }
  33          if (!$empty && $numeric && !$is_numeric)
  34          {
  35              $field->submitted['on_error'] = 3;
  36              return $field;
  37          }
  38          return parent::submitted($field);
  39      }
  40  
  41  	function attributes_filter($no_reset)
  42      {
  43          $visitor_name = (isset($this->field->settings['options']['visitor_name']) && $this->field->settings['options']['visitor_name']);
  44          if ($visitor_name)
  45          {
  46              global $user_ID; switch (true) { case ($user_ID != 0 && is_numeric($user_ID) ) : $user  = get_userdata($user_ID); $name  = $user->display_name; break; default : $name   = (isset($_COOKIE['comment_author_' . COOKIEHASH])) ? $_COOKIE['comment_author_' . COOKIEHASH] : ''; break; }
  47              if ( !empty($name) ) $this->field->settings['attributes']['value'] = $name;
  48          }
  49  
  50          if (!$no_reset) return;
  51  
  52          parent::attributes_filter($no_reset);
  53          $this->attributes_filter_css();
  54      }
  55  }
  56  new MP_Form_field_type_text(__('Text Input', MP_TXTDOM));


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