@@ -16,129 +16,129 @@ |
||
16 | 16 | interface NoticesContainerInterface |
17 | 17 | { |
18 | 18 | |
19 | - /** |
|
20 | - * @param string $notice |
|
21 | - * @param bool $dismissible |
|
22 | - * @param string $file |
|
23 | - * @param string $func |
|
24 | - * @param string $line |
|
25 | - */ |
|
26 | - public function addInformation($notice, $dismissible = true, $file = '', $func = '', $line = ''); |
|
19 | + /** |
|
20 | + * @param string $notice |
|
21 | + * @param bool $dismissible |
|
22 | + * @param string $file |
|
23 | + * @param string $func |
|
24 | + * @param string $line |
|
25 | + */ |
|
26 | + public function addInformation($notice, $dismissible = true, $file = '', $func = '', $line = ''); |
|
27 | 27 | |
28 | 28 | |
29 | - /** |
|
30 | - * @param string $notice |
|
31 | - * @param bool $dismissible |
|
32 | - * @param string $file |
|
33 | - * @param string $func |
|
34 | - * @param string $line |
|
35 | - * @return |
|
36 | - */ |
|
37 | - public function addAttention($notice, $dismissible = true, $file = '', $func = '', $line = ''); |
|
29 | + /** |
|
30 | + * @param string $notice |
|
31 | + * @param bool $dismissible |
|
32 | + * @param string $file |
|
33 | + * @param string $func |
|
34 | + * @param string $line |
|
35 | + * @return |
|
36 | + */ |
|
37 | + public function addAttention($notice, $dismissible = true, $file = '', $func = '', $line = ''); |
|
38 | 38 | |
39 | 39 | |
40 | 40 | |
41 | - /** |
|
42 | - * @param string $notice |
|
43 | - * @param bool $dismissible |
|
44 | - * @param string $file |
|
45 | - * @param string $func |
|
46 | - * @param string $line |
|
47 | - */ |
|
48 | - public function addError($notice, $dismissible = true, $file, $func, $line); |
|
41 | + /** |
|
42 | + * @param string $notice |
|
43 | + * @param bool $dismissible |
|
44 | + * @param string $file |
|
45 | + * @param string $func |
|
46 | + * @param string $line |
|
47 | + */ |
|
48 | + public function addError($notice, $dismissible = true, $file, $func, $line); |
|
49 | 49 | |
50 | 50 | |
51 | 51 | |
52 | - /** |
|
53 | - * @param string $notice |
|
54 | - * @param bool $dismissible |
|
55 | - * @param string $file |
|
56 | - * @param string $func |
|
57 | - * @param string $line |
|
58 | - */ |
|
59 | - public function addSuccess($notice, $dismissible = true, $file = '', $func = '', $line = ''); |
|
52 | + /** |
|
53 | + * @param string $notice |
|
54 | + * @param bool $dismissible |
|
55 | + * @param string $file |
|
56 | + * @param string $func |
|
57 | + * @param string $line |
|
58 | + */ |
|
59 | + public function addSuccess($notice, $dismissible = true, $file = '', $func = '', $line = ''); |
|
60 | 60 | |
61 | 61 | |
62 | 62 | |
63 | - /** |
|
64 | - * @return boolean |
|
65 | - */ |
|
66 | - public function hasInformation(); |
|
63 | + /** |
|
64 | + * @return boolean |
|
65 | + */ |
|
66 | + public function hasInformation(); |
|
67 | 67 | |
68 | 68 | |
69 | 69 | |
70 | - /** |
|
71 | - * @return boolean |
|
72 | - */ |
|
73 | - public function hasAttention(); |
|
70 | + /** |
|
71 | + * @return boolean |
|
72 | + */ |
|
73 | + public function hasAttention(); |
|
74 | 74 | |
75 | 75 | |
76 | 76 | |
77 | - /** |
|
78 | - * @return boolean |
|
79 | - */ |
|
80 | - public function hasError(); |
|
77 | + /** |
|
78 | + * @return boolean |
|
79 | + */ |
|
80 | + public function hasError(); |
|
81 | 81 | |
82 | 82 | |
83 | 83 | |
84 | - /** |
|
85 | - * @return boolean |
|
86 | - */ |
|
87 | - public function hasSuccess(); |
|
84 | + /** |
|
85 | + * @return boolean |
|
86 | + */ |
|
87 | + public function hasSuccess(); |
|
88 | 88 | |
89 | 89 | |
90 | 90 | |
91 | - /** |
|
92 | - * @return int |
|
93 | - */ |
|
94 | - public function countInformation(); |
|
91 | + /** |
|
92 | + * @return int |
|
93 | + */ |
|
94 | + public function countInformation(); |
|
95 | 95 | |
96 | 96 | |
97 | 97 | |
98 | - /** |
|
99 | - * @return int |
|
100 | - */ |
|
101 | - public function countAttention(); |
|
98 | + /** |
|
99 | + * @return int |
|
100 | + */ |
|
101 | + public function countAttention(); |
|
102 | 102 | |
103 | 103 | |
104 | 104 | |
105 | - /** |
|
106 | - * @return int |
|
107 | - */ |
|
108 | - public function countError(); |
|
105 | + /** |
|
106 | + * @return int |
|
107 | + */ |
|
108 | + public function countError(); |
|
109 | 109 | |
110 | 110 | |
111 | 111 | |
112 | - /** |
|
113 | - * @return int |
|
114 | - */ |
|
115 | - public function countSuccess(); |
|
112 | + /** |
|
113 | + * @return int |
|
114 | + */ |
|
115 | + public function countSuccess(); |
|
116 | 116 | |
117 | 117 | |
118 | 118 | |
119 | - /** |
|
120 | - * @return NoticeInterface[] |
|
121 | - */ |
|
122 | - public function getInformation(); |
|
119 | + /** |
|
120 | + * @return NoticeInterface[] |
|
121 | + */ |
|
122 | + public function getInformation(); |
|
123 | 123 | |
124 | 124 | |
125 | 125 | |
126 | - /** |
|
127 | - * @return NoticeInterface[] |
|
128 | - */ |
|
129 | - public function getAttention(); |
|
126 | + /** |
|
127 | + * @return NoticeInterface[] |
|
128 | + */ |
|
129 | + public function getAttention(); |
|
130 | 130 | |
131 | 131 | |
132 | 132 | |
133 | - /** |
|
134 | - * @return NoticeInterface[] |
|
135 | - */ |
|
136 | - public function getError(); |
|
133 | + /** |
|
134 | + * @return NoticeInterface[] |
|
135 | + */ |
|
136 | + public function getError(); |
|
137 | 137 | |
138 | 138 | |
139 | 139 | |
140 | - /** |
|
141 | - * @return NoticeInterface[] |
|
142 | - */ |
|
143 | - public function getSuccess(); |
|
140 | + /** |
|
141 | + * @return NoticeInterface[] |
|
142 | + */ |
|
143 | + public function getSuccess(); |
|
144 | 144 | } |
@@ -17,121 +17,121 @@ |
||
17 | 17 | class AdminNotice |
18 | 18 | { |
19 | 19 | |
20 | - const ERROR = 'notice-error'; |
|
21 | - |
|
22 | - const WARNING = 'notice-warning'; |
|
23 | - |
|
24 | - const SUCCESS = 'notice-success'; |
|
25 | - |
|
26 | - const INFORMATION = 'notice-info'; |
|
27 | - |
|
28 | - const DISMISSABLE = ' is-dismissible'; |
|
29 | - |
|
30 | - /** |
|
31 | - * generic system notice to be converted into a WP admin notice |
|
32 | - * |
|
33 | - * @var NoticeInterface $notice |
|
34 | - */ |
|
35 | - private $notice; |
|
36 | - |
|
37 | - |
|
38 | - /** |
|
39 | - * AdminNotice constructor. |
|
40 | - * |
|
41 | - * @param NoticeInterface $notice |
|
42 | - * @param bool $display_now |
|
43 | - */ |
|
44 | - public function __construct(NoticeInterface $notice, $display_now = true) |
|
45 | - { |
|
46 | - $this->notice = $notice; |
|
47 | - if (! did_action('admin_notices')) { |
|
48 | - add_action('admin_notices', array($this, 'displayNotice')); |
|
49 | - } elseif ($display_now) { |
|
50 | - $this->displayNotice(); |
|
51 | - } |
|
52 | - } |
|
53 | - |
|
54 | - |
|
55 | - /** |
|
56 | - * @return void |
|
57 | - */ |
|
58 | - public function displayNotice() |
|
59 | - { |
|
60 | - echo $this->getNotice(); |
|
61 | - } |
|
62 | - |
|
63 | - |
|
64 | - /** |
|
65 | - * produces something like: |
|
66 | - * <div class="notice notice-success is-dismissible event-espresso-admin-notice"> |
|
67 | - * <p>YOU DID IT!</p> |
|
68 | - * <button type="button" class="notice-dismiss"><span class="screen-reader-text">Dismiss this |
|
69 | - * notice.</span></button> |
|
70 | - * </div> |
|
71 | - * |
|
72 | - * @return string |
|
73 | - */ |
|
74 | - public function getNotice() |
|
75 | - { |
|
76 | - return sprintf( |
|
77 | - '<div class="notice %1$s%2$s event-espresso-admin-notice"><p>%3$s</p></div>', |
|
78 | - $this->getType(), |
|
79 | - $this->notice->isDismissible() ? AdminNotice::DISMISSABLE : '', |
|
80 | - $this->getMessage() |
|
81 | - ); |
|
82 | - } |
|
83 | - |
|
84 | - |
|
85 | - /** |
|
86 | - * @return string |
|
87 | - */ |
|
88 | - private function getType() |
|
89 | - { |
|
90 | - switch ($this->notice->type()) { |
|
91 | - case Notice::ERROR : |
|
92 | - return AdminNotice::ERROR; |
|
93 | - break; |
|
94 | - case Notice::ATTENTION : |
|
95 | - return AdminNotice::WARNING; |
|
96 | - break; |
|
97 | - case Notice::SUCCESS : |
|
98 | - return AdminNotice::SUCCESS; |
|
99 | - break; |
|
100 | - case Notice::INFORMATION : |
|
101 | - default: |
|
102 | - return AdminNotice::INFORMATION; |
|
103 | - break; |
|
104 | - } |
|
105 | - } |
|
106 | - |
|
107 | - |
|
108 | - /** |
|
109 | - * @return string |
|
110 | - */ |
|
111 | - protected function getMessage() |
|
112 | - { |
|
113 | - $message = $this->notice->message(); |
|
114 | - if (WP_DEBUG && $this->getType() === AdminNotice::ERROR) { |
|
115 | - $message .= '<br/><span class="tiny-text">' . $this->generateErrorCode() . '</span>'; |
|
116 | - } |
|
117 | - return $message; |
|
118 | - } |
|
119 | - |
|
120 | - |
|
121 | - /** |
|
122 | - * create error code from filepath, function name, |
|
123 | - * and line number where notice was generated |
|
124 | - * |
|
125 | - * @return string |
|
126 | - */ |
|
127 | - protected function generateErrorCode() |
|
128 | - { |
|
129 | - $file = explode('.', basename($this->notice->file())); |
|
130 | - $error_code = ! empty($file[0]) ? $file[0] : ''; |
|
131 | - $error_code .= ! empty($error_code) ? ' - ' . $this->notice->func() : $this->notice->func(); |
|
132 | - $error_code .= ' - ' . $this->notice->line(); |
|
133 | - return $error_code; |
|
134 | - } |
|
20 | + const ERROR = 'notice-error'; |
|
21 | + |
|
22 | + const WARNING = 'notice-warning'; |
|
23 | + |
|
24 | + const SUCCESS = 'notice-success'; |
|
25 | + |
|
26 | + const INFORMATION = 'notice-info'; |
|
27 | + |
|
28 | + const DISMISSABLE = ' is-dismissible'; |
|
29 | + |
|
30 | + /** |
|
31 | + * generic system notice to be converted into a WP admin notice |
|
32 | + * |
|
33 | + * @var NoticeInterface $notice |
|
34 | + */ |
|
35 | + private $notice; |
|
36 | + |
|
37 | + |
|
38 | + /** |
|
39 | + * AdminNotice constructor. |
|
40 | + * |
|
41 | + * @param NoticeInterface $notice |
|
42 | + * @param bool $display_now |
|
43 | + */ |
|
44 | + public function __construct(NoticeInterface $notice, $display_now = true) |
|
45 | + { |
|
46 | + $this->notice = $notice; |
|
47 | + if (! did_action('admin_notices')) { |
|
48 | + add_action('admin_notices', array($this, 'displayNotice')); |
|
49 | + } elseif ($display_now) { |
|
50 | + $this->displayNotice(); |
|
51 | + } |
|
52 | + } |
|
53 | + |
|
54 | + |
|
55 | + /** |
|
56 | + * @return void |
|
57 | + */ |
|
58 | + public function displayNotice() |
|
59 | + { |
|
60 | + echo $this->getNotice(); |
|
61 | + } |
|
62 | + |
|
63 | + |
|
64 | + /** |
|
65 | + * produces something like: |
|
66 | + * <div class="notice notice-success is-dismissible event-espresso-admin-notice"> |
|
67 | + * <p>YOU DID IT!</p> |
|
68 | + * <button type="button" class="notice-dismiss"><span class="screen-reader-text">Dismiss this |
|
69 | + * notice.</span></button> |
|
70 | + * </div> |
|
71 | + * |
|
72 | + * @return string |
|
73 | + */ |
|
74 | + public function getNotice() |
|
75 | + { |
|
76 | + return sprintf( |
|
77 | + '<div class="notice %1$s%2$s event-espresso-admin-notice"><p>%3$s</p></div>', |
|
78 | + $this->getType(), |
|
79 | + $this->notice->isDismissible() ? AdminNotice::DISMISSABLE : '', |
|
80 | + $this->getMessage() |
|
81 | + ); |
|
82 | + } |
|
83 | + |
|
84 | + |
|
85 | + /** |
|
86 | + * @return string |
|
87 | + */ |
|
88 | + private function getType() |
|
89 | + { |
|
90 | + switch ($this->notice->type()) { |
|
91 | + case Notice::ERROR : |
|
92 | + return AdminNotice::ERROR; |
|
93 | + break; |
|
94 | + case Notice::ATTENTION : |
|
95 | + return AdminNotice::WARNING; |
|
96 | + break; |
|
97 | + case Notice::SUCCESS : |
|
98 | + return AdminNotice::SUCCESS; |
|
99 | + break; |
|
100 | + case Notice::INFORMATION : |
|
101 | + default: |
|
102 | + return AdminNotice::INFORMATION; |
|
103 | + break; |
|
104 | + } |
|
105 | + } |
|
106 | + |
|
107 | + |
|
108 | + /** |
|
109 | + * @return string |
|
110 | + */ |
|
111 | + protected function getMessage() |
|
112 | + { |
|
113 | + $message = $this->notice->message(); |
|
114 | + if (WP_DEBUG && $this->getType() === AdminNotice::ERROR) { |
|
115 | + $message .= '<br/><span class="tiny-text">' . $this->generateErrorCode() . '</span>'; |
|
116 | + } |
|
117 | + return $message; |
|
118 | + } |
|
119 | + |
|
120 | + |
|
121 | + /** |
|
122 | + * create error code from filepath, function name, |
|
123 | + * and line number where notice was generated |
|
124 | + * |
|
125 | + * @return string |
|
126 | + */ |
|
127 | + protected function generateErrorCode() |
|
128 | + { |
|
129 | + $file = explode('.', basename($this->notice->file())); |
|
130 | + $error_code = ! empty($file[0]) ? $file[0] : ''; |
|
131 | + $error_code .= ! empty($error_code) ? ' - ' . $this->notice->func() : $this->notice->func(); |
|
132 | + $error_code .= ' - ' . $this->notice->line(); |
|
133 | + return $error_code; |
|
134 | + } |
|
135 | 135 | |
136 | 136 | |
137 | 137 | } |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | public function __construct(NoticeInterface $notice, $display_now = true) |
45 | 45 | { |
46 | 46 | $this->notice = $notice; |
47 | - if (! did_action('admin_notices')) { |
|
47 | + if ( ! did_action('admin_notices')) { |
|
48 | 48 | add_action('admin_notices', array($this, 'displayNotice')); |
49 | 49 | } elseif ($display_now) { |
50 | 50 | $this->displayNotice(); |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | { |
113 | 113 | $message = $this->notice->message(); |
114 | 114 | if (WP_DEBUG && $this->getType() === AdminNotice::ERROR) { |
115 | - $message .= '<br/><span class="tiny-text">' . $this->generateErrorCode() . '</span>'; |
|
115 | + $message .= '<br/><span class="tiny-text">'.$this->generateErrorCode().'</span>'; |
|
116 | 116 | } |
117 | 117 | return $message; |
118 | 118 | } |
@@ -128,8 +128,8 @@ discard block |
||
128 | 128 | { |
129 | 129 | $file = explode('.', basename($this->notice->file())); |
130 | 130 | $error_code = ! empty($file[0]) ? $file[0] : ''; |
131 | - $error_code .= ! empty($error_code) ? ' - ' . $this->notice->func() : $this->notice->func(); |
|
132 | - $error_code .= ' - ' . $this->notice->line(); |
|
131 | + $error_code .= ! empty($error_code) ? ' - '.$this->notice->func() : $this->notice->func(); |
|
132 | + $error_code .= ' - '.$this->notice->line(); |
|
133 | 133 | return $error_code; |
134 | 134 | } |
135 | 135 |
@@ -19,44 +19,44 @@ |
||
19 | 19 | class ConvertNoticesToAdminNotices extends NoticeConverter |
20 | 20 | { |
21 | 21 | |
22 | - /** |
|
23 | - * Converts Notice objects into AdminNotice notifications |
|
24 | - * |
|
25 | - * @param NoticesContainerInterface $notices |
|
26 | - * @throws DomainException |
|
27 | - */ |
|
28 | - public function process(NoticesContainerInterface $notices) |
|
29 | - { |
|
30 | - if ($notices->hasAttention()) { |
|
31 | - foreach ($notices->getAttention() as $notice) { |
|
32 | - new AdminNotice($notice); |
|
33 | - } |
|
34 | - } |
|
35 | - if ($notices->hasError()) { |
|
36 | - $error_string = esc_html__('The following errors occurred:', 'event_espresso'); |
|
37 | - foreach ($notices->getError() as $notice) { |
|
38 | - if ($this->getThrowExceptions()) { |
|
39 | - $error_string .= '<br />' . $notice->message(); |
|
40 | - } else { |
|
41 | - new AdminNotice($notice); |
|
42 | - } |
|
43 | - } |
|
44 | - if ($this->getThrowExceptions()) { |
|
45 | - throw new DomainException($error_string); |
|
46 | - } |
|
47 | - } |
|
48 | - if ($notices->hasSuccess()) { |
|
49 | - foreach ($notices->getSuccess() as $notice) { |
|
50 | - new AdminNotice($notice); |
|
51 | - } |
|
52 | - } |
|
53 | - if ($notices->hasInformation()) { |
|
54 | - foreach ($notices->getInformation() as $notice) { |
|
55 | - new AdminNotice($notice); |
|
56 | - } |
|
57 | - } |
|
58 | - $this->clearNotices(); |
|
59 | - } |
|
22 | + /** |
|
23 | + * Converts Notice objects into AdminNotice notifications |
|
24 | + * |
|
25 | + * @param NoticesContainerInterface $notices |
|
26 | + * @throws DomainException |
|
27 | + */ |
|
28 | + public function process(NoticesContainerInterface $notices) |
|
29 | + { |
|
30 | + if ($notices->hasAttention()) { |
|
31 | + foreach ($notices->getAttention() as $notice) { |
|
32 | + new AdminNotice($notice); |
|
33 | + } |
|
34 | + } |
|
35 | + if ($notices->hasError()) { |
|
36 | + $error_string = esc_html__('The following errors occurred:', 'event_espresso'); |
|
37 | + foreach ($notices->getError() as $notice) { |
|
38 | + if ($this->getThrowExceptions()) { |
|
39 | + $error_string .= '<br />' . $notice->message(); |
|
40 | + } else { |
|
41 | + new AdminNotice($notice); |
|
42 | + } |
|
43 | + } |
|
44 | + if ($this->getThrowExceptions()) { |
|
45 | + throw new DomainException($error_string); |
|
46 | + } |
|
47 | + } |
|
48 | + if ($notices->hasSuccess()) { |
|
49 | + foreach ($notices->getSuccess() as $notice) { |
|
50 | + new AdminNotice($notice); |
|
51 | + } |
|
52 | + } |
|
53 | + if ($notices->hasInformation()) { |
|
54 | + foreach ($notices->getInformation() as $notice) { |
|
55 | + new AdminNotice($notice); |
|
56 | + } |
|
57 | + } |
|
58 | + $this->clearNotices(); |
|
59 | + } |
|
60 | 60 | |
61 | 61 | } |
62 | 62 | // Location: ConvertNoticesToAdminNotices.php |
@@ -36,7 +36,7 @@ |
||
36 | 36 | $error_string = esc_html__('The following errors occurred:', 'event_espresso'); |
37 | 37 | foreach ($notices->getError() as $notice) { |
38 | 38 | if ($this->getThrowExceptions()) { |
39 | - $error_string .= '<br />' . $notice->message(); |
|
39 | + $error_string .= '<br />'.$notice->message(); |
|
40 | 40 | } else { |
41 | 41 | new AdminNotice($notice); |
42 | 42 | } |
@@ -20,232 +20,232 @@ |
||
20 | 20 | { |
21 | 21 | |
22 | 22 | |
23 | - /** |
|
24 | - * @var NoticeInterface[] $information |
|
25 | - */ |
|
26 | - private $information = array(); |
|
27 | - |
|
28 | - |
|
29 | - /** |
|
30 | - * @var NoticeInterface[] $attention |
|
31 | - */ |
|
32 | - private $attention = array(); |
|
33 | - |
|
34 | - |
|
35 | - /** |
|
36 | - * @var NoticeInterface[] $error |
|
37 | - */ |
|
38 | - private $error = array(); |
|
39 | - |
|
40 | - |
|
41 | - /** |
|
42 | - * @var NoticeInterface[] $success |
|
43 | - */ |
|
44 | - private $success = array(); |
|
45 | - |
|
46 | - |
|
47 | - /** |
|
48 | - * @param string $notice |
|
49 | - * @param bool $dismissible |
|
50 | - * @param string $file |
|
51 | - * @param string $func |
|
52 | - * @param string $line |
|
53 | - * @throws InvalidDataTypeException |
|
54 | - */ |
|
55 | - public function addInformation($notice, $dismissible = true, $file = '', $func = '', $line = '') |
|
56 | - { |
|
57 | - $this->information[] = new Notice( |
|
58 | - Notice::INFORMATION, |
|
59 | - $notice, |
|
60 | - $dismissible, |
|
61 | - $file, |
|
62 | - $func, |
|
63 | - $line |
|
64 | - ); |
|
65 | - } |
|
66 | - |
|
67 | - |
|
68 | - |
|
69 | - /** |
|
70 | - * @param string $notice |
|
71 | - * @param bool $dismissible |
|
72 | - * @param string $file |
|
73 | - * @param string $func |
|
74 | - * @param string $line |
|
75 | - * @throws InvalidDataTypeException |
|
76 | - */ |
|
77 | - public function addAttention($notice, $dismissible = true, $file = '', $func = '', $line = '') |
|
78 | - { |
|
79 | - $this->attention[] = new Notice( |
|
80 | - Notice::ATTENTION, |
|
81 | - $notice, |
|
82 | - $dismissible, |
|
83 | - $file, |
|
84 | - $func, |
|
85 | - $line |
|
86 | - ); |
|
87 | - } |
|
88 | - |
|
89 | - |
|
90 | - |
|
91 | - /** |
|
92 | - * @param string $notice |
|
93 | - * @param bool $dismissible |
|
94 | - * @param string $file |
|
95 | - * @param string $func |
|
96 | - * @param string $line |
|
97 | - * @throws InvalidDataTypeException |
|
98 | - */ |
|
99 | - public function addError($notice, $dismissible = true, $file, $func, $line) |
|
100 | - { |
|
101 | - $this->error[] = new Notice( |
|
102 | - Notice::ERROR, |
|
103 | - $notice, |
|
104 | - $dismissible, |
|
105 | - $file, |
|
106 | - $func, |
|
107 | - $line |
|
108 | - ); |
|
109 | - } |
|
110 | - |
|
111 | - |
|
112 | - |
|
113 | - /** |
|
114 | - * @param string $notice |
|
115 | - * @param bool $dismissible |
|
116 | - * @param string $file |
|
117 | - * @param string $func |
|
118 | - * @param string $line |
|
119 | - * @throws InvalidDataTypeException |
|
120 | - */ |
|
121 | - public function addSuccess($notice, $dismissible = true, $file = '', $func = '', $line = '') |
|
122 | - { |
|
123 | - $this->success[] = new Notice( |
|
124 | - Notice::SUCCESS, |
|
125 | - $notice, |
|
126 | - $dismissible, |
|
127 | - $file, |
|
128 | - $func, |
|
129 | - $line |
|
130 | - ); |
|
131 | - } |
|
132 | - |
|
133 | - |
|
134 | - /** |
|
135 | - * @return boolean |
|
136 | - */ |
|
137 | - public function hasInformation() |
|
138 | - { |
|
139 | - return ! empty($this->information); |
|
140 | - } |
|
141 | - |
|
142 | - |
|
143 | - |
|
144 | - /** |
|
145 | - * @return boolean |
|
146 | - */ |
|
147 | - public function hasAttention() |
|
148 | - { |
|
149 | - return ! empty($this->attention); |
|
150 | - } |
|
151 | - |
|
152 | - |
|
153 | - |
|
154 | - /** |
|
155 | - * @return boolean |
|
156 | - */ |
|
157 | - public function hasError() |
|
158 | - { |
|
159 | - return ! empty($this->error); |
|
160 | - } |
|
161 | - |
|
162 | - |
|
163 | - |
|
164 | - /** |
|
165 | - * @return boolean |
|
166 | - */ |
|
167 | - public function hasSuccess() |
|
168 | - { |
|
169 | - return ! empty($this->success); |
|
170 | - } |
|
171 | - |
|
172 | - |
|
173 | - /** |
|
174 | - * @return int |
|
175 | - */ |
|
176 | - public function countInformation() |
|
177 | - { |
|
178 | - return count($this->information); |
|
179 | - } |
|
180 | - |
|
181 | - |
|
182 | - |
|
183 | - /** |
|
184 | - * @return int |
|
185 | - */ |
|
186 | - public function countAttention() |
|
187 | - { |
|
188 | - return count($this->attention); |
|
189 | - } |
|
190 | - |
|
191 | - |
|
192 | - |
|
193 | - /** |
|
194 | - * @return int |
|
195 | - */ |
|
196 | - public function countError() |
|
197 | - { |
|
198 | - return count($this->error); |
|
199 | - } |
|
200 | - |
|
201 | - |
|
23 | + /** |
|
24 | + * @var NoticeInterface[] $information |
|
25 | + */ |
|
26 | + private $information = array(); |
|
27 | + |
|
28 | + |
|
29 | + /** |
|
30 | + * @var NoticeInterface[] $attention |
|
31 | + */ |
|
32 | + private $attention = array(); |
|
33 | + |
|
34 | + |
|
35 | + /** |
|
36 | + * @var NoticeInterface[] $error |
|
37 | + */ |
|
38 | + private $error = array(); |
|
39 | + |
|
40 | + |
|
41 | + /** |
|
42 | + * @var NoticeInterface[] $success |
|
43 | + */ |
|
44 | + private $success = array(); |
|
45 | + |
|
46 | + |
|
47 | + /** |
|
48 | + * @param string $notice |
|
49 | + * @param bool $dismissible |
|
50 | + * @param string $file |
|
51 | + * @param string $func |
|
52 | + * @param string $line |
|
53 | + * @throws InvalidDataTypeException |
|
54 | + */ |
|
55 | + public function addInformation($notice, $dismissible = true, $file = '', $func = '', $line = '') |
|
56 | + { |
|
57 | + $this->information[] = new Notice( |
|
58 | + Notice::INFORMATION, |
|
59 | + $notice, |
|
60 | + $dismissible, |
|
61 | + $file, |
|
62 | + $func, |
|
63 | + $line |
|
64 | + ); |
|
65 | + } |
|
66 | + |
|
67 | + |
|
68 | + |
|
69 | + /** |
|
70 | + * @param string $notice |
|
71 | + * @param bool $dismissible |
|
72 | + * @param string $file |
|
73 | + * @param string $func |
|
74 | + * @param string $line |
|
75 | + * @throws InvalidDataTypeException |
|
76 | + */ |
|
77 | + public function addAttention($notice, $dismissible = true, $file = '', $func = '', $line = '') |
|
78 | + { |
|
79 | + $this->attention[] = new Notice( |
|
80 | + Notice::ATTENTION, |
|
81 | + $notice, |
|
82 | + $dismissible, |
|
83 | + $file, |
|
84 | + $func, |
|
85 | + $line |
|
86 | + ); |
|
87 | + } |
|
88 | + |
|
89 | + |
|
90 | + |
|
91 | + /** |
|
92 | + * @param string $notice |
|
93 | + * @param bool $dismissible |
|
94 | + * @param string $file |
|
95 | + * @param string $func |
|
96 | + * @param string $line |
|
97 | + * @throws InvalidDataTypeException |
|
98 | + */ |
|
99 | + public function addError($notice, $dismissible = true, $file, $func, $line) |
|
100 | + { |
|
101 | + $this->error[] = new Notice( |
|
102 | + Notice::ERROR, |
|
103 | + $notice, |
|
104 | + $dismissible, |
|
105 | + $file, |
|
106 | + $func, |
|
107 | + $line |
|
108 | + ); |
|
109 | + } |
|
110 | + |
|
111 | + |
|
112 | + |
|
113 | + /** |
|
114 | + * @param string $notice |
|
115 | + * @param bool $dismissible |
|
116 | + * @param string $file |
|
117 | + * @param string $func |
|
118 | + * @param string $line |
|
119 | + * @throws InvalidDataTypeException |
|
120 | + */ |
|
121 | + public function addSuccess($notice, $dismissible = true, $file = '', $func = '', $line = '') |
|
122 | + { |
|
123 | + $this->success[] = new Notice( |
|
124 | + Notice::SUCCESS, |
|
125 | + $notice, |
|
126 | + $dismissible, |
|
127 | + $file, |
|
128 | + $func, |
|
129 | + $line |
|
130 | + ); |
|
131 | + } |
|
132 | + |
|
133 | + |
|
134 | + /** |
|
135 | + * @return boolean |
|
136 | + */ |
|
137 | + public function hasInformation() |
|
138 | + { |
|
139 | + return ! empty($this->information); |
|
140 | + } |
|
141 | + |
|
142 | + |
|
143 | + |
|
144 | + /** |
|
145 | + * @return boolean |
|
146 | + */ |
|
147 | + public function hasAttention() |
|
148 | + { |
|
149 | + return ! empty($this->attention); |
|
150 | + } |
|
151 | + |
|
152 | + |
|
153 | + |
|
154 | + /** |
|
155 | + * @return boolean |
|
156 | + */ |
|
157 | + public function hasError() |
|
158 | + { |
|
159 | + return ! empty($this->error); |
|
160 | + } |
|
161 | + |
|
162 | + |
|
163 | + |
|
164 | + /** |
|
165 | + * @return boolean |
|
166 | + */ |
|
167 | + public function hasSuccess() |
|
168 | + { |
|
169 | + return ! empty($this->success); |
|
170 | + } |
|
171 | + |
|
172 | + |
|
173 | + /** |
|
174 | + * @return int |
|
175 | + */ |
|
176 | + public function countInformation() |
|
177 | + { |
|
178 | + return count($this->information); |
|
179 | + } |
|
180 | + |
|
181 | + |
|
182 | + |
|
183 | + /** |
|
184 | + * @return int |
|
185 | + */ |
|
186 | + public function countAttention() |
|
187 | + { |
|
188 | + return count($this->attention); |
|
189 | + } |
|
190 | + |
|
191 | + |
|
192 | + |
|
193 | + /** |
|
194 | + * @return int |
|
195 | + */ |
|
196 | + public function countError() |
|
197 | + { |
|
198 | + return count($this->error); |
|
199 | + } |
|
200 | + |
|
201 | + |
|
202 | 202 | |
203 | - /** |
|
204 | - * @return int |
|
205 | - */ |
|
206 | - public function countSuccess() |
|
207 | - { |
|
208 | - return count($this->success); |
|
209 | - } |
|
203 | + /** |
|
204 | + * @return int |
|
205 | + */ |
|
206 | + public function countSuccess() |
|
207 | + { |
|
208 | + return count($this->success); |
|
209 | + } |
|
210 | 210 | |
211 | 211 | |
212 | - /** |
|
213 | - * @return NoticeInterface[] |
|
214 | - */ |
|
215 | - public function getInformation() |
|
216 | - { |
|
217 | - return $this->information; |
|
218 | - } |
|
212 | + /** |
|
213 | + * @return NoticeInterface[] |
|
214 | + */ |
|
215 | + public function getInformation() |
|
216 | + { |
|
217 | + return $this->information; |
|
218 | + } |
|
219 | 219 | |
220 | 220 | |
221 | 221 | |
222 | - /** |
|
223 | - * @return NoticeInterface[] |
|
224 | - */ |
|
225 | - public function getAttention() |
|
226 | - { |
|
227 | - return $this->attention; |
|
228 | - } |
|
222 | + /** |
|
223 | + * @return NoticeInterface[] |
|
224 | + */ |
|
225 | + public function getAttention() |
|
226 | + { |
|
227 | + return $this->attention; |
|
228 | + } |
|
229 | 229 | |
230 | 230 | |
231 | 231 | |
232 | - /** |
|
233 | - * @return NoticeInterface[] |
|
234 | - */ |
|
235 | - public function getError() |
|
236 | - { |
|
237 | - return $this->error; |
|
238 | - } |
|
232 | + /** |
|
233 | + * @return NoticeInterface[] |
|
234 | + */ |
|
235 | + public function getError() |
|
236 | + { |
|
237 | + return $this->error; |
|
238 | + } |
|
239 | 239 | |
240 | 240 | |
241 | 241 | |
242 | - /** |
|
243 | - * @return NoticeInterface[] |
|
244 | - */ |
|
245 | - public function getSuccess() |
|
246 | - { |
|
247 | - return $this->success; |
|
248 | - } |
|
242 | + /** |
|
243 | + * @return NoticeInterface[] |
|
244 | + */ |
|
245 | + public function getSuccess() |
|
246 | + { |
|
247 | + return $this->success; |
|
248 | + } |
|
249 | 249 | |
250 | 250 | |
251 | 251 | } |
@@ -19,266 +19,266 @@ |
||
19 | 19 | class Notice implements NoticeInterface |
20 | 20 | { |
21 | 21 | |
22 | - const ERROR = 'error'; |
|
22 | + const ERROR = 'error'; |
|
23 | 23 | |
24 | - const SUCCESS = 'success'; |
|
24 | + const SUCCESS = 'success'; |
|
25 | 25 | |
26 | - const ATTENTION = 'attention'; // alias for warning |
|
26 | + const ATTENTION = 'attention'; // alias for warning |
|
27 | 27 | |
28 | - const INFORMATION = 'information'; |
|
28 | + const INFORMATION = 'information'; |
|
29 | 29 | |
30 | - /** |
|
31 | - * @var string $type |
|
32 | - */ |
|
33 | - private $type; |
|
30 | + /** |
|
31 | + * @var string $type |
|
32 | + */ |
|
33 | + private $type; |
|
34 | 34 | |
35 | 35 | |
36 | - /** |
|
37 | - * @var string $message |
|
38 | - */ |
|
39 | - private $message; |
|
36 | + /** |
|
37 | + * @var string $message |
|
38 | + */ |
|
39 | + private $message; |
|
40 | 40 | |
41 | 41 | |
42 | - /** |
|
43 | - * @var string $file |
|
44 | - */ |
|
45 | - private $file; |
|
42 | + /** |
|
43 | + * @var string $file |
|
44 | + */ |
|
45 | + private $file; |
|
46 | 46 | |
47 | 47 | |
48 | - /** |
|
49 | - * @var string $func |
|
50 | - */ |
|
51 | - private $func; |
|
48 | + /** |
|
49 | + * @var string $func |
|
50 | + */ |
|
51 | + private $func; |
|
52 | 52 | |
53 | 53 | |
54 | - /** |
|
55 | - * @var string $line |
|
56 | - */ |
|
57 | - private $line; |
|
54 | + /** |
|
55 | + * @var string $line |
|
56 | + */ |
|
57 | + private $line; |
|
58 | 58 | |
59 | 59 | |
60 | - /** |
|
61 | - * @var boolean $dismissible |
|
62 | - */ |
|
63 | - private $dismissible; |
|
60 | + /** |
|
61 | + * @var boolean $dismissible |
|
62 | + */ |
|
63 | + private $dismissible; |
|
64 | 64 | |
65 | 65 | |
66 | 66 | |
67 | - /** |
|
68 | - * Notice constructor. |
|
69 | - * |
|
70 | - * @param string $type |
|
71 | - * @param string $message |
|
72 | - * @param bool $dismissible |
|
73 | - * @param string $file |
|
74 | - * @param string $func |
|
75 | - * @param string $line |
|
76 | - * @throws InvalidDataTypeException |
|
77 | - */ |
|
78 | - public function __construct($type, $message, $dismissible = true, $file = '', $func = '', $line = '') |
|
79 | - { |
|
80 | - $this->setType($type); |
|
81 | - $this->setMessage($message); |
|
82 | - $this->setDismissible($dismissible); |
|
83 | - $this->setFile($file); |
|
84 | - $this->setFunc($func); |
|
85 | - $this->setLine($line); |
|
86 | - } |
|
67 | + /** |
|
68 | + * Notice constructor. |
|
69 | + * |
|
70 | + * @param string $type |
|
71 | + * @param string $message |
|
72 | + * @param bool $dismissible |
|
73 | + * @param string $file |
|
74 | + * @param string $func |
|
75 | + * @param string $line |
|
76 | + * @throws InvalidDataTypeException |
|
77 | + */ |
|
78 | + public function __construct($type, $message, $dismissible = true, $file = '', $func = '', $line = '') |
|
79 | + { |
|
80 | + $this->setType($type); |
|
81 | + $this->setMessage($message); |
|
82 | + $this->setDismissible($dismissible); |
|
83 | + $this->setFile($file); |
|
84 | + $this->setFunc($func); |
|
85 | + $this->setLine($line); |
|
86 | + } |
|
87 | 87 | |
88 | 88 | |
89 | 89 | |
90 | - /** |
|
91 | - * @return array |
|
92 | - */ |
|
93 | - private function types() |
|
94 | - { |
|
95 | - return (array)apply_filters( |
|
96 | - 'FHEE__EventEspresso_core_services_notices_Notice__types', |
|
97 | - array( |
|
98 | - Notice::ERROR, |
|
99 | - Notice::SUCCESS, |
|
100 | - Notice::ATTENTION, |
|
101 | - Notice::INFORMATION, |
|
102 | - ) |
|
103 | - ); |
|
104 | - } |
|
105 | - |
|
106 | - |
|
107 | - |
|
108 | - /** |
|
109 | - * @return string |
|
110 | - */ |
|
111 | - public function type() |
|
112 | - { |
|
113 | - return $this->type; |
|
114 | - } |
|
115 | - |
|
116 | - |
|
117 | - |
|
118 | - /** |
|
119 | - * @return string |
|
120 | - */ |
|
121 | - public function message() |
|
122 | - { |
|
123 | - return $this->message; |
|
124 | - } |
|
125 | - |
|
126 | - |
|
127 | - |
|
128 | - /** |
|
129 | - * @return string |
|
130 | - */ |
|
131 | - public function file() |
|
132 | - { |
|
133 | - return $this->file; |
|
134 | - } |
|
135 | - |
|
136 | - |
|
137 | - |
|
138 | - /** |
|
139 | - * @return string |
|
140 | - */ |
|
141 | - public function func() |
|
142 | - { |
|
143 | - return $this->func; |
|
144 | - } |
|
145 | - |
|
146 | - |
|
147 | - |
|
148 | - /** |
|
149 | - * @return string |
|
150 | - */ |
|
151 | - public function line() |
|
152 | - { |
|
153 | - return $this->line; |
|
154 | - } |
|
155 | - |
|
156 | - |
|
157 | - /** |
|
158 | - * @return bool |
|
159 | - */ |
|
160 | - public function isDismissible() |
|
161 | - { |
|
162 | - return $this->dismissible; |
|
163 | - } |
|
164 | - |
|
165 | - |
|
166 | - /** |
|
167 | - * @param string $type |
|
168 | - * @throws InvalidDataTypeException |
|
169 | - */ |
|
170 | - private function setType($type) |
|
171 | - { |
|
172 | - if (! in_array($type, $this->types(), true)) { |
|
173 | - throw new InvalidDataTypeException( |
|
174 | - '$type', |
|
175 | - $type, |
|
176 | - $this->invalidTypeMessage() |
|
177 | - ); |
|
178 | - } |
|
179 | - $this->type = $type; |
|
180 | - } |
|
181 | - |
|
182 | - |
|
183 | - |
|
184 | - /** |
|
185 | - * gets the $invalid_type_message string |
|
186 | - */ |
|
187 | - private function invalidTypeMessage() |
|
188 | - { |
|
189 | - return apply_filters( |
|
190 | - 'FHEE__EventEspresso_core_services_notices_Notice__invalidTypeMessage', |
|
191 | - sprintf( |
|
192 | - esc_html__( |
|
193 | - ' one of the following notice types was expected: %1$s %2$s', |
|
194 | - 'event_espresso' |
|
195 | - ), |
|
196 | - '<br />', |
|
197 | - var_export($this->types(), true) |
|
198 | - ) |
|
199 | - ); |
|
200 | - } |
|
201 | - |
|
202 | - |
|
203 | - |
|
204 | - /** |
|
205 | - * @param string $message |
|
206 | - * @throws InvalidDataTypeException |
|
207 | - */ |
|
208 | - private function setMessage($message) |
|
209 | - { |
|
210 | - if (empty($message) || ! is_string($message)) { |
|
211 | - throw new InvalidDataTypeException( |
|
212 | - '$message', |
|
213 | - $message, |
|
214 | - esc_html__('non empty string', 'event_espresso') |
|
215 | - ); |
|
216 | - } |
|
217 | - $this->message = $message; |
|
218 | - } |
|
219 | - |
|
220 | - |
|
221 | - |
|
222 | - /** |
|
223 | - * @param string $file |
|
224 | - * @throws InvalidDataTypeException |
|
225 | - */ |
|
226 | - private function setFile($file) |
|
227 | - { |
|
228 | - if ($this->type === Notice::ERROR && (empty($file) || ! is_string($file))) { |
|
229 | - throw new InvalidDataTypeException( |
|
230 | - '$file', |
|
231 | - $file, |
|
232 | - esc_html__('non empty string', 'event_espresso') |
|
233 | - ); |
|
234 | - } |
|
235 | - $this->file = $file; |
|
236 | - } |
|
237 | - |
|
238 | - |
|
239 | - |
|
240 | - /** |
|
241 | - * @param string $func |
|
242 | - * @throws InvalidDataTypeException |
|
243 | - */ |
|
244 | - private function setFunc($func) |
|
245 | - { |
|
246 | - if ($this->type === Notice::ERROR && (empty($func) || ! is_string($func))) { |
|
247 | - throw new InvalidDataTypeException( |
|
248 | - '$func', |
|
249 | - $func, |
|
250 | - esc_html__('non empty string', 'event_espresso') |
|
251 | - ); |
|
252 | - } |
|
253 | - $this->func = $func; |
|
254 | - } |
|
255 | - |
|
256 | - |
|
257 | - |
|
258 | - /** |
|
259 | - * @param int $line |
|
260 | - * @throws InvalidDataTypeException |
|
261 | - */ |
|
262 | - private function setLine($line) |
|
263 | - { |
|
264 | - $line = absint($line); |
|
265 | - if ($this->type === Notice::ERROR && $line === 0) { |
|
266 | - throw new InvalidDataTypeException( |
|
267 | - '$line', |
|
268 | - $line, |
|
269 | - esc_html__('integer', 'event_espresso') |
|
270 | - ); |
|
271 | - } |
|
272 | - $this->line = $line; |
|
273 | - } |
|
274 | - |
|
275 | - |
|
276 | - /** |
|
277 | - * @param boolean $dismissible |
|
278 | - */ |
|
279 | - private function setDismissible($dismissible = true) |
|
280 | - { |
|
281 | - $this->dismissible = filter_var($dismissible, FILTER_VALIDATE_BOOLEAN); |
|
282 | - } |
|
90 | + /** |
|
91 | + * @return array |
|
92 | + */ |
|
93 | + private function types() |
|
94 | + { |
|
95 | + return (array)apply_filters( |
|
96 | + 'FHEE__EventEspresso_core_services_notices_Notice__types', |
|
97 | + array( |
|
98 | + Notice::ERROR, |
|
99 | + Notice::SUCCESS, |
|
100 | + Notice::ATTENTION, |
|
101 | + Notice::INFORMATION, |
|
102 | + ) |
|
103 | + ); |
|
104 | + } |
|
105 | + |
|
106 | + |
|
107 | + |
|
108 | + /** |
|
109 | + * @return string |
|
110 | + */ |
|
111 | + public function type() |
|
112 | + { |
|
113 | + return $this->type; |
|
114 | + } |
|
115 | + |
|
116 | + |
|
117 | + |
|
118 | + /** |
|
119 | + * @return string |
|
120 | + */ |
|
121 | + public function message() |
|
122 | + { |
|
123 | + return $this->message; |
|
124 | + } |
|
125 | + |
|
126 | + |
|
127 | + |
|
128 | + /** |
|
129 | + * @return string |
|
130 | + */ |
|
131 | + public function file() |
|
132 | + { |
|
133 | + return $this->file; |
|
134 | + } |
|
135 | + |
|
136 | + |
|
137 | + |
|
138 | + /** |
|
139 | + * @return string |
|
140 | + */ |
|
141 | + public function func() |
|
142 | + { |
|
143 | + return $this->func; |
|
144 | + } |
|
145 | + |
|
146 | + |
|
147 | + |
|
148 | + /** |
|
149 | + * @return string |
|
150 | + */ |
|
151 | + public function line() |
|
152 | + { |
|
153 | + return $this->line; |
|
154 | + } |
|
155 | + |
|
156 | + |
|
157 | + /** |
|
158 | + * @return bool |
|
159 | + */ |
|
160 | + public function isDismissible() |
|
161 | + { |
|
162 | + return $this->dismissible; |
|
163 | + } |
|
164 | + |
|
165 | + |
|
166 | + /** |
|
167 | + * @param string $type |
|
168 | + * @throws InvalidDataTypeException |
|
169 | + */ |
|
170 | + private function setType($type) |
|
171 | + { |
|
172 | + if (! in_array($type, $this->types(), true)) { |
|
173 | + throw new InvalidDataTypeException( |
|
174 | + '$type', |
|
175 | + $type, |
|
176 | + $this->invalidTypeMessage() |
|
177 | + ); |
|
178 | + } |
|
179 | + $this->type = $type; |
|
180 | + } |
|
181 | + |
|
182 | + |
|
183 | + |
|
184 | + /** |
|
185 | + * gets the $invalid_type_message string |
|
186 | + */ |
|
187 | + private function invalidTypeMessage() |
|
188 | + { |
|
189 | + return apply_filters( |
|
190 | + 'FHEE__EventEspresso_core_services_notices_Notice__invalidTypeMessage', |
|
191 | + sprintf( |
|
192 | + esc_html__( |
|
193 | + ' one of the following notice types was expected: %1$s %2$s', |
|
194 | + 'event_espresso' |
|
195 | + ), |
|
196 | + '<br />', |
|
197 | + var_export($this->types(), true) |
|
198 | + ) |
|
199 | + ); |
|
200 | + } |
|
201 | + |
|
202 | + |
|
203 | + |
|
204 | + /** |
|
205 | + * @param string $message |
|
206 | + * @throws InvalidDataTypeException |
|
207 | + */ |
|
208 | + private function setMessage($message) |
|
209 | + { |
|
210 | + if (empty($message) || ! is_string($message)) { |
|
211 | + throw new InvalidDataTypeException( |
|
212 | + '$message', |
|
213 | + $message, |
|
214 | + esc_html__('non empty string', 'event_espresso') |
|
215 | + ); |
|
216 | + } |
|
217 | + $this->message = $message; |
|
218 | + } |
|
219 | + |
|
220 | + |
|
221 | + |
|
222 | + /** |
|
223 | + * @param string $file |
|
224 | + * @throws InvalidDataTypeException |
|
225 | + */ |
|
226 | + private function setFile($file) |
|
227 | + { |
|
228 | + if ($this->type === Notice::ERROR && (empty($file) || ! is_string($file))) { |
|
229 | + throw new InvalidDataTypeException( |
|
230 | + '$file', |
|
231 | + $file, |
|
232 | + esc_html__('non empty string', 'event_espresso') |
|
233 | + ); |
|
234 | + } |
|
235 | + $this->file = $file; |
|
236 | + } |
|
237 | + |
|
238 | + |
|
239 | + |
|
240 | + /** |
|
241 | + * @param string $func |
|
242 | + * @throws InvalidDataTypeException |
|
243 | + */ |
|
244 | + private function setFunc($func) |
|
245 | + { |
|
246 | + if ($this->type === Notice::ERROR && (empty($func) || ! is_string($func))) { |
|
247 | + throw new InvalidDataTypeException( |
|
248 | + '$func', |
|
249 | + $func, |
|
250 | + esc_html__('non empty string', 'event_espresso') |
|
251 | + ); |
|
252 | + } |
|
253 | + $this->func = $func; |
|
254 | + } |
|
255 | + |
|
256 | + |
|
257 | + |
|
258 | + /** |
|
259 | + * @param int $line |
|
260 | + * @throws InvalidDataTypeException |
|
261 | + */ |
|
262 | + private function setLine($line) |
|
263 | + { |
|
264 | + $line = absint($line); |
|
265 | + if ($this->type === Notice::ERROR && $line === 0) { |
|
266 | + throw new InvalidDataTypeException( |
|
267 | + '$line', |
|
268 | + $line, |
|
269 | + esc_html__('integer', 'event_espresso') |
|
270 | + ); |
|
271 | + } |
|
272 | + $this->line = $line; |
|
273 | + } |
|
274 | + |
|
275 | + |
|
276 | + /** |
|
277 | + * @param boolean $dismissible |
|
278 | + */ |
|
279 | + private function setDismissible($dismissible = true) |
|
280 | + { |
|
281 | + $this->dismissible = filter_var($dismissible, FILTER_VALIDATE_BOOLEAN); |
|
282 | + } |
|
283 | 283 | |
284 | 284 | } |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | */ |
93 | 93 | private function types() |
94 | 94 | { |
95 | - return (array)apply_filters( |
|
95 | + return (array) apply_filters( |
|
96 | 96 | 'FHEE__EventEspresso_core_services_notices_Notice__types', |
97 | 97 | array( |
98 | 98 | Notice::ERROR, |
@@ -169,7 +169,7 @@ discard block |
||
169 | 169 | */ |
170 | 170 | private function setType($type) |
171 | 171 | { |
172 | - if (! in_array($type, $this->types(), true)) { |
|
172 | + if ( ! in_array($type, $this->types(), true)) { |
|
173 | 173 | throw new InvalidDataTypeException( |
174 | 174 | '$type', |
175 | 175 | $type, |
@@ -17,79 +17,79 @@ |
||
17 | 17 | abstract class NoticeConverter implements NoticeConverterInterface |
18 | 18 | { |
19 | 19 | |
20 | - /** |
|
21 | - * @var NoticesContainerInterface $notices |
|
22 | - */ |
|
23 | - private $notices; |
|
20 | + /** |
|
21 | + * @var NoticesContainerInterface $notices |
|
22 | + */ |
|
23 | + private $notices; |
|
24 | 24 | |
25 | - /** |
|
26 | - * if set to true, then errors will be thrown as exceptions |
|
27 | - * |
|
28 | - * @var boolean $throw_exceptions |
|
29 | - */ |
|
30 | - private $throw_exceptions; |
|
25 | + /** |
|
26 | + * if set to true, then errors will be thrown as exceptions |
|
27 | + * |
|
28 | + * @var boolean $throw_exceptions |
|
29 | + */ |
|
30 | + private $throw_exceptions; |
|
31 | 31 | |
32 | 32 | |
33 | 33 | |
34 | - /** |
|
35 | - * NoticeConverter constructor. |
|
36 | - * |
|
37 | - * @param bool $throw_exceptions |
|
38 | - */ |
|
39 | - public function __construct($throw_exceptions = false) |
|
40 | - { |
|
41 | - $this->throw_exceptions = $throw_exceptions; |
|
42 | - } |
|
34 | + /** |
|
35 | + * NoticeConverter constructor. |
|
36 | + * |
|
37 | + * @param bool $throw_exceptions |
|
38 | + */ |
|
39 | + public function __construct($throw_exceptions = false) |
|
40 | + { |
|
41 | + $this->throw_exceptions = $throw_exceptions; |
|
42 | + } |
|
43 | 43 | |
44 | 44 | |
45 | 45 | |
46 | - /** |
|
47 | - * @return NoticesContainerInterface |
|
48 | - */ |
|
49 | - public function getNotices() |
|
50 | - { |
|
51 | - return $this->notices; |
|
52 | - } |
|
46 | + /** |
|
47 | + * @return NoticesContainerInterface |
|
48 | + */ |
|
49 | + public function getNotices() |
|
50 | + { |
|
51 | + return $this->notices; |
|
52 | + } |
|
53 | 53 | |
54 | 54 | |
55 | 55 | |
56 | - /** |
|
57 | - * @param NoticesContainerInterface $notices |
|
58 | - */ |
|
59 | - protected function setNotices(NoticesContainerInterface $notices) |
|
60 | - { |
|
61 | - $this->notices = $notices; |
|
62 | - } |
|
56 | + /** |
|
57 | + * @param NoticesContainerInterface $notices |
|
58 | + */ |
|
59 | + protected function setNotices(NoticesContainerInterface $notices) |
|
60 | + { |
|
61 | + $this->notices = $notices; |
|
62 | + } |
|
63 | 63 | |
64 | 64 | |
65 | 65 | |
66 | - /** |
|
67 | - * @return bool |
|
68 | - */ |
|
69 | - public function getThrowExceptions() |
|
70 | - { |
|
71 | - return $this->throw_exceptions; |
|
72 | - } |
|
66 | + /** |
|
67 | + * @return bool |
|
68 | + */ |
|
69 | + public function getThrowExceptions() |
|
70 | + { |
|
71 | + return $this->throw_exceptions; |
|
72 | + } |
|
73 | 73 | |
74 | 74 | |
75 | 75 | |
76 | - /** |
|
77 | - * @param bool $throw_exceptions |
|
78 | - */ |
|
79 | - public function setThrowExceptions($throw_exceptions) |
|
80 | - { |
|
81 | - $this->throw_exceptions = filter_var($throw_exceptions, FILTER_VALIDATE_BOOLEAN); |
|
82 | - } |
|
76 | + /** |
|
77 | + * @param bool $throw_exceptions |
|
78 | + */ |
|
79 | + public function setThrowExceptions($throw_exceptions) |
|
80 | + { |
|
81 | + $this->throw_exceptions = filter_var($throw_exceptions, FILTER_VALIDATE_BOOLEAN); |
|
82 | + } |
|
83 | 83 | |
84 | 84 | |
85 | 85 | |
86 | - /** |
|
87 | - * @return void; |
|
88 | - */ |
|
89 | - public function clearNotices() |
|
90 | - { |
|
91 | - $this->notices = null; |
|
92 | - } |
|
86 | + /** |
|
87 | + * @return void; |
|
88 | + */ |
|
89 | + public function clearNotices() |
|
90 | + { |
|
91 | + $this->notices = null; |
|
92 | + } |
|
93 | 93 | |
94 | 94 | |
95 | 95 | } |
@@ -16,616 +16,616 @@ |
||
16 | 16 | class EE_SPCO_Line_Item_Display_Strategy implements EEI_Line_Item_Display |
17 | 17 | { |
18 | 18 | |
19 | - /** |
|
20 | - * array of events |
|
21 | - * |
|
22 | - * @type EE_Line_Item[] $_events |
|
23 | - */ |
|
24 | - private $_events = array(); |
|
25 | - |
|
26 | - /** |
|
27 | - * whether to display the taxes row or not |
|
28 | - * |
|
29 | - * @type bool $_show_taxes |
|
30 | - */ |
|
31 | - private $_show_taxes = false; |
|
32 | - |
|
33 | - /** |
|
34 | - * html for any tax rows |
|
35 | - * |
|
36 | - * @type string $_show_taxes |
|
37 | - */ |
|
38 | - private $_taxes_html = ''; |
|
39 | - |
|
40 | - /** |
|
41 | - * total amount including tax we can bill for at this time |
|
42 | - * |
|
43 | - * @type float $_grand_total |
|
44 | - */ |
|
45 | - private $_grand_total = 0.00; |
|
46 | - |
|
47 | - /** |
|
48 | - * total number of items being billed for |
|
49 | - * |
|
50 | - * @type int $_total_items |
|
51 | - */ |
|
52 | - private $_total_items = 0; |
|
53 | - |
|
54 | - |
|
55 | - |
|
56 | - /** |
|
57 | - * @return float |
|
58 | - */ |
|
59 | - public function grand_total() |
|
60 | - { |
|
61 | - return $this->_grand_total; |
|
62 | - } |
|
63 | - |
|
64 | - |
|
65 | - |
|
66 | - /** |
|
67 | - * @return int |
|
68 | - */ |
|
69 | - public function total_items() |
|
70 | - { |
|
71 | - return $this->_total_items; |
|
72 | - } |
|
73 | - |
|
74 | - |
|
75 | - |
|
76 | - /** |
|
77 | - * @param EE_Line_Item $line_item |
|
78 | - * @param array $options |
|
79 | - * @param EE_Line_Item $parent_line_item |
|
80 | - * @return mixed |
|
81 | - * @throws EE_Error |
|
82 | - */ |
|
83 | - public function display_line_item( |
|
84 | - EE_Line_Item $line_item, |
|
85 | - $options = array(), |
|
86 | - EE_Line_Item $parent_line_item = null |
|
87 | - ) { |
|
88 | - $html = ''; |
|
89 | - // set some default options and merge with incoming |
|
90 | - $default_options = array( |
|
91 | - 'show_desc' => true, // true false |
|
92 | - 'odd' => false, |
|
93 | - ); |
|
94 | - $options = array_merge($default_options, (array)$options); |
|
95 | - switch ($line_item->type()) { |
|
96 | - case EEM_Line_Item::type_line_item: |
|
97 | - $this->_show_taxes = $line_item->is_taxable() ? true : $this->_show_taxes; |
|
98 | - if ($line_item->OBJ_type() === 'Ticket') { |
|
99 | - // item row |
|
100 | - $html .= $this->_ticket_row($line_item, $options); |
|
101 | - } else { |
|
102 | - // item row |
|
103 | - $html .= $this->_item_row($line_item, $options); |
|
104 | - } |
|
105 | - if ( |
|
106 | - apply_filters( |
|
107 | - 'FHEE__EE_SPCO_Line_Item_Display_Strategy__display_line_item__display_sub_line_items', |
|
108 | - true |
|
109 | - ) |
|
110 | - ) { |
|
111 | - // got any kids? |
|
112 | - foreach ($line_item->children() as $child_line_item) { |
|
113 | - $html .= $this->display_line_item($child_line_item, $options, $line_item); |
|
114 | - } |
|
115 | - } |
|
116 | - break; |
|
117 | - case EEM_Line_Item::type_sub_line_item: |
|
118 | - $html .= $this->_sub_item_row($line_item, $options, $parent_line_item); |
|
119 | - break; |
|
120 | - case EEM_Line_Item::type_sub_total: |
|
121 | - static $sub_total = 0; |
|
122 | - $event_sub_total = 0; |
|
123 | - $text = esc_html__('Sub-Total', 'event_espresso'); |
|
124 | - if ($line_item->OBJ_type() === 'Event') { |
|
125 | - $options['event_id'] = $event_id = $line_item->OBJ_ID(); |
|
126 | - if (! isset($this->_events[$options['event_id']])) { |
|
127 | - $event = EEM_Event::instance()->get_one_by_ID($options['event_id']); |
|
128 | - // if event has default reg status of Not Approved, then don't display info on it |
|
129 | - if ( |
|
130 | - $event instanceof EE_Event |
|
131 | - && $event->default_registration_status() === EEM_Registration::status_id_not_approved |
|
132 | - ) { |
|
133 | - $display_event = false; |
|
134 | - // unless there are registrations for it that are returning to pay |
|
135 | - if (isset($options['registrations']) && is_array($options['registrations'])) { |
|
136 | - foreach ($options['registrations'] as $registration) { |
|
137 | - if (! $registration instanceof EE_Registration) { |
|
138 | - continue; |
|
139 | - } |
|
140 | - $display_event = $registration->event_ID() === $options['event_id'] |
|
141 | - && $registration->status_ID() !== EEM_Registration::status_id_not_approved |
|
142 | - ? true |
|
143 | - : $display_event; |
|
144 | - } |
|
145 | - } |
|
146 | - if (! $display_event) { |
|
147 | - return ''; |
|
148 | - } |
|
149 | - } |
|
150 | - $this->_events[$options['event_id']] = 0; |
|
151 | - $html .= $this->_event_row($line_item); |
|
152 | - $text = esc_html__('Event Sub-Total', 'event_espresso'); |
|
153 | - } |
|
154 | - } |
|
155 | - $child_line_items = $line_item->children(); |
|
156 | - // loop thru children |
|
157 | - foreach ($child_line_items as $child_line_item) { |
|
158 | - // recursively feed children back into this method |
|
159 | - $html .= $this->display_line_item($child_line_item, $options, $line_item); |
|
160 | - } |
|
161 | - $event_sub_total += isset($options['event_id']) ? $this->_events[$options['event_id']] : 0; |
|
162 | - $sub_total += $event_sub_total; |
|
163 | - if ( |
|
164 | - ( |
|
165 | - // event subtotals |
|
166 | - $line_item->code() !== 'pre-tax-subtotal' && count($child_line_items) > 1 |
|
167 | - ) |
|
168 | - || ( |
|
169 | - // pre-tax subtotals |
|
170 | - $line_item->code() === 'pre-tax-subtotal' && count($this->_events) > 1 |
|
171 | - ) |
|
172 | - ) { |
|
173 | - $options['sub_total'] = $line_item->OBJ_type() === 'Event' ? $event_sub_total : $sub_total; |
|
174 | - $html .= $this->_sub_total_row($line_item, $text, $options); |
|
175 | - } |
|
176 | - break; |
|
177 | - case EEM_Line_Item::type_tax: |
|
178 | - if ($this->_show_taxes) { |
|
179 | - $this->_taxes_html .= $this->_tax_row($line_item, $options); |
|
180 | - } |
|
181 | - break; |
|
182 | - case EEM_Line_Item::type_tax_sub_total: |
|
183 | - if ($this->_show_taxes) { |
|
184 | - $child_line_items = $line_item->children(); |
|
185 | - // loop thru children |
|
186 | - foreach ($child_line_items as $child_line_item) { |
|
187 | - // recursively feed children back into this method |
|
188 | - $html .= $this->display_line_item($child_line_item, $options, $line_item); |
|
189 | - } |
|
190 | - if (count($child_line_items) > 1) { |
|
191 | - $this->_taxes_html .= $this->_total_tax_row($line_item, esc_html__('Tax Total', 'event_espresso')); |
|
192 | - } |
|
193 | - } |
|
194 | - break; |
|
195 | - case EEM_Line_Item::type_total: |
|
196 | - // get all child line items |
|
197 | - $children = $line_item->children(); |
|
198 | - // loop thru all non-tax child line items |
|
199 | - foreach ($children as $child_line_item) { |
|
200 | - if ($child_line_item->type() !== EEM_Line_Item::type_tax_sub_total) { |
|
201 | - // recursively feed children back into this method |
|
202 | - $html .= $this->display_line_item($child_line_item, $options, $line_item); |
|
203 | - } |
|
204 | - } |
|
205 | - // now loop thru tax child line items |
|
206 | - foreach ($children as $child_line_item) { |
|
207 | - if ($child_line_item->type() === EEM_Line_Item::type_tax_sub_total) { |
|
208 | - // recursively feed children back into this method |
|
209 | - $html .= $this->display_line_item($child_line_item, $options, $line_item); |
|
210 | - } |
|
211 | - } |
|
212 | - $html .= $this->_taxes_html; |
|
213 | - $html .= $this->_total_row($line_item, esc_html__('Total', 'event_espresso')); |
|
214 | - $html .= $this->_payments_and_amount_owing_rows($line_item, $options); |
|
215 | - break; |
|
216 | - } |
|
217 | - return $html; |
|
218 | - } |
|
219 | - |
|
220 | - |
|
221 | - |
|
222 | - /** |
|
223 | - * _event_row - basically a Heading row displayed once above each event's ticket rows |
|
224 | - * |
|
225 | - * @param EE_Line_Item $line_item |
|
226 | - * @return mixed |
|
227 | - */ |
|
228 | - private function _event_row(EE_Line_Item $line_item) |
|
229 | - { |
|
230 | - // start of row |
|
231 | - $html = EEH_HTML::tr('', 'event-cart-total-row', 'total_tr odd'); |
|
232 | - // event name td |
|
233 | - $html .= EEH_HTML::td( |
|
234 | - EEH_HTML::strong($line_item->name()), |
|
235 | - '', |
|
236 | - 'event-header', |
|
237 | - '', |
|
238 | - ' colspan="4"' |
|
239 | - ); |
|
240 | - // end of row |
|
241 | - $html .= EEH_HTML::trx(); |
|
242 | - return $html; |
|
243 | - } |
|
244 | - |
|
245 | - |
|
246 | - |
|
247 | - /** |
|
248 | - * _ticket_row |
|
249 | - * |
|
250 | - * @param EE_Line_Item $line_item |
|
251 | - * @param array $options |
|
252 | - * @return mixed |
|
253 | - * @throws EE_Error |
|
254 | - */ |
|
255 | - private function _ticket_row(EE_Line_Item $line_item, $options = array()) |
|
256 | - { |
|
257 | - // start of row |
|
258 | - $row_class = $options['odd'] ? 'item odd' : 'item'; |
|
259 | - $html = EEH_HTML::tr('', '', $row_class); |
|
260 | - // name && desc |
|
261 | - $name_and_desc = apply_filters( |
|
262 | - 'FHEE__EE_SPCO_Line_Item_Display_Strategy__item_row__name', |
|
263 | - $line_item->name(), |
|
264 | - $line_item |
|
265 | - ); |
|
266 | - $name_and_desc .= apply_filters( |
|
267 | - 'FHEE__EE_SPCO_Line_Item_Display_Strategy__item_row__desc', |
|
268 | - ( |
|
269 | - $options['show_desc'] |
|
270 | - ? '<span class="line-item-desc-spn smaller-text">: ' . $line_item->desc() . '</span>' |
|
271 | - : '' |
|
272 | - ), |
|
273 | - $line_item, |
|
274 | - $options |
|
275 | - ); |
|
276 | - $name_and_desc .= $line_item->is_taxable() ? ' * ' : ''; |
|
277 | - // name td |
|
278 | - $html .= EEH_HTML::td( /*__FUNCTION__ .*/ |
|
279 | - $name_and_desc, '', 'item_l'); |
|
280 | - // price td |
|
281 | - $html .= EEH_HTML::td($line_item->unit_price_no_code(), '', 'item_c jst-rght'); |
|
282 | - // quantity td |
|
283 | - $html .= EEH_HTML::td($line_item->quantity(), '', 'item_l jst-rght'); |
|
284 | - $this->_total_items += $line_item->quantity(); |
|
285 | - // determine total for line item |
|
286 | - $total = $line_item->total(); |
|
287 | - $this->_events[$options['event_id']] += $total; |
|
288 | - // total td |
|
289 | - $html .= EEH_HTML::td( |
|
290 | - EEH_Template::format_currency($total, false, false), |
|
291 | - '', |
|
292 | - 'item_r jst-rght' |
|
293 | - ); |
|
294 | - // end of row |
|
295 | - $html .= EEH_HTML::trx(); |
|
296 | - return $html; |
|
297 | - } |
|
298 | - |
|
299 | - |
|
300 | - |
|
301 | - /** |
|
302 | - * _item_row |
|
303 | - * |
|
304 | - * @param EE_Line_Item $line_item |
|
305 | - * @param array $options |
|
306 | - * @return mixed |
|
307 | - * @throws EE_Error |
|
308 | - */ |
|
309 | - private function _item_row(EE_Line_Item $line_item, $options = array()) |
|
310 | - { |
|
311 | - // start of row |
|
312 | - $row_class = $options['odd'] ? 'item odd' : 'item'; |
|
313 | - $html = EEH_HTML::tr('', '', $row_class); |
|
314 | - $obj_name = $line_item->OBJ_type() ? $line_item->OBJ_type_i18n() . ': ' : ''; |
|
315 | - // name && desc |
|
316 | - $name_and_desc = apply_filters( |
|
317 | - 'FHEE__EE_SPCO_Line_Item_Display_Strategy__item_row__name', |
|
318 | - $obj_name . $line_item->name(), |
|
319 | - $line_item |
|
320 | - ); |
|
321 | - $name_and_desc .= apply_filters( |
|
322 | - 'FHEE__EE_SPCO_Line_Item_Display_Strategy__item_row__desc', |
|
323 | - ( |
|
324 | - $options['show_desc'] |
|
325 | - ? '<span class="line-item-desc-spn smaller-text">: ' . $line_item->desc() . '</span>' |
|
326 | - : '' |
|
327 | - ), |
|
328 | - $line_item, |
|
329 | - $options |
|
330 | - ); |
|
331 | - $name_and_desc .= $line_item->is_taxable() ? ' * ' : ''; |
|
332 | - // name td |
|
333 | - $html .= EEH_HTML::td($name_and_desc, '', 'item_l'); |
|
334 | - // price td |
|
335 | - if ($line_item->is_percent()) { |
|
336 | - $html .= EEH_HTML::td($line_item->percent() . '%', '', 'item_c jst-rght'); |
|
337 | - } else { |
|
338 | - $html .= EEH_HTML::td($line_item->unit_price_no_code(), '', 'item_c jst-rght'); |
|
339 | - } |
|
340 | - // quantity td |
|
341 | - $html .= EEH_HTML::td($line_item->quantity(), '', 'item_l jst-rght'); |
|
342 | - //$total = $line_item->total() * $line_item->quantity(); |
|
343 | - $total = $line_item->total(); |
|
344 | - if (isset($options['event_id'], $this->_events[$options['event_id']])) { |
|
345 | - $this->_events[$options['event_id']] += $total; |
|
346 | - } |
|
347 | - // total td |
|
348 | - $html .= EEH_HTML::td( |
|
349 | - EEH_Template::format_currency($total, false, false), |
|
350 | - '', |
|
351 | - 'item_r jst-rght' |
|
352 | - ); |
|
353 | - // end of row |
|
354 | - $html .= EEH_HTML::trx(); |
|
355 | - return $html; |
|
356 | - } |
|
357 | - |
|
358 | - |
|
359 | - |
|
360 | - /** |
|
361 | - * _sub_item_row |
|
362 | - * |
|
363 | - * @param EE_Line_Item $line_item |
|
364 | - * @param array $options |
|
365 | - * @param EE_Line_Item $parent_line_item |
|
366 | - * @return mixed |
|
367 | - * @throws EE_Error |
|
368 | - */ |
|
369 | - private function _sub_item_row(EE_Line_Item $line_item, $options = array(), EE_Line_Item $parent_line_item = null) |
|
370 | - { |
|
371 | - if( |
|
372 | - $parent_line_item instanceof EE_Line_Item |
|
373 | - && $line_item->children() === array() |
|
374 | - && $line_item->name() === $parent_line_item->name() |
|
375 | - ) { |
|
376 | - return ''; |
|
377 | - } |
|
378 | - // start of row |
|
379 | - $html = EEH_HTML::tr('', '', 'item sub-item-row'); |
|
380 | - // name && desc |
|
381 | - $name_and_desc = EEH_HTML::span('', '', 'sub-item-row-bullet dashicons dashicons-arrow-right') |
|
382 | - . $line_item->name(); |
|
383 | - $name_and_desc .= $options['show_desc'] ? '<span class="line-sub-item-desc-spn smaller-text">: ' |
|
384 | - . $line_item->desc() |
|
385 | - . '</span>' : ''; |
|
386 | - // name td |
|
387 | - $html .= EEH_HTML::td( $name_and_desc, '', 'item_l sub-item'); |
|
388 | - $qty = $parent_line_item instanceof EE_Line_Item ? $parent_line_item->quantity() : 1; |
|
389 | - // discount/surcharge td |
|
390 | - if ($line_item->is_percent()) { |
|
391 | - $html .= EEH_HTML::td( |
|
392 | - EEH_Template::format_currency( |
|
393 | - $line_item->total() / $qty, |
|
394 | - false, false |
|
395 | - ), |
|
396 | - '', 'item_c jst-rght' |
|
397 | - ); |
|
398 | - } else { |
|
399 | - $html .= EEH_HTML::td($line_item->unit_price_no_code(), '', 'item_c jst-rght'); |
|
400 | - } |
|
401 | - // no quantity td |
|
402 | - $html .= EEH_HTML::td(); |
|
403 | - // no total td |
|
404 | - $html .= EEH_HTML::td(); |
|
405 | - // end of row |
|
406 | - $html .= EEH_HTML::trx(); |
|
407 | - return $html; |
|
408 | - } |
|
409 | - |
|
410 | - |
|
411 | - |
|
412 | - /** |
|
413 | - * _tax_row |
|
414 | - * |
|
415 | - * @param EE_Line_Item $line_item |
|
416 | - * @param array $options |
|
417 | - * @return mixed |
|
418 | - * @throws EE_Error |
|
419 | - */ |
|
420 | - private function _tax_row(EE_Line_Item $line_item, $options = array()) |
|
421 | - { |
|
422 | - // start of row |
|
423 | - $html = EEH_HTML::tr('', 'item sub-item tax-total'); |
|
424 | - // name && desc |
|
425 | - $name_and_desc = $line_item->name(); |
|
426 | - $name_and_desc .= '<span class="smaller-text lt-grey-text" style="margin:0 0 0 2em;">' |
|
427 | - . esc_html__(' * taxable items', 'event_espresso') . '</span>'; |
|
428 | - $name_and_desc .= $options['show_desc'] ? '<br/>' . $line_item->desc() : ''; |
|
429 | - // name td |
|
430 | - $html .= EEH_HTML::td( /*__FUNCTION__ .*/ |
|
431 | - $name_and_desc, '', 'item_l sub-item'); |
|
432 | - // percent td |
|
433 | - $html .= EEH_HTML::td($line_item->percent() . '%', '', ' jst-rght', ''); |
|
434 | - // empty td (price) |
|
435 | - $html .= EEH_HTML::td(EEH_HTML::nbsp()); |
|
436 | - // total td |
|
437 | - $html .= EEH_HTML::td(EEH_Template::format_currency( |
|
438 | - $line_item->total(), false, false), |
|
439 | - '', |
|
440 | - 'item_r jst-rght' |
|
441 | - ); |
|
442 | - // end of row |
|
443 | - $html .= EEH_HTML::trx(); |
|
444 | - return $html; |
|
445 | - } |
|
446 | - |
|
447 | - |
|
448 | - |
|
449 | - /** |
|
450 | - * _total_row |
|
451 | - * |
|
452 | - * @param EE_Line_Item $line_item |
|
453 | - * @param string $text |
|
454 | - * @return mixed |
|
455 | - * @throws EE_Error |
|
456 | - */ |
|
457 | - private function _total_tax_row(EE_Line_Item $line_item, $text = '') |
|
458 | - { |
|
459 | - $html = ''; |
|
460 | - if ($line_item->total()) { |
|
461 | - // start of row |
|
462 | - $html = EEH_HTML::tr('', '', 'total_tr odd'); |
|
463 | - // total td |
|
464 | - $html .= EEH_HTML::td( |
|
465 | - $text, |
|
466 | - '', |
|
467 | - 'total_currency total jst-rght', |
|
468 | - '', |
|
469 | - ' colspan="2"' |
|
470 | - ); |
|
471 | - // empty td (price) |
|
472 | - $html .= EEH_HTML::td(EEH_HTML::nbsp()); |
|
473 | - // total td |
|
474 | - $html .= EEH_HTML::td( |
|
475 | - EEH_Template::format_currency($line_item->total(), false, false), |
|
476 | - '', |
|
477 | - 'total jst-rght' |
|
478 | - ); |
|
479 | - // end of row |
|
480 | - $html .= EEH_HTML::trx(); |
|
481 | - } |
|
482 | - return $html; |
|
483 | - } |
|
484 | - |
|
485 | - |
|
486 | - |
|
487 | - /** |
|
488 | - * _total_row |
|
489 | - * |
|
490 | - * @param EE_Line_Item $line_item |
|
491 | - * @param string $text |
|
492 | - * @param array $options |
|
493 | - * @return mixed |
|
494 | - * @throws EE_Error |
|
495 | - */ |
|
496 | - private function _sub_total_row(EE_Line_Item $line_item, $text = '', $options = array()) |
|
497 | - { |
|
498 | - $html = ''; |
|
499 | - if ($line_item->total()) { |
|
500 | - // start of row |
|
501 | - $html = EEH_HTML::tr('', '', 'total_tr odd'); |
|
502 | - // total td |
|
503 | - $html .= EEH_HTML::td( |
|
504 | - $text, |
|
505 | - '', |
|
506 | - 'total_currency total jst-rght', |
|
507 | - '', |
|
508 | - ' colspan="3"' |
|
509 | - ); |
|
510 | - // total td |
|
511 | - $html .= EEH_HTML::td( |
|
512 | - EEH_Template::format_currency($options['sub_total'], false, false), |
|
513 | - '', |
|
514 | - 'total jst-rght' |
|
515 | - ); |
|
516 | - // end of row |
|
517 | - $html .= EEH_HTML::trx(); |
|
518 | - } |
|
519 | - return $html; |
|
520 | - } |
|
521 | - |
|
522 | - |
|
523 | - |
|
524 | - /** |
|
525 | - * _total_row |
|
526 | - * |
|
527 | - * @param EE_Line_Item $line_item |
|
528 | - * @param string $text |
|
529 | - * @return mixed |
|
530 | - * @throws EE_Error |
|
531 | - */ |
|
532 | - private function _total_row(EE_Line_Item $line_item, $text = '') |
|
533 | - { |
|
534 | - // start of row |
|
535 | - $html = EEH_HTML::tr('', '', 'spco-grand-total total_tr odd'); |
|
536 | - // total td |
|
537 | - $html .= EEH_HTML::td($text, '', 'total_currency total jst-rght', '', ' colspan="3"'); |
|
538 | - // total td |
|
539 | - $html .= EEH_HTML::td( |
|
540 | - EEH_Template::format_currency($line_item->total(), false, false), |
|
541 | - '', |
|
542 | - 'total jst-rght' |
|
543 | - ); |
|
544 | - // end of row |
|
545 | - $html .= EEH_HTML::trx(); |
|
546 | - return $html; |
|
547 | - } |
|
548 | - |
|
549 | - |
|
550 | - |
|
551 | - /** |
|
552 | - * _payments_and_amount_owing_rows |
|
553 | - * |
|
554 | - * @param EE_Line_Item $line_item |
|
555 | - * @param array $options |
|
556 | - * @return mixed |
|
557 | - * @throws EE_Error |
|
558 | - */ |
|
559 | - private function _payments_and_amount_owing_rows(EE_Line_Item $line_item, $options = array()) |
|
560 | - { |
|
561 | - $html = ''; |
|
562 | - $owing = $line_item->total(); |
|
563 | - $transaction = EEM_Transaction::instance()->get_one_by_ID($line_item->TXN_ID()); |
|
564 | - if ($transaction instanceof EE_Transaction) { |
|
565 | - $registration_payments = array(); |
|
566 | - $registrations = ! empty($options['registrations']) |
|
567 | - ? $options['registrations'] |
|
568 | - : $transaction->registrations(); |
|
569 | - foreach ($registrations as $registration) { |
|
570 | - if ($registration instanceof EE_Registration && $registration->owes_monies_and_can_pay()) { |
|
571 | - $registration_payments += $registration->registration_payments(); |
|
572 | - } |
|
573 | - } |
|
574 | - if (! empty($registration_payments)) { |
|
575 | - foreach ($registration_payments as $registration_payment) { |
|
576 | - if ($registration_payment instanceof EE_Registration_Payment) { |
|
577 | - $owing -= $registration_payment->amount(); |
|
578 | - $payment = $registration_payment->payment(); |
|
579 | - $payment_desc = ''; |
|
580 | - if ($payment instanceof EE_Payment) { |
|
581 | - $payment_desc = sprintf( |
|
582 | - esc_html__('Payment%1$s Received: %2$s', 'event_espresso'), |
|
583 | - $payment->txn_id_chq_nmbr() !== '' |
|
584 | - ? ' <span class="small-text">(#' . $payment->txn_id_chq_nmbr() . ')</span> ' |
|
585 | - : '', |
|
586 | - $payment->timestamp() |
|
587 | - ); |
|
588 | - } |
|
589 | - // start of row |
|
590 | - $html .= EEH_HTML::tr('', '', 'total_tr odd'); |
|
591 | - // payment desc |
|
592 | - $html .= EEH_HTML::td($payment_desc, '', '', '', ' colspan="3"'); |
|
593 | - // total td |
|
594 | - $html .= EEH_HTML::td( |
|
595 | - EEH_Template::format_currency( |
|
596 | - $registration_payment->amount(), |
|
597 | - false, |
|
598 | - false |
|
599 | - ), |
|
600 | - '', |
|
601 | - 'total jst-rght' |
|
602 | - ); |
|
603 | - // end of row |
|
604 | - $html .= EEH_HTML::trx(); |
|
605 | - } |
|
606 | - } |
|
607 | - if ($line_item->total()) { |
|
608 | - // start of row |
|
609 | - $html .= EEH_HTML::tr('', '', 'total_tr odd'); |
|
610 | - // total td |
|
611 | - $html .= EEH_HTML::td( |
|
612 | - esc_html__('Amount Owing', 'event_espresso'), |
|
613 | - '', 'total_currency total jst-rght', '', ' colspan="3"' |
|
614 | - ); |
|
615 | - // total td |
|
616 | - $html .= EEH_HTML::td( |
|
617 | - EEH_Template::format_currency($owing, false, false), |
|
618 | - '', |
|
619 | - 'total jst-rght' |
|
620 | - ); |
|
621 | - // end of row |
|
622 | - $html .= EEH_HTML::trx(); |
|
623 | - } |
|
624 | - } |
|
625 | - } |
|
626 | - $this->_grand_total = $owing; |
|
627 | - return $html; |
|
628 | - } |
|
19 | + /** |
|
20 | + * array of events |
|
21 | + * |
|
22 | + * @type EE_Line_Item[] $_events |
|
23 | + */ |
|
24 | + private $_events = array(); |
|
25 | + |
|
26 | + /** |
|
27 | + * whether to display the taxes row or not |
|
28 | + * |
|
29 | + * @type bool $_show_taxes |
|
30 | + */ |
|
31 | + private $_show_taxes = false; |
|
32 | + |
|
33 | + /** |
|
34 | + * html for any tax rows |
|
35 | + * |
|
36 | + * @type string $_show_taxes |
|
37 | + */ |
|
38 | + private $_taxes_html = ''; |
|
39 | + |
|
40 | + /** |
|
41 | + * total amount including tax we can bill for at this time |
|
42 | + * |
|
43 | + * @type float $_grand_total |
|
44 | + */ |
|
45 | + private $_grand_total = 0.00; |
|
46 | + |
|
47 | + /** |
|
48 | + * total number of items being billed for |
|
49 | + * |
|
50 | + * @type int $_total_items |
|
51 | + */ |
|
52 | + private $_total_items = 0; |
|
53 | + |
|
54 | + |
|
55 | + |
|
56 | + /** |
|
57 | + * @return float |
|
58 | + */ |
|
59 | + public function grand_total() |
|
60 | + { |
|
61 | + return $this->_grand_total; |
|
62 | + } |
|
63 | + |
|
64 | + |
|
65 | + |
|
66 | + /** |
|
67 | + * @return int |
|
68 | + */ |
|
69 | + public function total_items() |
|
70 | + { |
|
71 | + return $this->_total_items; |
|
72 | + } |
|
73 | + |
|
74 | + |
|
75 | + |
|
76 | + /** |
|
77 | + * @param EE_Line_Item $line_item |
|
78 | + * @param array $options |
|
79 | + * @param EE_Line_Item $parent_line_item |
|
80 | + * @return mixed |
|
81 | + * @throws EE_Error |
|
82 | + */ |
|
83 | + public function display_line_item( |
|
84 | + EE_Line_Item $line_item, |
|
85 | + $options = array(), |
|
86 | + EE_Line_Item $parent_line_item = null |
|
87 | + ) { |
|
88 | + $html = ''; |
|
89 | + // set some default options and merge with incoming |
|
90 | + $default_options = array( |
|
91 | + 'show_desc' => true, // true false |
|
92 | + 'odd' => false, |
|
93 | + ); |
|
94 | + $options = array_merge($default_options, (array)$options); |
|
95 | + switch ($line_item->type()) { |
|
96 | + case EEM_Line_Item::type_line_item: |
|
97 | + $this->_show_taxes = $line_item->is_taxable() ? true : $this->_show_taxes; |
|
98 | + if ($line_item->OBJ_type() === 'Ticket') { |
|
99 | + // item row |
|
100 | + $html .= $this->_ticket_row($line_item, $options); |
|
101 | + } else { |
|
102 | + // item row |
|
103 | + $html .= $this->_item_row($line_item, $options); |
|
104 | + } |
|
105 | + if ( |
|
106 | + apply_filters( |
|
107 | + 'FHEE__EE_SPCO_Line_Item_Display_Strategy__display_line_item__display_sub_line_items', |
|
108 | + true |
|
109 | + ) |
|
110 | + ) { |
|
111 | + // got any kids? |
|
112 | + foreach ($line_item->children() as $child_line_item) { |
|
113 | + $html .= $this->display_line_item($child_line_item, $options, $line_item); |
|
114 | + } |
|
115 | + } |
|
116 | + break; |
|
117 | + case EEM_Line_Item::type_sub_line_item: |
|
118 | + $html .= $this->_sub_item_row($line_item, $options, $parent_line_item); |
|
119 | + break; |
|
120 | + case EEM_Line_Item::type_sub_total: |
|
121 | + static $sub_total = 0; |
|
122 | + $event_sub_total = 0; |
|
123 | + $text = esc_html__('Sub-Total', 'event_espresso'); |
|
124 | + if ($line_item->OBJ_type() === 'Event') { |
|
125 | + $options['event_id'] = $event_id = $line_item->OBJ_ID(); |
|
126 | + if (! isset($this->_events[$options['event_id']])) { |
|
127 | + $event = EEM_Event::instance()->get_one_by_ID($options['event_id']); |
|
128 | + // if event has default reg status of Not Approved, then don't display info on it |
|
129 | + if ( |
|
130 | + $event instanceof EE_Event |
|
131 | + && $event->default_registration_status() === EEM_Registration::status_id_not_approved |
|
132 | + ) { |
|
133 | + $display_event = false; |
|
134 | + // unless there are registrations for it that are returning to pay |
|
135 | + if (isset($options['registrations']) && is_array($options['registrations'])) { |
|
136 | + foreach ($options['registrations'] as $registration) { |
|
137 | + if (! $registration instanceof EE_Registration) { |
|
138 | + continue; |
|
139 | + } |
|
140 | + $display_event = $registration->event_ID() === $options['event_id'] |
|
141 | + && $registration->status_ID() !== EEM_Registration::status_id_not_approved |
|
142 | + ? true |
|
143 | + : $display_event; |
|
144 | + } |
|
145 | + } |
|
146 | + if (! $display_event) { |
|
147 | + return ''; |
|
148 | + } |
|
149 | + } |
|
150 | + $this->_events[$options['event_id']] = 0; |
|
151 | + $html .= $this->_event_row($line_item); |
|
152 | + $text = esc_html__('Event Sub-Total', 'event_espresso'); |
|
153 | + } |
|
154 | + } |
|
155 | + $child_line_items = $line_item->children(); |
|
156 | + // loop thru children |
|
157 | + foreach ($child_line_items as $child_line_item) { |
|
158 | + // recursively feed children back into this method |
|
159 | + $html .= $this->display_line_item($child_line_item, $options, $line_item); |
|
160 | + } |
|
161 | + $event_sub_total += isset($options['event_id']) ? $this->_events[$options['event_id']] : 0; |
|
162 | + $sub_total += $event_sub_total; |
|
163 | + if ( |
|
164 | + ( |
|
165 | + // event subtotals |
|
166 | + $line_item->code() !== 'pre-tax-subtotal' && count($child_line_items) > 1 |
|
167 | + ) |
|
168 | + || ( |
|
169 | + // pre-tax subtotals |
|
170 | + $line_item->code() === 'pre-tax-subtotal' && count($this->_events) > 1 |
|
171 | + ) |
|
172 | + ) { |
|
173 | + $options['sub_total'] = $line_item->OBJ_type() === 'Event' ? $event_sub_total : $sub_total; |
|
174 | + $html .= $this->_sub_total_row($line_item, $text, $options); |
|
175 | + } |
|
176 | + break; |
|
177 | + case EEM_Line_Item::type_tax: |
|
178 | + if ($this->_show_taxes) { |
|
179 | + $this->_taxes_html .= $this->_tax_row($line_item, $options); |
|
180 | + } |
|
181 | + break; |
|
182 | + case EEM_Line_Item::type_tax_sub_total: |
|
183 | + if ($this->_show_taxes) { |
|
184 | + $child_line_items = $line_item->children(); |
|
185 | + // loop thru children |
|
186 | + foreach ($child_line_items as $child_line_item) { |
|
187 | + // recursively feed children back into this method |
|
188 | + $html .= $this->display_line_item($child_line_item, $options, $line_item); |
|
189 | + } |
|
190 | + if (count($child_line_items) > 1) { |
|
191 | + $this->_taxes_html .= $this->_total_tax_row($line_item, esc_html__('Tax Total', 'event_espresso')); |
|
192 | + } |
|
193 | + } |
|
194 | + break; |
|
195 | + case EEM_Line_Item::type_total: |
|
196 | + // get all child line items |
|
197 | + $children = $line_item->children(); |
|
198 | + // loop thru all non-tax child line items |
|
199 | + foreach ($children as $child_line_item) { |
|
200 | + if ($child_line_item->type() !== EEM_Line_Item::type_tax_sub_total) { |
|
201 | + // recursively feed children back into this method |
|
202 | + $html .= $this->display_line_item($child_line_item, $options, $line_item); |
|
203 | + } |
|
204 | + } |
|
205 | + // now loop thru tax child line items |
|
206 | + foreach ($children as $child_line_item) { |
|
207 | + if ($child_line_item->type() === EEM_Line_Item::type_tax_sub_total) { |
|
208 | + // recursively feed children back into this method |
|
209 | + $html .= $this->display_line_item($child_line_item, $options, $line_item); |
|
210 | + } |
|
211 | + } |
|
212 | + $html .= $this->_taxes_html; |
|
213 | + $html .= $this->_total_row($line_item, esc_html__('Total', 'event_espresso')); |
|
214 | + $html .= $this->_payments_and_amount_owing_rows($line_item, $options); |
|
215 | + break; |
|
216 | + } |
|
217 | + return $html; |
|
218 | + } |
|
219 | + |
|
220 | + |
|
221 | + |
|
222 | + /** |
|
223 | + * _event_row - basically a Heading row displayed once above each event's ticket rows |
|
224 | + * |
|
225 | + * @param EE_Line_Item $line_item |
|
226 | + * @return mixed |
|
227 | + */ |
|
228 | + private function _event_row(EE_Line_Item $line_item) |
|
229 | + { |
|
230 | + // start of row |
|
231 | + $html = EEH_HTML::tr('', 'event-cart-total-row', 'total_tr odd'); |
|
232 | + // event name td |
|
233 | + $html .= EEH_HTML::td( |
|
234 | + EEH_HTML::strong($line_item->name()), |
|
235 | + '', |
|
236 | + 'event-header', |
|
237 | + '', |
|
238 | + ' colspan="4"' |
|
239 | + ); |
|
240 | + // end of row |
|
241 | + $html .= EEH_HTML::trx(); |
|
242 | + return $html; |
|
243 | + } |
|
244 | + |
|
245 | + |
|
246 | + |
|
247 | + /** |
|
248 | + * _ticket_row |
|
249 | + * |
|
250 | + * @param EE_Line_Item $line_item |
|
251 | + * @param array $options |
|
252 | + * @return mixed |
|
253 | + * @throws EE_Error |
|
254 | + */ |
|
255 | + private function _ticket_row(EE_Line_Item $line_item, $options = array()) |
|
256 | + { |
|
257 | + // start of row |
|
258 | + $row_class = $options['odd'] ? 'item odd' : 'item'; |
|
259 | + $html = EEH_HTML::tr('', '', $row_class); |
|
260 | + // name && desc |
|
261 | + $name_and_desc = apply_filters( |
|
262 | + 'FHEE__EE_SPCO_Line_Item_Display_Strategy__item_row__name', |
|
263 | + $line_item->name(), |
|
264 | + $line_item |
|
265 | + ); |
|
266 | + $name_and_desc .= apply_filters( |
|
267 | + 'FHEE__EE_SPCO_Line_Item_Display_Strategy__item_row__desc', |
|
268 | + ( |
|
269 | + $options['show_desc'] |
|
270 | + ? '<span class="line-item-desc-spn smaller-text">: ' . $line_item->desc() . '</span>' |
|
271 | + : '' |
|
272 | + ), |
|
273 | + $line_item, |
|
274 | + $options |
|
275 | + ); |
|
276 | + $name_and_desc .= $line_item->is_taxable() ? ' * ' : ''; |
|
277 | + // name td |
|
278 | + $html .= EEH_HTML::td( /*__FUNCTION__ .*/ |
|
279 | + $name_and_desc, '', 'item_l'); |
|
280 | + // price td |
|
281 | + $html .= EEH_HTML::td($line_item->unit_price_no_code(), '', 'item_c jst-rght'); |
|
282 | + // quantity td |
|
283 | + $html .= EEH_HTML::td($line_item->quantity(), '', 'item_l jst-rght'); |
|
284 | + $this->_total_items += $line_item->quantity(); |
|
285 | + // determine total for line item |
|
286 | + $total = $line_item->total(); |
|
287 | + $this->_events[$options['event_id']] += $total; |
|
288 | + // total td |
|
289 | + $html .= EEH_HTML::td( |
|
290 | + EEH_Template::format_currency($total, false, false), |
|
291 | + '', |
|
292 | + 'item_r jst-rght' |
|
293 | + ); |
|
294 | + // end of row |
|
295 | + $html .= EEH_HTML::trx(); |
|
296 | + return $html; |
|
297 | + } |
|
298 | + |
|
299 | + |
|
300 | + |
|
301 | + /** |
|
302 | + * _item_row |
|
303 | + * |
|
304 | + * @param EE_Line_Item $line_item |
|
305 | + * @param array $options |
|
306 | + * @return mixed |
|
307 | + * @throws EE_Error |
|
308 | + */ |
|
309 | + private function _item_row(EE_Line_Item $line_item, $options = array()) |
|
310 | + { |
|
311 | + // start of row |
|
312 | + $row_class = $options['odd'] ? 'item odd' : 'item'; |
|
313 | + $html = EEH_HTML::tr('', '', $row_class); |
|
314 | + $obj_name = $line_item->OBJ_type() ? $line_item->OBJ_type_i18n() . ': ' : ''; |
|
315 | + // name && desc |
|
316 | + $name_and_desc = apply_filters( |
|
317 | + 'FHEE__EE_SPCO_Line_Item_Display_Strategy__item_row__name', |
|
318 | + $obj_name . $line_item->name(), |
|
319 | + $line_item |
|
320 | + ); |
|
321 | + $name_and_desc .= apply_filters( |
|
322 | + 'FHEE__EE_SPCO_Line_Item_Display_Strategy__item_row__desc', |
|
323 | + ( |
|
324 | + $options['show_desc'] |
|
325 | + ? '<span class="line-item-desc-spn smaller-text">: ' . $line_item->desc() . '</span>' |
|
326 | + : '' |
|
327 | + ), |
|
328 | + $line_item, |
|
329 | + $options |
|
330 | + ); |
|
331 | + $name_and_desc .= $line_item->is_taxable() ? ' * ' : ''; |
|
332 | + // name td |
|
333 | + $html .= EEH_HTML::td($name_and_desc, '', 'item_l'); |
|
334 | + // price td |
|
335 | + if ($line_item->is_percent()) { |
|
336 | + $html .= EEH_HTML::td($line_item->percent() . '%', '', 'item_c jst-rght'); |
|
337 | + } else { |
|
338 | + $html .= EEH_HTML::td($line_item->unit_price_no_code(), '', 'item_c jst-rght'); |
|
339 | + } |
|
340 | + // quantity td |
|
341 | + $html .= EEH_HTML::td($line_item->quantity(), '', 'item_l jst-rght'); |
|
342 | + //$total = $line_item->total() * $line_item->quantity(); |
|
343 | + $total = $line_item->total(); |
|
344 | + if (isset($options['event_id'], $this->_events[$options['event_id']])) { |
|
345 | + $this->_events[$options['event_id']] += $total; |
|
346 | + } |
|
347 | + // total td |
|
348 | + $html .= EEH_HTML::td( |
|
349 | + EEH_Template::format_currency($total, false, false), |
|
350 | + '', |
|
351 | + 'item_r jst-rght' |
|
352 | + ); |
|
353 | + // end of row |
|
354 | + $html .= EEH_HTML::trx(); |
|
355 | + return $html; |
|
356 | + } |
|
357 | + |
|
358 | + |
|
359 | + |
|
360 | + /** |
|
361 | + * _sub_item_row |
|
362 | + * |
|
363 | + * @param EE_Line_Item $line_item |
|
364 | + * @param array $options |
|
365 | + * @param EE_Line_Item $parent_line_item |
|
366 | + * @return mixed |
|
367 | + * @throws EE_Error |
|
368 | + */ |
|
369 | + private function _sub_item_row(EE_Line_Item $line_item, $options = array(), EE_Line_Item $parent_line_item = null) |
|
370 | + { |
|
371 | + if( |
|
372 | + $parent_line_item instanceof EE_Line_Item |
|
373 | + && $line_item->children() === array() |
|
374 | + && $line_item->name() === $parent_line_item->name() |
|
375 | + ) { |
|
376 | + return ''; |
|
377 | + } |
|
378 | + // start of row |
|
379 | + $html = EEH_HTML::tr('', '', 'item sub-item-row'); |
|
380 | + // name && desc |
|
381 | + $name_and_desc = EEH_HTML::span('', '', 'sub-item-row-bullet dashicons dashicons-arrow-right') |
|
382 | + . $line_item->name(); |
|
383 | + $name_and_desc .= $options['show_desc'] ? '<span class="line-sub-item-desc-spn smaller-text">: ' |
|
384 | + . $line_item->desc() |
|
385 | + . '</span>' : ''; |
|
386 | + // name td |
|
387 | + $html .= EEH_HTML::td( $name_and_desc, '', 'item_l sub-item'); |
|
388 | + $qty = $parent_line_item instanceof EE_Line_Item ? $parent_line_item->quantity() : 1; |
|
389 | + // discount/surcharge td |
|
390 | + if ($line_item->is_percent()) { |
|
391 | + $html .= EEH_HTML::td( |
|
392 | + EEH_Template::format_currency( |
|
393 | + $line_item->total() / $qty, |
|
394 | + false, false |
|
395 | + ), |
|
396 | + '', 'item_c jst-rght' |
|
397 | + ); |
|
398 | + } else { |
|
399 | + $html .= EEH_HTML::td($line_item->unit_price_no_code(), '', 'item_c jst-rght'); |
|
400 | + } |
|
401 | + // no quantity td |
|
402 | + $html .= EEH_HTML::td(); |
|
403 | + // no total td |
|
404 | + $html .= EEH_HTML::td(); |
|
405 | + // end of row |
|
406 | + $html .= EEH_HTML::trx(); |
|
407 | + return $html; |
|
408 | + } |
|
409 | + |
|
410 | + |
|
411 | + |
|
412 | + /** |
|
413 | + * _tax_row |
|
414 | + * |
|
415 | + * @param EE_Line_Item $line_item |
|
416 | + * @param array $options |
|
417 | + * @return mixed |
|
418 | + * @throws EE_Error |
|
419 | + */ |
|
420 | + private function _tax_row(EE_Line_Item $line_item, $options = array()) |
|
421 | + { |
|
422 | + // start of row |
|
423 | + $html = EEH_HTML::tr('', 'item sub-item tax-total'); |
|
424 | + // name && desc |
|
425 | + $name_and_desc = $line_item->name(); |
|
426 | + $name_and_desc .= '<span class="smaller-text lt-grey-text" style="margin:0 0 0 2em;">' |
|
427 | + . esc_html__(' * taxable items', 'event_espresso') . '</span>'; |
|
428 | + $name_and_desc .= $options['show_desc'] ? '<br/>' . $line_item->desc() : ''; |
|
429 | + // name td |
|
430 | + $html .= EEH_HTML::td( /*__FUNCTION__ .*/ |
|
431 | + $name_and_desc, '', 'item_l sub-item'); |
|
432 | + // percent td |
|
433 | + $html .= EEH_HTML::td($line_item->percent() . '%', '', ' jst-rght', ''); |
|
434 | + // empty td (price) |
|
435 | + $html .= EEH_HTML::td(EEH_HTML::nbsp()); |
|
436 | + // total td |
|
437 | + $html .= EEH_HTML::td(EEH_Template::format_currency( |
|
438 | + $line_item->total(), false, false), |
|
439 | + '', |
|
440 | + 'item_r jst-rght' |
|
441 | + ); |
|
442 | + // end of row |
|
443 | + $html .= EEH_HTML::trx(); |
|
444 | + return $html; |
|
445 | + } |
|
446 | + |
|
447 | + |
|
448 | + |
|
449 | + /** |
|
450 | + * _total_row |
|
451 | + * |
|
452 | + * @param EE_Line_Item $line_item |
|
453 | + * @param string $text |
|
454 | + * @return mixed |
|
455 | + * @throws EE_Error |
|
456 | + */ |
|
457 | + private function _total_tax_row(EE_Line_Item $line_item, $text = '') |
|
458 | + { |
|
459 | + $html = ''; |
|
460 | + if ($line_item->total()) { |
|
461 | + // start of row |
|
462 | + $html = EEH_HTML::tr('', '', 'total_tr odd'); |
|
463 | + // total td |
|
464 | + $html .= EEH_HTML::td( |
|
465 | + $text, |
|
466 | + '', |
|
467 | + 'total_currency total jst-rght', |
|
468 | + '', |
|
469 | + ' colspan="2"' |
|
470 | + ); |
|
471 | + // empty td (price) |
|
472 | + $html .= EEH_HTML::td(EEH_HTML::nbsp()); |
|
473 | + // total td |
|
474 | + $html .= EEH_HTML::td( |
|
475 | + EEH_Template::format_currency($line_item->total(), false, false), |
|
476 | + '', |
|
477 | + 'total jst-rght' |
|
478 | + ); |
|
479 | + // end of row |
|
480 | + $html .= EEH_HTML::trx(); |
|
481 | + } |
|
482 | + return $html; |
|
483 | + } |
|
484 | + |
|
485 | + |
|
486 | + |
|
487 | + /** |
|
488 | + * _total_row |
|
489 | + * |
|
490 | + * @param EE_Line_Item $line_item |
|
491 | + * @param string $text |
|
492 | + * @param array $options |
|
493 | + * @return mixed |
|
494 | + * @throws EE_Error |
|
495 | + */ |
|
496 | + private function _sub_total_row(EE_Line_Item $line_item, $text = '', $options = array()) |
|
497 | + { |
|
498 | + $html = ''; |
|
499 | + if ($line_item->total()) { |
|
500 | + // start of row |
|
501 | + $html = EEH_HTML::tr('', '', 'total_tr odd'); |
|
502 | + // total td |
|
503 | + $html .= EEH_HTML::td( |
|
504 | + $text, |
|
505 | + '', |
|
506 | + 'total_currency total jst-rght', |
|
507 | + '', |
|
508 | + ' colspan="3"' |
|
509 | + ); |
|
510 | + // total td |
|
511 | + $html .= EEH_HTML::td( |
|
512 | + EEH_Template::format_currency($options['sub_total'], false, false), |
|
513 | + '', |
|
514 | + 'total jst-rght' |
|
515 | + ); |
|
516 | + // end of row |
|
517 | + $html .= EEH_HTML::trx(); |
|
518 | + } |
|
519 | + return $html; |
|
520 | + } |
|
521 | + |
|
522 | + |
|
523 | + |
|
524 | + /** |
|
525 | + * _total_row |
|
526 | + * |
|
527 | + * @param EE_Line_Item $line_item |
|
528 | + * @param string $text |
|
529 | + * @return mixed |
|
530 | + * @throws EE_Error |
|
531 | + */ |
|
532 | + private function _total_row(EE_Line_Item $line_item, $text = '') |
|
533 | + { |
|
534 | + // start of row |
|
535 | + $html = EEH_HTML::tr('', '', 'spco-grand-total total_tr odd'); |
|
536 | + // total td |
|
537 | + $html .= EEH_HTML::td($text, '', 'total_currency total jst-rght', '', ' colspan="3"'); |
|
538 | + // total td |
|
539 | + $html .= EEH_HTML::td( |
|
540 | + EEH_Template::format_currency($line_item->total(), false, false), |
|
541 | + '', |
|
542 | + 'total jst-rght' |
|
543 | + ); |
|
544 | + // end of row |
|
545 | + $html .= EEH_HTML::trx(); |
|
546 | + return $html; |
|
547 | + } |
|
548 | + |
|
549 | + |
|
550 | + |
|
551 | + /** |
|
552 | + * _payments_and_amount_owing_rows |
|
553 | + * |
|
554 | + * @param EE_Line_Item $line_item |
|
555 | + * @param array $options |
|
556 | + * @return mixed |
|
557 | + * @throws EE_Error |
|
558 | + */ |
|
559 | + private function _payments_and_amount_owing_rows(EE_Line_Item $line_item, $options = array()) |
|
560 | + { |
|
561 | + $html = ''; |
|
562 | + $owing = $line_item->total(); |
|
563 | + $transaction = EEM_Transaction::instance()->get_one_by_ID($line_item->TXN_ID()); |
|
564 | + if ($transaction instanceof EE_Transaction) { |
|
565 | + $registration_payments = array(); |
|
566 | + $registrations = ! empty($options['registrations']) |
|
567 | + ? $options['registrations'] |
|
568 | + : $transaction->registrations(); |
|
569 | + foreach ($registrations as $registration) { |
|
570 | + if ($registration instanceof EE_Registration && $registration->owes_monies_and_can_pay()) { |
|
571 | + $registration_payments += $registration->registration_payments(); |
|
572 | + } |
|
573 | + } |
|
574 | + if (! empty($registration_payments)) { |
|
575 | + foreach ($registration_payments as $registration_payment) { |
|
576 | + if ($registration_payment instanceof EE_Registration_Payment) { |
|
577 | + $owing -= $registration_payment->amount(); |
|
578 | + $payment = $registration_payment->payment(); |
|
579 | + $payment_desc = ''; |
|
580 | + if ($payment instanceof EE_Payment) { |
|
581 | + $payment_desc = sprintf( |
|
582 | + esc_html__('Payment%1$s Received: %2$s', 'event_espresso'), |
|
583 | + $payment->txn_id_chq_nmbr() !== '' |
|
584 | + ? ' <span class="small-text">(#' . $payment->txn_id_chq_nmbr() . ')</span> ' |
|
585 | + : '', |
|
586 | + $payment->timestamp() |
|
587 | + ); |
|
588 | + } |
|
589 | + // start of row |
|
590 | + $html .= EEH_HTML::tr('', '', 'total_tr odd'); |
|
591 | + // payment desc |
|
592 | + $html .= EEH_HTML::td($payment_desc, '', '', '', ' colspan="3"'); |
|
593 | + // total td |
|
594 | + $html .= EEH_HTML::td( |
|
595 | + EEH_Template::format_currency( |
|
596 | + $registration_payment->amount(), |
|
597 | + false, |
|
598 | + false |
|
599 | + ), |
|
600 | + '', |
|
601 | + 'total jst-rght' |
|
602 | + ); |
|
603 | + // end of row |
|
604 | + $html .= EEH_HTML::trx(); |
|
605 | + } |
|
606 | + } |
|
607 | + if ($line_item->total()) { |
|
608 | + // start of row |
|
609 | + $html .= EEH_HTML::tr('', '', 'total_tr odd'); |
|
610 | + // total td |
|
611 | + $html .= EEH_HTML::td( |
|
612 | + esc_html__('Amount Owing', 'event_espresso'), |
|
613 | + '', 'total_currency total jst-rght', '', ' colspan="3"' |
|
614 | + ); |
|
615 | + // total td |
|
616 | + $html .= EEH_HTML::td( |
|
617 | + EEH_Template::format_currency($owing, false, false), |
|
618 | + '', |
|
619 | + 'total jst-rght' |
|
620 | + ); |
|
621 | + // end of row |
|
622 | + $html .= EEH_HTML::trx(); |
|
623 | + } |
|
624 | + } |
|
625 | + } |
|
626 | + $this->_grand_total = $owing; |
|
627 | + return $html; |
|
628 | + } |
|
629 | 629 | |
630 | 630 | |
631 | 631 | } |
@@ -88,10 +88,10 @@ discard block |
||
88 | 88 | $html = ''; |
89 | 89 | // set some default options and merge with incoming |
90 | 90 | $default_options = array( |
91 | - 'show_desc' => true, // true false |
|
91 | + 'show_desc' => true, // true false |
|
92 | 92 | 'odd' => false, |
93 | 93 | ); |
94 | - $options = array_merge($default_options, (array)$options); |
|
94 | + $options = array_merge($default_options, (array) $options); |
|
95 | 95 | switch ($line_item->type()) { |
96 | 96 | case EEM_Line_Item::type_line_item: |
97 | 97 | $this->_show_taxes = $line_item->is_taxable() ? true : $this->_show_taxes; |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | $text = esc_html__('Sub-Total', 'event_espresso'); |
124 | 124 | if ($line_item->OBJ_type() === 'Event') { |
125 | 125 | $options['event_id'] = $event_id = $line_item->OBJ_ID(); |
126 | - if (! isset($this->_events[$options['event_id']])) { |
|
126 | + if ( ! isset($this->_events[$options['event_id']])) { |
|
127 | 127 | $event = EEM_Event::instance()->get_one_by_ID($options['event_id']); |
128 | 128 | // if event has default reg status of Not Approved, then don't display info on it |
129 | 129 | if ( |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | // unless there are registrations for it that are returning to pay |
135 | 135 | if (isset($options['registrations']) && is_array($options['registrations'])) { |
136 | 136 | foreach ($options['registrations'] as $registration) { |
137 | - if (! $registration instanceof EE_Registration) { |
|
137 | + if ( ! $registration instanceof EE_Registration) { |
|
138 | 138 | continue; |
139 | 139 | } |
140 | 140 | $display_event = $registration->event_ID() === $options['event_id'] |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | : $display_event; |
144 | 144 | } |
145 | 145 | } |
146 | - if (! $display_event) { |
|
146 | + if ( ! $display_event) { |
|
147 | 147 | return ''; |
148 | 148 | } |
149 | 149 | } |
@@ -267,7 +267,7 @@ discard block |
||
267 | 267 | 'FHEE__EE_SPCO_Line_Item_Display_Strategy__item_row__desc', |
268 | 268 | ( |
269 | 269 | $options['show_desc'] |
270 | - ? '<span class="line-item-desc-spn smaller-text">: ' . $line_item->desc() . '</span>' |
|
270 | + ? '<span class="line-item-desc-spn smaller-text">: '.$line_item->desc().'</span>' |
|
271 | 271 | : '' |
272 | 272 | ), |
273 | 273 | $line_item, |
@@ -311,18 +311,18 @@ discard block |
||
311 | 311 | // start of row |
312 | 312 | $row_class = $options['odd'] ? 'item odd' : 'item'; |
313 | 313 | $html = EEH_HTML::tr('', '', $row_class); |
314 | - $obj_name = $line_item->OBJ_type() ? $line_item->OBJ_type_i18n() . ': ' : ''; |
|
314 | + $obj_name = $line_item->OBJ_type() ? $line_item->OBJ_type_i18n().': ' : ''; |
|
315 | 315 | // name && desc |
316 | 316 | $name_and_desc = apply_filters( |
317 | 317 | 'FHEE__EE_SPCO_Line_Item_Display_Strategy__item_row__name', |
318 | - $obj_name . $line_item->name(), |
|
318 | + $obj_name.$line_item->name(), |
|
319 | 319 | $line_item |
320 | 320 | ); |
321 | 321 | $name_and_desc .= apply_filters( |
322 | 322 | 'FHEE__EE_SPCO_Line_Item_Display_Strategy__item_row__desc', |
323 | 323 | ( |
324 | 324 | $options['show_desc'] |
325 | - ? '<span class="line-item-desc-spn smaller-text">: ' . $line_item->desc() . '</span>' |
|
325 | + ? '<span class="line-item-desc-spn smaller-text">: '.$line_item->desc().'</span>' |
|
326 | 326 | : '' |
327 | 327 | ), |
328 | 328 | $line_item, |
@@ -333,7 +333,7 @@ discard block |
||
333 | 333 | $html .= EEH_HTML::td($name_and_desc, '', 'item_l'); |
334 | 334 | // price td |
335 | 335 | if ($line_item->is_percent()) { |
336 | - $html .= EEH_HTML::td($line_item->percent() . '%', '', 'item_c jst-rght'); |
|
336 | + $html .= EEH_HTML::td($line_item->percent().'%', '', 'item_c jst-rght'); |
|
337 | 337 | } else { |
338 | 338 | $html .= EEH_HTML::td($line_item->unit_price_no_code(), '', 'item_c jst-rght'); |
339 | 339 | } |
@@ -368,7 +368,7 @@ discard block |
||
368 | 368 | */ |
369 | 369 | private function _sub_item_row(EE_Line_Item $line_item, $options = array(), EE_Line_Item $parent_line_item = null) |
370 | 370 | { |
371 | - if( |
|
371 | + if ( |
|
372 | 372 | $parent_line_item instanceof EE_Line_Item |
373 | 373 | && $line_item->children() === array() |
374 | 374 | && $line_item->name() === $parent_line_item->name() |
@@ -384,7 +384,7 @@ discard block |
||
384 | 384 | . $line_item->desc() |
385 | 385 | . '</span>' : ''; |
386 | 386 | // name td |
387 | - $html .= EEH_HTML::td( $name_and_desc, '', 'item_l sub-item'); |
|
387 | + $html .= EEH_HTML::td($name_and_desc, '', 'item_l sub-item'); |
|
388 | 388 | $qty = $parent_line_item instanceof EE_Line_Item ? $parent_line_item->quantity() : 1; |
389 | 389 | // discount/surcharge td |
390 | 390 | if ($line_item->is_percent()) { |
@@ -424,13 +424,13 @@ discard block |
||
424 | 424 | // name && desc |
425 | 425 | $name_and_desc = $line_item->name(); |
426 | 426 | $name_and_desc .= '<span class="smaller-text lt-grey-text" style="margin:0 0 0 2em;">' |
427 | - . esc_html__(' * taxable items', 'event_espresso') . '</span>'; |
|
428 | - $name_and_desc .= $options['show_desc'] ? '<br/>' . $line_item->desc() : ''; |
|
427 | + . esc_html__(' * taxable items', 'event_espresso').'</span>'; |
|
428 | + $name_and_desc .= $options['show_desc'] ? '<br/>'.$line_item->desc() : ''; |
|
429 | 429 | // name td |
430 | 430 | $html .= EEH_HTML::td( /*__FUNCTION__ .*/ |
431 | 431 | $name_and_desc, '', 'item_l sub-item'); |
432 | 432 | // percent td |
433 | - $html .= EEH_HTML::td($line_item->percent() . '%', '', ' jst-rght', ''); |
|
433 | + $html .= EEH_HTML::td($line_item->percent().'%', '', ' jst-rght', ''); |
|
434 | 434 | // empty td (price) |
435 | 435 | $html .= EEH_HTML::td(EEH_HTML::nbsp()); |
436 | 436 | // total td |
@@ -571,7 +571,7 @@ discard block |
||
571 | 571 | $registration_payments += $registration->registration_payments(); |
572 | 572 | } |
573 | 573 | } |
574 | - if (! empty($registration_payments)) { |
|
574 | + if ( ! empty($registration_payments)) { |
|
575 | 575 | foreach ($registration_payments as $registration_payment) { |
576 | 576 | if ($registration_payment instanceof EE_Registration_Payment) { |
577 | 577 | $owing -= $registration_payment->amount(); |
@@ -581,7 +581,7 @@ discard block |
||
581 | 581 | $payment_desc = sprintf( |
582 | 582 | esc_html__('Payment%1$s Received: %2$s', 'event_espresso'), |
583 | 583 | $payment->txn_id_chq_nmbr() !== '' |
584 | - ? ' <span class="small-text">(#' . $payment->txn_id_chq_nmbr() . ')</span> ' |
|
584 | + ? ' <span class="small-text">(#'.$payment->txn_id_chq_nmbr().')</span> ' |
|
585 | 585 | : '', |
586 | 586 | $payment->timestamp() |
587 | 587 | ); |
@@ -15,285 +15,285 @@ |
||
15 | 15 | abstract class EE_Form_Section_Layout_Base |
16 | 16 | { |
17 | 17 | |
18 | - /** |
|
19 | - * Form form section to lay out |
|
20 | - * |
|
21 | - * @var EE_Form_Section_Proper |
|
22 | - */ |
|
23 | - protected $_form_section; |
|
24 | - |
|
25 | - |
|
26 | - |
|
27 | - /** |
|
28 | - * __construct |
|
29 | - */ |
|
30 | - public function __construct() |
|
31 | - { |
|
32 | - } |
|
33 | - |
|
34 | - |
|
35 | - |
|
36 | - /** |
|
37 | - * The form section on which this strategy is to perform |
|
38 | - * |
|
39 | - * @param EE_Form_Section_Proper $form |
|
40 | - */ |
|
41 | - public function _construct_finalize(EE_Form_Section_Proper $form) |
|
42 | - { |
|
43 | - $this->_form_section = $form; |
|
44 | - } |
|
45 | - |
|
46 | - |
|
47 | - |
|
48 | - /** |
|
49 | - * @return EE_Form_Section_Proper |
|
50 | - */ |
|
51 | - public function form_section() |
|
52 | - { |
|
53 | - return $this->_form_section; |
|
54 | - } |
|
55 | - |
|
56 | - |
|
57 | - |
|
58 | - /** |
|
59 | - * Also has teh side effect of enqueuing any needed JS and CSS for |
|
60 | - * this form. |
|
61 | - * Creates all the HTML necessary for displaying this form, its inputs, and |
|
62 | - * proper subsections. |
|
63 | - * Returns the HTML |
|
64 | - * |
|
65 | - * @return string HTML for displaying |
|
66 | - * @throws EE_Error |
|
67 | - */ |
|
68 | - public function layout_form() |
|
69 | - { |
|
70 | - $html = ''; |
|
71 | - // layout_form_begin |
|
72 | - $html .= apply_filters( |
|
73 | - 'FHEE__EE_Form_Section_Layout_Base__layout_form__start__for_' . $this->_form_section->name(), |
|
74 | - $this->layout_form_begin(), |
|
75 | - $this->_form_section |
|
76 | - ); |
|
77 | - // layout_form_loop |
|
78 | - $html .= apply_filters( |
|
79 | - 'FHEE__EE_Form_Section_Layout_Base__layout_form__loop__for_' . $this->_form_section->name(), |
|
80 | - $this->layout_form_loop(), |
|
81 | - $this->_form_section |
|
82 | - ); |
|
83 | - // layout_form_end |
|
84 | - $html .= apply_filters( |
|
85 | - 'FHEE__EE_Form_Section_Layout_Base__layout_form__end__for_' . $this->_form_section->name(), |
|
86 | - $this->layout_form_end(), |
|
87 | - $this->_form_section |
|
88 | - ); |
|
89 | - $html = $this->add_form_section_hooks_and_filters($html); |
|
90 | - return $html; |
|
91 | - } |
|
92 | - |
|
93 | - |
|
94 | - |
|
95 | - /** |
|
96 | - * @return string |
|
97 | - * @throws EE_Error |
|
98 | - */ |
|
99 | - public function layout_form_loop() |
|
100 | - { |
|
101 | - $html = ''; |
|
102 | - foreach ($this->_form_section->subsections() as $name => $subsection) { |
|
103 | - if ($subsection instanceof EE_Form_Input_Base) { |
|
104 | - $html .= apply_filters( |
|
105 | - 'FHEE__EE_Form_Section_Layout_Base__layout_form__loop_for_input_' |
|
106 | - . $name . '__in_' . $this->_form_section->name(), |
|
107 | - $this->layout_input($subsection), |
|
108 | - $this->_form_section, |
|
109 | - $subsection |
|
110 | - ); |
|
111 | - } elseif ($subsection instanceof EE_Form_Section_Base) { |
|
112 | - $html .= apply_filters( |
|
113 | - 'FHEE__EE_Form_Section_Layout_Base__layout_form__loop_for_non_input_' |
|
114 | - . $name . '__in_' . $this->_form_section->name(), |
|
115 | - $this->layout_subsection($subsection), |
|
116 | - $this->_form_section, |
|
117 | - $subsection |
|
118 | - ); |
|
119 | - } |
|
120 | - } |
|
121 | - return $html; |
|
122 | - } |
|
123 | - |
|
124 | - |
|
125 | - |
|
126 | - /** |
|
127 | - * Should be used to start teh form section (Eg a table tag, or a div tag, etc.) |
|
128 | - * |
|
129 | - * @return string |
|
130 | - */ |
|
131 | - abstract public function layout_form_begin(); |
|
132 | - |
|
133 | - |
|
134 | - |
|
135 | - /** |
|
136 | - * Should be used to end the form section (eg a /table tag, or a /div tag, etc) |
|
137 | - * |
|
138 | - * @return string |
|
139 | - */ |
|
140 | - abstract public function layout_form_end(); |
|
141 | - |
|
142 | - |
|
143 | - |
|
144 | - /** |
|
145 | - * Should be used internally by layout_form() to layout each input (eg, if this layout |
|
146 | - * is putting each input in a row of its own, this should probably be called by a |
|
147 | - * foreach loop in layout_form() (WITHOUT adding any content directly within layout_form()'s foreach loop. |
|
148 | - * Eg, this method should add the tr and td tags). This method is exposed in case you want to completely |
|
149 | - * customize the form's layout, but would like to make use of it for laying out |
|
150 | - * 'easy-to-layout' inputs |
|
151 | - * |
|
152 | - * @param EE_Form_Input_Base $input |
|
153 | - * @return string html |
|
154 | - */ |
|
155 | - abstract public function layout_input($input); |
|
156 | - |
|
157 | - |
|
158 | - |
|
159 | - /** |
|
160 | - * Similar to layout_input(), should be used internally by layout_form() within a |
|
161 | - * loop to layout each proper subsection. Unlike layout_input(), however, it is assumed |
|
162 | - * that the proper subsection will layout its container, label, etc on its own. |
|
163 | - * |
|
164 | - * @param EE_Form_Section_Base $subsection |
|
165 | - * @return string html |
|
166 | - */ |
|
167 | - abstract public function layout_subsection($subsection); |
|
168 | - |
|
169 | - |
|
170 | - |
|
171 | - /** |
|
172 | - * Gets the HTML for the label tag and its contents for the input |
|
173 | - * |
|
174 | - * @param EE_Form_Input_Base $input |
|
175 | - * @return string |
|
176 | - */ |
|
177 | - public function display_label($input) |
|
178 | - { |
|
179 | - $class = $input->required() |
|
180 | - ? 'ee-required-label ' . $input->html_label_class() |
|
181 | - : $input->html_label_class(); |
|
182 | - $label_text = $input->required() |
|
183 | - ? $input->html_label_text() . '<span class="ee-asterisk">*</span>' |
|
184 | - : $input->html_label_text(); |
|
185 | - return '<label id="' |
|
186 | - . $input->html_label_id() |
|
187 | - . '" class="' |
|
188 | - . $class |
|
189 | - . '" style="' |
|
190 | - . $input->html_label_style() |
|
191 | - . '" for="' . $input->html_name() |
|
192 | - . '">' |
|
193 | - . $label_text |
|
194 | - . '</label>'; |
|
195 | - } |
|
196 | - |
|
197 | - |
|
198 | - |
|
199 | - /** |
|
200 | - * Gets the HTML for all the form's form-wide errors (ie, errors which |
|
201 | - * are not for specific inputs. E.g., if two inputs somehow disagree, |
|
202 | - * those errors would probably be on the form section, not one of its inputs) |
|
203 | - * @return string |
|
204 | - */ |
|
205 | - public function display_form_wide_errors() |
|
206 | - { |
|
207 | - $html = ''; |
|
208 | - if ($this->_form_section->get_validation_errors()) { |
|
209 | - $html .= "<div class='ee-form-wide-errors'>"; |
|
210 | - //get all the errors on THIS form section (errors which aren't |
|
211 | - //for specific inputs, but instead for the entire form section) |
|
212 | - foreach ($this->_form_section->get_validation_errors() as $error) { |
|
213 | - $html .= $error->getMessage() . '<br>'; |
|
214 | - } |
|
215 | - $html .= '</div>'; |
|
216 | - } |
|
217 | - return apply_filters( |
|
218 | - 'FHEE__EE_Form_Section_Layout_Base__display_form_wide_errors', |
|
219 | - $html, |
|
220 | - $this |
|
221 | - ); |
|
222 | - } |
|
223 | - |
|
224 | - |
|
225 | - |
|
226 | - /** |
|
227 | - * returns the HTML for the server-side validation errors for the specified input |
|
228 | - * Note that if JS is enabled, it should remove these and instead |
|
229 | - * populate the form's errors in the jquery validate fashion |
|
230 | - * using the localized data provided to the JS |
|
231 | - * |
|
232 | - * @param EE_Form_Input_Base $input |
|
233 | - * @return string |
|
234 | - */ |
|
235 | - public function display_errors($input) |
|
236 | - { |
|
237 | - if ($input->get_validation_errors()) { |
|
238 | - return "<label id='" |
|
239 | - . $input->html_id() |
|
240 | - . "-error' class='error' for='{$input->html_name()}'>" |
|
241 | - . $input->get_validation_error_string() |
|
242 | - . '</label>'; |
|
243 | - } |
|
244 | - return ''; |
|
245 | - } |
|
246 | - |
|
247 | - |
|
248 | - |
|
249 | - /** |
|
250 | - * Displays the help span for the specified input |
|
251 | - * |
|
252 | - * @param EE_Form_Input_Base $input |
|
253 | - * @return string |
|
254 | - */ |
|
255 | - public function display_help_text($input) |
|
256 | - { |
|
257 | - $help_text = $input->html_help_text(); |
|
258 | - if ($help_text !== '' && $help_text !== null) { |
|
259 | - $tag = is_admin() ? 'p' : 'span'; |
|
260 | - return '<' |
|
261 | - . $tag |
|
262 | - . ' id="' |
|
263 | - . $input->html_id() |
|
264 | - . '-help" class="' |
|
265 | - . $input->html_help_class() |
|
266 | - . '" style="' |
|
267 | - . $input->html_help_style() |
|
268 | - . '">' |
|
269 | - . $help_text |
|
270 | - . '</' |
|
271 | - . $tag |
|
272 | - . '>'; |
|
273 | - } |
|
274 | - return ''; |
|
275 | - } |
|
276 | - |
|
277 | - |
|
278 | - |
|
279 | - /** |
|
280 | - * Does an action and hook onto the end of teh form |
|
281 | - * |
|
282 | - * @param string $html |
|
283 | - * @return string |
|
284 | - */ |
|
285 | - public function add_form_section_hooks_and_filters($html) |
|
286 | - { |
|
287 | - // replace dashes and spaces with underscores |
|
288 | - $hook_name = str_replace(array('-', ' '), '_', $this->_form_section->html_id()); |
|
289 | - do_action('AHEE__Form_Section_Layout__' . $hook_name, $this->_form_section); |
|
290 | - $html = (string) apply_filters( |
|
291 | - 'AFEE__Form_Section_Layout__' . $hook_name . '__html', |
|
292 | - $html, |
|
293 | - $this->_form_section |
|
294 | - ); |
|
295 | - $html .= EEH_HTML::nl() . '<!-- AHEE__Form_Section_Layout__' . $hook_name . '__html -->'; |
|
296 | - $html .= EEH_HTML::nl() . '<!-- AFEE__Form_Section_Layout__' . $hook_name . ' -->'; |
|
297 | - return $html; |
|
298 | - } |
|
18 | + /** |
|
19 | + * Form form section to lay out |
|
20 | + * |
|
21 | + * @var EE_Form_Section_Proper |
|
22 | + */ |
|
23 | + protected $_form_section; |
|
24 | + |
|
25 | + |
|
26 | + |
|
27 | + /** |
|
28 | + * __construct |
|
29 | + */ |
|
30 | + public function __construct() |
|
31 | + { |
|
32 | + } |
|
33 | + |
|
34 | + |
|
35 | + |
|
36 | + /** |
|
37 | + * The form section on which this strategy is to perform |
|
38 | + * |
|
39 | + * @param EE_Form_Section_Proper $form |
|
40 | + */ |
|
41 | + public function _construct_finalize(EE_Form_Section_Proper $form) |
|
42 | + { |
|
43 | + $this->_form_section = $form; |
|
44 | + } |
|
45 | + |
|
46 | + |
|
47 | + |
|
48 | + /** |
|
49 | + * @return EE_Form_Section_Proper |
|
50 | + */ |
|
51 | + public function form_section() |
|
52 | + { |
|
53 | + return $this->_form_section; |
|
54 | + } |
|
55 | + |
|
56 | + |
|
57 | + |
|
58 | + /** |
|
59 | + * Also has teh side effect of enqueuing any needed JS and CSS for |
|
60 | + * this form. |
|
61 | + * Creates all the HTML necessary for displaying this form, its inputs, and |
|
62 | + * proper subsections. |
|
63 | + * Returns the HTML |
|
64 | + * |
|
65 | + * @return string HTML for displaying |
|
66 | + * @throws EE_Error |
|
67 | + */ |
|
68 | + public function layout_form() |
|
69 | + { |
|
70 | + $html = ''; |
|
71 | + // layout_form_begin |
|
72 | + $html .= apply_filters( |
|
73 | + 'FHEE__EE_Form_Section_Layout_Base__layout_form__start__for_' . $this->_form_section->name(), |
|
74 | + $this->layout_form_begin(), |
|
75 | + $this->_form_section |
|
76 | + ); |
|
77 | + // layout_form_loop |
|
78 | + $html .= apply_filters( |
|
79 | + 'FHEE__EE_Form_Section_Layout_Base__layout_form__loop__for_' . $this->_form_section->name(), |
|
80 | + $this->layout_form_loop(), |
|
81 | + $this->_form_section |
|
82 | + ); |
|
83 | + // layout_form_end |
|
84 | + $html .= apply_filters( |
|
85 | + 'FHEE__EE_Form_Section_Layout_Base__layout_form__end__for_' . $this->_form_section->name(), |
|
86 | + $this->layout_form_end(), |
|
87 | + $this->_form_section |
|
88 | + ); |
|
89 | + $html = $this->add_form_section_hooks_and_filters($html); |
|
90 | + return $html; |
|
91 | + } |
|
92 | + |
|
93 | + |
|
94 | + |
|
95 | + /** |
|
96 | + * @return string |
|
97 | + * @throws EE_Error |
|
98 | + */ |
|
99 | + public function layout_form_loop() |
|
100 | + { |
|
101 | + $html = ''; |
|
102 | + foreach ($this->_form_section->subsections() as $name => $subsection) { |
|
103 | + if ($subsection instanceof EE_Form_Input_Base) { |
|
104 | + $html .= apply_filters( |
|
105 | + 'FHEE__EE_Form_Section_Layout_Base__layout_form__loop_for_input_' |
|
106 | + . $name . '__in_' . $this->_form_section->name(), |
|
107 | + $this->layout_input($subsection), |
|
108 | + $this->_form_section, |
|
109 | + $subsection |
|
110 | + ); |
|
111 | + } elseif ($subsection instanceof EE_Form_Section_Base) { |
|
112 | + $html .= apply_filters( |
|
113 | + 'FHEE__EE_Form_Section_Layout_Base__layout_form__loop_for_non_input_' |
|
114 | + . $name . '__in_' . $this->_form_section->name(), |
|
115 | + $this->layout_subsection($subsection), |
|
116 | + $this->_form_section, |
|
117 | + $subsection |
|
118 | + ); |
|
119 | + } |
|
120 | + } |
|
121 | + return $html; |
|
122 | + } |
|
123 | + |
|
124 | + |
|
125 | + |
|
126 | + /** |
|
127 | + * Should be used to start teh form section (Eg a table tag, or a div tag, etc.) |
|
128 | + * |
|
129 | + * @return string |
|
130 | + */ |
|
131 | + abstract public function layout_form_begin(); |
|
132 | + |
|
133 | + |
|
134 | + |
|
135 | + /** |
|
136 | + * Should be used to end the form section (eg a /table tag, or a /div tag, etc) |
|
137 | + * |
|
138 | + * @return string |
|
139 | + */ |
|
140 | + abstract public function layout_form_end(); |
|
141 | + |
|
142 | + |
|
143 | + |
|
144 | + /** |
|
145 | + * Should be used internally by layout_form() to layout each input (eg, if this layout |
|
146 | + * is putting each input in a row of its own, this should probably be called by a |
|
147 | + * foreach loop in layout_form() (WITHOUT adding any content directly within layout_form()'s foreach loop. |
|
148 | + * Eg, this method should add the tr and td tags). This method is exposed in case you want to completely |
|
149 | + * customize the form's layout, but would like to make use of it for laying out |
|
150 | + * 'easy-to-layout' inputs |
|
151 | + * |
|
152 | + * @param EE_Form_Input_Base $input |
|
153 | + * @return string html |
|
154 | + */ |
|
155 | + abstract public function layout_input($input); |
|
156 | + |
|
157 | + |
|
158 | + |
|
159 | + /** |
|
160 | + * Similar to layout_input(), should be used internally by layout_form() within a |
|
161 | + * loop to layout each proper subsection. Unlike layout_input(), however, it is assumed |
|
162 | + * that the proper subsection will layout its container, label, etc on its own. |
|
163 | + * |
|
164 | + * @param EE_Form_Section_Base $subsection |
|
165 | + * @return string html |
|
166 | + */ |
|
167 | + abstract public function layout_subsection($subsection); |
|
168 | + |
|
169 | + |
|
170 | + |
|
171 | + /** |
|
172 | + * Gets the HTML for the label tag and its contents for the input |
|
173 | + * |
|
174 | + * @param EE_Form_Input_Base $input |
|
175 | + * @return string |
|
176 | + */ |
|
177 | + public function display_label($input) |
|
178 | + { |
|
179 | + $class = $input->required() |
|
180 | + ? 'ee-required-label ' . $input->html_label_class() |
|
181 | + : $input->html_label_class(); |
|
182 | + $label_text = $input->required() |
|
183 | + ? $input->html_label_text() . '<span class="ee-asterisk">*</span>' |
|
184 | + : $input->html_label_text(); |
|
185 | + return '<label id="' |
|
186 | + . $input->html_label_id() |
|
187 | + . '" class="' |
|
188 | + . $class |
|
189 | + . '" style="' |
|
190 | + . $input->html_label_style() |
|
191 | + . '" for="' . $input->html_name() |
|
192 | + . '">' |
|
193 | + . $label_text |
|
194 | + . '</label>'; |
|
195 | + } |
|
196 | + |
|
197 | + |
|
198 | + |
|
199 | + /** |
|
200 | + * Gets the HTML for all the form's form-wide errors (ie, errors which |
|
201 | + * are not for specific inputs. E.g., if two inputs somehow disagree, |
|
202 | + * those errors would probably be on the form section, not one of its inputs) |
|
203 | + * @return string |
|
204 | + */ |
|
205 | + public function display_form_wide_errors() |
|
206 | + { |
|
207 | + $html = ''; |
|
208 | + if ($this->_form_section->get_validation_errors()) { |
|
209 | + $html .= "<div class='ee-form-wide-errors'>"; |
|
210 | + //get all the errors on THIS form section (errors which aren't |
|
211 | + //for specific inputs, but instead for the entire form section) |
|
212 | + foreach ($this->_form_section->get_validation_errors() as $error) { |
|
213 | + $html .= $error->getMessage() . '<br>'; |
|
214 | + } |
|
215 | + $html .= '</div>'; |
|
216 | + } |
|
217 | + return apply_filters( |
|
218 | + 'FHEE__EE_Form_Section_Layout_Base__display_form_wide_errors', |
|
219 | + $html, |
|
220 | + $this |
|
221 | + ); |
|
222 | + } |
|
223 | + |
|
224 | + |
|
225 | + |
|
226 | + /** |
|
227 | + * returns the HTML for the server-side validation errors for the specified input |
|
228 | + * Note that if JS is enabled, it should remove these and instead |
|
229 | + * populate the form's errors in the jquery validate fashion |
|
230 | + * using the localized data provided to the JS |
|
231 | + * |
|
232 | + * @param EE_Form_Input_Base $input |
|
233 | + * @return string |
|
234 | + */ |
|
235 | + public function display_errors($input) |
|
236 | + { |
|
237 | + if ($input->get_validation_errors()) { |
|
238 | + return "<label id='" |
|
239 | + . $input->html_id() |
|
240 | + . "-error' class='error' for='{$input->html_name()}'>" |
|
241 | + . $input->get_validation_error_string() |
|
242 | + . '</label>'; |
|
243 | + } |
|
244 | + return ''; |
|
245 | + } |
|
246 | + |
|
247 | + |
|
248 | + |
|
249 | + /** |
|
250 | + * Displays the help span for the specified input |
|
251 | + * |
|
252 | + * @param EE_Form_Input_Base $input |
|
253 | + * @return string |
|
254 | + */ |
|
255 | + public function display_help_text($input) |
|
256 | + { |
|
257 | + $help_text = $input->html_help_text(); |
|
258 | + if ($help_text !== '' && $help_text !== null) { |
|
259 | + $tag = is_admin() ? 'p' : 'span'; |
|
260 | + return '<' |
|
261 | + . $tag |
|
262 | + . ' id="' |
|
263 | + . $input->html_id() |
|
264 | + . '-help" class="' |
|
265 | + . $input->html_help_class() |
|
266 | + . '" style="' |
|
267 | + . $input->html_help_style() |
|
268 | + . '">' |
|
269 | + . $help_text |
|
270 | + . '</' |
|
271 | + . $tag |
|
272 | + . '>'; |
|
273 | + } |
|
274 | + return ''; |
|
275 | + } |
|
276 | + |
|
277 | + |
|
278 | + |
|
279 | + /** |
|
280 | + * Does an action and hook onto the end of teh form |
|
281 | + * |
|
282 | + * @param string $html |
|
283 | + * @return string |
|
284 | + */ |
|
285 | + public function add_form_section_hooks_and_filters($html) |
|
286 | + { |
|
287 | + // replace dashes and spaces with underscores |
|
288 | + $hook_name = str_replace(array('-', ' '), '_', $this->_form_section->html_id()); |
|
289 | + do_action('AHEE__Form_Section_Layout__' . $hook_name, $this->_form_section); |
|
290 | + $html = (string) apply_filters( |
|
291 | + 'AFEE__Form_Section_Layout__' . $hook_name . '__html', |
|
292 | + $html, |
|
293 | + $this->_form_section |
|
294 | + ); |
|
295 | + $html .= EEH_HTML::nl() . '<!-- AHEE__Form_Section_Layout__' . $hook_name . '__html -->'; |
|
296 | + $html .= EEH_HTML::nl() . '<!-- AFEE__Form_Section_Layout__' . $hook_name . ' -->'; |
|
297 | + return $html; |
|
298 | + } |
|
299 | 299 | } |
@@ -70,19 +70,19 @@ discard block |
||
70 | 70 | $html = ''; |
71 | 71 | // layout_form_begin |
72 | 72 | $html .= apply_filters( |
73 | - 'FHEE__EE_Form_Section_Layout_Base__layout_form__start__for_' . $this->_form_section->name(), |
|
73 | + 'FHEE__EE_Form_Section_Layout_Base__layout_form__start__for_'.$this->_form_section->name(), |
|
74 | 74 | $this->layout_form_begin(), |
75 | 75 | $this->_form_section |
76 | 76 | ); |
77 | 77 | // layout_form_loop |
78 | 78 | $html .= apply_filters( |
79 | - 'FHEE__EE_Form_Section_Layout_Base__layout_form__loop__for_' . $this->_form_section->name(), |
|
79 | + 'FHEE__EE_Form_Section_Layout_Base__layout_form__loop__for_'.$this->_form_section->name(), |
|
80 | 80 | $this->layout_form_loop(), |
81 | 81 | $this->_form_section |
82 | 82 | ); |
83 | 83 | // layout_form_end |
84 | 84 | $html .= apply_filters( |
85 | - 'FHEE__EE_Form_Section_Layout_Base__layout_form__end__for_' . $this->_form_section->name(), |
|
85 | + 'FHEE__EE_Form_Section_Layout_Base__layout_form__end__for_'.$this->_form_section->name(), |
|
86 | 86 | $this->layout_form_end(), |
87 | 87 | $this->_form_section |
88 | 88 | ); |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | if ($subsection instanceof EE_Form_Input_Base) { |
104 | 104 | $html .= apply_filters( |
105 | 105 | 'FHEE__EE_Form_Section_Layout_Base__layout_form__loop_for_input_' |
106 | - . $name . '__in_' . $this->_form_section->name(), |
|
106 | + . $name.'__in_'.$this->_form_section->name(), |
|
107 | 107 | $this->layout_input($subsection), |
108 | 108 | $this->_form_section, |
109 | 109 | $subsection |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | } elseif ($subsection instanceof EE_Form_Section_Base) { |
112 | 112 | $html .= apply_filters( |
113 | 113 | 'FHEE__EE_Form_Section_Layout_Base__layout_form__loop_for_non_input_' |
114 | - . $name . '__in_' . $this->_form_section->name(), |
|
114 | + . $name.'__in_'.$this->_form_section->name(), |
|
115 | 115 | $this->layout_subsection($subsection), |
116 | 116 | $this->_form_section, |
117 | 117 | $subsection |
@@ -177,10 +177,10 @@ discard block |
||
177 | 177 | public function display_label($input) |
178 | 178 | { |
179 | 179 | $class = $input->required() |
180 | - ? 'ee-required-label ' . $input->html_label_class() |
|
180 | + ? 'ee-required-label '.$input->html_label_class() |
|
181 | 181 | : $input->html_label_class(); |
182 | 182 | $label_text = $input->required() |
183 | - ? $input->html_label_text() . '<span class="ee-asterisk">*</span>' |
|
183 | + ? $input->html_label_text().'<span class="ee-asterisk">*</span>' |
|
184 | 184 | : $input->html_label_text(); |
185 | 185 | return '<label id="' |
186 | 186 | . $input->html_label_id() |
@@ -188,7 +188,7 @@ discard block |
||
188 | 188 | . $class |
189 | 189 | . '" style="' |
190 | 190 | . $input->html_label_style() |
191 | - . '" for="' . $input->html_name() |
|
191 | + . '" for="'.$input->html_name() |
|
192 | 192 | . '">' |
193 | 193 | . $label_text |
194 | 194 | . '</label>'; |
@@ -210,7 +210,7 @@ discard block |
||
210 | 210 | //get all the errors on THIS form section (errors which aren't |
211 | 211 | //for specific inputs, but instead for the entire form section) |
212 | 212 | foreach ($this->_form_section->get_validation_errors() as $error) { |
213 | - $html .= $error->getMessage() . '<br>'; |
|
213 | + $html .= $error->getMessage().'<br>'; |
|
214 | 214 | } |
215 | 215 | $html .= '</div>'; |
216 | 216 | } |
@@ -254,7 +254,7 @@ discard block |
||
254 | 254 | */ |
255 | 255 | public function display_help_text($input) |
256 | 256 | { |
257 | - $help_text = $input->html_help_text(); |
|
257 | + $help_text = $input->html_help_text(); |
|
258 | 258 | if ($help_text !== '' && $help_text !== null) { |
259 | 259 | $tag = is_admin() ? 'p' : 'span'; |
260 | 260 | return '<' |
@@ -286,14 +286,14 @@ discard block |
||
286 | 286 | { |
287 | 287 | // replace dashes and spaces with underscores |
288 | 288 | $hook_name = str_replace(array('-', ' '), '_', $this->_form_section->html_id()); |
289 | - do_action('AHEE__Form_Section_Layout__' . $hook_name, $this->_form_section); |
|
289 | + do_action('AHEE__Form_Section_Layout__'.$hook_name, $this->_form_section); |
|
290 | 290 | $html = (string) apply_filters( |
291 | - 'AFEE__Form_Section_Layout__' . $hook_name . '__html', |
|
291 | + 'AFEE__Form_Section_Layout__'.$hook_name.'__html', |
|
292 | 292 | $html, |
293 | 293 | $this->_form_section |
294 | 294 | ); |
295 | - $html .= EEH_HTML::nl() . '<!-- AHEE__Form_Section_Layout__' . $hook_name . '__html -->'; |
|
296 | - $html .= EEH_HTML::nl() . '<!-- AFEE__Form_Section_Layout__' . $hook_name . ' -->'; |
|
295 | + $html .= EEH_HTML::nl().'<!-- AHEE__Form_Section_Layout__'.$hook_name.'__html -->'; |
|
296 | + $html .= EEH_HTML::nl().'<!-- AFEE__Form_Section_Layout__'.$hook_name.' -->'; |
|
297 | 297 | return $html; |
298 | 298 | } |
299 | 299 | } |
@@ -14,139 +14,139 @@ |
||
14 | 14 | class EE_Div_Per_Section_Layout extends EE_Form_Section_Layout_Base |
15 | 15 | { |
16 | 16 | |
17 | - /** |
|
18 | - * opening div tag for a form |
|
19 | - * |
|
20 | - * @return string |
|
21 | - */ |
|
22 | - public function layout_form_begin() |
|
23 | - { |
|
24 | - return EEH_HTML::div( |
|
25 | - '', |
|
26 | - $this->_form_section->html_id(), |
|
27 | - $this->_form_section->html_class(), |
|
28 | - $this->_form_section->html_style() |
|
29 | - ); |
|
30 | - } |
|
31 | - |
|
32 | - |
|
33 | - |
|
34 | - /** |
|
35 | - * Lays out the row for the input, including label and errors |
|
36 | - * |
|
37 | - * @param EE_Form_Input_Base $input |
|
38 | - * @return string |
|
39 | - * @throws \EE_Error |
|
40 | - */ |
|
41 | - public function layout_input($input) |
|
42 | - { |
|
43 | - $html = ''; |
|
44 | - // set something unique for the id |
|
45 | - $html_id = (string)$input->html_id() !== '' |
|
46 | - ? (string)$input->html_id() |
|
47 | - : spl_object_hash($input); |
|
48 | - // and add a generic input type class |
|
49 | - $html_class = sanitize_key(str_replace('_', '-', get_class($input))) . '-dv'; |
|
50 | - if ($input instanceof EE_Hidden_Input) { |
|
51 | - $html .= EEH_HTML::nl() . $input->get_html_for_input(); |
|
52 | - } else if ($input instanceof EE_Submit_Input) { |
|
53 | - $html .= EEH_HTML::div( |
|
54 | - $input->get_html_for_input(), |
|
55 | - $html_id . '-submit-dv', |
|
56 | - "{$input->html_class()}-submit-dv {$html_class}" |
|
57 | - ); |
|
58 | - } else if ($input instanceof EE_Select_Input) { |
|
59 | - $html .= EEH_HTML::div( |
|
60 | - EEH_HTML::nl(1) . $input->get_html_for_label() . |
|
61 | - EEH_HTML::nl() . $input->get_html_for_errors() . |
|
62 | - EEH_HTML::nl() . $input->get_html_for_input() . |
|
63 | - EEH_HTML::nl() . $input->get_html_for_help(), |
|
64 | - $html_id . '-input-dv', |
|
65 | - "{$input->html_class()}-input-dv {$html_class}" |
|
66 | - ); |
|
67 | - } else if ($input instanceof EE_Form_Input_With_Options_Base) { |
|
68 | - $html .= EEH_HTML::div( |
|
69 | - EEH_HTML::nl() . $this->_display_label_for_option_type_question($input) . |
|
70 | - EEH_HTML::nl() . $input->get_html_for_errors() . |
|
71 | - EEH_HTML::nl() . $input->get_html_for_input() . |
|
72 | - EEH_HTML::nl() . $input->get_html_for_help(), |
|
73 | - $html_id . '-input-dv', |
|
74 | - "{$input->html_class()}-input-dv {$html_class}" |
|
75 | - ); |
|
76 | - } else { |
|
77 | - $html .= EEH_HTML::div( |
|
78 | - EEH_HTML::nl(1) . $input->get_html_for_label() . |
|
79 | - EEH_HTML::nl() . $input->get_html_for_errors() . |
|
80 | - EEH_HTML::nl() . $input->get_html_for_input() . |
|
81 | - EEH_HTML::nl() . $input->get_html_for_help(), |
|
82 | - $html_id . '-input-dv', |
|
83 | - "{$input->html_class()}-input-dv {$html_class}" |
|
84 | - ); |
|
85 | - } |
|
86 | - return $html; |
|
87 | - } |
|
88 | - |
|
89 | - |
|
90 | - |
|
91 | - /** |
|
92 | - * |
|
93 | - * _display_label_for_option_type_question |
|
94 | - * Gets the HTML for the 'label', which is just text for this (because labels |
|
95 | - * should be for each input) |
|
96 | - * |
|
97 | - * @param EE_Form_Input_With_Options_Base $input |
|
98 | - * @return string |
|
99 | - */ |
|
100 | - protected function _display_label_for_option_type_question(EE_Form_Input_With_Options_Base $input) |
|
101 | - { |
|
102 | - if ($input->display_html_label_text()) { |
|
103 | - $html_label_text = $input->html_label_text(); |
|
104 | - $label_html = EEH_HTML::div( |
|
105 | - $input->required() |
|
106 | - ? $html_label_text . EEH_HTML::span('*', '', 'ee-asterisk') |
|
107 | - : $html_label_text, |
|
108 | - $input->html_label_id(), |
|
109 | - $input->required() |
|
110 | - ? 'ee-required-label ' . $input->html_label_class() |
|
111 | - : $input->html_label_class(), |
|
112 | - $input->html_label_style(), |
|
113 | - $input->html_other_attributes() |
|
114 | - ); |
|
115 | - // if no content was provided to EEH_HTML::div() above (ie: an empty label), |
|
116 | - // then we need to close the div manually |
|
117 | - if(empty($html_label_text)){ |
|
118 | - $label_html .= EEH_HTML::divx($input->html_label_id(), $input->html_label_class()); |
|
119 | - } |
|
120 | - return $label_html; |
|
121 | - } |
|
122 | - return ''; |
|
123 | - } |
|
124 | - |
|
125 | - |
|
126 | - |
|
127 | - /** |
|
128 | - * Lays out a row for the subsection |
|
129 | - * |
|
130 | - * @param EE_Form_Section_Proper $form_section |
|
131 | - * @return string |
|
132 | - */ |
|
133 | - public function layout_subsection($form_section) |
|
134 | - { |
|
135 | - // d( $form_section ); |
|
136 | - return EEH_HTML::nl(1) . $form_section->get_html() . EEH_HTML::nl(-1); |
|
137 | - } |
|
138 | - |
|
139 | - |
|
140 | - |
|
141 | - /** |
|
142 | - * closing div tag for a form |
|
143 | - * |
|
144 | - * @return string |
|
145 | - */ |
|
146 | - public function layout_form_end() |
|
147 | - { |
|
148 | - return EEH_HTML::divx($this->_form_section->html_id(), $this->_form_section->html_class()); |
|
149 | - } |
|
17 | + /** |
|
18 | + * opening div tag for a form |
|
19 | + * |
|
20 | + * @return string |
|
21 | + */ |
|
22 | + public function layout_form_begin() |
|
23 | + { |
|
24 | + return EEH_HTML::div( |
|
25 | + '', |
|
26 | + $this->_form_section->html_id(), |
|
27 | + $this->_form_section->html_class(), |
|
28 | + $this->_form_section->html_style() |
|
29 | + ); |
|
30 | + } |
|
31 | + |
|
32 | + |
|
33 | + |
|
34 | + /** |
|
35 | + * Lays out the row for the input, including label and errors |
|
36 | + * |
|
37 | + * @param EE_Form_Input_Base $input |
|
38 | + * @return string |
|
39 | + * @throws \EE_Error |
|
40 | + */ |
|
41 | + public function layout_input($input) |
|
42 | + { |
|
43 | + $html = ''; |
|
44 | + // set something unique for the id |
|
45 | + $html_id = (string)$input->html_id() !== '' |
|
46 | + ? (string)$input->html_id() |
|
47 | + : spl_object_hash($input); |
|
48 | + // and add a generic input type class |
|
49 | + $html_class = sanitize_key(str_replace('_', '-', get_class($input))) . '-dv'; |
|
50 | + if ($input instanceof EE_Hidden_Input) { |
|
51 | + $html .= EEH_HTML::nl() . $input->get_html_for_input(); |
|
52 | + } else if ($input instanceof EE_Submit_Input) { |
|
53 | + $html .= EEH_HTML::div( |
|
54 | + $input->get_html_for_input(), |
|
55 | + $html_id . '-submit-dv', |
|
56 | + "{$input->html_class()}-submit-dv {$html_class}" |
|
57 | + ); |
|
58 | + } else if ($input instanceof EE_Select_Input) { |
|
59 | + $html .= EEH_HTML::div( |
|
60 | + EEH_HTML::nl(1) . $input->get_html_for_label() . |
|
61 | + EEH_HTML::nl() . $input->get_html_for_errors() . |
|
62 | + EEH_HTML::nl() . $input->get_html_for_input() . |
|
63 | + EEH_HTML::nl() . $input->get_html_for_help(), |
|
64 | + $html_id . '-input-dv', |
|
65 | + "{$input->html_class()}-input-dv {$html_class}" |
|
66 | + ); |
|
67 | + } else if ($input instanceof EE_Form_Input_With_Options_Base) { |
|
68 | + $html .= EEH_HTML::div( |
|
69 | + EEH_HTML::nl() . $this->_display_label_for_option_type_question($input) . |
|
70 | + EEH_HTML::nl() . $input->get_html_for_errors() . |
|
71 | + EEH_HTML::nl() . $input->get_html_for_input() . |
|
72 | + EEH_HTML::nl() . $input->get_html_for_help(), |
|
73 | + $html_id . '-input-dv', |
|
74 | + "{$input->html_class()}-input-dv {$html_class}" |
|
75 | + ); |
|
76 | + } else { |
|
77 | + $html .= EEH_HTML::div( |
|
78 | + EEH_HTML::nl(1) . $input->get_html_for_label() . |
|
79 | + EEH_HTML::nl() . $input->get_html_for_errors() . |
|
80 | + EEH_HTML::nl() . $input->get_html_for_input() . |
|
81 | + EEH_HTML::nl() . $input->get_html_for_help(), |
|
82 | + $html_id . '-input-dv', |
|
83 | + "{$input->html_class()}-input-dv {$html_class}" |
|
84 | + ); |
|
85 | + } |
|
86 | + return $html; |
|
87 | + } |
|
88 | + |
|
89 | + |
|
90 | + |
|
91 | + /** |
|
92 | + * |
|
93 | + * _display_label_for_option_type_question |
|
94 | + * Gets the HTML for the 'label', which is just text for this (because labels |
|
95 | + * should be for each input) |
|
96 | + * |
|
97 | + * @param EE_Form_Input_With_Options_Base $input |
|
98 | + * @return string |
|
99 | + */ |
|
100 | + protected function _display_label_for_option_type_question(EE_Form_Input_With_Options_Base $input) |
|
101 | + { |
|
102 | + if ($input->display_html_label_text()) { |
|
103 | + $html_label_text = $input->html_label_text(); |
|
104 | + $label_html = EEH_HTML::div( |
|
105 | + $input->required() |
|
106 | + ? $html_label_text . EEH_HTML::span('*', '', 'ee-asterisk') |
|
107 | + : $html_label_text, |
|
108 | + $input->html_label_id(), |
|
109 | + $input->required() |
|
110 | + ? 'ee-required-label ' . $input->html_label_class() |
|
111 | + : $input->html_label_class(), |
|
112 | + $input->html_label_style(), |
|
113 | + $input->html_other_attributes() |
|
114 | + ); |
|
115 | + // if no content was provided to EEH_HTML::div() above (ie: an empty label), |
|
116 | + // then we need to close the div manually |
|
117 | + if(empty($html_label_text)){ |
|
118 | + $label_html .= EEH_HTML::divx($input->html_label_id(), $input->html_label_class()); |
|
119 | + } |
|
120 | + return $label_html; |
|
121 | + } |
|
122 | + return ''; |
|
123 | + } |
|
124 | + |
|
125 | + |
|
126 | + |
|
127 | + /** |
|
128 | + * Lays out a row for the subsection |
|
129 | + * |
|
130 | + * @param EE_Form_Section_Proper $form_section |
|
131 | + * @return string |
|
132 | + */ |
|
133 | + public function layout_subsection($form_section) |
|
134 | + { |
|
135 | + // d( $form_section ); |
|
136 | + return EEH_HTML::nl(1) . $form_section->get_html() . EEH_HTML::nl(-1); |
|
137 | + } |
|
138 | + |
|
139 | + |
|
140 | + |
|
141 | + /** |
|
142 | + * closing div tag for a form |
|
143 | + * |
|
144 | + * @return string |
|
145 | + */ |
|
146 | + public function layout_form_end() |
|
147 | + { |
|
148 | + return EEH_HTML::divx($this->_form_section->html_id(), $this->_form_section->html_class()); |
|
149 | + } |
|
150 | 150 | |
151 | 151 | |
152 | 152 |
@@ -42,44 +42,44 @@ discard block |
||
42 | 42 | { |
43 | 43 | $html = ''; |
44 | 44 | // set something unique for the id |
45 | - $html_id = (string)$input->html_id() !== '' |
|
46 | - ? (string)$input->html_id() |
|
45 | + $html_id = (string) $input->html_id() !== '' |
|
46 | + ? (string) $input->html_id() |
|
47 | 47 | : spl_object_hash($input); |
48 | 48 | // and add a generic input type class |
49 | - $html_class = sanitize_key(str_replace('_', '-', get_class($input))) . '-dv'; |
|
49 | + $html_class = sanitize_key(str_replace('_', '-', get_class($input))).'-dv'; |
|
50 | 50 | if ($input instanceof EE_Hidden_Input) { |
51 | - $html .= EEH_HTML::nl() . $input->get_html_for_input(); |
|
51 | + $html .= EEH_HTML::nl().$input->get_html_for_input(); |
|
52 | 52 | } else if ($input instanceof EE_Submit_Input) { |
53 | 53 | $html .= EEH_HTML::div( |
54 | 54 | $input->get_html_for_input(), |
55 | - $html_id . '-submit-dv', |
|
55 | + $html_id.'-submit-dv', |
|
56 | 56 | "{$input->html_class()}-submit-dv {$html_class}" |
57 | 57 | ); |
58 | 58 | } else if ($input instanceof EE_Select_Input) { |
59 | 59 | $html .= EEH_HTML::div( |
60 | - EEH_HTML::nl(1) . $input->get_html_for_label() . |
|
61 | - EEH_HTML::nl() . $input->get_html_for_errors() . |
|
62 | - EEH_HTML::nl() . $input->get_html_for_input() . |
|
63 | - EEH_HTML::nl() . $input->get_html_for_help(), |
|
64 | - $html_id . '-input-dv', |
|
60 | + EEH_HTML::nl(1).$input->get_html_for_label(). |
|
61 | + EEH_HTML::nl().$input->get_html_for_errors(). |
|
62 | + EEH_HTML::nl().$input->get_html_for_input(). |
|
63 | + EEH_HTML::nl().$input->get_html_for_help(), |
|
64 | + $html_id.'-input-dv', |
|
65 | 65 | "{$input->html_class()}-input-dv {$html_class}" |
66 | 66 | ); |
67 | 67 | } else if ($input instanceof EE_Form_Input_With_Options_Base) { |
68 | 68 | $html .= EEH_HTML::div( |
69 | - EEH_HTML::nl() . $this->_display_label_for_option_type_question($input) . |
|
70 | - EEH_HTML::nl() . $input->get_html_for_errors() . |
|
71 | - EEH_HTML::nl() . $input->get_html_for_input() . |
|
72 | - EEH_HTML::nl() . $input->get_html_for_help(), |
|
73 | - $html_id . '-input-dv', |
|
69 | + EEH_HTML::nl().$this->_display_label_for_option_type_question($input). |
|
70 | + EEH_HTML::nl().$input->get_html_for_errors(). |
|
71 | + EEH_HTML::nl().$input->get_html_for_input(). |
|
72 | + EEH_HTML::nl().$input->get_html_for_help(), |
|
73 | + $html_id.'-input-dv', |
|
74 | 74 | "{$input->html_class()}-input-dv {$html_class}" |
75 | 75 | ); |
76 | 76 | } else { |
77 | 77 | $html .= EEH_HTML::div( |
78 | - EEH_HTML::nl(1) . $input->get_html_for_label() . |
|
79 | - EEH_HTML::nl() . $input->get_html_for_errors() . |
|
80 | - EEH_HTML::nl() . $input->get_html_for_input() . |
|
81 | - EEH_HTML::nl() . $input->get_html_for_help(), |
|
82 | - $html_id . '-input-dv', |
|
78 | + EEH_HTML::nl(1).$input->get_html_for_label(). |
|
79 | + EEH_HTML::nl().$input->get_html_for_errors(). |
|
80 | + EEH_HTML::nl().$input->get_html_for_input(). |
|
81 | + EEH_HTML::nl().$input->get_html_for_help(), |
|
82 | + $html_id.'-input-dv', |
|
83 | 83 | "{$input->html_class()}-input-dv {$html_class}" |
84 | 84 | ); |
85 | 85 | } |
@@ -103,18 +103,18 @@ discard block |
||
103 | 103 | $html_label_text = $input->html_label_text(); |
104 | 104 | $label_html = EEH_HTML::div( |
105 | 105 | $input->required() |
106 | - ? $html_label_text . EEH_HTML::span('*', '', 'ee-asterisk') |
|
106 | + ? $html_label_text.EEH_HTML::span('*', '', 'ee-asterisk') |
|
107 | 107 | : $html_label_text, |
108 | 108 | $input->html_label_id(), |
109 | 109 | $input->required() |
110 | - ? 'ee-required-label ' . $input->html_label_class() |
|
110 | + ? 'ee-required-label '.$input->html_label_class() |
|
111 | 111 | : $input->html_label_class(), |
112 | 112 | $input->html_label_style(), |
113 | 113 | $input->html_other_attributes() |
114 | 114 | ); |
115 | 115 | // if no content was provided to EEH_HTML::div() above (ie: an empty label), |
116 | 116 | // then we need to close the div manually |
117 | - if(empty($html_label_text)){ |
|
117 | + if (empty($html_label_text)) { |
|
118 | 118 | $label_html .= EEH_HTML::divx($input->html_label_id(), $input->html_label_class()); |
119 | 119 | } |
120 | 120 | return $label_html; |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | public function layout_subsection($form_section) |
134 | 134 | { |
135 | 135 | // d( $form_section ); |
136 | - return EEH_HTML::nl(1) . $form_section->get_html() . EEH_HTML::nl(-1); |
|
136 | + return EEH_HTML::nl(1).$form_section->get_html().EEH_HTML::nl(-1); |
|
137 | 137 | } |
138 | 138 | |
139 | 139 |