Clean up the libraries
diff --git a/system/libraries/Form_validation.php b/system/libraries/Form_validation.php
index c396580..67cbfd1 100644
--- a/system/libraries/Form_validation.php
+++ b/system/libraries/Form_validation.php
@@ -42,63 +42,63 @@
* @var object
*/
protected $CI;
-
+
/**
* Validation data for the current form submission
*
* @var array
*/
- protected $_field_data = array();
-
+ protected $_field_data = array();
+
/**
* Validation rules for the current form
*
* @var array
*/
- protected $_config_rules = array();
-
+ protected $_config_rules = array();
+
/**
* Array of validation errors
*
* @var array
*/
protected $_error_array = array();
-
+
/**
* Array of custom error messages
*
* @var array
*/
protected $_error_messages = array();
-
+
/**
* Start tag for error wrapping
*
* @var string
*/
protected $_error_prefix = '<p>';
-
+
/**
* End tag for error wrapping
- *
+ *
* @var string
*/
protected $_error_suffix = '</p>';
-
+
/**
* Custom error message
*
* @var string
*/
protected $error_string = '';
-
+
/**
* Whether the form data has been validated as safe
*
* @var bool
*/
protected $_safe_form_data = FALSE;
-
+
/**
* Custom data to validate
*
@@ -109,7 +109,8 @@
/**
* Initialize Form_Validation class
*
- * @param array $rules
+ * @param array $rules
+ * @return void
*/
public function __construct($rules = array())
{
@@ -222,13 +223,13 @@
// Build our master array
$this->_field_data[$field] = array(
- 'field' => $field,
- 'label' => $label,
- 'rules' => $rules,
- 'is_array' => $is_array,
- 'keys' => $indexes,
- 'postdata' => NULL,
- 'error' => ''
+ 'field' => $field,
+ 'label' => $label,
+ 'rules' => $rules,
+ 'is_array' => $is_array,
+ 'keys' => $indexes,
+ 'postdata' => NULL,
+ 'error' => ''
);
return $this;
@@ -595,17 +596,14 @@
// Set the message type
$type = in_array('required', $rules) ? 'required' : 'isset';
- if ( ! isset($this->_error_messages[$type]))
- {
- if (FALSE === ($line = $this->CI->lang->line($type)))
- {
- $line = 'The field was not set';
- }
- }
- else
+ if (isset($this->_error_messages[$type]))
{
$line = $this->_error_messages[$type];
}
+ elseif (FALSE === ($line = $this->CI->lang->line($type)))
+ {
+ $line = 'The field was not set';
+ }
// Build the error message
$message = sprintf($line, $this->_translate_fieldname($row['label']));
@@ -956,12 +954,8 @@
public function matches($str, $field)
{
$validation_array = empty($this->validation_data) ? $_POST : $this->validation_data;
- if ( ! isset($validation_array[$field]))
- {
- return FALSE;
- }
- return ($str === $validation_array[$field]);
+ return isset($validation_array[$field]) ? ($str === $validation_array[$field]) : FALSE;
}
// --------------------------------------------------------------------
@@ -1276,7 +1270,7 @@
*/
public function valid_base64($str)
{
- return (bool) ! preg_match('/[^a-zA-Z0-9\/\+=]/', $str);
+ return ! preg_match('/[^a-zA-Z0-9\/\+=]/', $str);
}
// --------------------------------------------------------------------