Completed
Branch FET/extra-logging-when-trashin... (b6e112)
by
unknown
36:04 queued 27:41
created
form_sections/strategies/normalization/EE_Null_Normalization.strategy.php 1 patch
Indentation   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -10,25 +10,25 @@
 block discarded – undo
10 10
 class EE_Null_Normalization extends EE_Normalization_Strategy_Base
11 11
 {
12 12
 
13
-    /**
14
-     * @param string $value_to_normalize
15
-     * @return null
16
-     */
17
-    public function normalize($value_to_normalize)
18
-    {
19
-        return null;
20
-    }
13
+	/**
14
+	 * @param string $value_to_normalize
15
+	 * @return null
16
+	 */
17
+	public function normalize($value_to_normalize)
18
+	{
19
+		return null;
20
+	}
21 21
 
22 22
 
23 23
 
24
-    /**
25
-     * In the form input we need some string, so use a blank one.
26
-     *
27
-     * @param string $normalized_value
28
-     * @return string
29
-     */
30
-    public function unnormalize($normalized_value)
31
-    {
32
-        return '';
33
-    }
24
+	/**
25
+	 * In the form input we need some string, so use a blank one.
26
+	 *
27
+	 * @param string $normalized_value
28
+	 * @return string
29
+	 */
30
+	public function unnormalize($normalized_value)
31
+	{
32
+		return '';
33
+	}
34 34
 }
Please login to merge, or discard this patch.
strategies/normalization/EE_All_Caps_Normalization.strategy.php 1 patch
Indentation   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -11,26 +11,26 @@
 block discarded – undo
11 11
 class EE_All_Caps_Normalization extends EE_Normalization_Strategy_Base
12 12
 {
13 13
 
14
-    /**
15
-     * @param string $value_to_normalize
16
-     * @return string
17
-     */
18
-    public function normalize($value_to_normalize)
19
-    {
20
-        return strtoupper($value_to_normalize);
21
-    }
14
+	/**
15
+	 * @param string $value_to_normalize
16
+	 * @return string
17
+	 */
18
+	public function normalize($value_to_normalize)
19
+	{
20
+		return strtoupper($value_to_normalize);
21
+	}
22 22
 
23 23
 
24 24
 
25
-    /**
26
-     * It's kinda hard to unnormalize this- we can't determine which parts used to be lowercase
27
-     * so just return it as-is.
28
-     *
29
-     * @param string $normalized_value
30
-     * @return string
31
-     */
32
-    public function unnormalize($normalized_value)
33
-    {
34
-        return $normalized_value;
35
-    }
25
+	/**
26
+	 * It's kinda hard to unnormalize this- we can't determine which parts used to be lowercase
27
+	 * so just return it as-is.
28
+	 *
29
+	 * @param string $normalized_value
30
+	 * @return string
31
+	 */
32
+	public function unnormalize($normalized_value)
33
+	{
34
+		return $normalized_value;
35
+	}
36 36
 }
Please login to merge, or discard this patch.
strategies/normalization/EE_Normalization_Strategy_Base.strategy.php 1 patch
Indentation   +46 added lines, -46 removed lines patch added patch discarded remove patch
@@ -9,59 +9,59 @@
 block discarded – undo
9 9
 abstract class EE_Normalization_Strategy_Base extends EE_Form_Input_Strategy_Base
10 10
 {
11 11
 
12
-    /**
13
-     * Takes the sanitized value for the input and casts it into the correct PHP type.
14
-     * Eg, turns it into an int, float, string, boolean, datetime, etc. The validation
15
-     * strategy should be able to depend on the normalized value being of the correct type.
16
-     * If the normalized value passes validation, the normalized value is what other code
17
-     * will operate on. If the sanitized value cannot be normalized, this method should either
18
-     * add a validation error onto the input, or wrangle the input into a format that can be normalized
19
-     * (eg, for a date input, if the user enters "2014/100/100", you can either add an error stating
20
-     * "hey! 2014/100/100 is not a valid date!", or simply convert it into a valid date like "2014/12/31".
21
-     * For this case, I'd prefer the former. But there may be cases where you'd just rather correct it for them)
22
-     *
23
-     * @param string $value_to_normalize it should always be a string. If the input receives an array, then the
24
-     *                                   validation strategy should be called on array elements, not on the entire array
25
-     * @return mixed the normalized value
26
-     */
27
-    abstract public function normalize($value_to_normalize);
12
+	/**
13
+	 * Takes the sanitized value for the input and casts it into the correct PHP type.
14
+	 * Eg, turns it into an int, float, string, boolean, datetime, etc. The validation
15
+	 * strategy should be able to depend on the normalized value being of the correct type.
16
+	 * If the normalized value passes validation, the normalized value is what other code
17
+	 * will operate on. If the sanitized value cannot be normalized, this method should either
18
+	 * add a validation error onto the input, or wrangle the input into a format that can be normalized
19
+	 * (eg, for a date input, if the user enters "2014/100/100", you can either add an error stating
20
+	 * "hey! 2014/100/100 is not a valid date!", or simply convert it into a valid date like "2014/12/31".
21
+	 * For this case, I'd prefer the former. But there may be cases where you'd just rather correct it for them)
22
+	 *
23
+	 * @param string $value_to_normalize it should always be a string. If the input receives an array, then the
24
+	 *                                   validation strategy should be called on array elements, not on the entire array
25
+	 * @return mixed the normalized value
26
+	 */
27
+	abstract public function normalize($value_to_normalize);
28 28
 
29 29
 
30 30
 
31
-    /**
32
-     * Identical to normalize, except normalize_one() CANNOT be passed an array and
33
-     * never returns an array. Useful if the normalization strategy converts between arrays
34
-     *
35
-     * @param string $individual_item_to_normalize
36
-     * @return mixed
37
-     */
38
-    public function normalize_one($individual_item_to_normalize)
39
-    {
40
-        return $this->normalize($individual_item_to_normalize);
41
-    }
31
+	/**
32
+	 * Identical to normalize, except normalize_one() CANNOT be passed an array and
33
+	 * never returns an array. Useful if the normalization strategy converts between arrays
34
+	 *
35
+	 * @param string $individual_item_to_normalize
36
+	 * @return mixed
37
+	 */
38
+	public function normalize_one($individual_item_to_normalize)
39
+	{
40
+		return $this->normalize($individual_item_to_normalize);
41
+	}
42 42
 
43 43
 
44 44
 
45
-    /**
46
-     * Takes the normalized value (for an Yes_No_Input this could be TRUE or FALSE), and converts it into
47
-     * the value you would use in the html form (for a Yes_No_Input this could be '1' or '0').
48
-     *
49
-     * @param $normalized_value
50
-     * @return array|string the 'raw' value as used in the form, usually a string or array of strings.
51
-     */
52
-    abstract public function unnormalize($normalized_value);
45
+	/**
46
+	 * Takes the normalized value (for an Yes_No_Input this could be TRUE or FALSE), and converts it into
47
+	 * the value you would use in the html form (for a Yes_No_Input this could be '1' or '0').
48
+	 *
49
+	 * @param $normalized_value
50
+	 * @return array|string the 'raw' value as used in the form, usually a string or array of strings.
51
+	 */
52
+	abstract public function unnormalize($normalized_value);
53 53
 
54 54
 
55 55
 
56
-    /**
57
-     * Normally the same as unnormalize, except it CANNOT be passed an array and
58
-     * ALWAYS returns a string
59
-     *
60
-     * @param mixed $individual_item_to_unnormalize NOT an array
61
-     * @return string
62
-     */
63
-    public function unnormalize_one($individual_item_to_unnormalize)
64
-    {
65
-        return $this->unnormalize($individual_item_to_unnormalize);
66
-    }
56
+	/**
57
+	 * Normally the same as unnormalize, except it CANNOT be passed an array and
58
+	 * ALWAYS returns a string
59
+	 *
60
+	 * @param mixed $individual_item_to_unnormalize NOT an array
61
+	 * @return string
62
+	 */
63
+	public function unnormalize_one($individual_item_to_unnormalize)
64
+	{
65
+		return $this->unnormalize($individual_item_to_unnormalize);
66
+	}
67 67
 }
