Completed
Branch EDTRv1 (e80574)
by
unknown
18:21 queued 09:05
created
strategies/validation/EE_Max_Length_Validation_Strategy.strategy.php 2 patches
Indentation   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -11,39 +11,39 @@
 block discarded – undo
11 11
 class EE_Max_Length_Validation_Strategy extends EE_Validation_Strategy_Base
12 12
 {
13 13
 
14
-    protected $_max_length;
14
+	protected $_max_length;
15 15
 
16
-    public function __construct($validation_error_message = null, $max_length = EE_INF)
17
-    {
18
-        $this->_max_length = $max_length;
19
-        if ($validation_error_message === null) {
20
-            $validation_error_message = sprintf(__('Input is too long. Maximum number of characters is %1$s', 'event_espresso'), $max_length);
21
-        }
22
-        parent::__construct($validation_error_message);
23
-    }
16
+	public function __construct($validation_error_message = null, $max_length = EE_INF)
17
+	{
18
+		$this->_max_length = $max_length;
19
+		if ($validation_error_message === null) {
20
+			$validation_error_message = sprintf(__('Input is too long. Maximum number of characters is %1$s', 'event_espresso'), $max_length);
21
+		}
22
+		parent::__construct($validation_error_message);
23
+	}
24 24
 
25
-    /**
26
-     * @param $normalized_value
27
-     */
28
-    public function validate($normalized_value)
29
-    {
30
-        if ($this->_max_length !== EE_INF &&
31
-                $normalized_value &&
32
-                is_string($normalized_value) &&
33
-                 strlen($normalized_value) > $this->_max_length) {
34
-            throw new EE_Validation_Error($this->get_validation_error_message(), 'maxlength');
35
-        }
36
-    }
25
+	/**
26
+	 * @param $normalized_value
27
+	 */
28
+	public function validate($normalized_value)
29
+	{
30
+		if ($this->_max_length !== EE_INF &&
31
+				$normalized_value &&
32
+				is_string($normalized_value) &&
33
+				 strlen($normalized_value) > $this->_max_length) {
34
+			throw new EE_Validation_Error($this->get_validation_error_message(), 'maxlength');
35
+		}
36
+	}
37 37
 
38
-    /**
39
-     * @return array
40
-     */
41
-    public function get_jquery_validation_rule_array()
42
-    {
43
-        if ($this->_max_length !== EE_INF) {
44
-            return array( 'maxlength'=> $this->_max_length, 'messages' => array( 'maxlength' => $this->get_validation_error_message() ) );
45
-        } else {
46
-            return array();
47
-        }
48
-    }
38
+	/**
39
+	 * @return array
40
+	 */
41
+	public function get_jquery_validation_rule_array()
42
+	{
43
+		if ($this->_max_length !== EE_INF) {
44
+			return array( 'maxlength'=> $this->_max_length, 'messages' => array( 'maxlength' => $this->get_validation_error_message() ) );
45
+		} else {
46
+			return array();
47
+		}
48
+	}
49 49
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -41,7 +41,7 @@
 block discarded – undo
41 41
     public function get_jquery_validation_rule_array()
42 42
     {
43 43
         if ($this->_max_length !== EE_INF) {
44
-            return array( 'maxlength'=> $this->_max_length, 'messages' => array( 'maxlength' => $this->get_validation_error_message() ) );
44
+            return array('maxlength'=> $this->_max_length, 'messages' => array('maxlength' => $this->get_validation_error_message()));
45 45
         } else {
46 46
             return array();
47 47
         }
Please login to merge, or discard this patch.
strategies/validation/EE_Enum_Validation_Strategy.strategy.php 2 patches
Indentation   +46 added lines, -46 removed lines patch added patch discarded remove patch
@@ -11,51 +11,51 @@
 block discarded – undo
11 11
 class EE_Enum_Validation_Strategy extends EE_Validation_Strategy_Base
12 12
 {
13 13
 
14
-    /**
15
-     * Check that the value is in the allowed list
16
-     * @param $normalized_value
17
-     * @throws EE_Error
18
-     * @throws EE_Validation_Error
19
-     * @return boolean
20
-     */
21
-    public function validate($normalized_value)
22
-    {
23
-        parent::validate($normalized_value);
24
-        if (! $this->_input instanceof EE_Form_Input_With_Options_Base) {
25
-            throw new EE_Error(sprintf(__("Cannot use Enum Validation Strategy with an input that doesn't have options", "event_espresso")));
26
-        }
27
-        $enum_options = $this->_input->flat_options();
28
-        if ($normalized_value === true) {
29
-            $normalized_value = 1;
30
-        } elseif ($normalized_value === false) {
31
-            $normalized_value = 0;
32
-        }
33
-        if ($normalized_value !== null && ! array_key_exists($normalized_value, $enum_options)) {
34
-            throw new EE_Validation_Error(
35
-                $this->get_validation_error_message(),
36
-                'invalid_enum_value'
37
-            );
38
-        } else {
39
-            return true;
40
-        }
41
-    }
14
+	/**
15
+	 * Check that the value is in the allowed list
16
+	 * @param $normalized_value
17
+	 * @throws EE_Error
18
+	 * @throws EE_Validation_Error
19
+	 * @return boolean
20
+	 */
21
+	public function validate($normalized_value)
22
+	{
23
+		parent::validate($normalized_value);
24
+		if (! $this->_input instanceof EE_Form_Input_With_Options_Base) {
25
+			throw new EE_Error(sprintf(__("Cannot use Enum Validation Strategy with an input that doesn't have options", "event_espresso")));
26
+		}
27
+		$enum_options = $this->_input->flat_options();
28
+		if ($normalized_value === true) {
29
+			$normalized_value = 1;
30
+		} elseif ($normalized_value === false) {
31
+			$normalized_value = 0;
32
+		}
33
+		if ($normalized_value !== null && ! array_key_exists($normalized_value, $enum_options)) {
34
+			throw new EE_Validation_Error(
35
+				$this->get_validation_error_message(),
36
+				'invalid_enum_value'
37
+			);
38
+		} else {
39
+			return true;
40
+		}
41
+	}
42 42
 
43
-    /**
44
-     * If we are using the default validation error message, make it dynamic based
45
-     * on the allowed options.
46
-     * @return string
47
-     */
48
-    public function get_validation_error_message()
49
-    {
50
-        $parent_validation_error_message = parent::get_validation_error_message();
51
-        if (! $parent_validation_error_message) {
52
-            $enum_options = $this->_input instanceof EE_Form_Input_With_Options_Base ? $this->_input->flat_options() : '';
53
-            return sprintf(
54
-                __("This is not allowed option. Allowed options are %s.", "event_espresso"),
55
-                implode(', ', $enum_options)
56
-            );
57
-        } else {
58
-            return $parent_validation_error_message;
59
-        }
60
-    }
43
+	/**
44
+	 * If we are using the default validation error message, make it dynamic based
45
+	 * on the allowed options.
46
+	 * @return string
47
+	 */
48
+	public function get_validation_error_message()
49
+	{
50
+		$parent_validation_error_message = parent::get_validation_error_message();
51
+		if (! $parent_validation_error_message) {
52
+			$enum_options = $this->_input instanceof EE_Form_Input_With_Options_Base ? $this->_input->flat_options() : '';
53
+			return sprintf(
54
+				__("This is not allowed option. Allowed options are %s.", "event_espresso"),
55
+				implode(', ', $enum_options)
56
+			);
57
+		} else {
58
+			return $parent_validation_error_message;
59
+		}
60
+	}
61 61
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
     public function validate($normalized_value)
22 22
     {
23 23
         parent::validate($normalized_value);
24
-        if (! $this->_input instanceof EE_Form_Input_With_Options_Base) {
24
+        if ( ! $this->_input instanceof EE_Form_Input_With_Options_Base) {
25 25
             throw new EE_Error(sprintf(__("Cannot use Enum Validation Strategy with an input that doesn't have options", "event_espresso")));
26 26
         }
27 27
         $enum_options = $this->_input->flat_options();
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
     public function get_validation_error_message()
49 49
     {
50 50
         $parent_validation_error_message = parent::get_validation_error_message();
51
-        if (! $parent_validation_error_message) {
51
+        if ( ! $parent_validation_error_message) {
52 52
             $enum_options = $this->_input instanceof EE_Form_Input_With_Options_Base ? $this->_input->flat_options() : '';
53 53
             return sprintf(
54 54
                 __("This is not allowed option. Allowed options are %s.", "event_espresso"),
Please login to merge, or discard this patch.
strategies/validation/EE_Validation_Strategy_Base.strategy.php 1 patch
Indentation   +92 added lines, -92 removed lines patch added patch discarded remove patch
@@ -11,97 +11,97 @@
 block discarded – undo
11 11
 {
12 12
 
13 13
 
14
-    protected $_validation_error_message = '';
15
-
16
-
17
-
18
-    /**
19
-     * @param null $validation_error_message
20
-     */
21
-    public function __construct($validation_error_message = null)
22
-    {
23
-        $this->_validation_error_message = $validation_error_message === null
24
-            ? __('Input invalid', 'event_espresso')
25
-            : $validation_error_message;
26
-        parent::__construct();
27
-    }
28
-
29
-
30
-
31
-    /**
32
-     * Performs validation on the request data that corresponds to this field.
33
-     * If validation fails, should throw an EE_Validation_Error.
34
-     * Note: most validate() functions should allow $normalized_value to be empty,
35
-     * as its the job of the EE_Required_Validation_Strategy to ensure that the field isn't empty.
36
-     *
37
-     * @param mixed $normalized_value ready for validation. May very well be NULL (which, unless
38
-     *                                this validation strategy is the 'required' validation strategy,
39
-     *                                most should be OK with a null, empty string, etc)
40
-     */
41
-    public function validate($normalized_value)
42
-    {
43
-        // by default, the validation strategy does no validation. this should be implemented
44
-    }
45
-
46
-
47
-
48
-    /**
49
-     * Gets the JS code for use in the jQuery validation js corresponding to this field when displaying.
50
-     * For documentation, see http://jqueryvalidation.org/
51
-     * Eg to generate the following js for validation, <br><code>
52
-     *  $( "#myform" ).validate({
53
-     *      rules: {
54
-     *          field_name: {
55
-     *              required: true,
56
-     *              minlength: 3,
57
-     *              equalTo: "#password"
58
-     *          }
59
-     *      }
60
-     *  });
61
-     * </code>
62
-     * this function should return array('required'=>true,'minlength'=>3,'equalTo'=>'"#password"' ).
63
-     * This is done so that if we are applying multiple sanitization strategies to a field,
64
-     * we can easily combine them.
65
-     *
66
-     * @return array
67
-     */
68
-    public function get_jquery_validation_rule_array()
69
-    {
70
-        return array();
71
-    }
72
-
73
-
74
-
75
-    /**
76
-     * Gets the i18n validation error message for when this validation strategy finds
77
-     * the input is invalid. Used for both frontend and backend validation.
78
-     *
79
-     * @return string
80
-     */
81
-    public function get_validation_error_message()
82
-    {
83
-        return $this->_validation_error_message;
84
-    }
85
-
86
-
87
-
88
-    /**
89
-     * Adds js variables for localization to the $other_js_data. These should be put
90
-     * in each form's "other_data" javascript object.
91
-     *
92
-     * @param array $other_js_data
93
-     * @return array
94
-     */
95
-    public function get_other_js_data($other_js_data = array())
96
-    {
97
-        return $other_js_data;
98
-    }
14
+	protected $_validation_error_message = '';
15
+
16
+
17
+
18
+	/**
19
+	 * @param null $validation_error_message
20
+	 */
21
+	public function __construct($validation_error_message = null)
22
+	{
23
+		$this->_validation_error_message = $validation_error_message === null
24
+			? __('Input invalid', 'event_espresso')
25
+			: $validation_error_message;
26
+		parent::__construct();
27
+	}
28
+
29
+
30
+
31
+	/**
32
+	 * Performs validation on the request data that corresponds to this field.
33
+	 * If validation fails, should throw an EE_Validation_Error.
34
+	 * Note: most validate() functions should allow $normalized_value to be empty,
35
+	 * as its the job of the EE_Required_Validation_Strategy to ensure that the field isn't empty.
36
+	 *
37
+	 * @param mixed $normalized_value ready for validation. May very well be NULL (which, unless
38
+	 *                                this validation strategy is the 'required' validation strategy,
39
+	 *                                most should be OK with a null, empty string, etc)
40
+	 */
41
+	public function validate($normalized_value)
42
+	{
43
+		// by default, the validation strategy does no validation. this should be implemented
44
+	}
45
+
46
+
47
+
48
+	/**
49
+	 * Gets the JS code for use in the jQuery validation js corresponding to this field when displaying.
50
+	 * For documentation, see http://jqueryvalidation.org/
51
+	 * Eg to generate the following js for validation, <br><code>
52
+	 *  $( "#myform" ).validate({
53
+	 *      rules: {
54
+	 *          field_name: {
55
+	 *              required: true,
56
+	 *              minlength: 3,
57
+	 *              equalTo: "#password"
58
+	 *          }
59
+	 *      }
60
+	 *  });
61
+	 * </code>
62
+	 * this function should return array('required'=>true,'minlength'=>3,'equalTo'=>'"#password"' ).
63
+	 * This is done so that if we are applying multiple sanitization strategies to a field,
64
+	 * we can easily combine them.
65
+	 *
66
+	 * @return array
67
+	 */
68
+	public function get_jquery_validation_rule_array()
69
+	{
70
+		return array();
71
+	}
72
+
73
+
74
+
75
+	/**
76
+	 * Gets the i18n validation error message for when this validation strategy finds
77
+	 * the input is invalid. Used for both frontend and backend validation.
78
+	 *
79
+	 * @return string
80
+	 */
81
+	public function get_validation_error_message()
82
+	{
83
+		return $this->_validation_error_message;
84
+	}
85
+
86
+
87
+
88
+	/**
89
+	 * Adds js variables for localization to the $other_js_data. These should be put
90
+	 * in each form's "other_data" javascript object.
91
+	 *
92
+	 * @param array $other_js_data
93
+	 * @return array
94
+	 */
95
+	public function get_other_js_data($other_js_data = array())
96
+	{
97
+		return $other_js_data;
98
+	}
99 99
     
100
-    /**
101
-     * Opportunity for this display strategy to call wp_enqueue_script and wp_enqueue_style.
102
-     * This should be called during wp_enqueue_scripts
103
-     */
104
-    public function enqueue_js()
105
-    {
106
-    }
100
+	/**
101
+	 * Opportunity for this display strategy to call wp_enqueue_script and wp_enqueue_style.
102
+	 * This should be called during wp_enqueue_scripts
103
+	 */
104
+	public function enqueue_js()
105
+	{
106
+	}
107 107
 }
Please login to merge, or discard this patch.
sensitive_data_removal/EE_Credit_Card_Sensitive_Data_Removal.strategy.php 2 patches
Indentation   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -11,18 +11,18 @@
 block discarded – undo
11 11
  */
12 12
 class EE_Credit_Card_Sensitive_Data_Removal extends EE_Sensitive_Data_Removal_Base
13 13
 {
14
-    public function remove_sensitive_data($normalized_value)
15
-    {
16
-        // Get the cc Length
17
-        $cc_length = strlen($normalized_value);
18
-        // Replace all characters of credit card except the last four and dashes
19
-        for ($i=0; $i<$cc_length-4; $i++) {
20
-            if ($normalized_value[ $i ] == '-') {
21
-                continue;
22
-            }
23
-            $normalized_value[ $i ] = 'X';
24
-        }
25
-        // Return the masked Credit Card #
26
-        return $normalized_value;
27
-    }
14
+	public function remove_sensitive_data($normalized_value)
15
+	{
16
+		// Get the cc Length
17
+		$cc_length = strlen($normalized_value);
18
+		// Replace all characters of credit card except the last four and dashes
19
+		for ($i=0; $i<$cc_length-4; $i++) {
20
+			if ($normalized_value[ $i ] == '-') {
21
+				continue;
22
+			}
23
+			$normalized_value[ $i ] = 'X';
24
+		}
25
+		// Return the masked Credit Card #
26
+		return $normalized_value;
27
+	}
28 28
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -16,11 +16,11 @@
 block discarded – undo
16 16
         // Get the cc Length
17 17
         $cc_length = strlen($normalized_value);
18 18
         // Replace all characters of credit card except the last four and dashes
19
-        for ($i=0; $i<$cc_length-4; $i++) {
20
-            if ($normalized_value[ $i ] == '-') {
19
+        for ($i = 0; $i < $cc_length - 4; $i++) {
20
+            if ($normalized_value[$i] == '-') {
21 21
                 continue;
22 22
             }
23
-            $normalized_value[ $i ] = 'X';
23
+            $normalized_value[$i] = 'X';
24 24
         }
25 25
         // Return the masked Credit Card #
26 26
         return $normalized_value;
Please login to merge, or discard this patch.
sensitive_data_removal/EE_Sensitive_Data_Removal_Base.strategy.php 1 patch
Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -11,16 +11,16 @@
 block discarded – undo
11 11
  */
12 12
 abstract class EE_Sensitive_Data_Removal_Base extends EE_Form_Input_Strategy_Base
13 13
 {
14
-    /**
15
-     * Removes all the sensitive data from this normalized value.
16
-     * For example, should could 'mask' a credit card from
17
-     * '1234 1234 1234 1234' TO '**** **** **** 1234'.
18
-     * Or turn a ccv number from
19
-     * '123' to '***',
20
-     * or turn a password from
21
-     * 'CantHac7Th15' to '*************',
22
-     * or just leave htevalue as-is
23
-     * @return mixed
24
-     */
25
-    abstract public function remove_sensitive_data($normalized_value);
14
+	/**
15
+	 * Removes all the sensitive data from this normalized value.
16
+	 * For example, should could 'mask' a credit card from
17
+	 * '1234 1234 1234 1234' TO '**** **** **** 1234'.
18
+	 * Or turn a ccv number from
19
+	 * '123' to '***',
20
+	 * or turn a password from
21
+	 * 'CantHac7Th15' to '*************',
22
+	 * or just leave htevalue as-is
23
+	 * @return mixed
24
+	 */
25
+	abstract public function remove_sensitive_data($normalized_value);
26 26
 }
Please login to merge, or discard this patch.
sensitive_data_removal/EE_All_Sensitive_Data_Removal.strategy.php 1 patch
Indentation   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -11,23 +11,23 @@
 block discarded – undo
11 11
  */
12 12
 class EE_All_Sensitive_Data_Removal extends EE_Sensitive_Data_Removal_Base
13 13
 {
14
-    public function remove_sensitive_data($normalized_value)
15
-    {
16
-        switch (gettype($normalized_value)) {
17
-            case "boolean":
18
-                return false;
19
-            case "integer":
20
-            case "double":
21
-                return 0;
22
-            case "string":
23
-                return '';
24
-            case "array":
25
-                return array();
26
-            case "object":
27
-            case "resource":
28
-            case "NULL":
29
-            default:
30
-                return null;
31
-        }
32
-    }
14
+	public function remove_sensitive_data($normalized_value)
15
+	{
16
+		switch (gettype($normalized_value)) {
17
+			case "boolean":
18
+				return false;
19
+			case "integer":
20
+			case "double":
21
+				return 0;
22
+			case "string":
23
+				return '';
24
+			case "array":
25
+				return array();
26
+			case "object":
27
+			case "resource":
28
+			case "NULL":
29
+			default:
30
+				return null;
31
+		}
32
+	}
33 33
 }
Please login to merge, or discard this patch.
sensitive_data_removal/EE_CCV_Sensitive_Data_Removal.strategy.php 2 patches
Indentation   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -11,18 +11,18 @@
 block discarded – undo
11 11
  */
12 12
 class EE_CCV_Sensitive_Data_Removal extends EE_Sensitive_Data_Removal_Base
13 13
 {
14
-    public function remove_sensitive_data($normalized_value)
15
-    {
16
-        // Get the ccv Length
17
-        $ccv_lenght = strlen($normalized_value);
18
-        // Replace all characters of credit card except the last four and dashes
19
-        for ($i=0; $i<$ccv_lenght; $i++) {
20
-            if ($normalized_value[ $i ] == '-') {
21
-                continue;
22
-            }
23
-            $normalized_value[ $i ] = 'X';
24
-        }
25
-        // Return the masked Credit Card #
26
-        return $normalized_value;
27
-    }
14
+	public function remove_sensitive_data($normalized_value)
15
+	{
16
+		// Get the ccv Length
17
+		$ccv_lenght = strlen($normalized_value);
18
+		// Replace all characters of credit card except the last four and dashes
19
+		for ($i=0; $i<$ccv_lenght; $i++) {
20
+			if ($normalized_value[ $i ] == '-') {
21
+				continue;
22
+			}
23
+			$normalized_value[ $i ] = 'X';
24
+		}
25
+		// Return the masked Credit Card #
26
+		return $normalized_value;
27
+	}
28 28
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -16,11 +16,11 @@
 block discarded – undo
16 16
         // Get the ccv Length
17 17
         $ccv_lenght = strlen($normalized_value);
18 18
         // Replace all characters of credit card except the last four and dashes
19
-        for ($i=0; $i<$ccv_lenght; $i++) {
20
-            if ($normalized_value[ $i ] == '-') {
19
+        for ($i = 0; $i < $ccv_lenght; $i++) {
20
+            if ($normalized_value[$i] == '-') {
21 21
                 continue;
22 22
             }
23
-            $normalized_value[ $i ] = 'X';
23
+            $normalized_value[$i] = 'X';
24 24
         }
25 25
         // Return the masked Credit Card #
26 26
         return $normalized_value;
Please login to merge, or discard this patch.
strategies/sensitive_data_removal/EE_No_Sensitive_Data_Removal.strategy.php 1 patch
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -11,8 +11,8 @@
 block discarded – undo
11 11
  */
12 12
 class EE_No_Sensitive_Data_Removal extends EE_Sensitive_Data_Removal_Base
13 13
 {
14
-    public function remove_sensitive_data($normalized_value)
15
-    {
16
-        return $normalized_value;
17
-    }
14
+	public function remove_sensitive_data($normalized_value)
15
+	{
16
+		return $normalized_value;
17
+	}
18 18
 }
Please login to merge, or discard this patch.
core/libraries/form_sections/base/EE_Form_Section_Base.form.php 2 patches
Indentation   +476 added lines, -476 removed lines patch added patch discarded remove patch
@@ -15,486 +15,486 @@
 block discarded – undo
15 15
 abstract class EE_Form_Section_Base
16 16
 {
17 17
 
18
-    /**
19
-     * the URL the form is submitted to
20
-     *
21
-     * @var string
22
-     */
23
-    protected $_action;
24
-
25
-    /**
26
-     * POST (default) or GET
27
-     *
28
-     * @var string
29
-     */
30
-    protected $_method;
31
-
32
-    /**
33
-     * html_id and html_name are derived from this by default
34
-     *
35
-     * @var string
36
-     */
37
-    protected $_name;
38
-
39
-    /**
40
-     * $_html_id
41
-     * @var string
42
-     */
43
-    protected $_html_id;
44
-
45
-    /**
46
-     * $_html_class
47
-     * @var string
48
-     */
49
-    protected $_html_class;
50
-
51
-    /**
52
-     * $_html_style
53
-     * @var string
54
-     */
55
-    protected $_html_style;
56
-
57
-    /**
58
-     * $_other_html_attributes
59
-     * @var string
60
-     */
61
-    protected $_other_html_attributes;
62
-
63
-    /**
64
-     * The form section of which this form section is a part
65
-     *
66
-     * @var EE_Form_Section_Proper
67
-     */
68
-    protected $_parent_section;
69
-
70
-    /**
71
-     * flag indicating that _construct_finalize has been called.
72
-     * If it has not been called and we try to use functions which require it, we call it
73
-     * with no parameters. But normally, _construct_finalize should be called by the instantiating class
74
-     *
75
-     * @var boolean
76
-     */
77
-    protected $_construction_finalized;
78
-
79
-    /**
80
-     * Strategy for parsing the form HTML upon display
81
-     *
82
-     * @var FormHtmlFilter
83
-     */
84
-    protected $_form_html_filter;
85
-
86
-
87
-    /**
88
-     * @param array $options_array {
89
-     * @type        $name          string the name for this form section, if you want to explicitly define it
90
-     *                             }
91
-     * @throws InvalidDataTypeException
92
-     */
93
-    public function __construct($options_array = array())
94
-    {
95
-        // used by display strategies
96
-        // assign incoming values to properties
97
-        foreach ($options_array as $key => $value) {
98
-            $key = '_' . $key;
99
-            if (property_exists($this, $key) && empty($this->{$key})) {
100
-                $this->{$key} = $value;
101
-                if ($key === '_subsections' && ! is_array($value)) {
102
-                    throw new InvalidDataTypeException($key, $value, 'array');
103
-                }
104
-            }
105
-        }
106
-        // set parser which allows the form section's rendered HTML to be filtered
107
-        if (isset($options_array['form_html_filter']) && $options_array['form_html_filter'] instanceof FormHtmlFilter) {
108
-            $this->_form_html_filter = $options_array['form_html_filter'];
109
-        }
110
-    }
111
-
112
-
113
-
114
-    /**
115
-     * @param $parent_form_section
116
-     * @param $name
117
-     * @throws \EE_Error
118
-     */
119
-    protected function _construct_finalize($parent_form_section, $name)
120
-    {
121
-        $this->_construction_finalized = true;
122
-        $this->_parent_section = $parent_form_section;
123
-        if ($name !== null) {
124
-            $this->_name = $name;
125
-        }
126
-    }
127
-
128
-
129
-
130
-    /**
131
-     * make sure construction finalized was called, otherwise children might not be ready
132
-     *
133
-     * @return void
134
-     * @throws \EE_Error
135
-     */
136
-    public function ensure_construct_finalized_called()
137
-    {
138
-        if (! $this->_construction_finalized) {
139
-            $this->_construct_finalize($this->_parent_section, $this->_name);
140
-        }
141
-    }
142
-
143
-
144
-
145
-    /**
146
-     * @return string
147
-     */
148
-    public function action()
149
-    {
150
-        return $this->_action;
151
-    }
152
-
153
-
154
-
155
-    /**
156
-     * @param string $action
157
-     */
158
-    public function set_action($action)
159
-    {
160
-        $this->_action = $action;
161
-    }
162
-
163
-
164
-
165
-    /**
166
-     * @return string
167
-     */
168
-    public function method()
169
-    {
170
-        return ! empty($this->_method) ? $this->_method : 'POST';
171
-    }
172
-
173
-
174
-
175
-    /**
176
-     * @param string $method
177
-     */
178
-    public function set_method($method)
179
-    {
180
-        switch ($method) {
181
-            case 'get':
182
-            case 'GET':
183
-                $this->_method = 'GET';
184
-                break;
185
-            default:
186
-                $this->_method = 'POST';
187
-        }
188
-    }
189
-
190
-
191
-
192
-    /**
193
-     * Sets the html_id to its default value, if none was specified in the constructor.
194
-     * Calculation involves using the name and the parent's html id
195
-     * return void
196
-     *
197
-     * @throws \EE_Error
198
-     */
199
-    protected function _set_default_html_id_if_empty()
200
-    {
201
-        if (! $this->_html_id) {
202
-            if ($this->_parent_section && $this->_parent_section instanceof EE_Form_Section_Proper) {
203
-                $this->_html_id = $this->_parent_section->html_id()
204
-                                  . '-'
205
-                                  . $this->_prep_name_for_html_id($this->name());
206
-            } else {
207
-                $this->_html_id = $this->_prep_name_for_html_id($this->name());
208
-            }
209
-        }
210
-    }
211
-
212
-
213
-
214
-    /**
215
-     * _prep_name_for_html_id
216
-     *
217
-     * @param $name
218
-     * @return string
219
-     */
220
-    private function _prep_name_for_html_id($name)
221
-    {
222
-        return sanitize_key(str_replace(array('&nbsp;', ' ', '_'), '-', $name));
223
-    }
18
+	/**
19
+	 * the URL the form is submitted to
20
+	 *
21
+	 * @var string
22
+	 */
23
+	protected $_action;
24
+
25
+	/**
26
+	 * POST (default) or GET
27
+	 *
28
+	 * @var string
29
+	 */
30
+	protected $_method;
31
+
32
+	/**
33
+	 * html_id and html_name are derived from this by default
34
+	 *
35
+	 * @var string
36
+	 */
37
+	protected $_name;
38
+
39
+	/**
40
+	 * $_html_id
41
+	 * @var string
42
+	 */
43
+	protected $_html_id;
44
+
45
+	/**
46
+	 * $_html_class
47
+	 * @var string
48
+	 */
49
+	protected $_html_class;
50
+
51
+	/**
52
+	 * $_html_style
53
+	 * @var string
54
+	 */
55
+	protected $_html_style;
56
+
57
+	/**
58
+	 * $_other_html_attributes
59
+	 * @var string
60
+	 */
61
+	protected $_other_html_attributes;
62
+
63
+	/**
64
+	 * The form section of which this form section is a part
65
+	 *
66
+	 * @var EE_Form_Section_Proper
67
+	 */
68
+	protected $_parent_section;
69
+
70
+	/**
71
+	 * flag indicating that _construct_finalize has been called.
72
+	 * If it has not been called and we try to use functions which require it, we call it
73
+	 * with no parameters. But normally, _construct_finalize should be called by the instantiating class
74
+	 *
75
+	 * @var boolean
76
+	 */
77
+	protected $_construction_finalized;
78
+
79
+	/**
80
+	 * Strategy for parsing the form HTML upon display
81
+	 *
82
+	 * @var FormHtmlFilter
83
+	 */
84
+	protected $_form_html_filter;
85
+
86
+
87
+	/**
88
+	 * @param array $options_array {
89
+	 * @type        $name          string the name for this form section, if you want to explicitly define it
90
+	 *                             }
91
+	 * @throws InvalidDataTypeException
92
+	 */
93
+	public function __construct($options_array = array())
94
+	{
95
+		// used by display strategies
96
+		// assign incoming values to properties
97
+		foreach ($options_array as $key => $value) {
98
+			$key = '_' . $key;
99
+			if (property_exists($this, $key) && empty($this->{$key})) {
100
+				$this->{$key} = $value;
101
+				if ($key === '_subsections' && ! is_array($value)) {
102
+					throw new InvalidDataTypeException($key, $value, 'array');
103
+				}
104
+			}
105
+		}
106
+		// set parser which allows the form section's rendered HTML to be filtered
107
+		if (isset($options_array['form_html_filter']) && $options_array['form_html_filter'] instanceof FormHtmlFilter) {
108
+			$this->_form_html_filter = $options_array['form_html_filter'];
109
+		}
110
+	}
111
+
112
+
113
+
114
+	/**
115
+	 * @param $parent_form_section
116
+	 * @param $name
117
+	 * @throws \EE_Error
118
+	 */
119
+	protected function _construct_finalize($parent_form_section, $name)
120
+	{
121
+		$this->_construction_finalized = true;
122
+		$this->_parent_section = $parent_form_section;
123
+		if ($name !== null) {
124
+			$this->_name = $name;
125
+		}
126
+	}
127
+
128
+
129
+
130
+	/**
131
+	 * make sure construction finalized was called, otherwise children might not be ready
132
+	 *
133
+	 * @return void
134
+	 * @throws \EE_Error
135
+	 */
136
+	public function ensure_construct_finalized_called()
137
+	{
138
+		if (! $this->_construction_finalized) {
139
+			$this->_construct_finalize($this->_parent_section, $this->_name);
140
+		}
141
+	}
142
+
143
+
144
+
145
+	/**
146
+	 * @return string
147
+	 */
148
+	public function action()
149
+	{
150
+		return $this->_action;
151
+	}
152
+
153
+
154
+
155
+	/**
156
+	 * @param string $action
157
+	 */
158
+	public function set_action($action)
159
+	{
160
+		$this->_action = $action;
161
+	}
162
+
163
+
164
+
165
+	/**
166
+	 * @return string
167
+	 */
168
+	public function method()
169
+	{
170
+		return ! empty($this->_method) ? $this->_method : 'POST';
171
+	}
172
+
173
+
174
+
175
+	/**
176
+	 * @param string $method
177
+	 */
178
+	public function set_method($method)
179
+	{
180
+		switch ($method) {
181
+			case 'get':
182
+			case 'GET':
183
+				$this->_method = 'GET';
184
+				break;
185
+			default:
186
+				$this->_method = 'POST';
187
+		}
188
+	}
189
+
190
+
191
+
192
+	/**
193
+	 * Sets the html_id to its default value, if none was specified in the constructor.
194
+	 * Calculation involves using the name and the parent's html id
195
+	 * return void
196
+	 *
197
+	 * @throws \EE_Error
198
+	 */
199
+	protected function _set_default_html_id_if_empty()
200
+	{
201
+		if (! $this->_html_id) {
202
+			if ($this->_parent_section && $this->_parent_section instanceof EE_Form_Section_Proper) {
203
+				$this->_html_id = $this->_parent_section->html_id()
204
+								  . '-'
205
+								  . $this->_prep_name_for_html_id($this->name());
206
+			} else {
207
+				$this->_html_id = $this->_prep_name_for_html_id($this->name());
208
+			}
209
+		}
210
+	}
211
+
212
+
213
+
214
+	/**
215
+	 * _prep_name_for_html_id
216
+	 *
217
+	 * @param $name
218
+	 * @return string
219
+	 */
220
+	private function _prep_name_for_html_id($name)
221
+	{
222
+		return sanitize_key(str_replace(array('&nbsp;', ' ', '_'), '-', $name));
223
+	}
224 224
 
225 225
 
226 226
 
227
-    /**
228
-     * Returns the HTML, JS, and CSS necessary to display this form section on a page.
229
-     * Note however, it's recommended that you instead call enqueue_js on the "wp_enqueue_scripts" action,
230
-     * and call get_html when you want to output the html. Calling get_html_and_js after
231
-     * "wp_enqueue_scripts" has already fired seems to work for now, but is contrary
232
-     * to the instructions on https://developer.wordpress.org/reference/functions/wp_enqueue_script/
233
-     * and so might stop working anytime.
234
-     *
235
-     * @return string
236
-     */
237
-    public function get_html_and_js()
238
-    {
239
-        return $this->get_html();
240
-    }
227
+	/**
228
+	 * Returns the HTML, JS, and CSS necessary to display this form section on a page.
229
+	 * Note however, it's recommended that you instead call enqueue_js on the "wp_enqueue_scripts" action,
230
+	 * and call get_html when you want to output the html. Calling get_html_and_js after
231
+	 * "wp_enqueue_scripts" has already fired seems to work for now, but is contrary
232
+	 * to the instructions on https://developer.wordpress.org/reference/functions/wp_enqueue_script/
233
+	 * and so might stop working anytime.
234
+	 *
235
+	 * @return string
236
+	 */
237
+	public function get_html_and_js()
238
+	{
239
+		return $this->get_html();
240
+	}
241 241
 
242 242
 
243
-
244
-    /**
245
-     * Gets the HTML for displaying this form section
246
-     *
247
-     * @return string
248
-     */
249
-    abstract public function get_html();
250
-
251
-
252
-    /**
253
-     * @param bool $add_pound_sign
254
-     * @return string
255
-     * @throws EE_Error
256
-     */
257
-    public function html_id($add_pound_sign = false)
258
-    {
259
-        $this->_set_default_html_id_if_empty();
260
-        return $add_pound_sign ? '#' . $this->_html_id : $this->_html_id;
261
-    }
262
-
263
-
264
-
265
-    /**
266
-     * @return string
267
-     */
268
-    public function html_class()
269
-    {
270
-        return $this->_html_class;
271
-    }
272
-
273
-
274
-
275
-    /**
276
-     * @return string
277
-     */
278
-    public function html_style()
279
-    {
280
-        return $this->_html_style;
281
-    }
282
-
283
-
284
-
285
-    /**
286
-     * @param mixed $html_class
287
-     */
288
-    public function set_html_class($html_class)
289
-    {
290
-        $this->_html_class = $html_class;
291
-    }
292
-
293
-
294
-
295
-    /**
296
-     * @param mixed $html_id
297
-     */
298
-    public function set_html_id($html_id)
299
-    {
300
-        $this->_html_id = $html_id;
301
-    }
302
-
303
-
304
-
305
-    /**
306
-     * @param mixed $html_style
307
-     */
308
-    public function set_html_style($html_style)
309
-    {
310
-        $this->_html_style = $html_style;
311
-    }
312
-
313
-
314
-
315
-    /**
316
-     * @param string $other_html_attributes
317
-     */
318
-    public function set_other_html_attributes($other_html_attributes)
319
-    {
320
-        $this->_other_html_attributes = $other_html_attributes;
321
-    }
322
-
323
-
324
-
325
-    /**
326
-     * @return string
327
-     */
328
-    public function other_html_attributes()
329
-    {
330
-        return $this->_other_html_attributes;
331
-    }
332
-
333
-
334
-
335
-    /**
336
-     * Gets the name of the form section. This is not the same as the HTML name.
337
-     *
338
-     * @throws EE_Error
339
-     * @return string
340
-     */
341
-    public function name()
342
-    {
343
-        if (! $this->_construction_finalized) {
344
-            throw new EE_Error(sprintf(__(
345
-                'You cannot use the form section\s name until _construct_finalize has been called on it (when we set the name). It was called on a form section of type \'s\'',
346
-                'event_espresso'
347
-            ), get_class($this)));
348
-        }
349
-        return $this->_name;
350
-    }
351
-
352
-
353
-
354
-    /**
355
-     * Gets the parent section
356
-     *
357
-     * @return EE_Form_Section_Proper
358
-     */
359
-    public function parent_section()
360
-    {
361
-        return $this->_parent_section;
362
-    }
363
-
364
-
365
-    /**
366
-     * returns HTML for generating the opening form HTML tag (<form>)
367
-     *
368
-     * @param string $action           the URL the form is submitted to
369
-     * @param string $method           POST (default) or GET
370
-     * @param string $other_attributes anything else added to the form open tag, MUST BE VALID HTML
371
-     * @return string
372
-     * @throws EE_Error
373
-     */
374
-    public function form_open($action = '', $method = '', $other_attributes = '')
375
-    {
376
-        if (! empty($action)) {
377
-            $this->set_action($action);
378
-        }
379
-        if (! empty($method)) {
380
-            $this->set_method($method);
381
-        }
382
-        $html = EEH_HTML::nl(1, 'form') . '<form';
383
-        $html .= $this->html_id() !== '' ? ' id="' . $this->get_html_id_for_form($this->html_id()) . '"' : '';
384
-        $html .= ' action="' . $this->action() . '"';
385
-        $html .= ' method="' . $this->method() . '"';
386
-        $html .= ' name="' . $this->name() . '"';
387
-        $html .= $other_attributes . '>';
388
-        return $html;
389
-    }
390
-
391
-
392
-
393
-    /**
394
-     * ensures that html id for form either ends in "-form" or "-frm"
395
-     * so that id doesn't conflict/collide with other elements
396
-     *
397
-     * @param string $html_id
398
-     * @return string
399
-     */
400
-    protected function get_html_id_for_form($html_id)
401
-    {
402
-        $strlen = strlen($html_id);
403
-        $html_id = strpos($html_id, '-form') === $strlen-5 || strpos($html_id, '-frm') === $strlen - 4
404
-            ? $html_id
405
-            : $html_id . '-frm';
406
-        return $html_id;
407
-    }
408
-
409
-
410
-    /**
411
-     * returns HTML for generating the closing form HTML tag (</form>)
412
-     *
413
-     * @return string
414
-     * @throws EE_Error
415
-     */
416
-    public function form_close()
417
-    {
418
-        return EEH_HTML::nl(-1, 'form')
419
-               . '</form>'
420
-               . EEH_HTML::nl()
421
-               . '<!-- end of ee-'
422
-               . $this->html_id()
423
-               . '-form -->'
424
-               . EEH_HTML::nl();
425
-    }
426
-
427
-
428
-
429
-    /**
430
-     * enqueues JS (and CSS) for the form (ie immediately call wp_enqueue_script and
431
-     * wp_enqueue_style; the scripts could have optionally been registered earlier)
432
-     * Default does nothing, but child classes can override
433
-     *
434
-     * @return void
435
-     */
436
-    public function enqueue_js()
437
-    {
438
-        // defaults to enqueue NO js or css
439
-    }
440
-
441
-
442
-
443
-    /**
444
-     * Adds any extra data needed by js. Eventually we'll call wp_localize_script
445
-     * with it, and it will be on each form section's 'other_data' property.
446
-     * By default nothing is added, but child classes can extend this method to add something.
447
-     * Eg, if you have an input that will cause a modal dialog to appear,
448
-     * here you could add an entry like 'modal_dialog_inputs' to this array
449
-     * to map between the input's html ID and the modal dialogue's ID, so that
450
-     * your JS code will know where to find the modal dialog when the input is pressed.
451
-     * Eg $form_other_js_data['modal_dialog_inputs']['some-input-id']='modal-dialog-id';
452
-     *
453
-     * @param array $form_other_js_data
454
-     * @return array
455
-     */
456
-    public function get_other_js_data($form_other_js_data = array())
457
-    {
458
-        return $form_other_js_data;
459
-    }
460
-
461
-
462
-
463
-    /**
464
-     * This isn't just the name of an input, it's a path pointing to an input. The
465
-     * path is similar to a folder path: slash (/) means to descend into a subsection,
466
-     * dot-dot-slash (../) means to ascend into the parent section.
467
-     * After a series of slashes and dot-dot-slashes, there should be the name of an input,
468
-     * which will be returned.
469
-     * Eg, if you want the related input to be conditional on a sibling input name 'foobar'
470
-     * just use 'foobar'. If you want it to be conditional on an aunt/uncle input name
471
-     * 'baz', use '../baz'. If you want it to be conditional on a cousin input,
472
-     * the child of 'baz_section' named 'baz_child', use '../baz_section/baz_child'.
473
-     * Etc
474
-     *
475
-     * @param string|false $form_section_path we accept false also because substr( '../', '../' ) = false
476
-     * @return EE_Form_Section_Base
477
-     */
478
-    public function find_section_from_path($form_section_path)
479
-    {
480
-        if (strpos($form_section_path, '/') === 0) {
481
-            $form_section_path = substr($form_section_path, strlen('/'));
482
-        }
483
-        if (empty($form_section_path)) {
484
-            return $this;
485
-        }
486
-        if (strpos($form_section_path, '../') === 0) {
487
-            $parent = $this->parent_section();
488
-            $form_section_path = substr($form_section_path, strlen('../'));
489
-            if ($parent instanceof EE_Form_Section_Base) {
490
-                return $parent->find_section_from_path($form_section_path);
491
-            }
492
-            if (empty($form_section_path)) {
493
-                return $this;
494
-            }
495
-        }
496
-        // couldn't find it using simple parent following
497
-        return null;
498
-    }
243
+
244
+	/**
245
+	 * Gets the HTML for displaying this form section
246
+	 *
247
+	 * @return string
248
+	 */
249
+	abstract public function get_html();
250
+
251
+
252
+	/**
253
+	 * @param bool $add_pound_sign
254
+	 * @return string
255
+	 * @throws EE_Error
256
+	 */
257
+	public function html_id($add_pound_sign = false)
258
+	{
259
+		$this->_set_default_html_id_if_empty();
260
+		return $add_pound_sign ? '#' . $this->_html_id : $this->_html_id;
261
+	}
262
+
263
+
264
+
265
+	/**
266
+	 * @return string
267
+	 */
268
+	public function html_class()
269
+	{
270
+		return $this->_html_class;
271
+	}
272
+
273
+
274
+
275
+	/**
276
+	 * @return string
277
+	 */
278
+	public function html_style()
279
+	{
280
+		return $this->_html_style;
281
+	}
282
+
283
+
284
+
285
+	/**
286
+	 * @param mixed $html_class
287
+	 */
288
+	public function set_html_class($html_class)
289
+	{
290
+		$this->_html_class = $html_class;
291
+	}
292
+
293
+
294
+
295
+	/**
296
+	 * @param mixed $html_id
297
+	 */
298
+	public function set_html_id($html_id)
299
+	{
300
+		$this->_html_id = $html_id;
301
+	}
302
+
303
+
304
+
305
+	/**
306
+	 * @param mixed $html_style
307
+	 */
308
+	public function set_html_style($html_style)
309
+	{
310
+		$this->_html_style = $html_style;
311
+	}
312
+
313
+
314
+
315
+	/**
316
+	 * @param string $other_html_attributes
317
+	 */
318
+	public function set_other_html_attributes($other_html_attributes)
319
+	{
320
+		$this->_other_html_attributes = $other_html_attributes;
321
+	}
322
+
323
+
324
+
325
+	/**
326
+	 * @return string
327
+	 */
328
+	public function other_html_attributes()
329
+	{
330
+		return $this->_other_html_attributes;
331
+	}
332
+
333
+
334
+
335
+	/**
336
+	 * Gets the name of the form section. This is not the same as the HTML name.
337
+	 *
338
+	 * @throws EE_Error
339
+	 * @return string
340
+	 */
341
+	public function name()
342
+	{
343
+		if (! $this->_construction_finalized) {
344
+			throw new EE_Error(sprintf(__(
345
+				'You cannot use the form section\s name until _construct_finalize has been called on it (when we set the name). It was called on a form section of type \'s\'',
346
+				'event_espresso'
347
+			), get_class($this)));
348
+		}
349
+		return $this->_name;
350
+	}
351
+
352
+
353
+
354
+	/**
355
+	 * Gets the parent section
356
+	 *
357
+	 * @return EE_Form_Section_Proper
358
+	 */
359
+	public function parent_section()
360
+	{
361
+		return $this->_parent_section;
362
+	}
363
+
364
+
365
+	/**
366
+	 * returns HTML for generating the opening form HTML tag (<form>)
367
+	 *
368
+	 * @param string $action           the URL the form is submitted to
369
+	 * @param string $method           POST (default) or GET
370
+	 * @param string $other_attributes anything else added to the form open tag, MUST BE VALID HTML
371
+	 * @return string
372
+	 * @throws EE_Error
373
+	 */
374
+	public function form_open($action = '', $method = '', $other_attributes = '')
375
+	{
376
+		if (! empty($action)) {
377
+			$this->set_action($action);
378
+		}
379
+		if (! empty($method)) {
380
+			$this->set_method($method);
381
+		}
382
+		$html = EEH_HTML::nl(1, 'form') . '<form';
383
+		$html .= $this->html_id() !== '' ? ' id="' . $this->get_html_id_for_form($this->html_id()) . '"' : '';
384
+		$html .= ' action="' . $this->action() . '"';
385
+		$html .= ' method="' . $this->method() . '"';
386
+		$html .= ' name="' . $this->name() . '"';
387
+		$html .= $other_attributes . '>';
388
+		return $html;
389
+	}
390
+
391
+
392
+
393
+	/**
394
+	 * ensures that html id for form either ends in "-form" or "-frm"
395
+	 * so that id doesn't conflict/collide with other elements
396
+	 *
397
+	 * @param string $html_id
398
+	 * @return string
399
+	 */
400
+	protected function get_html_id_for_form($html_id)
401
+	{
402
+		$strlen = strlen($html_id);
403
+		$html_id = strpos($html_id, '-form') === $strlen-5 || strpos($html_id, '-frm') === $strlen - 4
404
+			? $html_id
405
+			: $html_id . '-frm';
406
+		return $html_id;
407
+	}
408
+
409
+
410
+	/**
411
+	 * returns HTML for generating the closing form HTML tag (</form>)
412
+	 *
413
+	 * @return string
414
+	 * @throws EE_Error
415
+	 */
416
+	public function form_close()
417
+	{
418
+		return EEH_HTML::nl(-1, 'form')
419
+			   . '</form>'
420
+			   . EEH_HTML::nl()
421
+			   . '<!-- end of ee-'
422
+			   . $this->html_id()
423
+			   . '-form -->'
424
+			   . EEH_HTML::nl();
425
+	}
426
+
427
+
428
+
429
+	/**
430
+	 * enqueues JS (and CSS) for the form (ie immediately call wp_enqueue_script and
431
+	 * wp_enqueue_style; the scripts could have optionally been registered earlier)
432
+	 * Default does nothing, but child classes can override
433
+	 *
434
+	 * @return void
435
+	 */
436
+	public function enqueue_js()
437
+	{
438
+		// defaults to enqueue NO js or css
439
+	}
440
+
441
+
442
+
443
+	/**
444
+	 * Adds any extra data needed by js. Eventually we'll call wp_localize_script
445
+	 * with it, and it will be on each form section's 'other_data' property.
446
+	 * By default nothing is added, but child classes can extend this method to add something.
447
+	 * Eg, if you have an input that will cause a modal dialog to appear,
448
+	 * here you could add an entry like 'modal_dialog_inputs' to this array
449
+	 * to map between the input's html ID and the modal dialogue's ID, so that
450
+	 * your JS code will know where to find the modal dialog when the input is pressed.
451
+	 * Eg $form_other_js_data['modal_dialog_inputs']['some-input-id']='modal-dialog-id';
452
+	 *
453
+	 * @param array $form_other_js_data
454
+	 * @return array
455
+	 */
456
+	public function get_other_js_data($form_other_js_data = array())
457
+	{
458
+		return $form_other_js_data;
459
+	}
460
+
461
+
462
+
463
+	/**
464
+	 * This isn't just the name of an input, it's a path pointing to an input. The
465
+	 * path is similar to a folder path: slash (/) means to descend into a subsection,
466
+	 * dot-dot-slash (../) means to ascend into the parent section.
467
+	 * After a series of slashes and dot-dot-slashes, there should be the name of an input,
468
+	 * which will be returned.
469
+	 * Eg, if you want the related input to be conditional on a sibling input name 'foobar'
470
+	 * just use 'foobar'. If you want it to be conditional on an aunt/uncle input name
471
+	 * 'baz', use '../baz'. If you want it to be conditional on a cousin input,
472
+	 * the child of 'baz_section' named 'baz_child', use '../baz_section/baz_child'.
473
+	 * Etc
474
+	 *
475
+	 * @param string|false $form_section_path we accept false also because substr( '../', '../' ) = false
476
+	 * @return EE_Form_Section_Base
477
+	 */
478
+	public function find_section_from_path($form_section_path)
479
+	{
480
+		if (strpos($form_section_path, '/') === 0) {
481
+			$form_section_path = substr($form_section_path, strlen('/'));
482
+		}
483
+		if (empty($form_section_path)) {
484
+			return $this;
485
+		}
486
+		if (strpos($form_section_path, '../') === 0) {
487
+			$parent = $this->parent_section();
488
+			$form_section_path = substr($form_section_path, strlen('../'));
489
+			if ($parent instanceof EE_Form_Section_Base) {
490
+				return $parent->find_section_from_path($form_section_path);
491
+			}
492
+			if (empty($form_section_path)) {
493
+				return $this;
494
+			}
495
+		}
496
+		// couldn't find it using simple parent following
497
+		return null;
498
+	}
499 499
 }
500 500
 // End of file EE_Form_Section_Base.form.php
Please login to merge, or discard this patch.
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
         // used by display strategies
96 96
         // assign incoming values to properties
97 97
         foreach ($options_array as $key => $value) {
98
-            $key = '_' . $key;
98
+            $key = '_'.$key;
99 99
             if (property_exists($this, $key) && empty($this->{$key})) {
100 100
                 $this->{$key} = $value;
101 101
                 if ($key === '_subsections' && ! is_array($value)) {
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
      */
136 136
     public function ensure_construct_finalized_called()
137 137
     {
138
-        if (! $this->_construction_finalized) {
138
+        if ( ! $this->_construction_finalized) {
139 139
             $this->_construct_finalize($this->_parent_section, $this->_name);
140 140
         }
141 141
     }
@@ -198,7 +198,7 @@  discard block
 block discarded – undo
198 198
      */
199 199
     protected function _set_default_html_id_if_empty()
200 200
     {
201
-        if (! $this->_html_id) {
201
+        if ( ! $this->_html_id) {
202 202
             if ($this->_parent_section && $this->_parent_section instanceof EE_Form_Section_Proper) {
203 203
                 $this->_html_id = $this->_parent_section->html_id()
204 204
                                   . '-'
@@ -257,7 +257,7 @@  discard block
 block discarded – undo
257 257
     public function html_id($add_pound_sign = false)
258 258
     {
259 259
         $this->_set_default_html_id_if_empty();
260
-        return $add_pound_sign ? '#' . $this->_html_id : $this->_html_id;
260
+        return $add_pound_sign ? '#'.$this->_html_id : $this->_html_id;
261 261
     }
262 262
 
263 263
 
@@ -340,7 +340,7 @@  discard block
 block discarded – undo
340 340
      */
341 341
     public function name()
342 342
     {
343
-        if (! $this->_construction_finalized) {
343
+        if ( ! $this->_construction_finalized) {
344 344
             throw new EE_Error(sprintf(__(
345 345
                 'You cannot use the form section\s name until _construct_finalize has been called on it (when we set the name). It was called on a form section of type \'s\'',
346 346
                 'event_espresso'
@@ -373,18 +373,18 @@  discard block
 block discarded – undo
373 373
      */
374 374
     public function form_open($action = '', $method = '', $other_attributes = '')
375 375
     {
376
-        if (! empty($action)) {
376
+        if ( ! empty($action)) {
377 377
             $this->set_action($action);
378 378
         }
379
-        if (! empty($method)) {
379
+        if ( ! empty($method)) {
380 380
             $this->set_method($method);
381 381
         }
382
-        $html = EEH_HTML::nl(1, 'form') . '<form';
383
-        $html .= $this->html_id() !== '' ? ' id="' . $this->get_html_id_for_form($this->html_id()) . '"' : '';
384
-        $html .= ' action="' . $this->action() . '"';
385
-        $html .= ' method="' . $this->method() . '"';
386
-        $html .= ' name="' . $this->name() . '"';
387
-        $html .= $other_attributes . '>';
382
+        $html = EEH_HTML::nl(1, 'form').'<form';
383
+        $html .= $this->html_id() !== '' ? ' id="'.$this->get_html_id_for_form($this->html_id()).'"' : '';
384
+        $html .= ' action="'.$this->action().'"';
385
+        $html .= ' method="'.$this->method().'"';
386
+        $html .= ' name="'.$this->name().'"';
387
+        $html .= $other_attributes.'>';
388 388
         return $html;
389 389
     }
390 390
 
@@ -400,9 +400,9 @@  discard block
 block discarded – undo
400 400
     protected function get_html_id_for_form($html_id)
401 401
     {
402 402
         $strlen = strlen($html_id);
403
-        $html_id = strpos($html_id, '-form') === $strlen-5 || strpos($html_id, '-frm') === $strlen - 4
403
+        $html_id = strpos($html_id, '-form') === $strlen - 5 || strpos($html_id, '-frm') === $strlen - 4
404 404
             ? $html_id
405
-            : $html_id . '-frm';
405
+            : $html_id.'-frm';
406 406
         return $html_id;
407 407
     }
408 408
 
Please login to merge, or discard this patch.