@@ -57,11 +57,11 @@ |
||
57 | 57 | } |
58 | 58 | if( $field_obj instanceof \EE_Boolean_Field ) { |
59 | 59 | $datatype = 'Boolean'; |
60 | - }elseif( $field_obj->get_wpdb_data_type() == '%d' ) { |
|
60 | + } elseif( $field_obj->get_wpdb_data_type() == '%d' ) { |
|
61 | 61 | $datatype = 'Number'; |
62 | - }elseif( $field_name instanceof \EE_Serialized_Text_Field ) { |
|
62 | + } elseif( $field_name instanceof \EE_Serialized_Text_Field ) { |
|
63 | 63 | $datatype = 'Object'; |
64 | - }else{ |
|
64 | + } else{ |
|
65 | 65 | $datatype = 'String'; |
66 | 66 | } |
67 | 67 | $default_value = Model_Data_Translator::prepare_field_value_for_json( |
@@ -3,8 +3,8 @@ discard block |
||
3 | 3 | |
4 | 4 | use EventEspresso\core\libraries\rest_api\Model_Data_Translator; |
5 | 5 | |
6 | -if ( !defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
7 | - exit( 'No direct script access allowed' ); |
|
6 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
7 | + exit('No direct script access allowed'); |
|
8 | 8 | } |
9 | 9 | |
10 | 10 | /** |
@@ -25,20 +25,20 @@ discard block |
||
25 | 25 | * @param \WP_REST_Request $request |
26 | 26 | * @return array|\WP_REST_Response |
27 | 27 | */ |
28 | - public static function handle_request_models_meta( \WP_REST_Request $request ) { |
|
28 | + public static function handle_request_models_meta(\WP_REST_Request $request) { |
|
29 | 29 | $controller = new Meta(); |
30 | - try{ |
|
30 | + try { |
|
31 | 31 | $matches = $controller->parse_route( |
32 | 32 | $request->get_route(), |
33 | - '~' . \EED_Core_Rest_Api::ee_api_namespace_for_regex . 'resources~', |
|
34 | - array( 'version' ) ); |
|
35 | - if( $matches instanceof \WP_REST_Response ) { |
|
33 | + '~'.\EED_Core_Rest_Api::ee_api_namespace_for_regex.'resources~', |
|
34 | + array('version') ); |
|
35 | + if ($matches instanceof \WP_REST_Response) { |
|
36 | 36 | return $matches; |
37 | 37 | } |
38 | - $controller->set_requested_version( $matches[ 'version' ] ); |
|
39 | - return $controller->send_response( $controller->_get_models_metadata_entity() ); |
|
40 | - } catch( \Exception $e ) { |
|
41 | - return $controller->send_response( $e ); |
|
38 | + $controller->set_requested_version($matches['version']); |
|
39 | + return $controller->send_response($controller->_get_models_metadata_entity()); |
|
40 | + } catch (\Exception $e) { |
|
41 | + return $controller->send_response($e); |
|
42 | 42 | } |
43 | 43 | } |
44 | 44 | |
@@ -46,22 +46,22 @@ discard block |
||
46 | 46 | * Gets the model metadata resource entity |
47 | 47 | * @return array for JSON response, describing all the models available in teh requested version |
48 | 48 | */ |
49 | - protected function _get_models_metadata_entity(){ |
|
49 | + protected function _get_models_metadata_entity() { |
|
50 | 50 | $response = array(); |
51 | - foreach( $this->get_model_version_info()->models_for_requested_version() as $model_name => $model_classname ){ |
|
52 | - $model = $this->get_model_version_info()->load_model( $model_name ); |
|
51 | + foreach ($this->get_model_version_info()->models_for_requested_version() as $model_name => $model_classname) { |
|
52 | + $model = $this->get_model_version_info()->load_model($model_name); |
|
53 | 53 | $fields_json = array(); |
54 | - foreach( $this->get_model_version_info()->fields_on_model_in_this_version( $model ) as $field_name => $field_obj ) { |
|
55 | - if( $this->get_model_version_info()->field_is_ignored( $field_obj ) ) { |
|
54 | + foreach ($this->get_model_version_info()->fields_on_model_in_this_version($model) as $field_name => $field_obj) { |
|
55 | + if ($this->get_model_version_info()->field_is_ignored($field_obj)) { |
|
56 | 56 | continue; |
57 | 57 | } |
58 | - if( $field_obj instanceof \EE_Boolean_Field ) { |
|
58 | + if ($field_obj instanceof \EE_Boolean_Field) { |
|
59 | 59 | $datatype = 'Boolean'; |
60 | - }elseif( $field_obj->get_wpdb_data_type() == '%d' ) { |
|
60 | + }elseif ($field_obj->get_wpdb_data_type() == '%d') { |
|
61 | 61 | $datatype = 'Number'; |
62 | - }elseif( $field_name instanceof \EE_Serialized_Text_Field ) { |
|
62 | + }elseif ($field_name instanceof \EE_Serialized_Text_Field) { |
|
63 | 63 | $datatype = 'Object'; |
64 | - }else{ |
|
64 | + } else { |
|
65 | 65 | $datatype = 'String'; |
66 | 66 | } |
67 | 67 | $default_value = Model_Data_Translator::prepare_field_value_for_json( |
@@ -72,30 +72,30 @@ discard block |
||
72 | 72 | $field_json = array( |
73 | 73 | 'name' => $field_name, |
74 | 74 | 'nicename' => $field_obj->get_nicename(), |
75 | - 'has_rendered_format' => $this->get_model_version_info()->field_has_rendered_format( $field_obj ), |
|
76 | - 'has_pretty_format' => $this->get_model_version_info()->field_has_pretty_format( $field_obj ), |
|
77 | - 'type' => str_replace('EE_', '', get_class( $field_obj ) ), |
|
75 | + 'has_rendered_format' => $this->get_model_version_info()->field_has_rendered_format($field_obj), |
|
76 | + 'has_pretty_format' => $this->get_model_version_info()->field_has_pretty_format($field_obj), |
|
77 | + 'type' => str_replace('EE_', '', get_class($field_obj)), |
|
78 | 78 | 'datatype' => $datatype, |
79 | 79 | 'nullable' => $field_obj->is_nullable(), |
80 | 80 | 'default' => $default_value, |
81 | 81 | 'table_alias' => $field_obj->get_table_alias(), |
82 | 82 | 'table_column' => $field_obj->get_table_column(), |
83 | 83 | ); |
84 | - $fields_json[ $field_json[ 'name' ] ] = $field_json; |
|
84 | + $fields_json[$field_json['name']] = $field_json; |
|
85 | 85 | |
86 | 86 | } |
87 | - $fields_json = array_merge( $fields_json, $this->get_model_version_info()->extra_resource_properties_for_model( $model ) ); |
|
88 | - $response[ $model_name ]['fields'] = apply_filters( 'FHEE__Meta__handle_request_models_meta__fields', $fields_json, $model ); |
|
87 | + $fields_json = array_merge($fields_json, $this->get_model_version_info()->extra_resource_properties_for_model($model)); |
|
88 | + $response[$model_name]['fields'] = apply_filters('FHEE__Meta__handle_request_models_meta__fields', $fields_json, $model); |
|
89 | 89 | $relations_json = array(); |
90 | - foreach( $model->relation_settings() as $relation_name => $relation_obj ) { |
|
90 | + foreach ($model->relation_settings() as $relation_name => $relation_obj) { |
|
91 | 91 | $relation_json = array( |
92 | 92 | 'name' => $relation_name, |
93 | - 'type' => str_replace( 'EE_', '', get_class( $relation_obj ) ), |
|
93 | + 'type' => str_replace('EE_', '', get_class($relation_obj)), |
|
94 | 94 | 'single' => $relation_obj instanceof \EE_Belongs_To_Relation ? true : false, |
95 | 95 | ); |
96 | - $relations_json[ $relation_name ] = $relation_json; |
|
96 | + $relations_json[$relation_name] = $relation_json; |
|
97 | 97 | } |
98 | - $response[ $model_name ][ 'relations' ] = apply_filters( 'FHEE__Meta__handle_request_models_meta__relations', $relations_json, $model ); |
|
98 | + $response[$model_name]['relations'] = apply_filters('FHEE__Meta__handle_request_models_meta__relations', $relations_json, $model); |
|
99 | 99 | } |
100 | 100 | return $response; |
101 | 101 | } |
@@ -105,24 +105,24 @@ discard block |
||
105 | 105 | * @param \WP_REST_Response $rest_response_obj |
106 | 106 | * @return \WP_REST_Response |
107 | 107 | */ |
108 | - public static function filter_ee_metadata_into_index( \WP_REST_Response $rest_response_obj ) { |
|
108 | + public static function filter_ee_metadata_into_index(\WP_REST_Response $rest_response_obj) { |
|
109 | 109 | $response_data = $rest_response_obj->get_data(); |
110 | 110 | $addons = array(); |
111 | - foreach( \EE_Registry::instance()->addons as $addon){ |
|
111 | + foreach (\EE_Registry::instance()->addons as $addon) { |
|
112 | 112 | $addon_json = array( |
113 | 113 | 'name' => $addon->name(), |
114 | 114 | 'version' => $addon->version() |
115 | 115 | ); |
116 | - $addons[ $addon_json[ 'name' ] ] = $addon_json; |
|
116 | + $addons[$addon_json['name']] = $addon_json; |
|
117 | 117 | } |
118 | - $response_data[ 'ee' ] = array( |
|
118 | + $response_data['ee'] = array( |
|
119 | 119 | 'version' => \EEM_System_Status::instance()->get_ee_version(), |
120 | 120 | 'documentation_url' => 'https://github.com/eventespresso/event-espresso-core/tree/master/docs/C--REST-API', |
121 | 121 | 'addons' => $addons, |
122 | 122 | 'maintenance_mode' => \EE_Maintenance_Mode::instance()->real_level(), |
123 | - 'served_core_versions' => array_keys( \EED_Core_Rest_Api::versions_served() ) |
|
123 | + 'served_core_versions' => array_keys(\EED_Core_Rest_Api::versions_served()) |
|
124 | 124 | ); |
125 | - $rest_response_obj->set_data( $response_data ); |
|
125 | + $rest_response_obj->set_data($response_data); |
|
126 | 126 | return $rest_response_obj; |
127 | 127 | } |
128 | 128 | } |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( !defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
3 | - exit( 'No direct script access allowed' ); |
|
2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
3 | + exit('No direct script access allowed'); |
|
4 | 4 | } |
5 | 5 | |
6 | 6 | /** |
@@ -15,18 +15,18 @@ discard block |
||
15 | 15 | * @author Mike Nelson |
16 | 16 | * |
17 | 17 | */ |
18 | -class EE_Phone_Input extends EE_Text_Input{ |
|
18 | +class EE_Phone_Input extends EE_Text_Input { |
|
19 | 19 | /** |
20 | 20 | * @param array $options |
21 | 21 | */ |
22 | - function __construct($options = array()){ |
|
22 | + function __construct($options = array()) { |
|
23 | 23 | $this->_add_validation_strategy( |
24 | 24 | new EE_Text_Validation_Strategy( |
25 | - __( 'Please enter a valid phone number. Eg 123-456-7890 or 1234567890', 'event_espresso' ), |
|
25 | + __('Please enter a valid phone number. Eg 123-456-7890 or 1234567890', 'event_espresso'), |
|
26 | 26 | '~^(([\d]{10})|(^[\d]{3}-[\d]{3}-[\d]{4}))$~' |
27 | 27 | ) |
28 | 28 | ); |
29 | - parent::__construct( $options ); |
|
29 | + parent::__construct($options); |
|
30 | 30 | } |
31 | 31 | } |
32 | 32 |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if (!defined('EVENT_ESPRESSO_VERSION')) |
|
3 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) |
|
4 | 4 | exit('No direct script access allowed'); |
5 | 5 | |
6 | 6 | /** |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | * |
26 | 26 | * ------------------------------------------------------------------------ |
27 | 27 | */ |
28 | -class EE_Select_Multiple_Display_Strategy extends EE_Select_Display_Strategy{ |
|
28 | +class EE_Select_Multiple_Display_Strategy extends EE_Select_Display_Strategy { |
|
29 | 29 | |
30 | 30 | /** |
31 | 31 | * |
@@ -34,30 +34,30 @@ discard block |
||
34 | 34 | */ |
35 | 35 | public function display() { |
36 | 36 | |
37 | - if( ! $this->_input instanceof EE_Form_Input_With_Options_Base){ |
|
37 | + if ( ! $this->_input instanceof EE_Form_Input_With_Options_Base) { |
|
38 | 38 | throw new EE_Error(sprintf(__('Cannot use Select Multiple Display Strategy with an input that doesn\'t have options', "event_espresso"))); |
39 | 39 | } |
40 | 40 | |
41 | - $html = EEH_HTML::nl( 0, 'select' ); |
|
41 | + $html = EEH_HTML::nl(0, 'select'); |
|
42 | 42 | $html .= '<select multiple'; |
43 | - $html .= ' id="' . $this->_input->html_id() . '"'; |
|
44 | - $html .= ' name="' . $this->_input->html_name() . '[]"'; |
|
45 | - $class = $this->_input->required() ? $this->_input->required_css_class() . ' ' . $this->_input->html_class() : $this->_input->html_class(); |
|
46 | - $html .= ' class="' . $class . '"'; |
|
43 | + $html .= ' id="'.$this->_input->html_id().'"'; |
|
44 | + $html .= ' name="'.$this->_input->html_name().'[]"'; |
|
45 | + $class = $this->_input->required() ? $this->_input->required_css_class().' '.$this->_input->html_class() : $this->_input->html_class(); |
|
46 | + $html .= ' class="'.$class.'"'; |
|
47 | 47 | // add html5 required |
48 | 48 | $html .= $this->_input->required() ? ' required' : ''; |
49 | - $html .= ' style="' . $this->_input->html_style() . '"'; |
|
50 | - $html .= ' ' . $this->_input->other_html_attributes(); |
|
49 | + $html .= ' style="'.$this->_input->html_style().'"'; |
|
50 | + $html .= ' '.$this->_input->other_html_attributes(); |
|
51 | 51 | $html .= '>'; |
52 | 52 | |
53 | - EEH_HTML::indent( 1, 'select' ); |
|
54 | - if( EEH_Array::is_multi_dimensional_array( $this->_input->options() )){ |
|
53 | + EEH_HTML::indent(1, 'select'); |
|
54 | + if (EEH_Array::is_multi_dimensional_array($this->_input->options())) { |
|
55 | 55 | throw new EE_Error(sprintf(__("Select multiple display strategy does not allow for nested arrays of options.", "event_espresso"))); |
56 | - }else{ |
|
57 | - $html.=$this->_display_options( $this->_input->options() ); |
|
56 | + } else { |
|
57 | + $html .= $this->_display_options($this->_input->options()); |
|
58 | 58 | } |
59 | 59 | |
60 | - $html.= EEH_HTML::nl( -1, 'select' ) . "</select>"; |
|
60 | + $html .= EEH_HTML::nl( -1, 'select' )."</select>"; |
|
61 | 61 | return $html; |
62 | 62 | } |
63 | 63 | |
@@ -68,12 +68,12 @@ discard block |
||
68 | 68 | * @param string|int $value unnormalized value option (string) |
69 | 69 | * @return boolean |
70 | 70 | */ |
71 | - protected function _check_if_option_selected( $value ){ |
|
71 | + protected function _check_if_option_selected($value) { |
|
72 | 72 | $selected_options = $this->_input->raw_value(); |
73 | - if ( empty( $selected_options )){ |
|
73 | + if (empty($selected_options)) { |
|
74 | 74 | return FALSE; |
75 | 75 | } |
76 | - return in_array( $value, $selected_options ) ? TRUE : FALSE; |
|
76 | + return in_array($value, $selected_options) ? TRUE : FALSE; |
|
77 | 77 | } |
78 | 78 | |
79 | 79 |
@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | * @since 4.6 |
12 | 12 | * |
13 | 13 | */ |
14 | -class EE_Text_Input_Display_Strategy extends EE_Display_Strategy_Base{ |
|
14 | +class EE_Text_Input_Display_Strategy extends EE_Display_Strategy_Base { |
|
15 | 15 | /** |
16 | 16 | * The html "type" attribute value. default is "text" |
17 | 17 | * @var string |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | /** |
24 | 24 | * @param string $type |
25 | 25 | */ |
26 | - function __construct( $type = 'text' ) { |
|
26 | + function __construct($type = 'text') { |
|
27 | 27 | $this->_type = $type; |
28 | 28 | parent::__construct(); |
29 | 29 | } |
@@ -34,10 +34,10 @@ discard block |
||
34 | 34 | * Gets the html "type" attribute's value |
35 | 35 | * @return string |
36 | 36 | */ |
37 | - function get_type(){ |
|
37 | + function get_type() { |
|
38 | 38 | if ( |
39 | 39 | $this->_type == 'email' |
40 | - && ! apply_filters( 'FHEE__EE_Text_Input_Display_Strategy__use_html5_email', false ) |
|
40 | + && ! apply_filters('FHEE__EE_Text_Input_Display_Strategy__use_html5_email', false) |
|
41 | 41 | ) { |
42 | 42 | return 'text'; |
43 | 43 | } |
@@ -50,16 +50,16 @@ discard block |
||
50 | 50 | * |
51 | 51 | * @return string of html to display the field |
52 | 52 | */ |
53 | - function display(){ |
|
54 | - $input = '<input type="'. $this->get_type() .'"'; |
|
55 | - $input .= ' name="' . $this->_input->html_name() . '"'; |
|
56 | - $input .= ' id="' . $this->_input->html_id() . '"'; |
|
57 | - $class = $this->_input->required() ? $this->_input->required_css_class() . ' ' . $this->_input->html_class() : $this->_input->html_class(); |
|
58 | - $input .= ' class="' . $class . '"'; |
|
53 | + function display() { |
|
54 | + $input = '<input type="'.$this->get_type().'"'; |
|
55 | + $input .= ' name="'.$this->_input->html_name().'"'; |
|
56 | + $input .= ' id="'.$this->_input->html_id().'"'; |
|
57 | + $class = $this->_input->required() ? $this->_input->required_css_class().' '.$this->_input->html_class() : $this->_input->html_class(); |
|
58 | + $input .= ' class="'.$class.'"'; |
|
59 | 59 | // add html5 required |
60 | 60 | $input .= $this->_input->required() ? ' required' : ''; |
61 | - $input .= ' value="' . $this->_input->raw_value_in_form() . '"'; |
|
62 | - $input .= ' style="' . $this->_input->html_style() . '"'; |
|
61 | + $input .= ' value="'.$this->_input->raw_value_in_form().'"'; |
|
62 | + $input .= ' style="'.$this->_input->html_style().'"'; |
|
63 | 63 | $input .= $this->_input->other_html_attributes(); |
64 | 64 | $input .= '/>'; |
65 | 65 | return $input; |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if (!defined('EVENT_ESPRESSO_VERSION')) |
|
3 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) |
|
4 | 4 | exit('No direct script access allowed'); |
5 | 5 | |
6 | 6 | /** |
@@ -25,12 +25,12 @@ discard block |
||
25 | 25 | * |
26 | 26 | * ------------------------------------------------------------------------ |
27 | 27 | */ |
28 | -class EE_Hidden_Display_Strategy extends EE_Display_Strategy_Base{ |
|
28 | +class EE_Hidden_Display_Strategy extends EE_Display_Strategy_Base { |
|
29 | 29 | /** |
30 | 30 | * |
31 | 31 | * @return string of html to display the HIDDEN field |
32 | 32 | */ |
33 | - function display(){ |
|
33 | + function display() { |
|
34 | 34 | $input = $this->_input; |
35 | 35 | return "<input type='hidden' id='{$input->html_id()}' name='{$input->html_name()}' class='{$input->html_class()}' style='{$input->html_style()}' value='{$input->raw_value_in_form()}' {$input->other_html_attributes()}/>"; |
36 | 36 | } |
@@ -1,7 +1,8 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if (!defined('EVENT_ESPRESSO_VERSION')) |
|
3 | +if (!defined('EVENT_ESPRESSO_VERSION')) { |
|
4 | 4 | exit('No direct script access allowed'); |
5 | +} |
|
5 | 6 | |
6 | 7 | /** |
7 | 8 | * Event Espresso |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | * @subpackage Expression package is undefined on line 19, column 19 in Templates/Scripting/PHPClass.php. |
11 | 11 | * @author Mike Nelson |
12 | 12 | */ |
13 | -class EE_Model_Matching_Query_Validation_Strategy extends EE_Validation_Strategy_Base{ |
|
13 | +class EE_Model_Matching_Query_Validation_Strategy extends EE_Validation_Strategy_Base { |
|
14 | 14 | |
15 | 15 | /** |
16 | 16 | * |
@@ -29,17 +29,17 @@ discard block |
||
29 | 29 | * @param string $input_field_name the input will be treated as this field's value |
30 | 30 | * @throws \EE_Error |
31 | 31 | */ |
32 | - public function __construct( $validation_error_message = NULL, $model_name = '', $query_params = array(), $input_field_name = '' ) { |
|
33 | - if( ! EE_Registry::instance()->is_model_name( $model_name ) ) { |
|
34 | - throw new EE_Error( sprintf( __( 'You must provide a valid model object ', 'event_espresso'), $model_name ) ); |
|
32 | + public function __construct($validation_error_message = NULL, $model_name = '', $query_params = array(), $input_field_name = '') { |
|
33 | + if ( ! EE_Registry::instance()->is_model_name($model_name)) { |
|
34 | + throw new EE_Error(sprintf(__('You must provide a valid model object ', 'event_espresso'), $model_name)); |
|
35 | 35 | } |
36 | - $this->_model = EE_Registry::instance()->load_model( $model_name ); |
|
36 | + $this->_model = EE_Registry::instance()->load_model($model_name); |
|
37 | 37 | $this->_query_params = $query_params; |
38 | - if( empty( $input_field_name ) ) { |
|
38 | + if (empty($input_field_name)) { |
|
39 | 39 | $input_field_name = $this->_model->primary_key_name(); |
40 | 40 | } |
41 | 41 | $this->_input_field_name = $input_field_name; |
42 | - parent::__construct( $validation_error_message ); |
|
42 | + parent::__construct($validation_error_message); |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | |
@@ -51,13 +51,13 @@ discard block |
||
51 | 51 | * @throws \EE_Validation_Error |
52 | 52 | */ |
53 | 53 | public function validate($normalized_value) { |
54 | - if( empty( $normalized_value ) ) { |
|
54 | + if (empty($normalized_value)) { |
|
55 | 55 | return true; |
56 | 56 | } |
57 | 57 | $combined_query_params = $this->get_query_params(); |
58 | - $combined_query_params[0][ $this->treat_input_as_field() ] = $normalized_value; |
|
59 | - if( ! $this->get_model()->exists( $combined_query_params ) ) { |
|
60 | - throw new EE_Validation_Error( $this->get_validation_error_message(), 'no_matching_model_object' ); |
|
58 | + $combined_query_params[0][$this->treat_input_as_field()] = $normalized_value; |
|
59 | + if ( ! $this->get_model()->exists($combined_query_params)) { |
|
60 | + throw new EE_Validation_Error($this->get_validation_error_message(), 'no_matching_model_object'); |
|
61 | 61 | } |
62 | 62 | } |
63 | 63 | |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | * @return array |
75 | 75 | */ |
76 | 76 | public function get_query_params() { |
77 | - return (array)$this->_query_params; |
|
77 | + return (array) $this->_query_params; |
|
78 | 78 | } |
79 | 79 | |
80 | 80 | /** |
@@ -11,8 +11,8 @@ discard block |
||
11 | 11 | class EE_Email_Validation_Strategy extends EE_Text_Validation_Strategy{ |
12 | 12 | |
13 | 13 | /** |
14 | - * @param null $validation_error_message |
|
15 | - */ |
|
14 | + * @param null $validation_error_message |
|
15 | + */ |
|
16 | 16 | public function __construct( $validation_error_message = NULL ) { |
17 | 17 | if( ! $validation_error_message ){ |
18 | 18 | $validation_error_message = __("Please enter a valid email address.", "event_espresso"); |
@@ -38,8 +38,8 @@ discard block |
||
38 | 38 | |
39 | 39 | |
40 | 40 | /** |
41 | - * @return array |
|
42 | - */ |
|
41 | + * @return array |
|
42 | + */ |
|
43 | 43 | public function get_jquery_validation_rule_array(){ |
44 | 44 | return array( 'email'=>true, 'messages' => array( 'email' => $this->get_validation_error_message() ) ); |
45 | 45 | } |
@@ -1,5 +1,5 @@ discard block |
||
1 | -<?php if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
2 | - exit( 'No direct script access allowed' ); |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
2 | + exit('No direct script access allowed'); |
|
3 | 3 | } |
4 | 4 | |
5 | 5 | |
@@ -22,9 +22,9 @@ discard block |
||
22 | 22 | /** |
23 | 23 | * @param null $validation_error_message |
24 | 24 | */ |
25 | - public function __construct( $validation_error_message = null ) { |
|
25 | + public function __construct($validation_error_message = null) { |
|
26 | 26 | $this->_validation_error_message = $validation_error_message === null |
27 | - ? __( 'Input invalid', 'event_espresso' ) |
|
27 | + ? __('Input invalid', 'event_espresso') |
|
28 | 28 | : $validation_error_message; |
29 | 29 | parent::__construct(); |
30 | 30 | } |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | * this validation strategy is the 'required' validation strategy, |
42 | 42 | * most should be OK with a null, empty string, etc) |
43 | 43 | */ |
44 | - public function validate( $normalized_value ) { |
|
44 | + public function validate($normalized_value) { |
|
45 | 45 | //by default, the validation strategy does no validation. this should be implemented |
46 | 46 | } |
47 | 47 | |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | * @param array $other_js_data |
93 | 93 | * @return array |
94 | 94 | */ |
95 | - public function get_other_js_data( $other_js_data = array() ) { |
|
95 | + public function get_other_js_data($other_js_data = array()) { |
|
96 | 96 | return $other_js_data; |
97 | 97 | } |
98 | 98 |
@@ -173,7 +173,7 @@ |
||
173 | 173 | if( ! $this->_html_id ){ |
174 | 174 | if( $this->_parent_section && $this->_parent_section instanceof EE_Form_Section_Proper ){ |
175 | 175 | $this->_html_id = $this->_parent_section->html_id() . '-' . $this->_prep_name_for_html_id( $this->name() ); |
176 | - }else{ |
|
176 | + } else{ |
|
177 | 177 | $this->_html_id = $this->_prep_name_for_html_id( $this->name() ); |
178 | 178 | } |
179 | 179 | } |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if (!defined('EVENT_ESPRESSO_VERSION')){ |
|
2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
3 | 3 | exit('No direct script access allowed'); |
4 | 4 | } |
5 | 5 | /** |
@@ -79,12 +79,12 @@ discard block |
||
79 | 79 | * @type $name string the name for this form section, if you want to explicitly define it |
80 | 80 | * } |
81 | 81 | */ |
82 | - public function __construct( $options_array = array() ) { |
|
82 | + public function __construct($options_array = array()) { |
|
83 | 83 | // used by display strategies |
84 | 84 | // assign incoming values to properties |
85 | - foreach( $options_array as $key => $value ) { |
|
86 | - $key = '_' . $key; |
|
87 | - if ( property_exists( $this, $key ) && empty( $this->{$key} )) { |
|
85 | + foreach ($options_array as $key => $value) { |
|
86 | + $key = '_'.$key; |
|
87 | + if (property_exists($this, $key) && empty($this->{$key} )) { |
|
88 | 88 | $this->{$key} = $value; |
89 | 89 | } |
90 | 90 | } |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | * @param $name |
98 | 98 | * @throws \EE_Error |
99 | 99 | */ |
100 | - protected function _construct_finalize( $parent_form_section, $name ){ |
|
100 | + protected function _construct_finalize($parent_form_section, $name) { |
|
101 | 101 | $this->_construction_finalized = TRUE; |
102 | 102 | $this->_parent_section = $parent_form_section; |
103 | 103 | $this->_name = $name; |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | /** |
119 | 119 | * @param string $action |
120 | 120 | */ |
121 | - public function set_action( $action ) { |
|
121 | + public function set_action($action) { |
|
122 | 122 | $this->_action = $action; |
123 | 123 | } |
124 | 124 | |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | * @return string |
129 | 129 | */ |
130 | 130 | public function method() { |
131 | - return ! empty( $this->_method ) ? $this->_method : 'POST'; |
|
131 | + return ! empty($this->_method) ? $this->_method : 'POST'; |
|
132 | 132 | } |
133 | 133 | |
134 | 134 | |
@@ -136,8 +136,8 @@ discard block |
||
136 | 136 | /** |
137 | 137 | * @param string $method |
138 | 138 | */ |
139 | - public function set_method( $method ) { |
|
140 | - switch ( $method ) { |
|
139 | + public function set_method($method) { |
|
140 | + switch ($method) { |
|
141 | 141 | case 'get' : |
142 | 142 | case 'GET' : |
143 | 143 | $this->_method = 'GET'; |
@@ -156,12 +156,12 @@ discard block |
||
156 | 156 | * |
157 | 157 | * @throws \EE_Error |
158 | 158 | */ |
159 | - protected function _set_default_html_id_if_empty(){ |
|
160 | - if( ! $this->_html_id ){ |
|
161 | - if( $this->_parent_section && $this->_parent_section instanceof EE_Form_Section_Proper ){ |
|
162 | - $this->_html_id = $this->_parent_section->html_id() . '-' . $this->_prep_name_for_html_id( $this->name() ); |
|
163 | - }else{ |
|
164 | - $this->_html_id = $this->_prep_name_for_html_id( $this->name() ); |
|
159 | + protected function _set_default_html_id_if_empty() { |
|
160 | + if ( ! $this->_html_id) { |
|
161 | + if ($this->_parent_section && $this->_parent_section instanceof EE_Form_Section_Proper) { |
|
162 | + $this->_html_id = $this->_parent_section->html_id().'-'.$this->_prep_name_for_html_id($this->name()); |
|
163 | + } else { |
|
164 | + $this->_html_id = $this->_prep_name_for_html_id($this->name()); |
|
165 | 165 | } |
166 | 166 | } |
167 | 167 | } |
@@ -173,8 +173,8 @@ discard block |
||
173 | 173 | * @param $name |
174 | 174 | * @return string |
175 | 175 | */ |
176 | - private function _prep_name_for_html_id( $name ) { |
|
177 | - return sanitize_key( str_replace( array( ' ', ' ', '_' ), '-', $name )); |
|
176 | + private function _prep_name_for_html_id($name) { |
|
177 | + return sanitize_key(str_replace(array(' ', ' ', '_'), '-', $name)); |
|
178 | 178 | } |
179 | 179 | |
180 | 180 | |
@@ -188,7 +188,7 @@ discard block |
||
188 | 188 | * and so might stop working anytime. |
189 | 189 | * @return string |
190 | 190 | */ |
191 | - public function get_html_and_js(){ |
|
191 | + public function get_html_and_js() { |
|
192 | 192 | return $this->get_html(); |
193 | 193 | } |
194 | 194 | |
@@ -204,8 +204,8 @@ discard block |
||
204 | 204 | * @param bool $add_pound_sign |
205 | 205 | * @return string |
206 | 206 | */ |
207 | - public function html_id( $add_pound_sign = FALSE ){ |
|
208 | - return $add_pound_sign ? '#' . $this->_html_id : $this->_html_id; |
|
207 | + public function html_id($add_pound_sign = FALSE) { |
|
208 | + return $add_pound_sign ? '#'.$this->_html_id : $this->_html_id; |
|
209 | 209 | } |
210 | 210 | |
211 | 211 | |
@@ -213,7 +213,7 @@ discard block |
||
213 | 213 | /** |
214 | 214 | * @return string |
215 | 215 | */ |
216 | - public function html_class(){ |
|
216 | + public function html_class() { |
|
217 | 217 | return $this->_html_class; |
218 | 218 | } |
219 | 219 | |
@@ -222,7 +222,7 @@ discard block |
||
222 | 222 | /** |
223 | 223 | * @return string |
224 | 224 | */ |
225 | - public function html_style(){ |
|
225 | + public function html_style() { |
|
226 | 226 | return $this->_html_style; |
227 | 227 | } |
228 | 228 | |
@@ -231,7 +231,7 @@ discard block |
||
231 | 231 | /** |
232 | 232 | * @param mixed $html_class |
233 | 233 | */ |
234 | - public function set_html_class( $html_class ) { |
|
234 | + public function set_html_class($html_class) { |
|
235 | 235 | $this->_html_class = $html_class; |
236 | 236 | } |
237 | 237 | |
@@ -240,7 +240,7 @@ discard block |
||
240 | 240 | /** |
241 | 241 | * @param mixed $html_id |
242 | 242 | */ |
243 | - public function set_html_id( $html_id ) { |
|
243 | + public function set_html_id($html_id) { |
|
244 | 244 | $this->_html_id = $html_id; |
245 | 245 | } |
246 | 246 | |
@@ -249,7 +249,7 @@ discard block |
||
249 | 249 | /** |
250 | 250 | * @param mixed $html_style |
251 | 251 | */ |
252 | - public function set_html_style( $html_style ) { |
|
252 | + public function set_html_style($html_style) { |
|
253 | 253 | $this->_html_style = $html_style; |
254 | 254 | } |
255 | 255 | |
@@ -258,7 +258,7 @@ discard block |
||
258 | 258 | /** |
259 | 259 | * @param string $other_html_attributes |
260 | 260 | */ |
261 | - public function set_other_html_attributes( $other_html_attributes ) { |
|
261 | + public function set_other_html_attributes($other_html_attributes) { |
|
262 | 262 | $this->_other_html_attributes = $other_html_attributes; |
263 | 263 | } |
264 | 264 | |
@@ -278,9 +278,9 @@ discard block |
||
278 | 278 | * @throws EE_Error |
279 | 279 | * @return string |
280 | 280 | */ |
281 | - public function name(){ |
|
282 | - if( ! $this->_construction_finalized ){ |
|
283 | - throw new EE_Error(sprintf( __( '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\'', 'event_espresso' ), get_class($this) ) ); |
|
281 | + public function name() { |
|
282 | + if ( ! $this->_construction_finalized) { |
|
283 | + throw new EE_Error(sprintf(__('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\'', 'event_espresso'), get_class($this))); |
|
284 | 284 | } |
285 | 285 | return $this->_name; |
286 | 286 | } |
@@ -291,7 +291,7 @@ discard block |
||
291 | 291 | * Gets the parent section |
292 | 292 | * @return EE_Form_Section_Proper |
293 | 293 | */ |
294 | - public function parent_section(){ |
|
294 | + public function parent_section() { |
|
295 | 295 | return $this->_parent_section; |
296 | 296 | } |
297 | 297 | |
@@ -304,18 +304,18 @@ discard block |
||
304 | 304 | * @param string $other_attributes anything else added to the form open tag, MUST BE VALID HTML |
305 | 305 | * @return string |
306 | 306 | */ |
307 | - public function form_open( $action = '', $method = '', $other_attributes = '' ) { |
|
308 | - if ( ! empty( $action )) { |
|
309 | - $this->set_action( $action ); |
|
307 | + public function form_open($action = '', $method = '', $other_attributes = '') { |
|
308 | + if ( ! empty($action)) { |
|
309 | + $this->set_action($action); |
|
310 | 310 | } |
311 | - if ( ! empty( $method )) { |
|
312 | - $this->set_method( $method ); |
|
311 | + if ( ! empty($method)) { |
|
312 | + $this->set_method($method); |
|
313 | 313 | } |
314 | - $html = EEH_HTML::nl( 1, 'form' ) . '<form'; |
|
315 | - $html .= $this->html_id() !== '' ? ' id="' . $this->html_id() . '"' : ''; |
|
316 | - $html .= ' action="' . $this->action() . '"'; |
|
317 | - $html .= ' method="' . $this->method() . '"'; |
|
318 | - $html .= $other_attributes . '>'; |
|
314 | + $html = EEH_HTML::nl(1, 'form').'<form'; |
|
315 | + $html .= $this->html_id() !== '' ? ' id="'.$this->html_id().'"' : ''; |
|
316 | + $html .= ' action="'.$this->action().'"'; |
|
317 | + $html .= ' method="'.$this->method().'"'; |
|
318 | + $html .= $other_attributes.'>'; |
|
319 | 319 | return $html; |
320 | 320 | } |
321 | 321 | |
@@ -326,7 +326,7 @@ discard block |
||
326 | 326 | * @return string |
327 | 327 | */ |
328 | 328 | public function form_close() { |
329 | - return EEH_HTML::nl( -1, 'form' ) . '</form>' . EEH_HTML::nl() . '<!-- end of ee-' . $this->html_id() . '-form -->' . EEH_HTML::nl(); |
|
329 | + return EEH_HTML::nl( -1, 'form' ).'</form>'.EEH_HTML::nl().'<!-- end of ee-'.$this->html_id().'-form -->'.EEH_HTML::nl(); |
|
330 | 330 | } |
331 | 331 | |
332 | 332 | /** |
@@ -335,7 +335,7 @@ discard block |
||
335 | 335 | * Default does nothing, but child classes can override |
336 | 336 | * @return void |
337 | 337 | */ |
338 | - public function enqueue_js(){ |
|
338 | + public function enqueue_js() { |
|
339 | 339 | //defaults to enqueue NO js or css |
340 | 340 | } |
341 | 341 | |
@@ -351,7 +351,7 @@ discard block |
||
351 | 351 | * @param array $form_other_js_data |
352 | 352 | * @return array |
353 | 353 | */ |
354 | - public function get_other_js_data( $form_other_js_data = array() ) { |
|
354 | + public function get_other_js_data($form_other_js_data = array()) { |
|
355 | 355 | return $form_other_js_data; |
356 | 356 | } |
357 | 357 | |
@@ -369,20 +369,20 @@ discard block |
||
369 | 369 | * @param string|false $form_section_path we accept false also because substr( '../', '../' ) = false |
370 | 370 | * @return EE_Form_Section_Base |
371 | 371 | */ |
372 | - public function find_section_from_path( $form_section_path ) { |
|
373 | - if( strpos( $form_section_path, '/' ) === 0 ) { |
|
374 | - $form_section_path = substr( $form_section_path, strlen( '/' ) ); |
|
372 | + public function find_section_from_path($form_section_path) { |
|
373 | + if (strpos($form_section_path, '/') === 0) { |
|
374 | + $form_section_path = substr($form_section_path, strlen('/')); |
|
375 | 375 | } |
376 | - if( empty( $form_section_path ) ) { |
|
376 | + if (empty($form_section_path)) { |
|
377 | 377 | return $this; |
378 | 378 | } |
379 | - if( strpos( $form_section_path, '../' ) === 0 ) { |
|
379 | + if (strpos($form_section_path, '../') === 0) { |
|
380 | 380 | $parent = $this->parent_section(); |
381 | 381 | |
382 | - $form_section_path = substr( $form_section_path, strlen( '../' ) ); |
|
383 | - if( $parent instanceof EE_Form_Section_Base ) { |
|
384 | - return $parent->find_section_from_path( $form_section_path ); |
|
385 | - } elseif( empty( $form_section_path ) ) { |
|
382 | + $form_section_path = substr($form_section_path, strlen('../')); |
|
383 | + if ($parent instanceof EE_Form_Section_Base) { |
|
384 | + return $parent->find_section_from_path($form_section_path); |
|
385 | + } elseif (empty($form_section_path)) { |
|
386 | 386 | return $this; |
387 | 387 | } |
388 | 388 | } |