Please login to merge, or discard this patch.
strategies/normalization/EE_Boolean_Normalization.strategy.php 1 patch
Indentation   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -13,27 +13,27 @@
 block discarded – undo
13 13
 class EE_Boolean_Normalization extends EE_Normalization_Strategy_Base
14 14
 {
15 15
 
16
-    /**
17
-     * @param string | int | bool $value_to_normalize
18
-     * @return boolean
19
-     */
20
-    public function normalize($value_to_normalize)
21
-    {
22
-        return filter_var($value_to_normalize, FILTER_VALIDATE_BOOLEAN);
23
-    }
16
+	/**
17
+	 * @param string | int | bool $value_to_normalize
18
+	 * @return boolean
19
+	 */
20
+	public function normalize($value_to_normalize)
21
+	{
22
+		return filter_var($value_to_normalize, FILTER_VALIDATE_BOOLEAN);
23
+	}
24 24
 
25 25
 
26 26
 
27
-    /**
28
-     * @param boolean $normalized_value
29
-     * @return string
30
-     */
31
-    public function unnormalize($normalized_value)
32
-    {
33
-        if ($normalized_value) {
34
-            return '1';
35
-        } else {
36
-            return '0';
37
-        }
38
-    }
27
+	/**
28
+	 * @param boolean $normalized_value
29
+	 * @return string
30
+	 */
31
+	public function unnormalize($normalized_value)
32
+	{
33
+		if ($normalized_value) {
34
+			return '1';
35
+		} else {
36
+			return '0';
37
+		}
38
+	}
39 39
 }
Please login to merge, or discard this patch.
strategies/normalization/EE_Many_Valued_Normalization.strategy.php 2 patches
Indentation   +86 added lines, -86 removed lines patch added patch discarded remove patch
@@ -10,90 +10,90 @@
 block discarded – undo
10 10
 class EE_Many_Valued_Normalization extends EE_Normalization_Strategy_Base
