Completed
Branch FET-10304-welcome-to-vue (2869cd)
by
unknown
12:52
created
core/db_models/fields/EE_Money_Field.php 1 patch
Indentation   +72 added lines, -72 removed lines patch added patch discarded remove patch
@@ -6,85 +6,85 @@
 block discarded – undo
6 6
  */
7 7
 class EE_Money_Field extends EE_Float_Field
8 8
 {
9
-    function get_wpdb_data_type()
10
-    {
11
-        return '%f';
12
-    }
9
+	function get_wpdb_data_type()
10
+	{
11
+		return '%f';
12
+	}
13 13
 
14
-    /**
15
-     * Schemas:
16
-     *    'localized_float': "3,023.00"
17
-     *    'no_currency_code': "$3,023.00"
18
-     *    null: "$3,023.00<span>USD</span>"
19
-     *
20
-     * @param type $value_on_field_to_be_outputted
21
-     * @param type $schema
22
-     * @return string
23
-     */
24
-    function prepare_for_pretty_echoing($value_on_field_to_be_outputted, $schema = null)
25
-    {
26
-        $pretty_float = parent::prepare_for_pretty_echoing($value_on_field_to_be_outputted);
14
+	/**
15
+	 * Schemas:
16
+	 *    'localized_float': "3,023.00"
17
+	 *    'no_currency_code': "$3,023.00"
18
+	 *    null: "$3,023.00<span>USD</span>"
19
+	 *
20
+	 * @param type $value_on_field_to_be_outputted
21
+	 * @param type $schema
22
+	 * @return string
23
+	 */
24
+	function prepare_for_pretty_echoing($value_on_field_to_be_outputted, $schema = null)
25
+	{
26
+		$pretty_float = parent::prepare_for_pretty_echoing($value_on_field_to_be_outputted);
27 27
 
28
-        if ($schema == 'localized_float') {
29
-            return $pretty_float;
30
-        }
31
-        if ($schema == 'no_currency_code') {
28
+		if ($schema == 'localized_float') {
29
+			return $pretty_float;
30
+		}
31
+		if ($schema == 'no_currency_code') {
32 32
 //			echo "schema no currency!";
33
-            $display_code = false;
34
-        } else {
35
-            $display_code = true;
36
-        }
37
-        //we don't use the $pretty_float because format_currency will take care of it.
38
-        return EEH_Template::format_currency($value_on_field_to_be_outputted, false, $display_code);
39
-    }
33
+			$display_code = false;
34
+		} else {
35
+			$display_code = true;
36
+		}
37
+		//we don't use the $pretty_float because format_currency will take care of it.
38
+		return EEH_Template::format_currency($value_on_field_to_be_outputted, false, $display_code);
39
+	}
40 40
 
41
-    /**
42
-     * If provided witha string, strips out money-related formatting to turn it into a proper float.
43
-     * Rounds the float to the correct number of decimal places for this country's currency.
44
-     * Also, interprets periods and commas according to the country's currency settings.
45
-     * So if you want to pass in a string that NEEDS to interpret periods as decimal marks, call floatval() on it first.
46
-     *
47
-     * @param type $value_inputted_for_field_on_model_object
48
-     * @return float
49
-     */
50
-    function prepare_for_set($value_inputted_for_field_on_model_object)
51
-    {
52
-        //remove any currencies etc.
41
+	/**
42
+	 * If provided witha string, strips out money-related formatting to turn it into a proper float.
43
+	 * Rounds the float to the correct number of decimal places for this country's currency.
44
+	 * Also, interprets periods and commas according to the country's currency settings.
45
+	 * So if you want to pass in a string that NEEDS to interpret periods as decimal marks, call floatval() on it first.
46
+	 *
47
+	 * @param type $value_inputted_for_field_on_model_object
48
+	 * @return float
49
+	 */
50
+	function prepare_for_set($value_inputted_for_field_on_model_object)
51
+	{
52
+		//remove any currencies etc.
53 53
 //		if(is_string($value_inputted_for_field_on_model_object)){
54 54
 //			$value_inputted_for_field_on_model_object = preg_replace("/[^0-9,.]/", "", $value_inputted_for_field_on_model_object);
55 55
 //		}
56
-        //now it's a float-style string or number
57
-        $float_val = parent::prepare_for_set($value_inputted_for_field_on_model_object);
58
-        //round to the correctly number of decimal places for this  currency
59
-        $rounded_value = round($float_val, EE_Registry::instance()->CFG->currency->dec_plc);
60
-        return $rounded_value;
61
-    }
56
+		//now it's a float-style string or number
57
+		$float_val = parent::prepare_for_set($value_inputted_for_field_on_model_object);
58
+		//round to the correctly number of decimal places for this  currency
59
+		$rounded_value = round($float_val, EE_Registry::instance()->CFG->currency->dec_plc);
60
+		return $rounded_value;
61
+	}
62 62
 
63
-    function prepare_for_get($value_of_field_on_model_object)
64
-    {
65
-        $c = EE_Registry::instance()->CFG->currency;
66
-        return round(parent::prepare_for_get($value_of_field_on_model_object), $c->dec_plc);
67
-    }
63
+	function prepare_for_get($value_of_field_on_model_object)
64
+	{
65
+		$c = EE_Registry::instance()->CFG->currency;
66
+		return round(parent::prepare_for_get($value_of_field_on_model_object), $c->dec_plc);
67
+	}
68 68
 
69
-    public function get_schema()
70
-    {
71
-        $schema = parent::get_schema();
72
-        $schema['type'] = 'object';
73
-        $schema['properties'] = array(
74
-            'raw' => array(
75
-                'description' =>  sprintf(
76
-                    __('%s - the raw value as it exists in the database as a simple float.', 'event_espresso'),
77
-                    $this->get_nicename()
78
-                ),
79
-                'type' => 'number'
80
-            ),
81
-            'pretty' => array(
82
-                'description' =>  sprintf(
83
-                    __('%s - formatted for display in the set currency and decimal places.', 'event_espresso'),
84
-                    $this->get_nicename()
85
-                ),
86
-                'type' => 'string'
87
-            )
88
-        );
89
-    }
69
+	public function get_schema()
70
+	{
71
+		$schema = parent::get_schema();
72
+		$schema['type'] = 'object';
73
+		$schema['properties'] = array(
74
+			'raw' => array(
75
+				'description' =>  sprintf(
76
+					__('%s - the raw value as it exists in the database as a simple float.', 'event_espresso'),
77
+					$this->get_nicename()
78
+				),
79
+				'type' => 'number'
80
+			),
81
+			'pretty' => array(
82
+				'description' =>  sprintf(
83
+					__('%s - formatted for display in the set currency and decimal places.', 'event_espresso'),
84
+					$this->get_nicename()
85
+				),
86
+				'type' => 'string'
87
+			)
88
+		);
89
+	}
90 90
 }
91 91
\ No newline at end of file
Please login to merge, or discard this patch.
core/db_models/fields/EE_Foreign_Key_Field_Base.php 1 patch
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -7,10 +7,10 @@
 block discarded – undo
7 7
  */
8 8
 abstract class EE_Foreign_Key_Field_Base extends EE_Field_With_Model_Name
