@@ -66,9 +66,9 @@ discard block |
||
66 | 66 | */ |
67 | 67 | public static function adminUrl($page = 'espresso_events', $action = 'default', $additional_params = '') |
68 | 68 | { |
69 | - $url = self::URL_PREFIX . $page; |
|
70 | - $url .= $action ? '&action=' . $action : ''; |
|
71 | - $url .= $additional_params ? '&' . ltrim('&', ltrim('?', $additional_params)) : ''; |
|
69 | + $url = self::URL_PREFIX.$page; |
|
70 | + $url .= $action ? '&action='.$action : ''; |
|
71 | + $url .= $additional_params ? '&'.ltrim('&', ltrim('?', $additional_params)) : ''; |
|
72 | 72 | return $url; |
73 | 73 | } |
74 | 74 | |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | */ |
81 | 81 | public static function wpEditorTextTabSelector($field_reference) |
82 | 82 | { |
83 | - return '#content-' . $field_reference . '-content-html'; |
|
83 | + return '#content-'.$field_reference.'-content-html'; |
|
84 | 84 | } |
85 | 85 | |
86 | 86 | |
@@ -91,6 +91,6 @@ discard block |
||
91 | 91 | */ |
92 | 92 | public static function wpEditorTextAreaSelector($field_reference) |
93 | 93 | { |
94 | - return '#content-' . $field_reference . '-content'; |
|
94 | + return '#content-'.$field_reference.'-content'; |
|
95 | 95 | } |
96 | 96 | } |
@@ -13,96 +13,96 @@ |
||
13 | 13 | class CoreAdmin |
14 | 14 | { |
15 | 15 | |
16 | - /** |
|
17 | - * @var string |
|
18 | - */ |
|
19 | - const URL_PREFIX = 'admin.php?page='; |
|
20 | - |
|
21 | - |
|
22 | - /** |
|
23 | - * This is the selector for the next page button on list tables. |
|
24 | - * @var string |
|
25 | - */ |
|
26 | - const ADMIN_LIST_TABLE_NEXT_PAGE_CLASS = '.next-page'; |
|
27 | - |
|
28 | - |
|
29 | - /** |
|
30 | - * The selector for the search input submit button on list table pages |
|
31 | - * @var string |
|
32 | - */ |
|
33 | - const LIST_TABLE_SEARCH_SUBMIT_SELECTOR = '#search-submit'; |
|
34 | - |
|
35 | - |
|
36 | - /** |
|
37 | - * Selector for the screen options dropdown. |
|
38 | - * @var string |
|
39 | - */ |
|
40 | - const WP_SCREEN_SETTINGS_LINK_SELECTOR = '#show-settings-link'; |
|
41 | - |
|
42 | - |
|
43 | - /** |
|
44 | - * Selector for the per page field setting selector (found within screen options dropdown) |
|
45 | - * @var string |
|
46 | - */ |
|
47 | - const WP_SCREEN_SETTINGS_PER_PAGE_FIELD_SELECTOR = '.screen-per-page'; |
|
48 | - |
|
49 | - |
|
50 | - /** |
|
51 | - * Selector for apply screen options settings. |
|
52 | - * @var string |
|
53 | - */ |
|
54 | - const WP_SCREEN_OPTIONS_APPLY_SETTINGS_BUTTON_SELECTOR = '#screen-options-apply'; |
|
55 | - |
|
56 | - |
|
57 | - /** |
|
58 | - * Selector for bulk action select field on list tables. |
|
59 | - */ |
|
60 | - const SELECTOR_LIST_TABLE_BULK_ACTION_FIELD = '#bulk-action-selector-'; |
|
61 | - |
|
62 | - |
|
63 | - /** |
|
64 | - * Selector for applying a bulk action. |
|
65 | - */ |
|
66 | - const SELECTOR_LIST_TABLE_BULK_ACTTION_APPLY = '#doaction'; |
|
67 | - |
|
68 | - |
|
69 | - /** |
|
70 | - * Get the EE admin url for the given properties. |
|
71 | - * Note, this is JUST the endpoint for the admin route. It is expected that the actor/test would be calling this |
|
72 | - * with `amOnAdminPage` action. |
|
73 | - * |
|
74 | - * @param string $page |
|
75 | - * @param string $action |
|
76 | - * @param string $additional_params |
|
77 | - * @return string |
|
78 | - */ |
|
79 | - public static function adminUrl($page = 'espresso_events', $action = 'default', $additional_params = '') |
|
80 | - { |
|
81 | - $url = self::URL_PREFIX . $page; |
|
82 | - $url .= $action ? '&action=' . $action : ''; |
|
83 | - $url .= $additional_params ? '&' . ltrim('&', ltrim('?', $additional_params)) : ''; |
|
84 | - return $url; |
|
85 | - } |
|
86 | - |
|
87 | - |
|
88 | - /** |
|
89 | - * Returns the selector for the text tab switcher for a wp-editor instance. |
|
90 | - * @param $field_reference |
|
91 | - * @return string |
|
92 | - */ |
|
93 | - public static function wpEditorTextTabSelector($field_reference) |
|
94 | - { |
|
95 | - return '#content-' . $field_reference . '-content-html'; |
|
96 | - } |
|
97 | - |
|
98 | - |
|
99 | - /** |
|
100 | - * Returns the selector for the textarea exposed when clicing the text tab switcher for a wp-editor instance. |
|
101 | - * @param $field_reference |
|
102 | - * @return string |
|
103 | - */ |
|
104 | - public static function wpEditorTextAreaSelector($field_reference) |
|
105 | - { |
|
106 | - return '#content-' . $field_reference . '-content'; |
|
107 | - } |
|
16 | + /** |
|
17 | + * @var string |
|
18 | + */ |
|
19 | + const URL_PREFIX = 'admin.php?page='; |
|
20 | + |
|
21 | + |
|
22 | + /** |
|
23 | + * This is the selector for the next page button on list tables. |
|
24 | + * @var string |
|
25 | + */ |
|
26 | + const ADMIN_LIST_TABLE_NEXT_PAGE_CLASS = '.next-page'; |
|
27 | + |
|
28 | + |
|
29 | + /** |
|
30 | + * The selector for the search input submit button on list table pages |
|
31 | + * @var string |
|
32 | + */ |
|
33 | + const LIST_TABLE_SEARCH_SUBMIT_SELECTOR = '#search-submit'; |
|
34 | + |
|
35 | + |
|
36 | + /** |
|
37 | + * Selector for the screen options dropdown. |
|
38 | + * @var string |
|
39 | + */ |
|
40 | + const WP_SCREEN_SETTINGS_LINK_SELECTOR = '#show-settings-link'; |
|
41 | + |
|
42 | + |
|
43 | + /** |
|
44 | + * Selector for the per page field setting selector (found within screen options dropdown) |
|
45 | + * @var string |
|
46 | + */ |
|
47 | + const WP_SCREEN_SETTINGS_PER_PAGE_FIELD_SELECTOR = '.screen-per-page'; |
|
48 | + |
|
49 | + |
|
50 | + /** |
|
51 | + * Selector for apply screen options settings. |
|
52 | + * @var string |
|
53 | + */ |
|
54 | + const WP_SCREEN_OPTIONS_APPLY_SETTINGS_BUTTON_SELECTOR = '#screen-options-apply'; |
|
55 | + |
|
56 | + |
|
57 | + /** |
|
58 | + * Selector for bulk action select field on list tables. |
|
59 | + */ |
|
60 | + const SELECTOR_LIST_TABLE_BULK_ACTION_FIELD = '#bulk-action-selector-'; |
|
61 | + |
|
62 | + |
|
63 | + /** |
|
64 | + * Selector for applying a bulk action. |
|
65 | + */ |
|
66 | + const SELECTOR_LIST_TABLE_BULK_ACTTION_APPLY = '#doaction'; |
|
67 | + |
|
68 | + |
|
69 | + /** |
|
70 | + * Get the EE admin url for the given properties. |
|
71 | + * Note, this is JUST the endpoint for the admin route. It is expected that the actor/test would be calling this |
|
72 | + * with `amOnAdminPage` action. |
|
73 | + * |
|
74 | + * @param string $page |
|
75 | + * @param string $action |
|
76 | + * @param string $additional_params |
|
77 | + * @return string |
|
78 | + */ |
|
79 | + public static function adminUrl($page = 'espresso_events', $action = 'default', $additional_params = '') |
|
80 | + { |
|
81 | + $url = self::URL_PREFIX . $page; |
|
82 | + $url .= $action ? '&action=' . $action : ''; |
|
83 | + $url .= $additional_params ? '&' . ltrim('&', ltrim('?', $additional_params)) : ''; |
|
84 | + return $url; |
|
85 | + } |
|
86 | + |
|
87 | + |
|
88 | + /** |
|
89 | + * Returns the selector for the text tab switcher for a wp-editor instance. |
|
90 | + * @param $field_reference |
|
91 | + * @return string |
|
92 | + */ |
|
93 | + public static function wpEditorTextTabSelector($field_reference) |
|
94 | + { |
|
95 | + return '#content-' . $field_reference . '-content-html'; |
|
96 | + } |
|
97 | + |
|
98 | + |
|
99 | + /** |
|
100 | + * Returns the selector for the textarea exposed when clicing the text tab switcher for a wp-editor instance. |
|
101 | + * @param $field_reference |
|
102 | + * @return string |
|
103 | + */ |
|
104 | + public static function wpEditorTextAreaSelector($field_reference) |
|
105 | + { |
|
106 | + return '#content-' . $field_reference . '-content'; |
|
107 | + } |
|
108 | 108 | } |
@@ -14,115 +14,115 @@ |
||
14 | 14 | { |
15 | 15 | |
16 | 16 | |
17 | - /** |
|
18 | - * EE_Message_Template_Group_Collection constructor. |
|
19 | - */ |
|
20 | - public function __construct() |
|
21 | - { |
|
22 | - $this->interface = 'EE_Message_Template_Group'; |
|
23 | - } |
|
17 | + /** |
|
18 | + * EE_Message_Template_Group_Collection constructor. |
|
19 | + */ |
|
20 | + public function __construct() |
|
21 | + { |
|
22 | + $this->interface = 'EE_Message_Template_Group'; |
|
23 | + } |
|
24 | 24 | |
25 | 25 | |
26 | - /** |
|
27 | - * Adds the Message Template Group object to the repository. |
|
28 | - * |
|
29 | - * @param $message_template_group |
|
30 | - * @param array|int $EVT_ID Some templates are specific to EVT, so this is provided as a way of |
|
31 | - * indexing the template by key. If this template is shared among multiple events then |
|
32 | - * include the events as an array. |
|
33 | - * @return bool |
|
34 | - */ |
|
35 | - public function add($message_template_group, $EVT_ID = array()) |
|
36 | - { |
|
37 | - $EVT_ID = is_array($EVT_ID) ? $EVT_ID : (array) $EVT_ID; |
|
38 | - if ($message_template_group instanceof $this->interface) { |
|
39 | - $data['key'] = $this->getKey( |
|
40 | - $message_template_group->messenger(), |
|
41 | - $message_template_group->message_type(), |
|
42 | - $EVT_ID |
|
43 | - ); |
|
44 | - return parent::add($message_template_group, $data); |
|
45 | - } |
|
46 | - return false; |
|
47 | - } |
|
26 | + /** |
|
27 | + * Adds the Message Template Group object to the repository. |
|
28 | + * |
|
29 | + * @param $message_template_group |
|
30 | + * @param array|int $EVT_ID Some templates are specific to EVT, so this is provided as a way of |
|
31 | + * indexing the template by key. If this template is shared among multiple events then |
|
32 | + * include the events as an array. |
|
33 | + * @return bool |
|
34 | + */ |
|
35 | + public function add($message_template_group, $EVT_ID = array()) |
|
36 | + { |
|
37 | + $EVT_ID = is_array($EVT_ID) ? $EVT_ID : (array) $EVT_ID; |
|
38 | + if ($message_template_group instanceof $this->interface) { |
|
39 | + $data['key'] = $this->getKey( |
|
40 | + $message_template_group->messenger(), |
|
41 | + $message_template_group->message_type(), |
|
42 | + $EVT_ID |
|
43 | + ); |
|
44 | + return parent::add($message_template_group, $data); |
|
45 | + } |
|
46 | + return false; |
|
47 | + } |
|
48 | 48 | |
49 | 49 | |
50 | - /** |
|
51 | - * This retrieves any EE_Message_Template_Group in the repo by its ID. |
|
52 | - * |
|
53 | - * @param $GRP_ID |
|
54 | - * @return EE_Message_Template_Group | null |
|
55 | - */ |
|
56 | - public function get_by_ID($GRP_ID) |
|
57 | - { |
|
58 | - $this->rewind(); |
|
59 | - while ($this->valid()) { |
|
60 | - if ($this->current()->ID() === $GRP_ID) { |
|
61 | - /** @var EE_Message_Template_Group $message_template_group */ |
|
62 | - $message_template_group = $this->current(); |
|
63 | - $this->rewind(); |
|
64 | - return $message_template_group; |
|
65 | - } |
|
66 | - $this->next(); |
|
67 | - } |
|
68 | - return null; |
|
69 | - } |
|
50 | + /** |
|
51 | + * This retrieves any EE_Message_Template_Group in the repo by its ID. |
|
52 | + * |
|
53 | + * @param $GRP_ID |
|
54 | + * @return EE_Message_Template_Group | null |
|
55 | + */ |
|
56 | + public function get_by_ID($GRP_ID) |
|
57 | + { |
|
58 | + $this->rewind(); |
|
59 | + while ($this->valid()) { |
|
60 | + if ($this->current()->ID() === $GRP_ID) { |
|
61 | + /** @var EE_Message_Template_Group $message_template_group */ |
|
62 | + $message_template_group = $this->current(); |
|
63 | + $this->rewind(); |
|
64 | + return $message_template_group; |
|
65 | + } |
|
66 | + $this->next(); |
|
67 | + } |
|
68 | + return null; |
|
69 | + } |
|
70 | 70 | |
71 | 71 | |
72 | - /** |
|
73 | - * Generates a hash used to identify a given Message Template Group. |
|
74 | - * |
|
75 | - * @param string $messenger The EE_messenger->name |
|
76 | - * @param string $message_type The EE_message_type->name |
|
77 | - * @param int $EVT_ID Optional. If the template is for a specific EVT then that should be included. |
|
78 | - * @deprecated 4.9.40.rc.017 Use getKey instead. |
|
79 | - * @return string |
|
80 | - */ |
|
81 | - public function get_key($messenger, $message_type, $EVT_ID = 0) |
|
82 | - { |
|
83 | - $EVT_ID = (array) $EVT_ID; |
|
84 | - return $this->getKey($messenger, $message_type, $EVT_ID); |
|
85 | - } |
|
72 | + /** |
|
73 | + * Generates a hash used to identify a given Message Template Group. |
|
74 | + * |
|
75 | + * @param string $messenger The EE_messenger->name |
|
76 | + * @param string $message_type The EE_message_type->name |
|
77 | + * @param int $EVT_ID Optional. If the template is for a specific EVT then that should be included. |
|
78 | + * @deprecated 4.9.40.rc.017 Use getKey instead. |
|
79 | + * @return string |
|
80 | + */ |
|
81 | + public function get_key($messenger, $message_type, $EVT_ID = 0) |
|
82 | + { |
|
83 | + $EVT_ID = (array) $EVT_ID; |
|
84 | + return $this->getKey($messenger, $message_type, $EVT_ID); |
|
85 | + } |
|
86 | 86 | |
87 | 87 | |
88 | - /** |
|
89 | - * Generates a hash used to identify a given Message Template Group |
|
90 | - * @param string $messenger The EE_messenger->name |
|
91 | - * @param string $message_type The EE_message_type->name |
|
92 | - * @param array $EVT_ID Optional. If the template is for a specific EVT_ID (or events) then that should |
|
93 | - * be included. |
|
94 | - * @since 4.9.40.rc.017 |
|
95 | - * @return string |
|
96 | - */ |
|
97 | - public function getKey($messenger, $message_type, array $EVT_ID = array()) |
|
98 | - { |
|
99 | - sort($EVT_ID); |
|
100 | - $EVT_ID = implode(',', array_unique($EVT_ID)); |
|
101 | - return md5($messenger . $message_type . $EVT_ID); |
|
102 | - } |
|
88 | + /** |
|
89 | + * Generates a hash used to identify a given Message Template Group |
|
90 | + * @param string $messenger The EE_messenger->name |
|
91 | + * @param string $message_type The EE_message_type->name |
|
92 | + * @param array $EVT_ID Optional. If the template is for a specific EVT_ID (or events) then that should |
|
93 | + * be included. |
|
94 | + * @since 4.9.40.rc.017 |
|
95 | + * @return string |
|
96 | + */ |
|
97 | + public function getKey($messenger, $message_type, array $EVT_ID = array()) |
|
98 | + { |
|
99 | + sort($EVT_ID); |
|
100 | + $EVT_ID = implode(',', array_unique($EVT_ID)); |
|
101 | + return md5($messenger . $message_type . $EVT_ID); |
|
102 | + } |
|
103 | 103 | |
104 | 104 | |
105 | - /** |
|
106 | - * This returns a saved EE_Message_Template_Group object if there is one in the repository indexed by a key matching |
|
107 | - * the given string. |
|
108 | - * |
|
109 | - * @param string $key @see EE_Message_Template_Group::get_key() to setup a key formatted for searching. |
|
110 | - * @return null|EE_Message_Template_Group |
|
111 | - */ |
|
112 | - public function get_by_key($key) |
|
113 | - { |
|
114 | - $this->rewind(); |
|
115 | - while ($this->valid()) { |
|
116 | - $data = $this->getInfo(); |
|
117 | - if (isset($data['key']) && $data['key'] === $key) { |
|
118 | - /** @var EE_Message_Template_Group $message_template_group */ |
|
119 | - $message_template_group = $this->current(); |
|
120 | - $this->rewind(); |
|
121 | - return $message_template_group; |
|
122 | - } |
|
123 | - $this->next(); |
|
124 | - } |
|
125 | - return null; |
|
126 | - } |
|
105 | + /** |
|
106 | + * This returns a saved EE_Message_Template_Group object if there is one in the repository indexed by a key matching |
|
107 | + * the given string. |
|
108 | + * |
|
109 | + * @param string $key @see EE_Message_Template_Group::get_key() to setup a key formatted for searching. |
|
110 | + * @return null|EE_Message_Template_Group |
|
111 | + */ |
|
112 | + public function get_by_key($key) |
|
113 | + { |
|
114 | + $this->rewind(); |
|
115 | + while ($this->valid()) { |
|
116 | + $data = $this->getInfo(); |
|
117 | + if (isset($data['key']) && $data['key'] === $key) { |
|
118 | + /** @var EE_Message_Template_Group $message_template_group */ |
|
119 | + $message_template_group = $this->current(); |
|
120 | + $this->rewind(); |
|
121 | + return $message_template_group; |
|
122 | + } |
|
123 | + $this->next(); |
|
124 | + } |
|
125 | + return null; |
|
126 | + } |
|
127 | 127 | |
128 | 128 | } |
@@ -98,7 +98,7 @@ |
||
98 | 98 | { |
99 | 99 | sort($EVT_ID); |
100 | 100 | $EVT_ID = implode(',', array_unique($EVT_ID)); |
101 | - return md5($messenger . $message_type . $EVT_ID); |
|
101 | + return md5($messenger.$message_type.$EVT_ID); |
|
102 | 102 | } |
103 | 103 | |
104 | 104 |
@@ -18,7 +18,7 @@ discard block |
||
18 | 18 | $this->_form_section->html_id(), |
19 | 19 | $this->_form_section->html_class(), |
20 | 20 | $this->_form_section->html_style() |
21 | - ) . EEH_HTML::tbody(); |
|
21 | + ).EEH_HTML::tbody(); |
|
22 | 22 | } |
23 | 23 | |
24 | 24 | |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | */ |
32 | 32 | public function layout_form_end($additional_args = array()) |
33 | 33 | { |
34 | - return EEH_HTML::tbodyx() . EEH_HTML::tablex($this->_form_section->html_id()); |
|
34 | + return EEH_HTML::tbodyx().EEH_HTML::tablex($this->_form_section->html_id()); |
|
35 | 35 | } |
36 | 36 | |
37 | 37 | |
@@ -50,11 +50,11 @@ discard block |
||
50 | 50 | } else { |
51 | 51 | $html_for_input = $input->get_html_for_input(); |
52 | 52 | $html_for_input .= $input->get_html_for_errors() != '' |
53 | - ? EEH_HTML::nl() . $input->get_html_for_errors() |
|
53 | + ? EEH_HTML::nl().$input->get_html_for_errors() |
|
54 | 54 | : ''; |
55 | - $html_for_input .= $input->get_html_for_help() != '' ? EEH_HTML::nl() . $input->get_html_for_help() : ''; |
|
55 | + $html_for_input .= $input->get_html_for_help() != '' ? EEH_HTML::nl().$input->get_html_for_help() : ''; |
|
56 | 56 | $html .= EEH_HTML::tr( |
57 | - EEH_HTML::th($input->get_html_for_label()) . |
|
57 | + EEH_HTML::th($input->get_html_for_label()). |
|
58 | 58 | EEH_HTML::td($html_for_input) |
59 | 59 | ); |
60 | 60 | } |
@@ -5,81 +5,81 @@ |
||
5 | 5 | class EE_Two_Column_Layout extends EE_Form_Section_Layout_Base |
6 | 6 | { |
7 | 7 | |
8 | - /** |
|
9 | - * Should be used to start teh form section (Eg a table tag, or a div tag, etc.) |
|
10 | - * |
|
11 | - * @param array $additional_args |
|
12 | - * @return string |
|
13 | - */ |
|
14 | - public function layout_form_begin($additional_args = array()) |
|
15 | - { |
|
16 | - return $this->display_form_wide_errors() |
|
17 | - . EEH_HTML::table( |
|
18 | - '', |
|
19 | - $this->_form_section->html_id(), |
|
20 | - $this->_form_section->html_class(), |
|
21 | - $this->_form_section->html_style() |
|
22 | - ) . EEH_HTML::tbody(); |
|
23 | - } |
|
8 | + /** |
|
9 | + * Should be used to start teh form section (Eg a table tag, or a div tag, etc.) |
|
10 | + * |
|
11 | + * @param array $additional_args |
|
12 | + * @return string |
|
13 | + */ |
|
14 | + public function layout_form_begin($additional_args = array()) |
|
15 | + { |
|
16 | + return $this->display_form_wide_errors() |
|
17 | + . EEH_HTML::table( |
|
18 | + '', |
|
19 | + $this->_form_section->html_id(), |
|
20 | + $this->_form_section->html_class(), |
|
21 | + $this->_form_section->html_style() |
|
22 | + ) . EEH_HTML::tbody(); |
|
23 | + } |
|
24 | 24 | |
25 | 25 | |
26 | 26 | |
27 | - /** |
|
28 | - * Should be used to end the form section (eg a /table tag, or a /div tag, etc) |
|
29 | - * |
|
30 | - * @param array $additional_args |
|
31 | - * @return string |
|
32 | - */ |
|
33 | - public function layout_form_end($additional_args = array()) |
|
34 | - { |
|
35 | - return EEH_HTML::tbodyx() . EEH_HTML::tablex($this->_form_section->html_id()); |
|
36 | - } |
|
27 | + /** |
|
28 | + * Should be used to end the form section (eg a /table tag, or a /div tag, etc) |
|
29 | + * |
|
30 | + * @param array $additional_args |
|
31 | + * @return string |
|
32 | + */ |
|
33 | + public function layout_form_end($additional_args = array()) |
|
34 | + { |
|
35 | + return EEH_HTML::tbodyx() . EEH_HTML::tablex($this->_form_section->html_id()); |
|
36 | + } |
|
37 | 37 | |
38 | 38 | |
39 | 39 | |
40 | - /** |
|
41 | - * Lays out the row for the input, including label and errors |
|
42 | - * |
|
43 | - * @param EE_Form_Input_Base $input |
|
44 | - * @return string |
|
45 | - */ |
|
46 | - public function layout_input($input) |
|
47 | - { |
|
48 | - $html = ''; |
|
49 | - if ($input instanceof EE_Hidden_Input) { |
|
50 | - $html .= $input->get_html_for_input(); |
|
51 | - } else { |
|
52 | - $html_for_input = $input->get_html_for_input(); |
|
53 | - $html_for_input .= $input->get_html_for_errors() != '' |
|
54 | - ? EEH_HTML::nl() . $input->get_html_for_errors() |
|
55 | - : ''; |
|
56 | - $html_for_input .= $input->get_html_for_help() != '' ? EEH_HTML::nl() . $input->get_html_for_help() : ''; |
|
57 | - $html .= EEH_HTML::tr( |
|
58 | - EEH_HTML::th($input->get_html_for_label()) . |
|
59 | - EEH_HTML::td($html_for_input) |
|
60 | - ); |
|
61 | - } |
|
62 | - return $html; |
|
63 | - } |
|
40 | + /** |
|
41 | + * Lays out the row for the input, including label and errors |
|
42 | + * |
|
43 | + * @param EE_Form_Input_Base $input |
|
44 | + * @return string |
|
45 | + */ |
|
46 | + public function layout_input($input) |
|
47 | + { |
|
48 | + $html = ''; |
|
49 | + if ($input instanceof EE_Hidden_Input) { |
|
50 | + $html .= $input->get_html_for_input(); |
|
51 | + } else { |
|
52 | + $html_for_input = $input->get_html_for_input(); |
|
53 | + $html_for_input .= $input->get_html_for_errors() != '' |
|
54 | + ? EEH_HTML::nl() . $input->get_html_for_errors() |
|
55 | + : ''; |
|
56 | + $html_for_input .= $input->get_html_for_help() != '' ? EEH_HTML::nl() . $input->get_html_for_help() : ''; |
|
57 | + $html .= EEH_HTML::tr( |
|
58 | + EEH_HTML::th($input->get_html_for_label()) . |
|
59 | + EEH_HTML::td($html_for_input) |
|
60 | + ); |
|
61 | + } |
|
62 | + return $html; |
|
63 | + } |
|
64 | 64 | |
65 | 65 | |
66 | 66 | |
67 | - /** |
|
68 | - * Lays out a row for the subsection. Please note that if you have a subsection which you don't want wrapped in |
|
69 | - * a tr and td with a colspan=2, you should use a different layout strategy, like EE_No_Layout, EE_Template_Layout, |
|
70 | - * or EE_Div_Per_Section_Layout, and create subsections using EE_Two_Column_Layout for everywhere you want the |
|
71 | - * two-column layout, and then other sub-sections can be outside the EE_Two_Column_Layout table. |
|
72 | - * |
|
73 | - * @param EE_Form_Section_Proper $form_section |
|
74 | - * @return string |
|
75 | - */ |
|
76 | - public function layout_subsection($form_section) |
|
77 | - { |
|
78 | - if ($form_section instanceof EE_Form_Section_Proper |
|
79 | - || $form_section instanceof EE_Form_Section_HTML |
|
80 | - ) { |
|
81 | - return EEH_HTML::no_row($form_section->get_html()); |
|
82 | - } |
|
83 | - return ''; |
|
84 | - } |
|
67 | + /** |
|
68 | + * Lays out a row for the subsection. Please note that if you have a subsection which you don't want wrapped in |
|
69 | + * a tr and td with a colspan=2, you should use a different layout strategy, like EE_No_Layout, EE_Template_Layout, |
|
70 | + * or EE_Div_Per_Section_Layout, and create subsections using EE_Two_Column_Layout for everywhere you want the |
|
71 | + * two-column layout, and then other sub-sections can be outside the EE_Two_Column_Layout table. |
|
72 | + * |
|
73 | + * @param EE_Form_Section_Proper $form_section |
|
74 | + * @return string |
|
75 | + */ |
|
76 | + public function layout_subsection($form_section) |
|
77 | + { |
|
78 | + if ($form_section instanceof EE_Form_Section_Proper |
|
79 | + || $form_section instanceof EE_Form_Section_HTML |
|
80 | + ) { |
|
81 | + return EEH_HTML::no_row($form_section->get_html()); |
|
82 | + } |
|
83 | + return ''; |
|
84 | + } |
|
85 | 85 | } |
@@ -14,51 +14,51 @@ |
||
14 | 14 | { |
15 | 15 | |
16 | 16 | |
17 | - const COUNTRY_SETTINGS_SAVE_BUTTON = '#country_settings_save_2'; |
|
17 | + const COUNTRY_SETTINGS_SAVE_BUTTON = '#country_settings_save_2'; |
|
18 | 18 | |
19 | 19 | |
20 | 20 | |
21 | - /** |
|
22 | - * Return the url for the country settings admin page. |
|
23 | - * @param string $additional_params |
|
24 | - * @return string |
|
25 | - */ |
|
26 | - public static function url($additional_params = '') |
|
27 | - { |
|
28 | - return self::adminUrl('espresso_general_settings', 'country_settings', $additional_params); |
|
29 | - } |
|
21 | + /** |
|
22 | + * Return the url for the country settings admin page. |
|
23 | + * @param string $additional_params |
|
24 | + * @return string |
|
25 | + */ |
|
26 | + public static function url($additional_params = '') |
|
27 | + { |
|
28 | + return self::adminUrl('espresso_general_settings', 'country_settings', $additional_params); |
|
29 | + } |
|
30 | 30 | |
31 | 31 | |
32 | - /** |
|
33 | - * Return the decimal places (precision) radio field locator for selection. |
|
34 | - * @param int $decimal_place_value |
|
35 | - * @param string $country_code |
|
36 | - * @return string |
|
37 | - */ |
|
38 | - public static function currencyDecimalPlacesRadioField($decimal_place_value = 2, $country_code = 'US') |
|
39 | - { |
|
40 | - return "//input[@id='CNT_cur_dec_plc-$country_code-$decimal_place_value']"; |
|
41 | - } |
|
32 | + /** |
|
33 | + * Return the decimal places (precision) radio field locator for selection. |
|
34 | + * @param int $decimal_place_value |
|
35 | + * @param string $country_code |
|
36 | + * @return string |
|
37 | + */ |
|
38 | + public static function currencyDecimalPlacesRadioField($decimal_place_value = 2, $country_code = 'US') |
|
39 | + { |
|
40 | + return "//input[@id='CNT_cur_dec_plc-$country_code-$decimal_place_value']"; |
|
41 | + } |
|
42 | 42 | |
43 | 43 | |
44 | - /** |
|
45 | - * Return the currency decimal mark field locator for selection. |
|
46 | - * @param string $decimal_mark |
|
47 | - * @return string |
|
48 | - */ |
|
49 | - public static function currencyDecimalMarkRadioField($decimal_mark = '.') |
|
50 | - { |
|
51 | - return "//input[@class='CNT_cur_dec_mrk' and @value='$decimal_mark']"; |
|
52 | - } |
|
44 | + /** |
|
45 | + * Return the currency decimal mark field locator for selection. |
|
46 | + * @param string $decimal_mark |
|
47 | + * @return string |
|
48 | + */ |
|
49 | + public static function currencyDecimalMarkRadioField($decimal_mark = '.') |
|
50 | + { |
|
51 | + return "//input[@class='CNT_cur_dec_mrk' and @value='$decimal_mark']"; |
|
52 | + } |
|
53 | 53 | |
54 | 54 | |
55 | - /** |
|
56 | - * Return the currency thousands separator field locator for selection. |
|
57 | - * @param string $thousands_separator |
|
58 | - * @return string |
|
59 | - */ |
|
60 | - public static function currencyThousandsSeparatorField($thousands_separator = ',') |
|
61 | - { |
|
62 | - return "//input[@class='CNT_cur_thsnds' and @value='$thousands_separator']"; |
|
63 | - } |
|
55 | + /** |
|
56 | + * Return the currency thousands separator field locator for selection. |
|
57 | + * @param string $thousands_separator |
|
58 | + * @return string |
|
59 | + */ |
|
60 | + public static function currencyThousandsSeparatorField($thousands_separator = ',') |
|
61 | + { |
|
62 | + return "//input[@class='CNT_cur_thsnds' and @value='$thousands_separator']"; |
|
63 | + } |
|
64 | 64 | } |
65 | 65 | \ No newline at end of file |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | $email_address, |
35 | 35 | $this->getAtIndex($email_address) |
36 | 36 | ); |
37 | - if (! checkdnsrr($domain, 'MX')) { |
|
37 | + if ( ! checkdnsrr($domain, 'MX')) { |
|
38 | 38 | // domain not found in MX records |
39 | 39 | throw new EmailValidationException( |
40 | 40 | __( |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | ) |
46 | 46 | ); |
47 | 47 | } |
48 | - if (! checkdnsrr($domain, 'A')) { |
|
48 | + if ( ! checkdnsrr($domain, 'A')) { |
|
49 | 49 | // domain not found in A records |
50 | 50 | throw new EmailValidationException( |
51 | 51 | __( |
@@ -15,43 +15,43 @@ |
||
15 | 15 | class InternationalDNS extends International |
16 | 16 | { |
17 | 17 | |
18 | - /** |
|
19 | - * Validates the email in teh same way as the parent, but also |
|
20 | - * verifies the domain exists. |
|
21 | - * |
|
22 | - * @param string $email_address |
|
23 | - * @return bool |
|
24 | - * @throws EmailValidationException |
|
25 | - */ |
|
26 | - public function validate($email_address) |
|
27 | - { |
|
28 | - parent::validate($email_address); |
|
29 | - $domain = $this->getDomainPartOfEmail( |
|
30 | - $email_address, |
|
31 | - $this->getAtIndex($email_address) |
|
32 | - ); |
|
33 | - if (! checkdnsrr($domain, 'MX')) { |
|
34 | - // domain not found in MX records |
|
35 | - throw new EmailValidationException( |
|
36 | - __( |
|
37 | - // @codingStandardsIgnoreStart |
|
38 | - 'Although the email address provided is formatted correctly, a valid "MX record" could not be located for that address and domain. Please enter a valid email address.', |
|
39 | - // @codingStandardsIgnoreEnd |
|
40 | - 'event_espresso' |
|
41 | - ) |
|
42 | - ); |
|
43 | - } |
|
44 | - if (! checkdnsrr($domain, 'A')) { |
|
45 | - // domain not found in A records |
|
46 | - throw new EmailValidationException( |
|
47 | - __( |
|
48 | - // @codingStandardsIgnoreStart |
|
49 | - 'Although the email address provided is formatted correctly, a valid "A record" could not be located for that address and domain. Please enter a valid email address.', |
|
50 | - // @codingStandardsIgnoreEnd |
|
51 | - 'event_espresso' |
|
52 | - ) |
|
53 | - ); |
|
54 | - } |
|
55 | - return true; |
|
56 | - } |
|
18 | + /** |
|
19 | + * Validates the email in teh same way as the parent, but also |
|
20 | + * verifies the domain exists. |
|
21 | + * |
|
22 | + * @param string $email_address |
|
23 | + * @return bool |
|
24 | + * @throws EmailValidationException |
|
25 | + */ |
|
26 | + public function validate($email_address) |
|
27 | + { |
|
28 | + parent::validate($email_address); |
|
29 | + $domain = $this->getDomainPartOfEmail( |
|
30 | + $email_address, |
|
31 | + $this->getAtIndex($email_address) |
|
32 | + ); |
|
33 | + if (! checkdnsrr($domain, 'MX')) { |
|
34 | + // domain not found in MX records |
|
35 | + throw new EmailValidationException( |
|
36 | + __( |
|
37 | + // @codingStandardsIgnoreStart |
|
38 | + 'Although the email address provided is formatted correctly, a valid "MX record" could not be located for that address and domain. Please enter a valid email address.', |
|
39 | + // @codingStandardsIgnoreEnd |
|
40 | + 'event_espresso' |
|
41 | + ) |
|
42 | + ); |
|
43 | + } |
|
44 | + if (! checkdnsrr($domain, 'A')) { |
|
45 | + // domain not found in A records |
|
46 | + throw new EmailValidationException( |
|
47 | + __( |
|
48 | + // @codingStandardsIgnoreStart |
|
49 | + 'Although the email address provided is formatted correctly, a valid "A record" could not be located for that address and domain. Please enter a valid email address.', |
|
50 | + // @codingStandardsIgnoreEnd |
|
51 | + 'event_espresso' |
|
52 | + ) |
|
53 | + ); |
|
54 | + } |
|
55 | + return true; |
|
56 | + } |
|
57 | 57 | } |
@@ -18,14 +18,14 @@ |
||
18 | 18 | interface EmailValidatorInterface |
19 | 19 | { |
20 | 20 | |
21 | - /** |
|
22 | - * Validates the supplied email address. If it is invalid, throws EmailValidationException |
|
23 | - * |
|
24 | - * @param string $email_address |
|
25 | - * @return boolean |
|
26 | - * @throws EmailValidationException |
|
27 | - */ |
|
28 | - public function validate($email_address); |
|
21 | + /** |
|
22 | + * Validates the supplied email address. If it is invalid, throws EmailValidationException |
|
23 | + * |
|
24 | + * @param string $email_address |
|
25 | + * @return boolean |
|
26 | + * @throws EmailValidationException |
|
27 | + */ |
|
28 | + public function validate($email_address); |
|
29 | 29 | |
30 | 30 | |
31 | 31 | } |
@@ -18,72 +18,72 @@ |
||
18 | 18 | { |
19 | 19 | |
20 | 20 | |
21 | - /** |
|
22 | - * @param string $validation_error_message |
|
23 | - */ |
|
24 | - public function __construct($validation_error_message = '') |
|
25 | - { |
|
26 | - if (! $validation_error_message) { |
|
27 | - $validation_error_message = esc_html__('Please enter a valid email address.', 'event_espresso'); |
|
28 | - } |
|
29 | - parent::__construct($validation_error_message); |
|
30 | - } |
|
21 | + /** |
|
22 | + * @param string $validation_error_message |
|
23 | + */ |
|
24 | + public function __construct($validation_error_message = '') |
|
25 | + { |
|
26 | + if (! $validation_error_message) { |
|
27 | + $validation_error_message = esc_html__('Please enter a valid email address.', 'event_espresso'); |
|
28 | + } |
|
29 | + parent::__construct($validation_error_message); |
|
30 | + } |
|
31 | 31 | |
32 | 32 | |
33 | 33 | |
34 | - /** |
|
35 | - * just checks the field isn't blank |
|
36 | - * |
|
37 | - * @param $normalized_value |
|
38 | - * @return bool |
|
39 | - * @throws InvalidArgumentException |
|
40 | - * @throws InvalidInterfaceException |
|
41 | - * @throws InvalidDataTypeException |
|
42 | - * @throws EE_Validation_Error |
|
43 | - */ |
|
44 | - public function validate($normalized_value) |
|
45 | - { |
|
46 | - if ($normalized_value && ! $this->_validate_email($normalized_value)) { |
|
47 | - throw new EE_Validation_Error($this->get_validation_error_message(), 'required'); |
|
48 | - } |
|
49 | - return true; |
|
50 | - } |
|
34 | + /** |
|
35 | + * just checks the field isn't blank |
|
36 | + * |
|
37 | + * @param $normalized_value |
|
38 | + * @return bool |
|
39 | + * @throws InvalidArgumentException |
|
40 | + * @throws InvalidInterfaceException |
|
41 | + * @throws InvalidDataTypeException |
|
42 | + * @throws EE_Validation_Error |
|
43 | + */ |
|
44 | + public function validate($normalized_value) |
|
45 | + { |
|
46 | + if ($normalized_value && ! $this->_validate_email($normalized_value)) { |
|
47 | + throw new EE_Validation_Error($this->get_validation_error_message(), 'required'); |
|
48 | + } |
|
49 | + return true; |
|
50 | + } |
|
51 | 51 | |
52 | 52 | |
53 | 53 | |
54 | - /** |
|
55 | - * @return array |
|
56 | - */ |
|
57 | - public function get_jquery_validation_rule_array() |
|
58 | - { |
|
59 | - return array('email' => true, 'messages' => array('email' => $this->get_validation_error_message())); |
|
60 | - } |
|
54 | + /** |
|
55 | + * @return array |
|
56 | + */ |
|
57 | + public function get_jquery_validation_rule_array() |
|
58 | + { |
|
59 | + return array('email' => true, 'messages' => array('email' => $this->get_validation_error_message())); |
|
60 | + } |
|
61 | 61 | |
62 | 62 | |
63 | 63 | |
64 | - /** |
|
65 | - * Validate an email address. |
|
66 | - * Provide email address (raw input) |
|
67 | - * |
|
68 | - * @param $email |
|
69 | - * @return bool of whether the email is valid or not |
|
70 | - * @throws InvalidArgumentException |
|
71 | - * @throws InvalidInterfaceException |
|
72 | - * @throws InvalidDataTypeException |
|
73 | - * @throws EE_Validation_Error |
|
74 | - */ |
|
75 | - private function _validate_email($email) |
|
76 | - { |
|
77 | - try { |
|
78 | - EmailAddressFactory::create($email); |
|
79 | - } catch (EmailValidationException $e) { |
|
80 | - throw new EE_Validation_Error( |
|
81 | - $e->getMessage(), |
|
82 | - 'invalid_email', |
|
83 | - $this->_input, |
|
84 | - $e |
|
85 | - ); |
|
86 | - } |
|
87 | - return true; |
|
88 | - } |
|
64 | + /** |
|
65 | + * Validate an email address. |
|
66 | + * Provide email address (raw input) |
|
67 | + * |
|
68 | + * @param $email |
|
69 | + * @return bool of whether the email is valid or not |
|
70 | + * @throws InvalidArgumentException |
|
71 | + * @throws InvalidInterfaceException |
|
72 | + * @throws InvalidDataTypeException |
|
73 | + * @throws EE_Validation_Error |
|
74 | + */ |
|
75 | + private function _validate_email($email) |
|
76 | + { |
|
77 | + try { |
|
78 | + EmailAddressFactory::create($email); |
|
79 | + } catch (EmailValidationException $e) { |
|
80 | + throw new EE_Validation_Error( |
|
81 | + $e->getMessage(), |
|
82 | + 'invalid_email', |
|
83 | + $this->_input, |
|
84 | + $e |
|
85 | + ); |
|
86 | + } |
|
87 | + return true; |
|
88 | + } |
|
89 | 89 | } |
@@ -23,7 +23,7 @@ |
||
23 | 23 | */ |
24 | 24 | public function __construct($validation_error_message = '') |
25 | 25 | { |
26 | - if (! $validation_error_message) { |
|
26 | + if ( ! $validation_error_message) { |
|
27 | 27 | $validation_error_message = esc_html__('Please enter a valid email address.', 'event_espresso'); |
28 | 28 | } |
29 | 29 | parent::__construct($validation_error_message); |
@@ -48,7 +48,7 @@ |
||
48 | 48 | */ |
49 | 49 | public function verifySystemActivated(ActivatableInterface $system_activated) |
50 | 50 | { |
51 | - if (! ($system_activated instanceof EE_System || $system_activated instanceof EE_Addon)) { |
|
51 | + if ( ! ($system_activated instanceof EE_System || $system_activated instanceof EE_Addon)) { |
|
52 | 52 | throw new InvalidArgumentException( |
53 | 53 | sprintf( |
54 | 54 | esc_html__( |
@@ -23,205 +23,205 @@ |
||
23 | 23 | class ActivationHandler |
24 | 24 | { |
25 | 25 | |
26 | - /** |
|
27 | - * @var EE_Maintenance_Mode $maintenance_mode |
|
28 | - */ |
|
29 | - private $maintenance_mode; |
|
30 | - |
|
31 | - |
|
32 | - |
|
33 | - /** |
|
34 | - * ActivationHandler constructor. |
|
35 | - * |
|
36 | - * @param EE_Maintenance_Mode $maintenance_mode |
|
37 | - */ |
|
38 | - public function __construct(EE_Maintenance_Mode $maintenance_mode) |
|
39 | - { |
|
40 | - $this->maintenance_mode = $maintenance_mode; |
|
41 | - } |
|
42 | - |
|
43 | - |
|
44 | - |
|
45 | - /** |
|
46 | - * @param ActivatableInterface $system_activated |
|
47 | - * @throws InvalidArgumentException |
|
48 | - */ |
|
49 | - public function verifySystemActivated(ActivatableInterface $system_activated) |
|
50 | - { |
|
51 | - if (! ($system_activated instanceof EE_System || $system_activated instanceof EE_Addon)) { |
|
52 | - throw new InvalidArgumentException( |
|
53 | - sprintf( |
|
54 | - esc_html__( |
|
55 | - 'The %1$s parameter must either be an instance of EE_System for Core, or an EE_Addon class. The following was supplied: %2$s%3$s', |
|
56 | - 'event_espresso' |
|
57 | - ), |
|
58 | - '$system', |
|
59 | - '<br />', |
|
60 | - var_export($system_activated, true) |
|
61 | - ) |
|
62 | - ); |
|
63 | - } |
|
64 | - } |
|
65 | - |
|
66 | - |
|
67 | - |
|
68 | - /** |
|
69 | - * switches handling based on activation type |
|
70 | - * |
|
71 | - * @param ActivatableInterface $system_activated |
|
72 | - * @param ActivationType $activation_type |
|
73 | - * @param ActivationHistory $activation_history |
|
74 | - * @return bool |
|
75 | - * @throws InvalidArgumentException |
|
76 | - */ |
|
77 | - public function detectActivationOrVersionChange( |
|
78 | - ActivatableInterface $system_activated, |
|
79 | - ActivationType $activation_type, |
|
80 | - ActivationHistory $activation_history |
|
81 | - ) { |
|
82 | - $this->verifySystemActivated($system_activated); |
|
83 | - do_action( |
|
84 | - 'AHEE__EventEspresso_core_services_activation_ActivationHandler__detectActivationOrVersionChange__before_detection', |
|
85 | - $system_activated, |
|
86 | - $this |
|
87 | - ); |
|
88 | - switch ($activation_type->getActivationType()) { |
|
89 | - case ActivationType::NEW_ACTIVATION: |
|
90 | - $activation_detected = $this->handleNewActivation( |
|
91 | - $system_activated, |
|
92 | - $activation_history |
|
93 | - ); |
|
94 | - break; |
|
95 | - case ActivationType::REACTIVATION: |
|
96 | - $activation_detected = $this->handleReactivation( |
|
97 | - $system_activated, |
|
98 | - $activation_history |
|
99 | - ); |
|
100 | - break; |
|
101 | - case ActivationType::UPGRADE: |
|
102 | - $activation_detected = $this->handleUpgrade( |
|
103 | - $system_activated, |
|
104 | - $activation_history |
|
105 | - ); |
|
106 | - break; |
|
107 | - case ActivationType::DOWNGRADE: |
|
108 | - $activation_detected = $this->handleDowngrade( |
|
109 | - $system_activated, |
|
110 | - $activation_history |
|
111 | - ); |
|
112 | - break; |
|
113 | - case ActivationType::NOT_ACTIVATION: |
|
114 | - default: |
|
115 | - $activation_detected = $this->handleNormalRequest($system_activated); |
|
116 | - break; |
|
117 | - } |
|
118 | - do_action( |
|
119 | - 'AHEE__EventEspresso_core_services_activation_ActivationHandler__detectActivationOrVersionChange__detection_complete', |
|
120 | - $system_activated, |
|
121 | - $this |
|
122 | - ); |
|
123 | - return $activation_detected; |
|
124 | - } |
|
125 | - |
|
126 | - |
|
127 | - |
|
128 | - /** |
|
129 | - * handling for new activations |
|
130 | - * |
|
131 | - * @param ActivatableInterface $system_activated |
|
132 | - * @param ActivationHistory $activation_history |
|
133 | - * @return boolean |
|
134 | - */ |
|
135 | - private function handleNewActivation(ActivatableInterface $system_activated, ActivationHistory $activation_history) |
|
136 | - { |
|
137 | - do_action( |
|
138 | - 'AHEE__EventEspresso_core_services_activation_ActivationHandler__handleNewActivation', |
|
139 | - $system_activated, |
|
140 | - $this |
|
141 | - ); |
|
142 | - $activation_history->updateActivationHistory(); |
|
143 | - return true; |
|
144 | - } |
|
145 | - |
|
146 | - |
|
147 | - |
|
148 | - /** |
|
149 | - * handling for reactivations |
|
150 | - * |
|
151 | - * @param ActivatableInterface $system_activated |
|
152 | - * @param ActivationHistory $activation_history |
|
153 | - * @return boolean |
|
154 | - */ |
|
155 | - private function handleReactivation(ActivatableInterface $system_activated, ActivationHistory $activation_history) |
|
156 | - { |
|
157 | - do_action( |
|
158 | - 'AHEE__EventEspresso_core_services_activation_ActivationHandler__handleReactivation', |
|
159 | - $system_activated, |
|
160 | - $this |
|
161 | - ); |
|
162 | - $activation_history->updateActivationHistory(); |
|
163 | - return true; |
|
164 | - } |
|
165 | - |
|
166 | - |
|
167 | - |
|
168 | - /** |
|
169 | - * handling for upgrades |
|
170 | - * |
|
171 | - * @param ActivatableInterface $system_activated |
|
172 | - * @param ActivationHistory $activation_history |
|
173 | - * @return boolean |
|
174 | - */ |
|
175 | - private function handleUpgrade(ActivatableInterface $system_activated, ActivationHistory $activation_history) |
|
176 | - { |
|
177 | - do_action( |
|
178 | - 'AHEE__EventEspresso_core_services_activation_ActivationHandler__handleUpgrade', |
|
179 | - $system_activated, |
|
180 | - $this |
|
181 | - ); |
|
182 | - $this->maintenance_mode->set_maintenance_mode_if_db_old(); |
|
183 | - $activation_history->updateActivationHistory(); |
|
184 | - return true; |
|
185 | - } |
|
186 | - |
|
187 | - |
|
188 | - |
|
189 | - /** |
|
190 | - * handling for downgrades |
|
191 | - * |
|
192 | - * @param ActivatableInterface $system_activated |
|
193 | - * @param ActivationHistory $activation_history |
|
194 | - * @return boolean |
|
195 | - */ |
|
196 | - private function handleDowngrade(ActivatableInterface $system_activated, ActivationHistory $activation_history) |
|
197 | - { |
|
198 | - do_action( |
|
199 | - 'AHEE__EventEspresso_core_services_activation_ActivationHandler__handleDowngrade', |
|
200 | - $system_activated, |
|
201 | - $this |
|
202 | - ); |
|
203 | - $this->maintenance_mode->set_maintenance_mode_if_db_old(); |
|
204 | - $activation_history->updateActivationHistory(); |
|
205 | - return true; |
|
206 | - } |
|
207 | - |
|
208 | - |
|
209 | - |
|
210 | - /** |
|
211 | - * handling for normal requests |
|
212 | - * |
|
213 | - * @param ActivatableInterface $system_activated |
|
214 | - * @return boolean |
|
215 | - */ |
|
216 | - private function handleNormalRequest(ActivatableInterface $system_activated) |
|
217 | - { |
|
218 | - do_action( |
|
219 | - 'AHEE__EventEspresso_core_services_activation_ActivationHandler__handleNormalRequest', |
|
220 | - $system_activated, |
|
221 | - $this |
|
222 | - ); |
|
223 | - return false; |
|
224 | - } |
|
26 | + /** |
|
27 | + * @var EE_Maintenance_Mode $maintenance_mode |
|
28 | + */ |
|
29 | + private $maintenance_mode; |
|
30 | + |
|
31 | + |
|
32 | + |
|
33 | + /** |
|
34 | + * ActivationHandler constructor. |
|
35 | + * |
|
36 | + * @param EE_Maintenance_Mode $maintenance_mode |
|
37 | + */ |
|
38 | + public function __construct(EE_Maintenance_Mode $maintenance_mode) |
|
39 | + { |
|
40 | + $this->maintenance_mode = $maintenance_mode; |
|
41 | + } |
|
42 | + |
|
43 | + |
|
44 | + |
|
45 | + /** |
|
46 | + * @param ActivatableInterface $system_activated |
|
47 | + * @throws InvalidArgumentException |
|
48 | + */ |
|
49 | + public function verifySystemActivated(ActivatableInterface $system_activated) |
|
50 | + { |
|
51 | + if (! ($system_activated instanceof EE_System || $system_activated instanceof EE_Addon)) { |
|
52 | + throw new InvalidArgumentException( |
|
53 | + sprintf( |
|
54 | + esc_html__( |
|
55 | + 'The %1$s parameter must either be an instance of EE_System for Core, or an EE_Addon class. The following was supplied: %2$s%3$s', |
|
56 | + 'event_espresso' |
|
57 | + ), |
|
58 | + '$system', |
|
59 | + '<br />', |
|
60 | + var_export($system_activated, true) |
|
61 | + ) |
|
62 | + ); |
|
63 | + } |
|
64 | + } |
|
65 | + |
|
66 | + |
|
67 | + |
|
68 | + /** |
|
69 | + * switches handling based on activation type |
|
70 | + * |
|
71 | + * @param ActivatableInterface $system_activated |
|
72 | + * @param ActivationType $activation_type |
|
73 | + * @param ActivationHistory $activation_history |
|
74 | + * @return bool |
|
75 | + * @throws InvalidArgumentException |
|
76 | + */ |
|
77 | + public function detectActivationOrVersionChange( |
|
78 | + ActivatableInterface $system_activated, |
|
79 | + ActivationType $activation_type, |
|
80 | + ActivationHistory $activation_history |
|
81 | + ) { |
|
82 | + $this->verifySystemActivated($system_activated); |
|
83 | + do_action( |
|
84 | + 'AHEE__EventEspresso_core_services_activation_ActivationHandler__detectActivationOrVersionChange__before_detection', |
|
85 | + $system_activated, |
|
86 | + $this |
|
87 | + ); |
|
88 | + switch ($activation_type->getActivationType()) { |
|
89 | + case ActivationType::NEW_ACTIVATION: |
|
90 | + $activation_detected = $this->handleNewActivation( |
|
91 | + $system_activated, |
|
92 | + $activation_history |
|
93 | + ); |
|
94 | + break; |
|
95 | + case ActivationType::REACTIVATION: |
|
96 | + $activation_detected = $this->handleReactivation( |
|
97 | + $system_activated, |
|
98 | + $activation_history |
|
99 | + ); |
|
100 | + break; |
|
101 | + case ActivationType::UPGRADE: |
|
102 | + $activation_detected = $this->handleUpgrade( |
|
103 | + $system_activated, |
|
104 | + $activation_history |
|
105 | + ); |
|
106 | + break; |
|
107 | + case ActivationType::DOWNGRADE: |
|
108 | + $activation_detected = $this->handleDowngrade( |
|
109 | + $system_activated, |
|
110 | + $activation_history |
|
111 | + ); |
|
112 | + break; |
|
113 | + case ActivationType::NOT_ACTIVATION: |
|
114 | + default: |
|
115 | + $activation_detected = $this->handleNormalRequest($system_activated); |
|
116 | + break; |
|
117 | + } |
|
118 | + do_action( |
|
119 | + 'AHEE__EventEspresso_core_services_activation_ActivationHandler__detectActivationOrVersionChange__detection_complete', |
|
120 | + $system_activated, |
|
121 | + $this |
|
122 | + ); |
|
123 | + return $activation_detected; |
|
124 | + } |
|
125 | + |
|
126 | + |
|
127 | + |
|
128 | + /** |
|
129 | + * handling for new activations |
|
130 | + * |
|
131 | + * @param ActivatableInterface $system_activated |
|
132 | + * @param ActivationHistory $activation_history |
|
133 | + * @return boolean |
|
134 | + */ |
|
135 | + private function handleNewActivation(ActivatableInterface $system_activated, ActivationHistory $activation_history) |
|
136 | + { |
|
137 | + do_action( |
|
138 | + 'AHEE__EventEspresso_core_services_activation_ActivationHandler__handleNewActivation', |
|
139 | + $system_activated, |
|
140 | + $this |
|
141 | + ); |
|
142 | + $activation_history->updateActivationHistory(); |
|
143 | + return true; |
|
144 | + } |
|
145 | + |
|
146 | + |
|
147 | + |
|
148 | + /** |
|
149 | + * handling for reactivations |
|
150 | + * |
|
151 | + * @param ActivatableInterface $system_activated |
|
152 | + * @param ActivationHistory $activation_history |
|
153 | + * @return boolean |
|
154 | + */ |
|
155 | + private function handleReactivation(ActivatableInterface $system_activated, ActivationHistory $activation_history) |
|
156 | + { |
|
157 | + do_action( |
|
158 | + 'AHEE__EventEspresso_core_services_activation_ActivationHandler__handleReactivation', |
|
159 | + $system_activated, |
|
160 | + $this |
|
161 | + ); |
|
162 | + $activation_history->updateActivationHistory(); |
|
163 | + return true; |
|
164 | + } |
|
165 | + |
|
166 | + |
|
167 | + |
|
168 | + /** |
|
169 | + * handling for upgrades |
|
170 | + * |
|
171 | + * @param ActivatableInterface $system_activated |
|
172 | + * @param ActivationHistory $activation_history |
|
173 | + * @return boolean |
|
174 | + */ |
|
175 | + private function handleUpgrade(ActivatableInterface $system_activated, ActivationHistory $activation_history) |
|
176 | + { |
|
177 | + do_action( |
|
178 | + 'AHEE__EventEspresso_core_services_activation_ActivationHandler__handleUpgrade', |
|
179 | + $system_activated, |
|
180 | + $this |
|
181 | + ); |
|
182 | + $this->maintenance_mode->set_maintenance_mode_if_db_old(); |
|
183 | + $activation_history->updateActivationHistory(); |
|
184 | + return true; |
|
185 | + } |
|
186 | + |
|
187 | + |
|
188 | + |
|
189 | + /** |
|
190 | + * handling for downgrades |
|
191 | + * |
|
192 | + * @param ActivatableInterface $system_activated |
|
193 | + * @param ActivationHistory $activation_history |
|
194 | + * @return boolean |
|
195 | + */ |
|
196 | + private function handleDowngrade(ActivatableInterface $system_activated, ActivationHistory $activation_history) |
|
197 | + { |
|
198 | + do_action( |
|
199 | + 'AHEE__EventEspresso_core_services_activation_ActivationHandler__handleDowngrade', |
|
200 | + $system_activated, |
|
201 | + $this |
|
202 | + ); |
|
203 | + $this->maintenance_mode->set_maintenance_mode_if_db_old(); |
|
204 | + $activation_history->updateActivationHistory(); |
|
205 | + return true; |
|
206 | + } |
|
207 | + |
|
208 | + |
|
209 | + |
|
210 | + /** |
|
211 | + * handling for normal requests |
|
212 | + * |
|
213 | + * @param ActivatableInterface $system_activated |
|
214 | + * @return boolean |
|
215 | + */ |
|
216 | + private function handleNormalRequest(ActivatableInterface $system_activated) |
|
217 | + { |
|
218 | + do_action( |
|
219 | + 'AHEE__EventEspresso_core_services_activation_ActivationHandler__handleNormalRequest', |
|
220 | + $system_activated, |
|
221 | + $this |
|
222 | + ); |
|
223 | + return false; |
|
224 | + } |
|
225 | 225 | |
226 | 226 | |
227 | 227 |
@@ -15,10 +15,10 @@ |
||
15 | 15 | interface InitializeInterface |
16 | 16 | { |
17 | 17 | |
18 | - /** |
|
19 | - * @param bool $verify_schema whether to verify the database's schema during this activation, or just its data. |
|
20 | - * This is a resource-intensive job so we prefer to only do it when necessary |
|
21 | - * @return void |
|
22 | - */ |
|
23 | - public function initialize($verify_schema = true); |
|
18 | + /** |
|
19 | + * @param bool $verify_schema whether to verify the database's schema during this activation, or just its data. |
|
20 | + * This is a resource-intensive job so we prefer to only do it when necessary |
|
21 | + * @return void |
|
22 | + */ |
|
23 | + public function initialize($verify_schema = true); |
|
24 | 24 | } |