11 11
 {
12 12
 
13
-    protected $_individual_item_normalization_strategy = array();
14
-
15
-
16
-
17
-    /**
18
-     * @param EE_Normalization_Strategy_Base $individual_item_normalization_strategy
19
-     */
20
-    public function __construct($individual_item_normalization_strategy)
21
-    {
22
-        $this->_individual_item_normalization_strategy = $individual_item_normalization_strategy;
23
-        parent::__construct();
24
-    }
25
-
26
-
27
-
28
-    /**
29
-     * Normalizes the input into an array, and normalizes each item according to its
30
-     * individual item normalization strategy
31
-     *
32
-     * @param array | string $value_to_normalize
33
-     * @return array
34
-     */
35
-    public function normalize($value_to_normalize)
36
-    {
37
-        if (is_array($value_to_normalize)) {
38
-            $items_to_normalize = $value_to_normalize;
39
-        } elseif ($value_to_normalize !== null) {
40
-            $items_to_normalize = array($value_to_normalize);
41
-        } else {
42
-            $items_to_normalize = array();
43
-        }
44
-        $normalized_array_value = array();
45
-        foreach ($items_to_normalize as $key => $individual_item) {
46
-            $normalized_array_value[ $key ] = $this->normalize_one($individual_item);
47
-        }
48
-        return $normalized_array_value;
49
-    }
50
-
51
-
52
-
53
-    /**
54
-     * Normalized the one item (called for each array item in EE_Many_values_Normalization::normalize())
55
-     *
56
-     * @param string $individual_value_to_normalize but definitely NOT an array
57
-     * @return mixed
58
-     */
59
-    public function normalize_one($individual_value_to_normalize)
60
-    {
61
-        return $this->_individual_item_normalization_strategy->normalize($individual_value_to_normalize);
62
-    }
63
-
64
-
65
-
66
-    /**
67
-     * Converts the array of normalized things to an array of raw html values.
68
-     *
69
-     * @param array $normalized_values
70
-     * @return string[]
71
-     */
72
-    public function unnormalize($normalized_values)
73
-    {
74
-        if ($normalized_values === null) {
75
-            $normalized_values = array();
76
-        }
77
-        if (! is_array($normalized_values)) {
78
-            $normalized_values = array($normalized_values);
79
-        }
80
-        $non_normal_values = array();
81
-        foreach ($normalized_values as $key => $value) {
82
-            $non_normal_values[ $key ] = $this->unnormalize_one($value);
83
-        }
84
-        return $non_normal_values;
85
-    }
86
-
87
-
88
-
89
-    /**
90
-     * Unnormalizes an individual item in the array of values
91
-     *
92
-     * @param mixed $individual_value_to_unnormalize but certainly NOT an array
93
-     * @return string
94
-     */
95
-    public function unnormalize_one($individual_value_to_unnormalize)
96
-    {
97
-        return $this->_individual_item_normalization_strategy->unnormalize($individual_value_to_unnormalize);
98
-    }
13
+	protected $_individual_item_normalization_strategy = array();
14
+
15
+
16
+
17
+	/**
18
+	 * @param EE_Normalization_Strategy_Base $individual_item_normalization_strategy
19
+	 */
20
+	public function __construct($individual_item_normalization_strategy)
21
+	{
22
+		$this->_individual_item_normalization_strategy = $individual_item_normalization_strategy;
23
+		parent::__construct();
24
+	}
25
+
26
+
27
+
28
+	/**
29
+	 * Normalizes the input into an array, and normalizes each item according to its
30
+	 * individual item normalization strategy
31
+	 *
32
+	 * @param array | string $value_to_normalize
33
+	 * @return array
34
+	 */
35
+	public function normalize($value_to_normalize)
36
+	{
37
+		if (is_array($value_to_normalize)) {
38
+			$items_to_normalize = $value_to_normalize;
39
+		} elseif ($value_to_normalize !== null) {
40
+			$items_to_normalize = array($value_to_normalize);
41
+		} else {
42
+			$items_to_normalize = array();
43
+		}
44
+		$normalized_array_value = array();
45
+		foreach ($items_to_normalize as $key => $individual_item) {
46
+			$normalized_array_value[ $key ] = $this->normalize_one($individual_item);
47
+		}
48
+		return $normalized_array_value;
49
+	}
50
+
51
+
52
+
53
+	/**
54
+	 * Normalized the one item (called for each array item in EE_Many_values_Normalization::normalize())
55
+	 *
56
+	 * @param string $individual_value_to_normalize but definitely NOT an array
57
+	 * @return mixed
58
+	 */
59
+	public function normalize_one($individual_value_to_normalize)
60
+	{
61
+		return $this->_individual_item_normalization_strategy->normalize($individual_value_to_normalize);
62
+	}
63
+
64
+
65
+
66
+	/**
67
+	 * Converts the array of normalized things to an array of raw html values.
68
+	 *
69
+	 * @param array $normalized_values
70
+	 * @return string[]
71
+	 */
72
+	public function unnormalize($normalized_values)
73
+	{
74
+		if ($normalized_values === null) {
75
+			$normalized_values = array();
76
+		}
77
+		if (! is_array($normalized_values)) {
78
+			$normalized_values = array($normalized_values);
79
+		}
80
+		$non_normal_values = array();
81
+		foreach ($normalized_values as $key => $value) {
82
+			$non_normal_values[ $key ] = $this->unnormalize_one($value);
83
+		}
84
+		return $non_normal_values;
85
+	}
86
+
87
+
88
+
89
+	/**
90
+	 * Unnormalizes an individual item in the array of values
91
+	 *
92
+	 * @param mixed $individual_value_to_unnormalize but certainly NOT an array
93
+	 * @return string
94
+	 */
95
+	public function unnormalize_one($individual_value_to_unnormalize)
96
+	{
97
+		return $this->_individual_item_normalization_strategy->unnormalize($individual_value_to_unnormalize);
98
+	}
99 99
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
         }
44 44
         $normalized_array_value = array();
45 45
         foreach ($items_to_normalize as $key => $individual_item) {
46
-            $normalized_array_value[ $key ] = $this->normalize_one($individual_item);
46
+            $normalized_array_value[$key] = $this->normalize_one($individual_item);
47 47
         }
48 48
         return $normalized_array_value;
49 49
     }
@@ -74,12 +74,12 @@  discard block
 block discarded – undo
74 74
         if ($normalized_values === null) {
75 75
             $normalized_values = array();
76 76
         }
77
-        if (! is_array($normalized_values)) {
77
+        if ( ! is_array($normalized_values)) {
78 78
             $normalized_values = array($normalized_values);
79 79
         }
80 80
         $non_normal_values = array();
81 81
         foreach ($normalized_values as $key => $value) {
82
-            $non_normal_values[ $key ] = $this->unnormalize_one($value);
82
+            $non_normal_values[$key] = $this->unnormalize_one($value);
83 83
         }
84 84
         return $non_normal_values;
85 85
     }
Please login to merge, or discard this patch.
form_sections/strategies/normalization/EE_Slug_Normalization.strategy.php 1 patch
Indentation   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -10,25 +10,25 @@
 block discarded – undo
10 10
 class EE_Slug_Normalization extends EE_Normalization_Strategy_Base