9 9
 {
10
-    public function get_schema()
11
-    {
12
-        $schema = parent::get_schema();
13
-        $schema['foreign_key'] = $this->get_model_class_names_pointed_to();
14
-        return $schema;
15
-    }
10
+	public function get_schema()
11
+	{
12
+		$schema = parent::get_schema();
13
+		$schema['foreign_key'] = $this->get_model_class_names_pointed_to();
14
+		return $schema;
15
+	}
16 16
 }
Please login to merge, or discard this patch.
core/db_models/fields/EE_Integer_Field.php 1 patch
Indentation   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -6,34 +6,34 @@
 block discarded – undo
6 6
  */
7 7
 class EE_Integer_Field extends EE_Model_Field_Base
8 8
 {
9
-    function get_wpdb_data_type()
10
-    {
11
-        return '%d';
12
-    }
9
+	function get_wpdb_data_type()
10
+	{
11
+		return '%d';
12
+	}
13 13
 
14
-    function prepare_for_set($value_inputted_for_field_on_model_object)
15
-    {
16
-        return intval($value_inputted_for_field_on_model_object);
17
-    }
14
+	function prepare_for_set($value_inputted_for_field_on_model_object)
15
+	{
16
+		return intval($value_inputted_for_field_on_model_object);
17
+	}
18 18
 
19
-    function prepare_for_set_from_db($value_inputted_for_field_on_model_object)
20
-    {
21
-        return intval($value_inputted_for_field_on_model_object);
22
-    }
19
+	function prepare_for_set_from_db($value_inputted_for_field_on_model_object)
20
+	{
21
+		return intval($value_inputted_for_field_on_model_object);
22
+	}
23 23
 
24
-    /**
25
-     * This returns any elements used to represent this field in the json schema.
26
-     * Note: It is expected this will only return field specific elements such as "type" or "format".  Other details
27
-     * will have to be inferred from the other data injected into the object on construct (title, description etc).
28
-     *
29
-     * @link http://json-schema.org/
30
-     * @return array
31
-     */
32
-    public function get_schema()
33
-    {
34
-        return array(
35
-            'description' => $this->get_nicename(),
36
-            'type' => 'integer',
37
-        );
38
-    }
24
+	/**
25
+	 * This returns any elements used to represent this field in the json schema.
26
+	 * Note: It is expected this will only return field specific elements such as "type" or "format".  Other details
27
+	 * will have to be inferred from the other data injected into the object on construct (title, description etc).
28
+	 *
29
+	 * @link http://json-schema.org/
30
+	 * @return array
31
+	 */
32
+	public function get_schema()
33
+	{
34
+		return array(
35
+			'description' => $this->get_nicename(),
36
+			'type' => 'integer',
37
+		);
38
+	}
39 39
 }
Please login to merge, or discard this patch.
core/db_models/fields/EE_Float_Field.php 1 patch
Indentation   +55 added lines, -55 removed lines patch added patch discarded remove patch
@@ -6,70 +6,70 @@
 block discarded – undo
6 6
  */
7 7
 class EE_Float_Field extends EE_Model_Field_Base
8 8
 {
9
-    function get_wpdb_data_type()
10
-    {
11
-        return '%f';
12
-    }
9
+	function get_wpdb_data_type()
10
+	{
11
+		return '%f';
12
+	}
13 13
 
14
-    /**
15
-     * If provided a string, strips out number-related formatting, like commas, periods, spaces, other junk, etc.
16
-     * However, treats commas and periods as thousand-separators ro decimal marks, as indicate by the config's currency.
17
-     * So if you want to pass in a string that NEEDS to interpret periods as decimal marks, call floatval() on it first.
18
-     * Returns a float
19
-     *
20
-     * @param type $value_inputted_for_field_on_model_object
21
-     * @return float
22
-     */
23
-    function prepare_for_set($value_inputted_for_field_on_model_object)
24
-    {
14
+	/**
15
+	 * If provided a string, strips out number-related formatting, like commas, periods, spaces, other junk, etc.
16
+	 * However, treats commas and periods as thousand-separators ro decimal marks, as indicate by the config's currency.
17
+	 * So if you want to pass in a string that NEEDS to interpret periods as decimal marks, call floatval() on it first.
18
+	 * Returns a float
19
+	 *
20
+	 * @param type $value_inputted_for_field_on_model_object
21
+	 * @return float
22
+	 */
23
+	function prepare_for_set($value_inputted_for_field_on_model_object)
24
+	{
25 25
 //		echo __LINE__."$value_inputted_for_field_on_model_object<br>";
26
-        //remove whitespaces and thousands separators
27
-        if (is_string($value_inputted_for_field_on_model_object)) {
28
-            $value_inputted_for_field_on_model_object = str_replace(array(" ", EE_Config::instance()->currency->thsnds),
29
-                "", $value_inputted_for_field_on_model_object);
26
+		//remove whitespaces and thousands separators
27
+		if (is_string($value_inputted_for_field_on_model_object)) {
28
+			$value_inputted_for_field_on_model_object = str_replace(array(" ", EE_Config::instance()->currency->thsnds),
29
+				"", $value_inputted_for_field_on_model_object);
30 30
 //echo __LINE__."$value_inputted_for_field_on_model_object<br>";
31 31
 //normalize it so periods are decimal marks (we don't care where you're from: we're talking PHP now)
32
-            $value_inputted_for_field_on_model_object = str_replace(EE_Config::instance()->currency->dec_mrk, ".",
33
-                $value_inputted_for_field_on_model_object);
32
+			$value_inputted_for_field_on_model_object = str_replace(EE_Config::instance()->currency->dec_mrk, ".",
33
+				$value_inputted_for_field_on_model_object);
34 34
 //echo __LINE__."$value_inputted_for_field_on_model_object<br>";
35 35
 //double-check there's absolutely nothing left on this string besides numbers
36
-            $value_inputted_for_field_on_model_object = preg_replace("/[^0-9,.]/", "",
37
-                $value_inputted_for_field_on_model_object);
38
-        }
36
+			$value_inputted_for_field_on_model_object = preg_replace("/[^0-9,.]/", "",
37
+				$value_inputted_for_field_on_model_object);
38
+		}
39 39
 //		echo __LINE__."$value_inputted_for_field_on_model_object<br>";
40
-        return floatval($value_inputted_for_field_on_model_object);
41
-    }
40
+		return floatval($value_inputted_for_field_on_model_object);
41
+	}
42 42
 
43
-    /**
44
-     * Returns the number formatted according to local custom (set by the country of the blog).
45
-     *
46
-     * @param float $value_on_field_to_be_outputted
47
-     * @return string
48
-     */
49
-    function prepare_for_pretty_echoing($value_on_field_to_be_outputted, $schema = null)
50
-    {
51
-        $EE = EE_Registry::instance();
52
-        return number_format($value_on_field_to_be_outputted, $EE->CFG->currency->dec_plc, $EE->CFG->currency->dec_mrk,
53
-            $EE->CFG->currency->thsnds);
54
-    }
43
+	/**
44
+	 * Returns the number formatted according to local custom (set by the country of the blog).
45
+	 *
46
+	 * @param float $value_on_field_to_be_outputted
47
+	 * @return string
48
+	 */
49
+	function prepare_for_pretty_echoing($value_on_field_to_be_outputted, $schema = null)
50
+	{
51
+		$EE = EE_Registry::instance();
52
+		return number_format($value_on_field_to_be_outputted, $EE->CFG->currency->dec_plc, $EE->CFG->currency->dec_mrk,
53
+			$EE->CFG->currency->thsnds);
54
+	}
55 55
 
56
-    function prepare_for_set_from_db($value_found_in_db_for_model_object)
57
-    {
56
+	function prepare_for_set_from_db($value_found_in_db_for_model_object)
57
+	{
58 58
 //		echo "prepare for set from db of ";d($value_found_in_db_for_model_object);
59
-        return floatval($value_found_in_db_for_model_object);
60
-    }
59
+		return floatval($value_found_in_db_for_model_object);
60
+	}
61 61
 
62
-    /**
63
-     * This returns elements used to represent this field in the json schema.
64
-     *
65
-     * @link http://json-schema.org/
66
-     * @return array
67
-     */
68
-    public function get_schema()
69
-    {
70
-        return array(
71
-            'description' => $this->get_nicename(),
72
-            'type' => 'number'
73
-        );
74
-    }
62
+	/**
63
+	 * This returns elements used to represent this field in the json schema.
64
+	 *
65
+	 * @link http://json-schema.org/
66
+	 * @return array
67
+	 */
68
+	public function get_schema()
69
+	{
70
+		return array(
71
+			'description' => $this->get_nicename(),
72
+			'type' => 'number'
73
+		);
74
+	}
75 75
 }