11 11
 {
12 12
 
13
-    /**
14
-     * @param string $value_to_normalize
15
-     * @return string
16
-     */
17
-    public function normalize($value_to_normalize)
18
-    {
19
-        return sanitize_title($value_to_normalize);
20
-    }
13
+	/**
14
+	 * @param string $value_to_normalize
15
+	 * @return string
16
+	 */
17
+	public function normalize($value_to_normalize)
18
+	{
19
+		return sanitize_title($value_to_normalize);
20
+	}
21 21
 
22 22
 
23 23
 
24
-    /**
25
-     * It's hard to unnormalize this- let's just take a guess
26
-     *
27
-     * @param string $normalized_value
28
-     * @return string
29
-     */
30
-    public function unnormalize($normalized_value)
31
-    {
32
-        return str_replace("-", " ", $normalized_value);
33
-    }
24
+	/**
25
+	 * It's hard to unnormalize this- let's just take a guess
26
+	 *
27
+	 * @param string $normalized_value
28
+	 * @return string
29
+	 */
30
+	public function unnormalize($normalized_value)
31
+	{
32
+		return str_replace("-", " ", $normalized_value);
33
+	}
34 34
 }
Please login to merge, or discard this patch.
strategies/normalization/EE_Credit_Card_Normalization.strategy.php 1 patch
Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -9,14 +9,14 @@
 block discarded – undo
9 9
 class EE_Credit_Card_Normalization extends EE_Text_Normalization
10 10
 {
11 11
 
12
-    /**
13
-     * @param string $value_to_normalize
14
-     * @return mixed
15
-     */
16
-    public function normalize($value_to_normalize)
17
-    {
18
-        $normalized_by_parent = parent::normalize($value_to_normalize);
19
-        // we want to make it consistent, so remove whitespace from cc number
20
-        return preg_replace('/\s+/', '', $normalized_by_parent);
21
-    }
12
+	/**
13
+	 * @param string $value_to_normalize
14
+	 * @return mixed
15
+	 */
16
+	public function normalize($value_to_normalize)
17
+	{
18
+		$normalized_by_parent = parent::normalize($value_to_normalize);
19
+		// we want to make it consistent, so remove whitespace from cc number
20
+		return preg_replace('/\s+/', '', $normalized_by_parent);
21
+	}
22 22
 }
Please login to merge, or discard this patch.
form_sections/strategies/normalization/EE_Text_Normalization.strategy.php 1 patch
Indentation   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -10,38 +10,38 @@
 block discarded – undo
10 10
 class EE_Text_Normalization extends EE_Normalization_Strategy_Base
11 11
 {
12 12
 
13
-    /**
14
-     * @param string $value_to_normalize
15
-     * @return array|mixed|string
16
-     */
17
-    public function normalize($value_to_normalize)
18
-    {
19
-        if (is_array($value_to_normalize)) {
20
-            return (string) array_shift($value_to_normalize);
21
-        }
22
-        // consider `"null"` values to be equivalent to null.
23
-        if ($value_to_normalize === '' || $value_to_normalize === null) {
24
-            return null;
25
-        }
26
-        return (string) $value_to_normalize;
27
-    }
13
+	/**
14
+	 * @param string $value_to_normalize
15
+	 * @return array|mixed|string
16
+	 */
17
+	public function normalize($value_to_normalize)
18
+	{
19
+		if (is_array($value_to_normalize)) {
20
+			return (string) array_shift($value_to_normalize);
21
+		}
22
+		// consider `"null"` values to be equivalent to null.
23
+		if ($value_to_normalize === '' || $value_to_normalize === null) {
24
+			return null;
25
+		}
26
+		return (string) $value_to_normalize;
27
+	}
28 28
 
29 29
 
30 30
 
31
-    /**
32
-     * IF its a string in PHP, it will be a string in the HTML form. easy
33
-     *
34
-     * @param string $normalized_value
35
-     * @return string
36
-     */
37
-    public function unnormalize($normalized_value)
38
-    {
39
-        // account for default "select here" option values
40
-        if ($normalized_value === null) {
41
-            return '';
42
-        }
43
-        // double-check it's a string. It's possible this value was a question option that happened to be a numeric
44
-        // string, in which case PHP has automatically converted it to an integer!
45
-        return (string) $normalized_value;
46
-    }
31
+	/**
32
+	 * IF its a string in PHP, it will be a string in the HTML form. easy
33
+	 *
34
+	 * @param string $normalized_value
35
+	 * @return string
36
+	 */
37
+	public function unnormalize($normalized_value)
38
+	{
39
+		// account for default "select here" option values
40
+		if ($normalized_value === null) {
41
+			return '';
42
+		}
43
+		// double-check it's a string. It's possible this value was a question option that happened to be a numeric
44
+		// string, in which case PHP has automatically converted it to an integer!
45
+		return (string) $normalized_value;
46
+	}
47 47
 }
Please login to merge, or discard this patch.
form_sections/strategies/layout/EE_Form_Section_Layout_Base.strategy.php 2 patches
Indentation   +284 added lines, -284 removed lines patch added patch discarded remove patch
@@ -12,288 +12,288 @@
 block discarded – undo
12 12
 abstract class EE_Form_Section_Layout_Base
13 13
 {
14 14
 
15
-    /**
16
-     * Form form section to lay out
17
-     *
18
-     * @var EE_Form_Section_Proper
19
-     */
20
-    protected $_form_section;
21
-
22
-
23
-
24
-    /**
25
-     *  __construct
26
-     */
27
-    public function __construct()
28
-    {
29
-    }
30
-
31
-
32
-
33
-    /**
34
-     * The form section on which this strategy is to perform
35
-     *
36
-     * @param EE_Form_Section_Proper $form
37
-     */
38
-    public function _construct_finalize(EE_Form_Section_Proper $form)
39
-    {
40
-        $this->_form_section = $form;
41
-    }
42
-
43
-
44
-
45
-    /**
46
-     * @return EE_Form_Section_Proper
47
-     */
48
-    public function form_section()
49
-    {
50
-        return $this->_form_section;
51
-    }
52
-
53
-
54
-
55
-    /**
56
-     * Also has teh side effect of enqueuing any needed JS and CSS for
57
-     * this form.
58
-     * Creates all the HTML necessary for displaying this form, its inputs, and
59
-     * proper subsections.
60
-     * Returns the HTML
61
-     *
62
-     * @return string HTML for displaying
63
-     * @throws EE_Error
64
-     */
65
-    public function layout_form()
66
-    {
67
-        $html = '';
68
-        // layout_form_begin
69
-        $html .= apply_filters(
70
-            'FHEE__EE_Form_Section_Layout_Base__layout_form__start__for_' . $this->_form_section->name(),
71
-            $this->layout_form_begin(),
72
-            $this->_form_section
73
-        );
74
-        // layout_form_loop
75
-        $html .= apply_filters(
76
-            'FHEE__EE_Form_Section_Layout_Base__layout_form__loop__for_' . $this->_form_section->name(),
77
-            $this->layout_form_loop(),
78
-            $this->_form_section
79
-        );
80
-        // layout_form_end
81
-        $html .= apply_filters(
82
-            'FHEE__EE_Form_Section_Layout_Base__layout_form__end__for_' . $this->_form_section->name(),
83
-            $this->layout_form_end(),
84
-            $this->_form_section
85
-        );
86
-        $html = $this->add_form_section_hooks_and_filters($html);
87
-        return $html;
88
-    }
89
-
90
-
91
-
92
-    /**
93
-     * @return string
94
-     * @throws EE_Error
95
-     */
96
-    public function layout_form_loop()
97
-    {
98
-        $html = '';
99
-        foreach ($this->_form_section->subsections() as $name => $subsection) {
100
-            if ($subsection instanceof EE_Form_Input_Base) {
101
-                $html .= apply_filters(
102
-                    'FHEE__EE_Form_Section_Layout_Base__layout_form__loop_for_input_'
103
-                    . $name . '__in_' . $this->_form_section->name(),
104
-                    $this->layout_input($subsection),
105
-                    $this->_form_section,
106
-                    $subsection
107
-                );
108
-            } elseif ($subsection instanceof EE_Form_Section_Base) {
109
-                $html .= apply_filters(
110
-                    'FHEE__EE_Form_Section_Layout_Base__layout_form__loop_for_non_input_'
111
-                    . $name . '__in_' . $this->_form_section->name(),
112
-                    $this->layout_subsection($subsection),
113
-                    $this->_form_section,
114
-                    $subsection
115
-                );
116
-            }
117
-        }
118
-        return $html;
119
-    }
120
-
121
-
122
-
123
-    /**
124
-     * Should be used to start teh form section (Eg a table tag, or a div tag, etc.)
125
-     *
126
-     * @return string
127
-     */
128
-    abstract public function layout_form_begin();
129
-
130
-
131
-
132
-    /**
133
-     * Should be used to end the form section (eg a /table tag, or a /div tag, etc)
134
-     *
135
-     * @return string
136
-     */
137
-    abstract public function layout_form_end();
138
-
139
-
140
-
141
-    /**
142
-     * Should be used internally by layout_form() to layout each input (eg, if this layout
143
-     * is putting each input in a row of its own, this should probably be called by a
144
-     *  foreach loop in layout_form() (WITHOUT adding any content directly within layout_form()'s foreach loop.
145
-     * Eg, this method should add the tr and td tags). This method is exposed in case you want to completely
146
-     * customize the form's layout, but would like to make use of it for laying out
147
-     * 'easy-to-layout' inputs
148
-     *
149
-     * @param EE_Form_Input_Base $input
150
-     * @return string html
151
-     */
152
-    abstract public function layout_input($input);
153
-
154
-
155
-
156
-    /**
157
-     * Similar to layout_input(), should be used internally by layout_form() within a
158
-     * loop to layout each proper subsection. Unlike layout_input(), however, it is assumed
159
-     * that the proper subsection will layout its container, label, etc on its own.
160
-     *
161
-     * @param EE_Form_Section_Base $subsection
162
-     * @return string html
163
-     */
164
-    abstract public function layout_subsection($subsection);
165
-
166
-
167
-
168
-    /**
169
-     * Gets the HTML for the label tag and its contents for the input
170
-     *
171
-     * @param EE_Form_Input_Base $input
172
-     * @return string
173
-     */
174
-    public function display_label($input)
175
-    {
176
-        if ($input->get_display_strategy() instanceof EE_Hidden_Display_Strategy) {
177
-            return '';
178
-        }
179
-        $class = $input->required()
180
-            ? 'ee-required-label ' . $input->html_label_class()
181
-            : $input->html_label_class();
182
-        $label_text = $input->required()
183
-            ? $input->html_label_text() . '<span class="ee-asterisk">*</span>'
184
-            : $input->html_label_text();
185
-        return '<label id="'
186
-               . $input->html_label_id()
187
-               . '" class="'
188
-               . $class
189
-               . '" style="'
190
-               . $input->html_label_style()
191
-               . '" for="' . $input->html_name()
192
-               . '">'
193
-               . $label_text
194
-               . '</label>';
195
-    }
196
-
197
-
198
-
199
-    /**
200
-     * Gets the HTML for all the form's form-wide errors (ie, errors which
201
-     * are not for specific inputs. E.g., if two inputs somehow disagree,
202
-     * those errors would probably be on the form section, not one of its inputs)
203
-     * @return string
204
-     */
205
-    public function display_form_wide_errors()
206
-    {
207
-        $html = '';
208
-        if ($this->_form_section->get_validation_errors()) {
209
-            $html .= "<div class='ee-form-wide-errors'>";
210
-            // get all the errors on THIS form section (errors which aren't
211
-            // for specific inputs, but instead for the entire form section)
212
-            foreach ($this->_form_section->get_validation_errors() as $error) {
213
-                $html .= $error->getMessage() . '<br>';
214
-            }
215
-            $html .= '</div>';
216
-        }
217
-        return apply_filters(
218
-            'FHEE__EE_Form_Section_Layout_Base__display_form_wide_errors',
219
-            $html,
220
-            $this
221
-        );
222
-    }
223
-
224
-
225
-
226
-    /**
227
-     * returns the HTML for the server-side validation errors for the specified input
228
-     * Note that if JS is enabled, it should remove these and instead
229
-     * populate the form's errors in the jquery validate fashion
230
-     * using the localized data provided to the JS
231
-     *
232
-     * @param EE_Form_Input_Base $input
233
-     * @return string
234
-     */
235
-    public function display_errors($input)
236
-    {
237
-        if ($input->get_validation_errors()) {
238
-            return "<label  id='"
239
-                   . $input->html_id()
240
-                   . "-error' class='error' for='{$input->html_name()}'>"
241
-                   . $input->get_validation_error_string()
242
-                   . '</label>';
243
-        }
244
-        return '';
245
-    }
246
-
247
-
248
-
249
-    /**
250
-     * Displays the help span for the specified input
251
-     *
252
-     * @param EE_Form_Input_Base $input
253
-     * @return string
254
-     */
255
-    public function display_help_text($input)
256
-    {
257
-        $help_text  = $input->html_help_text();
258
-        if ($help_text !== '' && $help_text !== null) {
259
-            $tag = is_admin() ? 'p' : 'span';
260
-            return '<'
261
-                   . $tag
262
-                   . ' id="'
263
-                   . $input->html_id()
264
-                   . '-help" class="'
265
-                   . $input->html_help_class()
266
-                   . '" style="'
267
-                   . $input->html_help_style()
268
-                   . '">'
269
-                   . $help_text
270
-                   . '</'
271
-                   . $tag
272
-                   . '>';
273
-        }
274
-        return '';
275
-    }
276
-
277
-
278
-
279
-    /**
280
-     * Does an action and hook onto the end of teh form
281
-     *
282
-     * @param string $html
283
-     * @return string
284
-     */
285
-    public function add_form_section_hooks_and_filters($html)
286
-    {
287
-        // replace dashes and spaces with underscores
288
-        $hook_name = str_replace(array('-', ' '), '_', $this->_form_section->html_id());
289
-        do_action('AHEE__Form_Section_Layout__' . $hook_name, $this->_form_section);
290
-        $html = (string) apply_filters(
291
-            'AFEE__Form_Section_Layout__' . $hook_name . '__html',
292
-            $html,
293
-            $this->_form_section
294
-        );
295
-        $html .= EEH_HTML::nl() . '<!-- AHEE__Form_Section_Layout__' . $hook_name . '__html -->';
296
-        $html .= EEH_HTML::nl() . '<!-- AFEE__Form_Section_Layout__' . $hook_name . ' -->';
297
-        return $html;
298
-    }
15
+	/**
16
+	 * Form form section to lay out
17
+	 *
18
+	 * @var EE_Form_Section_Proper
19
+	 */
20
+	protected $_form_section;
21
+
22
+
23
+
24
+	/**
25
+	 *  __construct
26
+	 */
27
+	public function __construct()
28
+	{
29
+	}
30
+
31
+
32
+
33
+	/**
34
+	 * The form section on which this strategy is to perform
35
+	 *
36
+	 * @param EE_Form_Section_Proper $form
37
+	 */
38
+	public function _construct_finalize(EE_Form_Section_Proper $form)
39
+	{
40
+		$this->_form_section = $form;
41
+	}
42
+
43
+
44
+
45
+	/**
46
+	 * @return EE_Form_Section_Proper
47
+	 */
48
+	public function form_section()
49
+	{
50
+		return $this->_form_section;
51
+	}
52
+
53
+
54
+
55
+	/**
56
+	 * Also has teh side effect of enqueuing any needed JS and CSS for
57
+	 * this form.
58
+	 * Creates all the HTML necessary for displaying this form, its inputs, and
59
+	 * proper subsections.
60
+	 * Returns the HTML
61
+	 *
62
+	 * @return string HTML for displaying
63
+	 * @throws EE_Error
64
+	 */
65
+	public function layout_form()
66
+	{
67
+		$html = '';
68
+		// layout_form_begin
69
+		$html .= apply_filters(
70
+			'FHEE__EE_Form_Section_Layout_Base__layout_form__start__for_' . $this->_form_section->name(),
71
+			$this->layout_form_begin(),
72
+			$this->_form_section
73
+		);
74
+		// layout_form_loop
75
+		$html .= apply_filters(
76
+			'FHEE__EE_Form_Section_Layout_Base__layout_form__loop__for_' . $this->_form_section->name(),
77
+			$this->layout_form_loop(),
78
+			$this->_form_section
79
+		);
80
+		// layout_form_end
81
+		$html .= apply_filters(
82
+			'FHEE__EE_Form_Section_Layout_Base__layout_form__end__for_' . $this->_form_section->name(),
83
+			$this->layout_form_end(),
84
+			$this->_form_section
85
+		);
86
+		$html = $this->add_form_section_hooks_and_filters($html);
87
+		return $html;
88
+	}
89
+
90
+
91
+
92
+	/**
93
+	 * @return string
94
+	 * @throws EE_Error
95
+	 */
96
+	public function layout_form_loop()
97
+	{
98
+		$html = '';
99
+		foreach ($this->_form_section->subsections() as $name => $subsection) {
100
+			if ($subsection instanceof EE_Form_Input_Base) {
101
+				$html .= apply_filters(
102
+					'FHEE__EE_Form_Section_Layout_Base__layout_form__loop_for_input_'
103
+					. $name . '__in_' . $this->_form_section->name(),
104
+					$this->layout_input($subsection),
105
+					$this->_form_section,
106
+					$subsection
107
+				);
108
+			} elseif ($subsection instanceof EE_Form_Section_Base) {
109
+				$html .= apply_filters(
110
+					'FHEE__EE_Form_Section_Layout_Base__layout_form__loop_for_non_input_'
111
+					. $name . '__in_' . $this->_form_section->name(),
112
+					$this->layout_subsection($subsection),
113
+					$this->_form_section,
114
+					$subsection
115
+				);
116
+			}
117
+		}
118
+		return $html;
119
+	}
120
+
121
+
122
+
123
+	/**
124
+	 * Should be used to start teh form section (Eg a table tag, or a div tag, etc.)
125
+	 *
126
+	 * @return string
127
+	 */
128
+	abstract public function layout_form_begin();
129
+
130
+
131
+
132
+	/**
133
+	 * Should be used to end the form section (eg a /table tag, or a /div tag, etc)
134
+	 *
135
+	 * @return string
136
+	 */
137
+	abstract public function layout_form_end();
138
+
139
+
140
+
141
+	/**
142
+	 * Should be used internally by layout_form() to layout each input (eg, if this layout
143
+	 * is putting each input in a row of its own, this should probably be called by a
144
+	 *  foreach loop in layout_form() (WITHOUT adding any content directly within layout_form()'s foreach loop.
145
+	 * Eg, this method should add the tr and td tags). This method is exposed in case you want to completely
146
+	 * customize the form's layout, but would like to make use of it for laying out
147
+	 * 'easy-to-layout' inputs
148
+	 *
149
+	 * @param EE_Form_Input_Base $input
150
+	 * @return string html
151
+	 */
152
+	abstract public function layout_input($input);
153
+
154
+
155
+
156
+	/**
157
+	 * Similar to layout_input(), should be used internally by layout_form() within a
158
+	 * loop to layout each proper subsection. Unlike layout_input(), however, it is assumed
159
+	 * that the proper subsection will layout its container, label, etc on its own.
160
+	 *
161
+	 * @param EE_Form_Section_Base $subsection
162
+	 * @return string html
163
+	 */
164
+	abstract public function layout_subsection($subsection);
165
+
166
+
167
+
168
+	/**
169
+	 * Gets the HTML for the label tag and its contents for the input
170
+	 *
171
+	 * @param EE_Form_Input_Base $input
172
+	 * @return string
173
+	 */
174
+	public function display_label($input)
175
+	{
176
+		if ($input->get_display_strategy() instanceof EE_Hidden_Display_Strategy) {
177
+			return '';
178
+		}
179
+		$class = $input->required()
180
+			? 'ee-required-label ' . $input->html_label_class()
181
+			: $input->html_label_class();
182
+		$label_text = $input->required()
183
+			? $input->html_label_text() . '<span class="ee-asterisk">*</span>'
184
+			: $input->html_label_text();
185
+		return '<label id="'
186
+			   . $input->html_label_id()
187
+			   . '" class="'
188
+			   . $class
189
+			   . '" style="'
190
+			   . $input->html_label_style()
191
+			   . '" for="' . $input->html_name()
192
+			   . '">'
193
+			   . $label_text
194
+			   . '</label>';
195
+	}
196
+
197
+
198
+
199
+	/**
200
+	 * Gets the HTML for all the form's form-wide errors (ie, errors which
201
+	 * are not for specific inputs. E.g., if two inputs somehow disagree,
202
+	 * those errors would probably be on the form section, not one of its inputs)
203
+	 * @return string
204
+	 */
205
+	public function display_form_wide_errors()
206
+	{
207
+		$html = '';
208
+		if ($this->_form_section->get_validation_errors()) {
209
+			$html .= "<div class='ee-form-wide-errors'>";
210
+			// get all the errors on THIS form section (errors which aren't
211
+			// for specific inputs, but instead for the entire form section)
212
+			foreach ($this->_form_section->get_validation_errors() as $error) {
213
+				$html .= $error->getMessage() . '<br>';
214
+			}
215
+			$html .= '</div>';
216
+		}
217
+		return apply_filters(
218
+			'FHEE__EE_Form_Section_Layout_Base__display_form_wide_errors',
219
+			$html,
220
+			$this
221
+		);
222
+	}
223
+
224
+
225
+
226
+	/**
227
+	 * returns the HTML for the server-side validation errors for the specified input
228
+	 * Note that if JS is enabled, it should remove these and instead
229
+	 * populate the form's errors in the jquery validate fashion
230
+	 * using the localized data provided to the JS
231
+	 *
232
+	 * @param EE_Form_Input_Base $input
233
+	 * @return string
234
+	 */
235
+	public function display_errors($input)
236
+	{
237
+		if ($input->get_validation_errors()) {
238
+			return "<label  id='"
239
+				   . $input->html_id()
240
+				   . "-error' class='error' for='{$input->html_name()}'>"
241
+				   . $input->get_validation_error_string()
242
+				   . '</label>';
243
+		}
244
+		return '';
245
+	}
246
+
247
+
248
+
249
+	/**
250
+	 * Displays the help span for the specified input
251
+	 *
252
+	 * @param EE_Form_Input_Base $input
253
+	 * @return string
254
+	 */
255
+	public function display_help_text($input)
256
+	{
257
+		$help_text  = $input->html_help_text();
258
+		if ($help_text !== '' && $help_text !== null) {
259
+			$tag = is_admin() ? 'p' : 'span';
260
+			return '<'
261
+				   . $tag
262
+				   . ' id="'
263
+				   . $input->html_id()
264
+				   . '-help" class="'
265
+				   . $input->html_help_class()
266
+				   . '" style="'
267
+				   . $input->html_help_style()
268
+				   . '">'
269
+				   . $help_text
270
+				   . '</'
271
+				   . $tag
272
+				   . '>';
273
+		}
274
+		return '';
275
+	}
276
+
277
+
278
+
279
+	/**
280
+	 * Does an action and hook onto the end of teh form
281
+	 *
282
+	 * @param string $html
283
+	 * @return string
284
+	 */
285
+	public function add_form_section_hooks_and_filters($html)
286
+	{
287
+		// replace dashes and spaces with underscores
288
+		$hook_name = str_replace(array('-', ' '), '_', $this->_form_section->html_id());
289
+		do_action('AHEE__Form_Section_Layout__' . $hook_name, $this->_form_section);
290
+		$html = (string) apply_filters(
291
+			'AFEE__Form_Section_Layout__' . $hook_name . '__html',
292
+			$html,
293
+			$this->_form_section
294
+		);
295
+		$html .= EEH_HTML::nl() . '<!-- AHEE__Form_Section_Layout__' . $hook_name . '__html -->';
296
+		$html .= EEH_HTML::nl() . '<!-- AFEE__Form_Section_Layout__' . $hook_name . ' -->';
297
+		return $html;
298
+	}
299 299
 }