76 76
\ No newline at end of file
Please login to merge, or discard this patch.
core/db_models/fields/EE_Serialized_Text_Field.php 2 patches
Indentation   +58 added lines, -58 removed lines patch added patch discarded remove patch
@@ -11,67 +11,67 @@
 block discarded – undo
11 11
 
12 12
 class EE_Serialized_Text_Field extends EE_Text_Field_Base
13 13
 {
14
-    /**
15
-     * Value SHOULD be an array, and we want to now convert it to a serialized string
16
-     *
17
-     * @param array $value_of_field_on_model_object
18
-     * @return string
19
-     */
20
-    function prepare_for_use_in_db($value_of_field_on_model_object)
21
-    {
22
-        return maybe_serialize($value_of_field_on_model_object);
23
-    }
14
+	/**
15
+	 * Value SHOULD be an array, and we want to now convert it to a serialized string
16
+	 *
17
+	 * @param array $value_of_field_on_model_object
18
+	 * @return string
19
+	 */
20
+	function prepare_for_use_in_db($value_of_field_on_model_object)
21
+	{
22
+		return maybe_serialize($value_of_field_on_model_object);
23
+	}
24 24
 
25
-    function prepare_for_set($value_inputted_for_field_on_model_object)
26
-    {
27
-        $value_inputted_for_field_on_model_object = EEH_Array::maybe_unserialize($value_inputted_for_field_on_model_object);
28
-        if (is_string($value_inputted_for_field_on_model_object)) {
29
-            return parent::prepare_for_set($value_inputted_for_field_on_model_object);
30
-        } elseif (is_array($value_inputted_for_field_on_model_object)) {
31
-            return array_map(array($this, 'prepare_for_set'), $value_inputted_for_field_on_model_object);
32
-        } else {//so they passed NULL or an INT or something wack
33
-            return $value_inputted_for_field_on_model_object;
34
-        }
35
-    }
25
+	function prepare_for_set($value_inputted_for_field_on_model_object)
26
+	{
27
+		$value_inputted_for_field_on_model_object = EEH_Array::maybe_unserialize($value_inputted_for_field_on_model_object);
28
+		if (is_string($value_inputted_for_field_on_model_object)) {
29
+			return parent::prepare_for_set($value_inputted_for_field_on_model_object);
30
+		} elseif (is_array($value_inputted_for_field_on_model_object)) {
31
+			return array_map(array($this, 'prepare_for_set'), $value_inputted_for_field_on_model_object);
32
+		} else {//so they passed NULL or an INT or something wack
33
+			return $value_inputted_for_field_on_model_object;
34
+		}
35
+	}
36 36
 
37
-    /**
38
-     * Value provided should definetely be a serialized string. We should unserialize into an array
39
-     *
40
-     * @param string $value_found_in_db_for_model_object
41
-     * @return array
42
-     */
43
-    function prepare_for_set_from_db($value_found_in_db_for_model_object)
44
-    {
45
-        return EEH_Array::maybe_unserialize($value_found_in_db_for_model_object);
46
-    }
37
+	/**
38
+	 * Value provided should definetely be a serialized string. We should unserialize into an array
39
+	 *
40
+	 * @param string $value_found_in_db_for_model_object
41
+	 * @return array
42
+	 */
43
+	function prepare_for_set_from_db($value_found_in_db_for_model_object)
44
+	{
45
+		return EEH_Array::maybe_unserialize($value_found_in_db_for_model_object);
46
+	}
47 47
 
48
-    /**
49
-     * Gets a string representation of the array
50
-     *
51
-     * @param type   $value_on_field_to_be_outputted
52
-     * @param string $schema , possible values are ',', others can be added
53
-     * @return string
54
-     */
55
-    function prepare_for_pretty_echoing($value_on_field_to_be_outputted, $schema = null)
56
-    {
57
-        switch ($schema) {
58
-            case 'print_r':
59
-                $pretty_value = print_r($value_on_field_to_be_outputted, true);
60
-                break;
61
-            case 'as_table':
62
-                $pretty_value = EEH_Template::layout_array_as_table($value_on_field_to_be_outputted);
63
-                break;
64
-            default:
65
-                $pretty_value = implode(", ", $value_on_field_to_be_outputted);
66
-        }
67
-        return $pretty_value;
68
-    }
48
+	/**
49
+	 * Gets a string representation of the array
50
+	 *
51
+	 * @param type   $value_on_field_to_be_outputted
52
+	 * @param string $schema , possible values are ',', others can be added
53
+	 * @return string
54
+	 */
55
+	function prepare_for_pretty_echoing($value_on_field_to_be_outputted, $schema = null)
56
+	{
57
+		switch ($schema) {
58
+			case 'print_r':
59
+				$pretty_value = print_r($value_on_field_to_be_outputted, true);
60
+				break;
61
+			case 'as_table':
62
+				$pretty_value = EEH_Template::layout_array_as_table($value_on_field_to_be_outputted);
63
+				break;
64
+			default:
65
+				$pretty_value = implode(", ", $value_on_field_to_be_outputted);
66
+		}
67
+		return $pretty_value;
68
+	}
69 69
 
70 70
 
71
-    public function get_schema()
72
-    {
73
-        $schema = parent::get_schema();
74
-        $schema['type'] = array( 'object', 'string' );
75
-        return $schema;
76
-    }
71
+	public function get_schema()
72
+	{
73
+		$schema = parent::get_schema();
74
+		$schema['type'] = array( 'object', 'string' );
75
+		return $schema;
76
+	}
77 77
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
7 7
  * However, when inserting into the DB, it should be serialized.
8 8
  * Upon retrieval from the DB, it should be unserialized back into an array.
9 9
  */
10
-require_once(EE_MODELS . 'fields/EE_Text_Field_Base.php');
10
+require_once(EE_MODELS.'fields/EE_Text_Field_Base.php');
11 11
 
12 12
 class EE_Serialized_Text_Field extends EE_Text_Field_Base
13 13
 {
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
     public function get_schema()
72 72
     {
73 73
         $schema = parent::get_schema();
74
-        $schema['type'] = array( 'object', 'string' );
74
+        $schema['type'] = array('object', 'string');
75 75
         return $schema;
76 76
     }
77 77
 }
Please login to merge, or discard this patch.
core/db_models/fields/EE_DB_Only_Field_Base.php 1 patch
Indentation   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -9,29 +9,29 @@
 block discarded – undo
9 9
  */
10 10
 abstract class EE_DB_Only_Field_Base extends EE_Model_Field_Base
11 11
 {
12
-    /**
13
-     * All these children classes are for the db-only (meaning, we should select them
14
-     * on get_all queries, update, delete, and will still want to set their default value
15
-     * on inserts, but the model object won't have reference to these fields)
16
-     *
17
-     * @return boolean
18
-     */
19
-    function is_db_only_field()
20
-    {
21
-        return true;
22
-    }
12
+	/**
13
+	 * All these children classes are for the db-only (meaning, we should select them
14
+	 * on get_all queries, update, delete, and will still want to set their default value
15
+	 * on inserts, but the model object won't have reference to these fields)
16
+	 *
17
+	 * @return boolean
18
+	 */
19
+	function is_db_only_field()
20
+	{
21
+		return true;
22
+	}
23 23
 
24
-    /**
25
-     * This returns elements used to represent this field in the json schema.
26
-     *
27
-     * @link http://json-schema.org/
28
-     * @return array
29
-     */
30
-    public function get_schema()
31
-    {
32
-        return array(
33
-            'description' => $this->get_nicename(),
34
-            'type' => 'string'
35
-        );
36
-    }
24
+	/**
25
+	 * This returns elements used to represent this field in the json schema.
26
+	 *
27
+	 * @link http://json-schema.org/
28
+	 * @return array
29
+	 */
30
+	public function get_schema()
31
+	{
32
+		return array(
33
+			'description' => $this->get_nicename(),
34
+			'type' => 'string'
35
+		);
36
+	}
37 37
 }
38 38
\ No newline at end of file
Please login to merge, or discard this patch.
core/db_models/fields/EE_Email_Field.php 1 patch
Indentation   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -9,43 +9,43 @@
 block discarded – undo
9 9
 class EE_Email_Field extends EE_Text_Field_Base
10 10
 {
11 11
 
12
-    /**
13
-     * In form inputs, we should have called htmlentities and addslashes() on form inputs,
14
-     * so we need to undo that on setting of these fields
15
-     *
16
-     * @param string $email_address
17
-     * @return string
18
-     */
19
-    function prepare_for_set($email_address)
20
-    {
21
-        $validation_level = isset(EE_Registry::instance()->CFG->registration->email_validation_level)
22
-            ? EE_Registry::instance()->CFG->registration->email_validation_level
23
-            : 'wp_default';
24
-        if ($validation_level === 'basic' && ! preg_match('/^.+\@\S+$/', $email_address)) {
25
-            // email not even in correct {string}@{string} format
26
-            return '';
27
-        } else if ($validation_level === 'wp_default' && ! is_email($email_address)) {
28
-            //not a valid email.
29
-            return '';
30
-        } else if (
31
-            ($validation_level === 'i18n' || $validation_level === 'i18n_dns')
32
-            // plz see http://stackoverflow.com/a/24817336 re: the following regex
33
-            && ! preg_match(
34
-                '/^(?!\.)((?!.*\.{2})[a-zA-Z0-9\x{0080}-\x{00FF}\x{0100}-\x{017F}\x{0180}-\x{024F}\x{0250}-\x{02AF}\x{0300}-\x{036F}\x{0370}-\x{03FF}\x{0400}-\x{04FF}\x{0500}-\x{052F}\x{0530}-\x{058F}\x{0590}-\x{05FF}\x{0600}-\x{06FF}\x{0700}-\x{074F}\x{0750}-\x{077F}\x{0780}-\x{07BF}\x{07C0}-\x{07FF}\x{0900}-\x{097F}\x{0980}-\x{09FF}\x{0A00}-\x{0A7F}\x{0A80}-\x{0AFF}\x{0B00}-\x{0B7F}\x{0B80}-\x{0BFF}\x{0C00}-\x{0C7F}\x{0C80}-\x{0CFF}\x{0D00}-\x{0D7F}\x{0D80}-\x{0DFF}\x{0E00}-\x{0E7F}\x{0E80}-\x{0EFF}\x{0F00}-\x{0FFF}\x{1000}-\x{109F}\x{10A0}-\x{10FF}\x{1100}-\x{11FF}\x{1200}-\x{137F}\x{1380}-\x{139F}\x{13A0}-\x{13FF}\x{1400}-\x{167F}\x{1680}-\x{169F}\x{16A0}-\x{16FF}\x{1700}-\x{171F}\x{1720}-\x{173F}\x{1740}-\x{175F}\x{1760}-\x{177F}\x{1780}-\x{17FF}\x{1800}-\x{18AF}\x{1900}-\x{194F}\x{1950}-\x{197F}\x{1980}-\x{19DF}\x{19E0}-\x{19FF}\x{1A00}-\x{1A1F}\x{1B00}-\x{1B7F}\x{1D00}-\x{1D7F}\x{1D80}-\x{1DBF}\x{1DC0}-\x{1DFF}\x{1E00}-\x{1EFF}\x{1F00}-\x{1FFF}\x{20D0}-\x{20FF}\x{2100}-\x{214F}\x{2C00}-\x{2C5F}\x{2C60}-\x{2C7F}\x{2C80}-\x{2CFF}\x{2D00}-\x{2D2F}\x{2D30}-\x{2D7F}\x{2D80}-\x{2DDF}\x{2F00}-\x{2FDF}\x{2FF0}-\x{2FFF}\x{3040}-\x{309F}\x{30A0}-\x{30FF}\x{3100}-\x{312F}\x{3130}-\x{318F}\x{3190}-\x{319F}\x{31C0}-\x{31EF}\x{31F0}-\x{31FF}\x{3200}-\x{32FF}\x{3300}-\x{33FF}\x{3400}-\x{4DBF}\x{4DC0}-\x{4DFF}\x{4E00}-\x{9FFF}\x{A000}-\x{A48F}\x{A490}-\x{A4CF}\x{A700}-\x{A71F}\x{A800}-\x{A82F}\x{A840}-\x{A87F}\x{AC00}-\x{D7AF}\x{F900}-\x{FAFF}\.!#$%&\'*+-\/=?^_`{|}~\-\d]+)@(?!\.)([a-zA-Z0-9\x{0080}-\x{00FF}\x{0100}-\x{017F}\x{0180}-\x{024F}\x{0250}-\x{02AF}\x{0300}-\x{036F}\x{0370}-\x{03FF}\x{0400}-\x{04FF}\x{0500}-\x{052F}\x{0530}-\x{058F}\x{0590}-\x{05FF}\x{0600}-\x{06FF}\x{0700}-\x{074F}\x{0750}-\x{077F}\x{0780}-\x{07BF}\x{07C0}-\x{07FF}\x{0900}-\x{097F}\x{0980}-\x{09FF}\x{0A00}-\x{0A7F}\x{0A80}-\x{0AFF}\x{0B00}-\x{0B7F}\x{0B80}-\x{0BFF}\x{0C00}-\x{0C7F}\x{0C80}-\x{0CFF}\x{0D00}-\x{0D7F}\x{0D80}-\x{0DFF}\x{0E00}-\x{0E7F}\x{0E80}-\x{0EFF}\x{0F00}-\x{0FFF}\x{1000}-\x{109F}\x{10A0}-\x{10FF}\x{1100}-\x{11FF}\x{1200}-\x{137F}\x{1380}-\x{139F}\x{13A0}-\x{13FF}\x{1400}-\x{167F}\x{1680}-\x{169F}\x{16A0}-\x{16FF}\x{1700}-\x{171F}\x{1720}-\x{173F}\x{1740}-\x{175F}\x{1760}-\x{177F}\x{1780}-\x{17FF}\x{1800}-\x{18AF}\x{1900}-\x{194F}\x{1950}-\x{197F}\x{1980}-\x{19DF}\x{19E0}-\x{19FF}\x{1A00}-\x{1A1F}\x{1B00}-\x{1B7F}\x{1D00}-\x{1D7F}\x{1D80}-\x{1DBF}\x{1DC0}-\x{1DFF}\x{1E00}-\x{1EFF}\x{1F00}-\x{1FFF}\x{20D0}-\x{20FF}\x{2100}-\x{214F}\x{2C00}-\x{2C5F}\x{2C60}-\x{2C7F}\x{2C80}-\x{2CFF}\x{2D00}-\x{2D2F}\x{2D30}-\x{2D7F}\x{2D80}-\x{2DDF}\x{2F00}-\x{2FDF}\x{2FF0}-\x{2FFF}\x{3040}-\x{309F}\x{30A0}-\x{30FF}\x{3100}-\x{312F}\x{3130}-\x{318F}\x{3190}-\x{319F}\x{31C0}-\x{31EF}\x{31F0}-\x{31FF}\x{3200}-\x{32FF}\x{3300}-\x{33FF}\x{3400}-\x{4DBF}\x{4DC0}-\x{4DFF}\x{4E00}-\x{9FFF}\x{A000}-\x{A48F}\x{A490}-\x{A4CF}\x{A700}-\x{A71F}\x{A800}-\x{A82F}\x{A840}-\x{A87F}\x{AC00}-\x{D7AF}\x{F900}-\x{FAFF}\-\.\d]+)((\.([a-zA-Z\x{0080}-\x{00FF}\x{0100}-\x{017F}\x{0180}-\x{024F}\x{0250}-\x{02AF}\x{0300}-\x{036F}\x{0370}-\x{03FF}\x{0400}-\x{04FF}\x{0500}-\x{052F}\x{0530}-\x{058F}\x{0590}-\x{05FF}\x{0600}-\x{06FF}\x{0700}-\x{074F}\x{0750}-\x{077F}\x{0780}-\x{07BF}\x{07C0}-\x{07FF}\x{0900}-\x{097F}\x{0980}-\x{09FF}\x{0A00}-\x{0A7F}\x{0A80}-\x{0AFF}\x{0B00}-\x{0B7F}\x{0B80}-\x{0BFF}\x{0C00}-\x{0C7F}\x{0C80}-\x{0CFF}\x{0D00}-\x{0D7F}\x{0D80}-\x{0DFF}\x{0E00}-\x{0E7F}\x{0E80}-\x{0EFF}\x{0F00}-\x{0FFF}\x{1000}-\x{109F}\x{10A0}-\x{10FF}\x{1100}-\x{11FF}\x{1200}-\x{137F}\x{1380}-\x{139F}\x{13A0}-\x{13FF}\x{1400}-\x{167F}\x{1680}-\x{169F}\x{16A0}-\x{16FF}\x{1700}-\x{171F}\x{1720}-\x{173F}\x{1740}-\x{175F}\x{1760}-\x{177F}\x{1780}-\x{17FF}\x{1800}-\x{18AF}\x{1900}-\x{194F}\x{1950}-\x{197F}\x{1980}-\x{19DF}\x{19E0}-\x{19FF}\x{1A00}-\x{1A1F}\x{1B00}-\x{1B7F}\x{1D00}-\x{1D7F}\x{1D80}-\x{1DBF}\x{1DC0}-\x{1DFF}\x{1E00}-\x{1EFF}\x{1F00}-\x{1FFF}\x{20D0}-\x{20FF}\x{2100}-\x{214F}\x{2C00}-\x{2C5F}\x{2C60}-\x{2C7F}\x{2C80}-\x{2CFF}\x{2D00}-\x{2D2F}\x{2D30}-\x{2D7F}\x{2D80}-\x{2DDF}\x{2F00}-\x{2FDF}\x{2FF0}-\x{2FFF}\x{3040}-\x{309F}\x{30A0}-\x{30FF}\x{3100}-\x{312F}\x{3130}-\x{318F}\x{3190}-\x{319F}\x{31C0}-\x{31EF}\x{31F0}-\x{31FF}\x{3200}-\x{32FF}\x{3300}-\x{33FF}\x{3400}-\x{4DBF}\x{4DC0}-\x{4DFF}\x{4E00}-\x{9FFF}\x{A000}-\x{A48F}\x{A490}-\x{A4CF}\x{A700}-\x{A71F}\x{A800}-\x{A82F}\x{A840}-\x{A87F}\x{AC00}-\x{D7AF}\x{F900}-\x{FAFF}]){2,63})+)$/u',
35
-                $email_address
36
-            )
37
-        ) {
38
-            //not a valid email.
39
-            return '';
40
-        }
41
-        return $email_address;
42
-    }
12
+	/**
13
+	 * In form inputs, we should have called htmlentities and addslashes() on form inputs,
14
+	 * so we need to undo that on setting of these fields
15
+	 *
16
+	 * @param string $email_address
17
+	 * @return string
18
+	 */
19
+	function prepare_for_set($email_address)
20
+	{
21
+		$validation_level = isset(EE_Registry::instance()->CFG->registration->email_validation_level)
22
+			? EE_Registry::instance()->CFG->registration->email_validation_level
23
+			: 'wp_default';
24
+		if ($validation_level === 'basic' && ! preg_match('/^.+\@\S+$/', $email_address)) {
25
+			// email not even in correct {string}@{string} format
26
+			return '';
27
+		} else if ($validation_level === 'wp_default' && ! is_email($email_address)) {
28
+			//not a valid email.
29
+			return '';
30
+		} else if (
31
+			($validation_level === 'i18n' || $validation_level === 'i18n_dns')
32
+			// plz see http://stackoverflow.com/a/24817336 re: the following regex
33
+			&& ! preg_match(
34
+				'/^(?!\.)((?!.*\.{2})[a-zA-Z0-9\x{0080}-\x{00FF}\x{0100}-\x{017F}\x{0180}-\x{024F}\x{0250}-\x{02AF}\x{0300}-\x{036F}\x{0370}-\x{03FF}\x{0400}-\x{04FF}\x{0500}-\x{052F}\x{0530}-\x{058F}\x{0590}-\x{05FF}\x{0600}-\x{06FF}\x{0700}-\x{074F}\x{0750}-\x{077F}\x{0780}-\x{07BF}\x{07C0}-\x{07FF}\x{0900}-\x{097F}\x{0980}-\x{09FF}\x{0A00}-\x{0A7F}\x{0A80}-\x{0AFF}\x{0B00}-\x{0B7F}\x{0B80}-\x{0BFF}\x{0C00}-\x{0C7F}\x{0C80}-\x{0CFF}\x{0D00}-\x{0D7F}\x{0D80}-\x{0DFF}\x{0E00}-\x{0E7F}\x{0E80}-\x{0EFF}\x{0F00}-\x{0FFF}\x{1000}-\x{109F}\x{10A0}-\x{10FF}\x{1100}-\x{11FF}\x{1200}-\x{137F}\x{1380}-\x{139F}\x{13A0}-\x{13FF}\x{1400}-\x{167F}\x{1680}-\x{169F}\x{16A0}-\x{16FF}\x{1700}-\x{171F}\x{1720}-\x{173F}\x{1740}-\x{175F}\x{1760}-\x{177F}\x{1780}-\x{17FF}\x{1800}-\x{18AF}\x{1900}-\x{194F}\x{1950}-\x{197F}\x{1980}-\x{19DF}\x{19E0}-\x{19FF}\x{1A00}-\x{1A1F}\x{1B00}-\x{1B7F}\x{1D00}-\x{1D7F}\x{1D80}-\x{1DBF}\x{1DC0}-\x{1DFF}\x{1E00}-\x{1EFF}\x{1F00}-\x{1FFF}\x{20D0}-\x{20FF}\x{2100}-\x{214F}\x{2C00}-\x{2C5F}\x{2C60}-\x{2C7F}\x{2C80}-\x{2CFF}\x{2D00}-\x{2D2F}\x{2D30}-\x{2D7F}\x{2D80}-\x{2DDF}\x{2F00}-\x{2FDF}\x{2FF0}-\x{2FFF}\x{3040}-\x{309F}\x{30A0}-\x{30FF}\x{3100}-\x{312F}\x{3130}-\x{318F}\x{3190}-\x{319F}\x{31C0}-\x{31EF}\x{31F0}-\x{31FF}\x{3200}-\x{32FF}\x{3300}-\x{33FF}\x{3400}-\x{4DBF}\x{4DC0}-\x{4DFF}\x{4E00}-\x{9FFF}\x{A000}-\x{A48F}\x{A490}-\x{A4CF}\x{A700}-\x{A71F}\x{A800}-\x{A82F}\x{A840}-\x{A87F}\x{AC00}-\x{D7AF}\x{F900}-\x{FAFF}\.!#$%&\'*+-\/=?^_`{|}~\-\d]+)@(?!\.)([a-zA-Z0-9\x{0080}-\x{00FF}\x{0100}-\x{017F}\x{0180}-\x{024F}\x{0250}-\x{02AF}\x{0300}-\x{036F}\x{0370}-\x{03FF}\x{0400}-\x{04FF}\x{0500}-\x{052F}\x{0530}-\x{058F}\x{0590}-\x{05FF}\x{0600}-\x{06FF}\x{0700}-\x{074F}\x{0750}-\x{077F}\x{0780}-\x{07BF}\x{07C0}-\x{07FF}\x{0900}-\x{097F}\x{0980}-\x{09FF}\x{0A00}-\x{0A7F}\x{0A80}-\x{0AFF}\x{0B00}-\x{0B7F}\x{0B80}-\x{0BFF}\x{0C00}-\x{0C7F}\x{0C80}-\x{0CFF}\x{0D00}-\x{0D7F}\x{0D80}-\x{0DFF}\x{0E00}-\x{0E7F}\x{0E80}-\x{0EFF}\x{0F00}-\x{0FFF}\x{1000}-\x{109F}\x{10A0}-\x{10FF}\x{1100}-\x{11FF}\x{1200}-\x{137F}\x{1380}-\x{139F}\x{13A0}-\x{13FF}\x{1400}-\x{167F}\x{1680}-\x{169F}\x{16A0}-\x{16FF}\x{1700}-\x{171F}\x{1720}-\x{173F}\x{1740}-\x{175F}\x{1760}-\x{177F}\x{1780}-\x{17FF}\x{1800}-\x{18AF}\x{1900}-\x{194F}\x{1950}-\x{197F}\x{1980}-\x{19DF}\x{19E0}-\x{19FF}\x{1A00}-\x{1A1F}\x{1B00}-\x{1B7F}\x{1D00}-\x{1D7F}\x{1D80}-\x{1DBF}\x{1DC0}-\x{1DFF}\x{1E00}-\x{1EFF}\x{1F00}-\x{1FFF}\x{20D0}-\x{20FF}\x{2100}-\x{214F}\x{2C00}-\x{2C5F}\x{2C60}-\x{2C7F}\x{2C80}-\x{2CFF}\x{2D00}-\x{2D2F}\x{2D30}-\x{2D7F}\x{2D80}-\x{2DDF}\x{2F00}-\x{2FDF}\x{2FF0}-\x{2FFF}\x{3040}-\x{309F}\x{30A0}-\x{30FF}\x{3100}-\x{312F}\x{3130}-\x{318F}\x{3190}-\x{319F}\x{31C0}-\x{31EF}\x{31F0}-\x{31FF}\x{3200}-\x{32FF}\x{3300}-\x{33FF}\x{3400}-\x{4DBF}\x{4DC0}-\x{4DFF}\x{4E00}-\x{9FFF}\x{A000}-\x{A48F}\x{A490}-\x{A4CF}\x{A700}-\x{A71F}\x{A800}-\x{A82F}\x{A840}-\x{A87F}\x{AC00}-\x{D7AF}\x{F900}-\x{FAFF}\-\.\d]+)((\.([a-zA-Z\x{0080}-\x{00FF}\x{0100}-\x{017F}\x{0180}-\x{024F}\x{0250}-\x{02AF}\x{0300}-\x{036F}\x{0370}-\x{03FF}\x{0400}-\x{04FF}\x{0500}-\x{052F}\x{0530}-\x{058F}\x{0590}-\x{05FF}\x{0600}-\x{06FF}\x{0700}-\x{074F}\x{0750}-\x{077F}\x{0780}-\x{07BF}\x{07C0}-\x{07FF}\x{0900}-\x{097F}\x{0980}-\x{09FF}\x{0A00}-\x{0A7F}\x{0A80}-\x{0AFF}\x{0B00}-\x{0B7F}\x{0B80}-\x{0BFF}\x{0C00}-\x{0C7F}\x{0C80}-\x{0CFF}\x{0D00}-\x{0D7F}\x{0D80}-\x{0DFF}\x{0E00}-\x{0E7F}\x{0E80}-\x{0EFF}\x{0F00}-\x{0FFF}\x{1000}-\x{109F}\x{10A0}-\x{10FF}\x{1100}-\x{11FF}\x{1200}-\x{137F}\x{1380}-\x{139F}\x{13A0}-\x{13FF}\x{1400}-\x{167F}\x{1680}-\x{169F}\x{16A0}-\x{16FF}\x{1700}-\x{171F}\x{1720}-\x{173F}\x{1740}-\x{175F}\x{1760}-\x{177F}\x{1780}-\x{17FF}\x{1800}-\x{18AF}\x{1900}-\x{194F}\x{1950}-\x{197F}\x{1980}-\x{19DF}\x{19E0}-\x{19FF}\x{1A00}-\x{1A1F}\x{1B00}-\x{1B7F}\x{1D00}-\x{1D7F}\x{1D80}-\x{1DBF}\x{1DC0}-\x{1DFF}\x{1E00}-\x{1EFF}\x{1F00}-\x{1FFF}\x{20D0}-\x{20FF}\x{2100}-\x{214F}\x{2C00}-\x{2C5F}\x{2C60}-\x{2C7F}\x{2C80}-\x{2CFF}\x{2D00}-\x{2D2F}\x{2D30}-\x{2D7F}\x{2D80}-\x{2DDF}\x{2F00}-\x{2FDF}\x{2FF0}-\x{2FFF}\x{3040}-\x{309F}\x{30A0}-\x{30FF}\x{3100}-\x{312F}\x{3130}-\x{318F}\x{3190}-\x{319F}\x{31C0}-\x{31EF}\x{31F0}-\x{31FF}\x{3200}-\x{32FF}\x{3300}-\x{33FF}\x{3400}-\x{4DBF}\x{4DC0}-\x{4DFF}\x{4E00}-\x{9FFF}\x{A000}-\x{A48F}\x{A490}-\x{A4CF}\x{A700}-\x{A71F}\x{A800}-\x{A82F}\x{A840}-\x{A87F}\x{AC00}-\x{D7AF}\x{F900}-\x{FAFF}]){2,63})+)$/u',
35
+				$email_address
36
+			)
37
+		) {
38
+			//not a valid email.
39
+			return '';
40
+		}
41
+		return $email_address;
42
+	}
43 43
 
44 44
 
45
-    public function get_schema()
46
-    {
47
-        $schema = parent::get_schema();
48
-        $schema['format'] = 'email';
49
-        return $schema;
50
-    }
45
+	public function get_schema()
46
+	{
47
+		$schema = parent::get_schema();
48
+		$schema['format'] = 'email';
49
+		return $schema;
50
+	}
51 51
 }
Please login to merge, or discard this patch.
core/db_models/fields/EE_Text_Field_Base.php 1 patch
Indentation   +49 added lines, -49 removed lines patch added patch discarded remove patch
@@ -6,57 +6,57 @@
 block discarded – undo
6 6
  */
7 7
 abstract class EE_Text_Field_Base extends EE_Model_Field_Base
8 8
 {
9
-    function get_wpdb_data_type()
10
-    {
11
-        return '%s';
12
-    }
9
+	function get_wpdb_data_type()
10
+	{
11
+		return '%s';
12
+	}
13 13
 
14
-    function prepare_for_get($value_of_field_on_model_object)
15
-    {
16
-        return is_string($value_of_field_on_model_object) ? stripslashes($value_of_field_on_model_object) : $value_of_field_on_model_object;
17
-    }
14
+	function prepare_for_get($value_of_field_on_model_object)
15
+	{
16
+		return is_string($value_of_field_on_model_object) ? stripslashes($value_of_field_on_model_object) : $value_of_field_on_model_object;
17
+	}
18 18
 
19
-    /**
20
-     * Accepts schema of 'form_input' which formats the string for echoing in form input's value.
21
-     *
22
-     * @param string $value_on_field_to_be_outputted
23
-     * @param string $schema
24
-     * @return string
25
-     */
26
-    function prepare_for_pretty_echoing($value_on_field_to_be_outputted, $schema = null)
27
-    {
28
-        if ($schema == 'form_input') {
29
-            $value_on_field_to_be_outputted = htmlentities($value_on_field_to_be_outputted, ENT_QUOTES, 'UTF-8');
30
-        }
31
-        return parent::prepare_for_pretty_echoing($value_on_field_to_be_outputted, $schema);
32
-    }
19
+	/**
20
+	 * Accepts schema of 'form_input' which formats the string for echoing in form input's value.
21
+	 *
22
+	 * @param string $value_on_field_to_be_outputted
23
+	 * @param string $schema
24
+	 * @return string
25
+	 */
26
+	function prepare_for_pretty_echoing($value_on_field_to_be_outputted, $schema = null)
27
+	{
28
+		if ($schema == 'form_input') {
29
+			$value_on_field_to_be_outputted = htmlentities($value_on_field_to_be_outputted, ENT_QUOTES, 'UTF-8');
30
+		}
31
+		return parent::prepare_for_pretty_echoing($value_on_field_to_be_outputted, $schema);
32
+	}
33 33
 
34
-    /**
35
-     * In form inputs, we should have called htmlentities and addslashes on form inputs,
36
-     * so we need to undo that on setting of these fields
37
-     *
38
-     * @param string $value_inputted_for_field_on_model_object
39
-     * @return string
40
-     */
41
-    function prepare_for_set($value_inputted_for_field_on_model_object)
42
-    {
43
-        return stripslashes(html_entity_decode(parent::prepare_for_set($value_inputted_for_field_on_model_object),
44
-            ENT_QUOTES, 'UTF-8'));
45
-    }
34
+	/**
35
+	 * In form inputs, we should have called htmlentities and addslashes on form inputs,
36
+	 * so we need to undo that on setting of these fields
37
+	 *
38
+	 * @param string $value_inputted_for_field_on_model_object
39
+	 * @return string
40
+	 */
41
+	function prepare_for_set($value_inputted_for_field_on_model_object)
42
+	{
43
+		return stripslashes(html_entity_decode(parent::prepare_for_set($value_inputted_for_field_on_model_object),
44
+			ENT_QUOTES, 'UTF-8'));
45
+	}
46 46
 
47
-    /**
48
-     * This returns any elements used to represent this field in the json schema.
49
-     * Note: It is expected this will only return field specific elements such as "type" or "format".  Other details
50
-     * will have to be inferred from the other data injected into the object on construct (title, description etc).
51
-     *
52
-     * @link http://json-schema.org/
53
-     * @return array
54
-     */
55
-    public function get_schema()
56
-    {
57
-        return array(
58
-            'description' => $this->get_nicename(),
59
-            'type' => 'string'
60
-        );
61
-    }
47
+	/**
48
+	 * This returns any elements used to represent this field in the json schema.
49
+	 * Note: It is expected this will only return field specific elements such as "type" or "format".  Other details
50
+	 * will have to be inferred from the other data injected into the object on construct (title, description etc).
51
+	 *
52
+	 * @link http://json-schema.org/
53
+	 * @return array
54
+	 */
55
+	public function get_schema()
56
+	{
57
+		return array(
58
+			'description' => $this->get_nicename(),
59
+			'type' => 'string'
60
+		);
61
+	}
62 62
 }
63 63
\ No newline at end of file
Please login to merge, or discard this patch.
core/db_models/helpers/ModelSchema.php 2 patches
Indentation   +75 added lines, -75 removed lines patch added patch discarded remove patch
@@ -19,87 +19,87 @@
 block discarded – undo
19 19
  */
20 20
 class ModelSchema
21 21
 {
22
-    /**
23
-     * Return the schema for a given model from a given model.
24
-     * @param \EEM_Base $model
25
-     * @return array
26
-     */
27
-    public function getModelSchema(EEM_Base $model)
28
-    {
29
-        $schema = $this->getInitialSchemaStructure($model);
30
-        $fields_on_model = $model->field_settings();
31
-        $relations_on_model = $model->relation_settings();
32
-        $schema = array_merge($schema, $this->getModelSchemaForFields($fields_on_model));
33
-        return array_merge($schema, $this->getModelSchemaForRelations($relations_on_model));
34
-    }
22
+	/**
23
+	 * Return the schema for a given model from a given model.
24
+	 * @param \EEM_Base $model
25
+	 * @return array
26
+	 */
27
+	public function getModelSchema(EEM_Base $model)
28
+	{
29
+		$schema = $this->getInitialSchemaStructure($model);
30
+		$fields_on_model = $model->field_settings();
31
+		$relations_on_model = $model->relation_settings();
32
+		$schema = array_merge($schema, $this->getModelSchemaForFields($fields_on_model));
33
+		return array_merge($schema, $this->getModelSchemaForRelations($relations_on_model));
34
+	}
35 35
 
36 36
 
37
-    /**
38
-     * Get the schema for a given set of model fields.
39
-     * @param \EE_Model_Field_Base[]     $model_fields
40
-     * @return array
41
-     */
42
-    public function getModelSchemaForFields(array $model_fields)
43
-    {
44
-        $schema = array();
45
-        foreach ($model_fields as $field => $model_field) {
46
-            if (! $model_field instanceof EE_Model_Field_Base) {
47
-                continue;
48
-            }
49
-            $schema['properties'][$field] = $model_field->get_schema();
50
-        }
51
-        return $schema;
52
-    }
37
+	/**
38
+	 * Get the schema for a given set of model fields.
39
+	 * @param \EE_Model_Field_Base[]     $model_fields
40
+	 * @return array
41
+	 */
42
+	public function getModelSchemaForFields(array $model_fields)
43
+	{
44
+		$schema = array();
45
+		foreach ($model_fields as $field => $model_field) {
46
+			if (! $model_field instanceof EE_Model_Field_Base) {
47
+				continue;
48
+			}
49
+			$schema['properties'][$field] = $model_field->get_schema();
50
+		}
51
+		return $schema;
52
+	}
53 53
 
54 54
 
55
-    /**
56
-     * Get the schema for a given set of model relations
57
-     * @param EE_Model_Relation_Base[] $relations_on_model
58
-     */
59
-    public function getModelSchemaForRelations(array $relations_on_model)
60
-    {
61
-        $schema = array(
62
-            'relations' => array(
63
-                'type' => 'object',
64
-                'description' => __('Relations for this model', 'event_espresso'),
65
-                'properties' => array(),
66
-                'readonly' => true
67
-            )
68
-        );
69
-        foreach ($relations_on_model as $model_name => $relation) {
70
-            if (! $relation instanceof EE_Model_Relation_Base) {
71
-                continue;
72
-            }
73
-            $schema['relations']['properties'][$model_name] = $relation->get_schema();
74
-        }
75
-        return $schema;
76
-    }
55
+	/**
56
+	 * Get the schema for a given set of model relations
57
+	 * @param EE_Model_Relation_Base[] $relations_on_model
58
+	 */
59
+	public function getModelSchemaForRelations(array $relations_on_model)
60
+	{
61
+		$schema = array(
62
+			'relations' => array(
63
+				'type' => 'object',
64
+				'description' => __('Relations for this model', 'event_espresso'),
65
+				'properties' => array(),
66
+				'readonly' => true
67
+			)
68
+		);
69
+		foreach ($relations_on_model as $model_name => $relation) {
70
+			if (! $relation instanceof EE_Model_Relation_Base) {
71
+				continue;
72
+			}
73
+			$schema['relations']['properties'][$model_name] = $relation->get_schema();
74
+		}
75
+		return $schema;
76
+	}
77 77
 
78 78
 
79
-    /**
80
-     * Outputs the schema header for a model.
81
-     * @param \EEM_Base $model
82
-     * @return array
83
-     */
84
-    public function getInitialSchemaStructure(EEM_Base $model)
85
-    {
86
-        return array(
87
-            '$schema' => 'http://json-schema.org/draft-04/schema#',
88
-            'title' => $model->get_this_model_name(),
89
-            'type' => 'object',
90
-            'properties' => array()
91
-        );
92
-    }
79
+	/**
80
+	 * Outputs the schema header for a model.
81
+	 * @param \EEM_Base $model
82
+	 * @return array
83
+	 */
84
+	public function getInitialSchemaStructure(EEM_Base $model)
85
+	{
86
+		return array(
87
+			'$schema' => 'http://json-schema.org/draft-04/schema#',
88
+			'title' => $model->get_this_model_name(),
89
+			'type' => 'object',
90
+			'properties' => array()
91
+		);
92
+	}
93 93
 
94 94
 
95
-    /**
96
-     * Helper function that simply allows one to get whatever has been generated in an actual json object as opposed to
97
-     * an array.
98
-     * @param array $array_to_convert
99
-     * @return bool|false|mixed|string
100
-     */
101
-    public function toJson($array_to_convert)
102
-    {
103
-        return wp_json_encode($array_to_convert);
104
-    }
95
+	/**
96
+	 * Helper function that simply allows one to get whatever has been generated in an actual json object as opposed to
97
+	 * an array.
98
+	 * @param array $array_to_convert
99
+	 * @return bool|false|mixed|string
100
+	 */
101
+	public function toJson($array_to_convert)
102
+	{
103
+		return wp_json_encode($array_to_convert);
104
+	}
105 105
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
     {
44 44
         $schema = array();
45 45
         foreach ($model_fields as $field => $model_field) {
46
-            if (! $model_field instanceof EE_Model_Field_Base) {
46
+            if ( ! $model_field instanceof EE_Model_Field_Base) {
47 47
                 continue;
48 48
             }
49 49
             $schema['properties'][$field] = $model_field->get_schema();
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
             )
68 68
         );
69 69
         foreach ($relations_on_model as $model_name => $relation) {
70
-            if (! $relation instanceof EE_Model_Relation_Base) {
70
+            if ( ! $relation instanceof EE_Model_Relation_Base) {
71 71
                 continue;
72 72
             }
73 73
             $schema['relations']['properties'][$model_name] = $relation->get_schema();
Please login to merge, or discard this patch.