Please login to merge, or discard this patch.
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -67,19 +67,19 @@  discard block
 block discarded – undo
67 67
         $html = '';
68 68
         // layout_form_begin
69 69
         $html .= apply_filters(
70
-            'FHEE__EE_Form_Section_Layout_Base__layout_form__start__for_' . $this->_form_section->name(),
70
+            'FHEE__EE_Form_Section_Layout_Base__layout_form__start__for_'.$this->_form_section->name(),
71 71
             $this->layout_form_begin(),
72 72
             $this->_form_section
73 73
         );
74 74
         // layout_form_loop
75 75
         $html .= apply_filters(
76
-            'FHEE__EE_Form_Section_Layout_Base__layout_form__loop__for_' . $this->_form_section->name(),
76
+            'FHEE__EE_Form_Section_Layout_Base__layout_form__loop__for_'.$this->_form_section->name(),
77 77
             $this->layout_form_loop(),
78 78
             $this->_form_section
79 79
         );
80 80
         // layout_form_end
81 81
         $html .= apply_filters(
82
-            'FHEE__EE_Form_Section_Layout_Base__layout_form__end__for_' . $this->_form_section->name(),
82
+            'FHEE__EE_Form_Section_Layout_Base__layout_form__end__for_'.$this->_form_section->name(),
83 83
             $this->layout_form_end(),
84 84
             $this->_form_section
85 85
         );
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
100 100
             if ($subsection instanceof EE_Form_Input_Base) {
101 101
                 $html .= apply_filters(
102 102
                     'FHEE__EE_Form_Section_Layout_Base__layout_form__loop_for_input_'
103
-                    . $name . '__in_' . $this->_form_section->name(),
103
+                    . $name.'__in_'.$this->_form_section->name(),
104 104
                     $this->layout_input($subsection),
105 105
                     $this->_form_section,
106 106
                     $subsection
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
             } elseif ($subsection instanceof EE_Form_Section_Base) {
109 109
                 $html .= apply_filters(
110 110
                     'FHEE__EE_Form_Section_Layout_Base__layout_form__loop_for_non_input_'
111
-                    . $name . '__in_' . $this->_form_section->name(),
111
+                    . $name.'__in_'.$this->_form_section->name(),
112 112
                     $this->layout_subsection($subsection),
113 113
                     $this->_form_section,
114 114
                     $subsection
@@ -177,10 +177,10 @@  discard block
 block discarded – undo
177 177
             return '';
178 178
         }
179 179
         $class = $input->required()
180
-            ? 'ee-required-label ' . $input->html_label_class()
180
+            ? 'ee-required-label '.$input->html_label_class()
181 181
             : $input->html_label_class();
182 182
         $label_text = $input->required()
183
-            ? $input->html_label_text() . '<span class="ee-asterisk">*</span>'
183
+            ? $input->html_label_text().'<span class="ee-asterisk">*</span>'
184 184
             : $input->html_label_text();
185 185
         return '<label id="'
186 186
                . $input->html_label_id()
@@ -188,7 +188,7 @@  discard block
 block discarded – undo
188 188
                . $class
189 189
                . '" style="'
190 190
                . $input->html_label_style()
191
-               . '" for="' . $input->html_name()
191
+               . '" for="'.$input->html_name()
192 192
                . '">'
193 193
                . $label_text
194 194
                . '</label>';
@@ -210,7 +210,7 @@  discard block
 block discarded – undo
210 210
             // get all the errors on THIS form section (errors which aren't
211 211
             // for specific inputs, but instead for the entire form section)
212 212
             foreach ($this->_form_section->get_validation_errors() as $error) {
213
-                $html .= $error->getMessage() . '<br>';
213
+                $html .= $error->getMessage().'<br>';
214 214
             }
215 215
             $html .= '</div>';
216 216
         }
@@ -254,7 +254,7 @@  discard block
 block discarded – undo
254 254
      */
255 255
     public function display_help_text($input)
256 256
     {
257
-        $help_text  = $input->html_help_text();
257
+        $help_text = $input->html_help_text();
258 258
         if ($help_text !== '' && $help_text !== null) {
259 259
             $tag = is_admin() ? 'p' : 'span';
260 260
             return '<'
@@ -286,14 +286,14 @@  discard block
 block discarded – undo
286 286
     {
287 287
         // replace dashes and spaces with underscores
288 288
         $hook_name = str_replace(array('-', ' '), '_', $this->_form_section->html_id());
289
-        do_action('AHEE__Form_Section_Layout__' . $hook_name, $this->_form_section);
289
+        do_action('AHEE__Form_Section_Layout__'.$hook_name, $this->_form_section);
290 290
         $html = (string) apply_filters(
291
-            'AFEE__Form_Section_Layout__' . $hook_name . '__html',
291
+            'AFEE__Form_Section_Layout__'.$hook_name.'__html',
292 292
             $html,
293 293
             $this->_form_section
294 294
         );
295
-        $html .= EEH_HTML::nl() . '<!-- AHEE__Form_Section_Layout__' . $hook_name . '__html -->';
296
-        $html .= EEH_HTML::nl() . '<!-- AFEE__Form_Section_Layout__' . $hook_name . ' -->';
295
+        $html .= EEH_HTML::nl().'<!-- AHEE__Form_Section_Layout__'.$hook_name.'__html -->';
296
+        $html .= EEH_HTML::nl().'<!-- AFEE__Form_Section_Layout__'.$hook_name.' -->';
297 297
         return $html;
298 298
     }
299 299
 }
Please login to merge, or discard this patch.