@@ -21,643 +21,642 @@ |
||
21 | 21 | */ |
22 | 22 | abstract class EE_Model_Field_Base implements HasSchemaInterface |
23 | 23 | { |
24 | - /** |
|
25 | - * The alias for the table the column belongs to. |
|
26 | - * @var string |
|
27 | - */ |
|
28 | - protected $_table_alias; |
|
29 | - |
|
30 | - /** |
|
31 | - * The actual db column name for the table |
|
32 | - * @var string |
|
33 | - */ |
|
34 | - protected $_table_column; |
|
35 | - |
|
36 | - |
|
37 | - /** |
|
38 | - * The authoritative name for the table column (used by client code to reference the field). |
|
39 | - * @var string |
|
40 | - */ |
|
41 | - protected $_name; |
|
42 | - |
|
43 | - |
|
44 | - /** |
|
45 | - * A description for the field. |
|
46 | - * @var string |
|
47 | - */ |
|
48 | - protected $_nicename; |
|
49 | - |
|
50 | - |
|
51 | - /** |
|
52 | - * Whether the field is nullable or not |
|
53 | - * @var bool |
|
54 | - */ |
|
55 | - protected $_nullable; |
|
56 | - |
|
57 | - |
|
58 | - /** |
|
59 | - * What the default value for the field should be. |
|
60 | - * @var mixed |
|
61 | - */ |
|
62 | - protected $_default_value; |
|
63 | - |
|
64 | - |
|
65 | - /** |
|
66 | - * Other configuration for the field |
|
67 | - * @var mixed |
|
68 | - */ |
|
69 | - protected $_other_config; |
|
70 | - |
|
71 | - |
|
72 | - /** |
|
73 | - * The name of the model this field is instantiated for. |
|
74 | - * @var string |
|
75 | - */ |
|
76 | - protected $_model_name; |
|
77 | - |
|
78 | - |
|
79 | - /** |
|
80 | - * This should be a json-schema valid data type for the field. |
|
81 | - * @link http://json-schema.org/latest/json-schema-core.html#rfc.section.4.2 |
|
82 | - * @var string |
|
83 | - */ |
|
84 | - private $_schema_type = 'string'; |
|
85 | - |
|
86 | - |
|
87 | - /** |
|
88 | - * If the schema has a defined format then it should be defined via this property. |
|
89 | - * @link http://json-schema.org/latest/json-schema-validation.html#rfc.section.7 |
|
90 | - * @var string |
|
91 | - */ |
|
92 | - private $_schema_format = ''; |
|
93 | - |
|
94 | - |
|
95 | - /** |
|
96 | - * Indicates that the value of the field is managed exclusively by the server/model and not something |
|
97 | - * settable by client code. |
|
98 | - * @link http://json-schema.org/latest/json-schema-hypermedia.html#rfc.section.4.4 |
|
99 | - * @var bool |
|
100 | - */ |
|
101 | - private $_schema_readonly = false; |
|
102 | - |
|
103 | - |
|
104 | - /** |
|
105 | - * @param string $table_column |
|
106 | - * @param string $nicename |
|
107 | - * @param bool $nullable |
|
108 | - * @param null $default_value |
|
109 | - */ |
|
110 | - public function __construct($table_column, $nicename, $nullable, $default_value = null) |
|
111 | - { |
|
112 | - $this->_table_column = $table_column; |
|
113 | - $this->_nicename = $nicename; |
|
114 | - $this->_nullable = $nullable; |
|
115 | - $this->_default_value = $default_value; |
|
116 | - } |
|
117 | - |
|
118 | - |
|
119 | - /** |
|
120 | - * @param $table_alias |
|
121 | - * @param $name |
|
122 | - * @param $model_name |
|
123 | - */ |
|
124 | - public function _construct_finalize($table_alias, $name, $model_name) |
|
125 | - { |
|
126 | - $this->_table_alias = $table_alias; |
|
127 | - $this->_name = $name; |
|
128 | - $this->_model_name = $model_name; |
|
129 | - /** |
|
130 | - * allow for changing the defaults |
|
131 | - */ |
|
132 | - $this->_nicename = apply_filters('FHEE__EE_Model_Field_Base___construct_finalize___nicename', |
|
133 | - $this->_nicename, $this); |
|
134 | - $this->_default_value = apply_filters('FHEE__EE_Model_Field_Base___construct_finalize___default_value', |
|
135 | - $this->_default_value, $this); |
|
136 | - } |
|
137 | - |
|
138 | - public function get_table_alias() |
|
139 | - { |
|
140 | - return $this->_table_alias; |
|
141 | - } |
|
142 | - |
|
143 | - public function get_table_column() |
|
144 | - { |
|
145 | - return $this->_table_column; |
|
146 | - } |
|
147 | - |
|
148 | - /** |
|
149 | - * Returns the name of the model this field is on. Eg 'Event' or 'Ticket_Datetime' |
|
150 | - * |
|
151 | - * @return string |
|
152 | - */ |
|
153 | - public function get_model_name() |
|
154 | - { |
|
155 | - return $this->_model_name; |
|
156 | - } |
|
157 | - |
|
158 | - /** |
|
159 | - * @throws \EE_Error |
|
160 | - * @return string |
|
161 | - */ |
|
162 | - public function get_name() |
|
163 | - { |
|
164 | - if ($this->_name) { |
|
165 | - return $this->_name; |
|
166 | - } else { |
|
167 | - throw new EE_Error(sprintf(__("Model field '%s' has no name set. Did you make a model and forget to call the parent model constructor?", |
|
168 | - "event_espresso"), get_class($this))); |
|
169 | - } |
|
170 | - } |
|
171 | - |
|
172 | - public function get_nicename() |
|
173 | - { |
|
174 | - return $this->_nicename; |
|
175 | - } |
|
176 | - |
|
177 | - public function is_nullable() |
|
178 | - { |
|
179 | - return $this->_nullable; |
|
180 | - } |
|
181 | - |
|
182 | - /** |
|
183 | - * returns whether this field is an auto-increment field or not. If it is, then |
|
184 | - * on insertion it can be null. However, on updates it must be present. |
|
185 | - * |
|
186 | - * @return boolean |
|
187 | - */ |
|
188 | - public function is_auto_increment() |
|
189 | - { |
|
190 | - return false; |
|
191 | - } |
|
192 | - |
|
193 | - /** |
|
194 | - * The default value in the model object's value domain. See lengthy comment about |
|
195 | - * value domains at the top of EEM_Base |
|
196 | - * |
|
197 | - * @return mixed |
|
198 | - */ |
|
199 | - public function get_default_value() |
|
200 | - { |
|
201 | - return $this->_default_value; |
|
202 | - } |
|
203 | - |
|
204 | - /** |
|
205 | - * Returns the table alias joined to the table column, however this isn't the right |
|
206 | - * table alias if the aliased table is being joined to. In that case, you can use |
|
207 | - * EE_Model_Parser::extract_table_alias_model_relation_chain_prefix() to find the table's current alias |
|
208 | - * in the current query |
|
209 | - * |
|
210 | - * @return string |
|
211 | - */ |
|
212 | - public function get_qualified_column() |
|
213 | - { |
|
214 | - return $this->get_table_alias() . "." . $this->get_table_column(); |
|
215 | - } |
|
216 | - |
|
217 | - /** |
|
218 | - * When get() is called on a model object (eg EE_Event), before returning its value, |
|
219 | - * call this function on it, allowing us to customize the returned value based on |
|
220 | - * the field's type. Eg, we may want to unserialize it, strip tags, etc. By default, |
|
221 | - * we simply return it. |
|
222 | - * |
|
223 | - * @param mixed $value_of_field_on_model_object |
|
224 | - * @return mixed |
|
225 | - */ |
|
226 | - public function prepare_for_get($value_of_field_on_model_object) |
|
227 | - { |
|
228 | - return $value_of_field_on_model_object; |
|
229 | - } |
|
230 | - |
|
231 | - /** |
|
232 | - * When inserting or updating a field on a model object, run this function on each |
|
233 | - * value to prepare it for insertion into the db. Generally this converts |
|
234 | - * the validated input on the model object into the format used in the DB. |
|
235 | - * |
|
236 | - * @param mixed $value_of_field_on_model_object |
|
237 | - * @return mixed |
|
238 | - */ |
|
239 | - public function prepare_for_use_in_db($value_of_field_on_model_object) |
|
240 | - { |
|
241 | - return $value_of_field_on_model_object; |
|
242 | - } |
|
243 | - |
|
244 | - /** |
|
245 | - * When creating a brand-new model object, or setting a particular value for one of its fields, this function |
|
246 | - * is called before setting it on the model object. We may want to strip slashes, unserialize the value, etc. |
|
247 | - * By default, we do nothing. |
|
248 | - * |
|
249 | - * If the model field is going to perform any validation on the input, this is where it should be done |
|
250 | - * (once the value is on the model object, it may be used in other ways besides putting it into the DB |
|
251 | - * so it's best to validate it right away). |
|
252 | - * |
|
253 | - * @param mixed $value_inputted_for_field_on_model_object |
|
254 | - * @return mixed |
|
255 | - */ |
|
256 | - public function prepare_for_set($value_inputted_for_field_on_model_object) |
|
257 | - { |
|
258 | - return $value_inputted_for_field_on_model_object; |
|
259 | - } |
|
260 | - |
|
261 | - |
|
262 | - /** |
|
263 | - * When instantiating a model object from DB results, this function is called before setting each field. |
|
264 | - * We may want to serialize the value, etc. By default, we return the value using prepare_for_set() method as that |
|
265 | - * is the one child classes will most often define. |
|
266 | - * |
|
267 | - * @param mixed $value_found_in_db_for_model_object |
|
268 | - * @return mixed |
|
269 | - */ |
|
270 | - public function prepare_for_set_from_db($value_found_in_db_for_model_object) |
|
271 | - { |
|
272 | - return $this->prepare_for_set($value_found_in_db_for_model_object); |
|
273 | - } |
|
274 | - |
|
275 | - /** |
|
276 | - * When echoing a field's value on a model object, this function is run to prepare the value for presentation in a |
|
277 | - * webpage. For example, we may want to output floats with 2 decimal places by default, dates as "Monday Jan 12, |
|
278 | - * 2013, at 3:23pm" instead of |
|
279 | - * "8765678632", or any other modifications to how the value should be displayed, but not modified itself. |
|
280 | - * |
|
281 | - * @param mixed $value_on_field_to_be_outputted |
|
282 | - * @return mixed |
|
283 | - */ |
|
284 | - public function prepare_for_pretty_echoing($value_on_field_to_be_outputted) |
|
285 | - { |
|
286 | - return $value_on_field_to_be_outputted; |
|
287 | - } |
|
288 | - |
|
289 | - |
|
290 | - /** |
|
291 | - * Returns whatever is set as the nicename for the object. |
|
292 | - * @return string |
|
293 | - */ |
|
294 | - public function getSchemaDescription() |
|
295 | - { |
|
296 | - return $this->get_nicename(); |
|
297 | - } |
|
298 | - |
|
299 | - |
|
300 | - /** |
|
301 | - * Returns whatever is set as the $_schema_type property for the object. |
|
302 | - * Note: this will automatically add 'null' to the schema if the object is_nullable() |
|
303 | - * @return string|array |
|
304 | - */ |
|
305 | - public function getSchemaType() |
|
306 | - { |
|
307 | - if ($this->is_nullable()) { |
|
308 | - $this->_schema_type = (array) $this->_schema_type; |
|
309 | - if (! in_array('null', $this->_schema_type)) { |
|
310 | - $this->_schema_type[] = 'null'; |
|
311 | - }; |
|
312 | - } |
|
313 | - return $this->_schema_type; |
|
314 | - } |
|
315 | - |
|
316 | - |
|
317 | - /** |
|
318 | - * Sets the _schema_type property. Child classes should call this in their constructors to override the default state |
|
319 | - * for this property. |
|
320 | - * @param string|array $type |
|
321 | - * @throws InvalidArgumentException |
|
322 | - */ |
|
323 | - protected function setSchemaType($type) |
|
324 | - { |
|
325 | - $this->validateSchemaType($type); |
|
326 | - $this->_schema_type = $type; |
|
327 | - } |
|
328 | - |
|
329 | - |
|
330 | - /** |
|
331 | - * This is usually present when the $_schema_type property is 'object'. Any child classes will need to override |
|
332 | - * this method and return the properties for the schema. |
|
333 | - * |
|
334 | - * The reason this is not a property on the class is because there may be filters set on the values for the property |
|
335 | - * that won't be exposed on construct. For example enum type schemas may have the enum values filtered. |
|
336 | - * |
|
337 | - * @return array |
|
338 | - */ |
|
339 | - public function getSchemaProperties() |
|
340 | - { |
|
341 | - return array(); |
|
342 | - } |
|
343 | - |
|
344 | - |
|
345 | - |
|
346 | - /** |
|
347 | - * By default this returns the scalar default value that was sent in on the class prepped according to the class type |
|
348 | - * as the default. However, when there are schema properties, then the default property is setup to mirror the |
|
349 | - * property keys and correctly prepare the default according to that expected property value. |
|
350 | - * The getSchema method validates whether the schema for default is setup correctly or not according to the schema type |
|
351 | - * |
|
352 | - * @return mixed |
|
353 | - */ |
|
354 | - public function getSchemaDefault() |
|
355 | - { |
|
356 | - $default_value = $this->prepare_for_use_in_db($this->prepare_for_set($this->get_default_value())); |
|
357 | - $schema_properties = $this->getSchemaProperties(); |
|
358 | - |
|
359 | - //if this schema has properties than shape the default value to match the properties shape. |
|
360 | - if ($schema_properties) { |
|
361 | - $value_to_return = array(); |
|
362 | - foreach ($schema_properties as $property_key => $property_schema) { |
|
363 | - switch ($property_key) { |
|
364 | - case 'pretty': |
|
365 | - case 'rendered': |
|
366 | - $value_to_return[$property_key] = $this->prepare_for_pretty_echoing($this->prepare_for_set($default_value)); |
|
367 | - break; |
|
368 | - default: |
|
369 | - $value_to_return[$property_key] = $default_value; |
|
370 | - break; |
|
371 | - } |
|
372 | - } |
|
373 | - $default_value = $value_to_return; |
|
374 | - } |
|
375 | - return $default_value; |
|
376 | - } |
|
377 | - |
|
378 | - |
|
379 | - |
|
380 | - |
|
381 | - /** |
|
382 | - * If a child class has enum values, they should override this method and provide a simple array |
|
383 | - * of the enum values. |
|
384 | - |
|
385 | - * The reason this is not a property on the class is because there may be filterable enum values that |
|
386 | - * are set on the instantiated object that could be filtered after construct. |
|
387 | - * |
|
388 | - * @return array |
|
389 | - */ |
|
390 | - public function getSchemaEnum() |
|
391 | - { |
|
392 | - return array(); |
|
393 | - } |
|
394 | - |
|
395 | - |
|
396 | - /** |
|
397 | - * This returns the value of the $_schema_format property on the object. |
|
398 | - * @return string |
|
399 | - */ |
|
400 | - public function getSchemaFormat() |
|
401 | - { |
|
402 | - return $this->_schema_format; |
|
403 | - } |
|
404 | - |
|
405 | - |
|
406 | - /** |
|
407 | - * Sets the schema format property. |
|
408 | - * @throws InvalidArgumentException |
|
409 | - * @param string $format |
|
410 | - */ |
|
411 | - protected function setSchemaFormat($format) |
|
412 | - { |
|
413 | - $this->validateSchemaFormat($format); |
|
414 | - $this->_schema_format = $format; |
|
415 | - } |
|
416 | - |
|
417 | - |
|
418 | - /** |
|
419 | - * This returns the value of the $_schema_readonly property on the object. |
|
420 | - * @return bool |
|
421 | - */ |
|
422 | - public function getSchemaReadonly() |
|
423 | - { |
|
424 | - return $this->_schema_readonly; |
|
425 | - } |
|
426 | - |
|
427 | - |
|
428 | - /** |
|
429 | - * This sets the value for the $_schema_readonly property. |
|
430 | - * @param bool $readonly (only explicit boolean values are accepted) |
|
431 | - */ |
|
432 | - protected function setSchemaReadOnly($readonly) |
|
433 | - { |
|
434 | - if (! is_bool($readonly)) { |
|
435 | - throw new InvalidArgumentException( |
|
436 | - sprintf( |
|
437 | - esc_html__('The incoming argument (%s) must be a boolean.', 'event_espresso'), |
|
438 | - print_r($readonly, true) |
|
439 | - ) |
|
440 | - ); |
|
441 | - } |
|
442 | - |
|
443 | - $this->_schema_readonly = $readonly; |
|
444 | - } |
|
445 | - |
|
446 | - |
|
447 | - |
|
448 | - |
|
449 | - /** |
|
450 | - * Return `%d`, `%s` or `%f` to indicate the data type for the field. |
|
451 | - * @uses _get_wpdb_data_type() |
|
452 | - * |
|
453 | - * @return string |
|
454 | - */ |
|
455 | - public function get_wpdb_data_type() |
|
456 | - { |
|
457 | - return $this->_get_wpdb_data_type(); |
|
458 | - } |
|
459 | - |
|
460 | - |
|
461 | - /** |
|
462 | - * Return `%d`, `%s` or `%f` to indicate the data type for the field that should be indicated in wpdb queries. |
|
463 | - * @param string $type Included if a specific type is requested. |
|
464 | - * @uses get_schema_type() |
|
465 | - * @return string |
|
466 | - */ |
|
467 | - protected function _get_wpdb_data_type($type='') |
|
468 | - { |
|
469 | - $type = empty($type) ? $this->getSchemaType() : $type; |
|
470 | - |
|
471 | - //if type is an array, then different parsing is required. |
|
472 | - if (is_array($type)) { |
|
473 | - return $this->_get_wpdb_data_type_for_type_array($type); |
|
474 | - } |
|
475 | - |
|
476 | - $wpdb_type = '%s'; |
|
477 | - switch ($type) { |
|
478 | - case 'number': |
|
479 | - $wpdb_type = '%f'; |
|
480 | - break; |
|
481 | - case 'integer': |
|
482 | - case 'boolean': |
|
483 | - $wpdb_type = '%d'; |
|
484 | - break; |
|
485 | - case 'object': |
|
486 | - $properties = $this->getSchemaProperties(); |
|
487 | - if (isset($properties['raw'], $properties['raw']['type'])) { |
|
488 | - $wpdb_type = $this->_get_wpdb_data_type($properties['raw']['type']); |
|
489 | - } |
|
490 | - break; //leave at default |
|
491 | - } |
|
492 | - return $wpdb_type; |
|
493 | - } |
|
494 | - |
|
495 | - |
|
496 | - |
|
497 | - protected function _get_wpdb_data_type_for_type_array($type) |
|
498 | - { |
|
499 | - $type = (array) $type; |
|
500 | - //first let's flip because then we can do a faster key check |
|
501 | - $type = array_flip($type); |
|
502 | - |
|
503 | - //check for things that mean '%s' |
|
504 | - if (isset($type['string'],$type['object'],$type['array'])) { |
|
505 | - return '%s'; |
|
506 | - } |
|
507 | - |
|
508 | - //if makes it past the above condition and there's float in the array |
|
509 | - //then the type is %f |
|
510 | - if (isset($type['number'])) { |
|
511 | - return '%f'; |
|
512 | - } |
|
513 | - |
|
514 | - //if it makes it above the above conditions and there is an integer in the array |
|
515 | - //then the type is %d |
|
516 | - if (isset($type['integer'])) { |
|
517 | - return '%d'; |
|
518 | - } |
|
519 | - |
|
520 | - //anything else is a string |
|
521 | - return '%s'; |
|
522 | - } |
|
523 | - |
|
524 | - |
|
525 | - /** |
|
526 | - * This returns elements used to represent this field in the json schema. |
|
527 | - * |
|
528 | - * @link http://json-schema.org/ |
|
529 | - * @return array |
|
530 | - */ |
|
531 | - public function getSchema() |
|
532 | - { |
|
533 | - $schema = array( |
|
534 | - 'description' => $this->getSchemaDescription(), |
|
535 | - 'type' => $this->getSchemaType(), |
|
536 | - 'readonly' => $this->getSchemaReadonly(), |
|
537 | - 'default' => $this->getSchemaDefault() |
|
538 | - ); |
|
539 | - |
|
540 | - //optional properties of the schema |
|
541 | - $enum = $this->getSchemaEnum(); |
|
542 | - $properties = $this->getSchemaProperties(); |
|
543 | - $format = $this->getSchemaFormat(); |
|
544 | - if ($enum) { |
|
545 | - $schema['enum'] = $enum; |
|
546 | - } |
|
547 | - |
|
548 | - if ($properties) { |
|
549 | - $schema['properties'] = $properties; |
|
550 | - } |
|
551 | - |
|
552 | - if ($format) { |
|
553 | - $schema['format'] = $format; |
|
554 | - } |
|
555 | - return $schema; |
|
556 | - } |
|
557 | - |
|
558 | - /** |
|
559 | - * Some fields are in the database-only, (ie, used in queries etc), but shouldn't necessarily be part |
|
560 | - * of the model objects (ie, client code shouldn't care to ever see their value... if client code does |
|
561 | - * want to see their value, then they shouldn't be db-only fields!) |
|
562 | - * Eg, when doing events as custom post types, querying the post_type is essential, but |
|
563 | - * post_type is irrelevant for EE_Event objects (because they will ALL be of post_type 'esp_event'). |
|
564 | - * By default, all fields aren't db-only. |
|
565 | - * |
|
566 | - * @return boolean |
|
567 | - */ |
|
568 | - public function is_db_only_field() |
|
569 | - { |
|
570 | - return false; |
|
571 | - } |
|
572 | - |
|
573 | - |
|
574 | - /** |
|
575 | - * Validates the incoming string|array to ensure its an allowable type. |
|
576 | - * @throws InvalidArgumentException |
|
577 | - * @param string|array $type |
|
578 | - */ |
|
579 | - private function validateSchemaType($type) |
|
580 | - { |
|
581 | - if (! (is_string($type) || is_array($type))) { |
|
582 | - throw new InvalidArgumentException( |
|
583 | - sprintf( |
|
584 | - esc_html__('The incoming argument (%s) must be a string or an array.', 'event_espresso'), |
|
585 | - print_r($type, true) |
|
586 | - ) |
|
587 | - ); |
|
588 | - } |
|
589 | - |
|
590 | - //validate allowable types. |
|
591 | - //@link http://json-schema.org/latest/json-schema-core.html#rfc.section.4.2 |
|
592 | - $allowable_types = array_flip( |
|
593 | - array( |
|
594 | - 'string', |
|
595 | - 'number', |
|
596 | - 'null', |
|
597 | - 'object', |
|
598 | - 'array', |
|
599 | - 'boolean', |
|
600 | - 'integer' |
|
601 | - ) |
|
602 | - ); |
|
603 | - |
|
604 | - if (is_array($type)) { |
|
605 | - foreach ($type as $item_in_type) { |
|
606 | - $this->validateSchemaType($item_in_type); |
|
607 | - } |
|
608 | - return; |
|
609 | - } |
|
610 | - |
|
611 | - if (! isset($allowable_types[$type])) { |
|
612 | - throw new InvalidArgumentException( |
|
613 | - sprintf( |
|
614 | - esc_html__('The incoming argument (%1$s) must be one of the allowable types: %2$s', 'event_espresso'), |
|
615 | - $type, |
|
616 | - implode(',', array_flip($allowable_types)) |
|
617 | - ) |
|
618 | - ); |
|
619 | - } |
|
620 | - } |
|
621 | - |
|
622 | - |
|
623 | - /** |
|
624 | - * Validates that the incoming format is an allowable string to use for the _schema_format property |
|
625 | - * @throws InvalidArgumentException |
|
626 | - * @param $format |
|
627 | - */ |
|
628 | - private function validateSchemaFormat($format) |
|
629 | - { |
|
630 | - if (! is_string($format)) { |
|
631 | - throw new InvalidArgumentException( |
|
632 | - sprintf( |
|
633 | - esc_html__('The incoming argument (%s) must be a string.', 'event_espresso'), |
|
634 | - print_r($format, true) |
|
635 | - ) |
|
636 | - ); |
|
637 | - } |
|
638 | - |
|
639 | - //validate allowable format values |
|
640 | - //@link http://json-schema.org/latest/json-schema-validation.html#rfc.section.7 |
|
641 | - $allowable_formats = array_flip( |
|
642 | - array( |
|
643 | - 'date-time', |
|
644 | - 'email', |
|
645 | - 'hostname', |
|
646 | - 'ipv4', |
|
647 | - 'ipv6', |
|
648 | - 'uri', |
|
649 | - 'uriref' |
|
650 | - ) |
|
651 | - ); |
|
652 | - |
|
653 | - if (! isset($allowable_formats[$format])) { |
|
654 | - throw new InvalidArgumentException( |
|
655 | - sprintf( |
|
656 | - esc_html__('The incoming argument (%1$s) must be one of the allowable formats: %2$s', 'event_espresso'), |
|
657 | - $format, |
|
658 | - implode(',', array_flip($allowable_formats)) |
|
659 | - ) |
|
660 | - ); |
|
661 | - } |
|
662 | - } |
|
24 | + /** |
|
25 | + * The alias for the table the column belongs to. |
|
26 | + * @var string |
|
27 | + */ |
|
28 | + protected $_table_alias; |
|
29 | + |
|
30 | + /** |
|
31 | + * The actual db column name for the table |
|
32 | + * @var string |
|
33 | + */ |
|
34 | + protected $_table_column; |
|
35 | + |
|
36 | + |
|
37 | + /** |
|
38 | + * The authoritative name for the table column (used by client code to reference the field). |
|
39 | + * @var string |
|
40 | + */ |
|
41 | + protected $_name; |
|
42 | + |
|
43 | + |
|
44 | + /** |
|
45 | + * A description for the field. |
|
46 | + * @var string |
|
47 | + */ |
|
48 | + protected $_nicename; |
|
49 | + |
|
50 | + |
|
51 | + /** |
|
52 | + * Whether the field is nullable or not |
|
53 | + * @var bool |
|
54 | + */ |
|
55 | + protected $_nullable; |
|
56 | + |
|
57 | + |
|
58 | + /** |
|
59 | + * What the default value for the field should be. |
|
60 | + * @var mixed |
|
61 | + */ |
|
62 | + protected $_default_value; |
|
63 | + |
|
64 | + |
|
65 | + /** |
|
66 | + * Other configuration for the field |
|
67 | + * @var mixed |
|
68 | + */ |
|
69 | + protected $_other_config; |
|
70 | + |
|
71 | + |
|
72 | + /** |
|
73 | + * The name of the model this field is instantiated for. |
|
74 | + * @var string |
|
75 | + */ |
|
76 | + protected $_model_name; |
|
77 | + |
|
78 | + |
|
79 | + /** |
|
80 | + * This should be a json-schema valid data type for the field. |
|
81 | + * @link http://json-schema.org/latest/json-schema-core.html#rfc.section.4.2 |
|
82 | + * @var string |
|
83 | + */ |
|
84 | + private $_schema_type = 'string'; |
|
85 | + |
|
86 | + |
|
87 | + /** |
|
88 | + * If the schema has a defined format then it should be defined via this property. |
|
89 | + * @link http://json-schema.org/latest/json-schema-validation.html#rfc.section.7 |
|
90 | + * @var string |
|
91 | + */ |
|
92 | + private $_schema_format = ''; |
|
93 | + |
|
94 | + |
|
95 | + /** |
|
96 | + * Indicates that the value of the field is managed exclusively by the server/model and not something |
|
97 | + * settable by client code. |
|
98 | + * @link http://json-schema.org/latest/json-schema-hypermedia.html#rfc.section.4.4 |
|
99 | + * @var bool |
|
100 | + */ |
|
101 | + private $_schema_readonly = false; |
|
102 | + |
|
103 | + |
|
104 | + /** |
|
105 | + * @param string $table_column |
|
106 | + * @param string $nicename |
|
107 | + * @param bool $nullable |
|
108 | + * @param null $default_value |
|
109 | + */ |
|
110 | + public function __construct($table_column, $nicename, $nullable, $default_value = null) |
|
111 | + { |
|
112 | + $this->_table_column = $table_column; |
|
113 | + $this->_nicename = $nicename; |
|
114 | + $this->_nullable = $nullable; |
|
115 | + $this->_default_value = $default_value; |
|
116 | + } |
|
117 | + |
|
118 | + |
|
119 | + /** |
|
120 | + * @param $table_alias |
|
121 | + * @param $name |
|
122 | + * @param $model_name |
|
123 | + */ |
|
124 | + public function _construct_finalize($table_alias, $name, $model_name) |
|
125 | + { |
|
126 | + $this->_table_alias = $table_alias; |
|
127 | + $this->_name = $name; |
|
128 | + $this->_model_name = $model_name; |
|
129 | + /** |
|
130 | + * allow for changing the defaults |
|
131 | + */ |
|
132 | + $this->_nicename = apply_filters('FHEE__EE_Model_Field_Base___construct_finalize___nicename', |
|
133 | + $this->_nicename, $this); |
|
134 | + $this->_default_value = apply_filters('FHEE__EE_Model_Field_Base___construct_finalize___default_value', |
|
135 | + $this->_default_value, $this); |
|
136 | + } |
|
137 | + |
|
138 | + public function get_table_alias() |
|
139 | + { |
|
140 | + return $this->_table_alias; |
|
141 | + } |
|
142 | + |
|
143 | + public function get_table_column() |
|
144 | + { |
|
145 | + return $this->_table_column; |
|
146 | + } |
|
147 | + |
|
148 | + /** |
|
149 | + * Returns the name of the model this field is on. Eg 'Event' or 'Ticket_Datetime' |
|
150 | + * |
|
151 | + * @return string |
|
152 | + */ |
|
153 | + public function get_model_name() |
|
154 | + { |
|
155 | + return $this->_model_name; |
|
156 | + } |
|
157 | + |
|
158 | + /** |
|
159 | + * @throws \EE_Error |
|
160 | + * @return string |
|
161 | + */ |
|
162 | + public function get_name() |
|
163 | + { |
|
164 | + if ($this->_name) { |
|
165 | + return $this->_name; |
|
166 | + } else { |
|
167 | + throw new EE_Error(sprintf(__("Model field '%s' has no name set. Did you make a model and forget to call the parent model constructor?", |
|
168 | + "event_espresso"), get_class($this))); |
|
169 | + } |
|
170 | + } |
|
171 | + |
|
172 | + public function get_nicename() |
|
173 | + { |
|
174 | + return $this->_nicename; |
|
175 | + } |
|
176 | + |
|
177 | + public function is_nullable() |
|
178 | + { |
|
179 | + return $this->_nullable; |
|
180 | + } |
|
181 | + |
|
182 | + /** |
|
183 | + * returns whether this field is an auto-increment field or not. If it is, then |
|
184 | + * on insertion it can be null. However, on updates it must be present. |
|
185 | + * |
|
186 | + * @return boolean |
|
187 | + */ |
|
188 | + public function is_auto_increment() |
|
189 | + { |
|
190 | + return false; |
|
191 | + } |
|
192 | + |
|
193 | + /** |
|
194 | + * The default value in the model object's value domain. See lengthy comment about |
|
195 | + * value domains at the top of EEM_Base |
|
196 | + * |
|
197 | + * @return mixed |
|
198 | + */ |
|
199 | + public function get_default_value() |
|
200 | + { |
|
201 | + return $this->_default_value; |
|
202 | + } |
|
203 | + |
|
204 | + /** |
|
205 | + * Returns the table alias joined to the table column, however this isn't the right |
|
206 | + * table alias if the aliased table is being joined to. In that case, you can use |
|
207 | + * EE_Model_Parser::extract_table_alias_model_relation_chain_prefix() to find the table's current alias |
|
208 | + * in the current query |
|
209 | + * |
|
210 | + * @return string |
|
211 | + */ |
|
212 | + public function get_qualified_column() |
|
213 | + { |
|
214 | + return $this->get_table_alias() . "." . $this->get_table_column(); |
|
215 | + } |
|
216 | + |
|
217 | + /** |
|
218 | + * When get() is called on a model object (eg EE_Event), before returning its value, |
|
219 | + * call this function on it, allowing us to customize the returned value based on |
|
220 | + * the field's type. Eg, we may want to unserialize it, strip tags, etc. By default, |
|
221 | + * we simply return it. |
|
222 | + * |
|
223 | + * @param mixed $value_of_field_on_model_object |
|
224 | + * @return mixed |
|
225 | + */ |
|
226 | + public function prepare_for_get($value_of_field_on_model_object) |
|
227 | + { |
|
228 | + return $value_of_field_on_model_object; |
|
229 | + } |
|
230 | + |
|
231 | + /** |
|
232 | + * When inserting or updating a field on a model object, run this function on each |
|
233 | + * value to prepare it for insertion into the db. Generally this converts |
|
234 | + * the validated input on the model object into the format used in the DB. |
|
235 | + * |
|
236 | + * @param mixed $value_of_field_on_model_object |
|
237 | + * @return mixed |
|
238 | + */ |
|
239 | + public function prepare_for_use_in_db($value_of_field_on_model_object) |
|
240 | + { |
|
241 | + return $value_of_field_on_model_object; |
|
242 | + } |
|
243 | + |
|
244 | + /** |
|
245 | + * When creating a brand-new model object, or setting a particular value for one of its fields, this function |
|
246 | + * is called before setting it on the model object. We may want to strip slashes, unserialize the value, etc. |
|
247 | + * By default, we do nothing. |
|
248 | + * |
|
249 | + * If the model field is going to perform any validation on the input, this is where it should be done |
|
250 | + * (once the value is on the model object, it may be used in other ways besides putting it into the DB |
|
251 | + * so it's best to validate it right away). |
|
252 | + * |
|
253 | + * @param mixed $value_inputted_for_field_on_model_object |
|
254 | + * @return mixed |
|
255 | + */ |
|
256 | + public function prepare_for_set($value_inputted_for_field_on_model_object) |
|
257 | + { |
|
258 | + return $value_inputted_for_field_on_model_object; |
|
259 | + } |
|
260 | + |
|
261 | + |
|
262 | + /** |
|
263 | + * When instantiating a model object from DB results, this function is called before setting each field. |
|
264 | + * We may want to serialize the value, etc. By default, we return the value using prepare_for_set() method as that |
|
265 | + * is the one child classes will most often define. |
|
266 | + * |
|
267 | + * @param mixed $value_found_in_db_for_model_object |
|
268 | + * @return mixed |
|
269 | + */ |
|
270 | + public function prepare_for_set_from_db($value_found_in_db_for_model_object) |
|
271 | + { |
|
272 | + return $this->prepare_for_set($value_found_in_db_for_model_object); |
|
273 | + } |
|
274 | + |
|
275 | + /** |
|
276 | + * When echoing a field's value on a model object, this function is run to prepare the value for presentation in a |
|
277 | + * webpage. For example, we may want to output floats with 2 decimal places by default, dates as "Monday Jan 12, |
|
278 | + * 2013, at 3:23pm" instead of |
|
279 | + * "8765678632", or any other modifications to how the value should be displayed, but not modified itself. |
|
280 | + * |
|
281 | + * @param mixed $value_on_field_to_be_outputted |
|
282 | + * @return mixed |
|
283 | + */ |
|
284 | + public function prepare_for_pretty_echoing($value_on_field_to_be_outputted) |
|
285 | + { |
|
286 | + return $value_on_field_to_be_outputted; |
|
287 | + } |
|
288 | + |
|
289 | + |
|
290 | + /** |
|
291 | + * Returns whatever is set as the nicename for the object. |
|
292 | + * @return string |
|
293 | + */ |
|
294 | + public function getSchemaDescription() |
|
295 | + { |
|
296 | + return $this->get_nicename(); |
|
297 | + } |
|
298 | + |
|
299 | + |
|
300 | + /** |
|
301 | + * Returns whatever is set as the $_schema_type property for the object. |
|
302 | + * Note: this will automatically add 'null' to the schema if the object is_nullable() |
|
303 | + * @return string|array |
|
304 | + */ |
|
305 | + public function getSchemaType() |
|
306 | + { |
|
307 | + if ($this->is_nullable()) { |
|
308 | + $this->_schema_type = (array) $this->_schema_type; |
|
309 | + if (! in_array('null', $this->_schema_type)) { |
|
310 | + $this->_schema_type[] = 'null'; |
|
311 | + }; |
|
312 | + } |
|
313 | + return $this->_schema_type; |
|
314 | + } |
|
315 | + |
|
316 | + |
|
317 | + /** |
|
318 | + * Sets the _schema_type property. Child classes should call this in their constructors to override the default state |
|
319 | + * for this property. |
|
320 | + * @param string|array $type |
|
321 | + * @throws InvalidArgumentException |
|
322 | + */ |
|
323 | + protected function setSchemaType($type) |
|
324 | + { |
|
325 | + $this->validateSchemaType($type); |
|
326 | + $this->_schema_type = $type; |
|
327 | + } |
|
328 | + |
|
329 | + |
|
330 | + /** |
|
331 | + * This is usually present when the $_schema_type property is 'object'. Any child classes will need to override |
|
332 | + * this method and return the properties for the schema. |
|
333 | + * |
|
334 | + * The reason this is not a property on the class is because there may be filters set on the values for the property |
|
335 | + * that won't be exposed on construct. For example enum type schemas may have the enum values filtered. |
|
336 | + * |
|
337 | + * @return array |
|
338 | + */ |
|
339 | + public function getSchemaProperties() |
|
340 | + { |
|
341 | + return array(); |
|
342 | + } |
|
343 | + |
|
344 | + |
|
345 | + |
|
346 | + /** |
|
347 | + * By default this returns the scalar default value that was sent in on the class prepped according to the class type |
|
348 | + * as the default. However, when there are schema properties, then the default property is setup to mirror the |
|
349 | + * property keys and correctly prepare the default according to that expected property value. |
|
350 | + * The getSchema method validates whether the schema for default is setup correctly or not according to the schema type |
|
351 | + * |
|
352 | + * @return mixed |
|
353 | + */ |
|
354 | + public function getSchemaDefault() |
|
355 | + { |
|
356 | + $default_value = $this->prepare_for_use_in_db($this->prepare_for_set($this->get_default_value())); |
|
357 | + $schema_properties = $this->getSchemaProperties(); |
|
358 | + |
|
359 | + //if this schema has properties than shape the default value to match the properties shape. |
|
360 | + if ($schema_properties) { |
|
361 | + $value_to_return = array(); |
|
362 | + foreach ($schema_properties as $property_key => $property_schema) { |
|
363 | + switch ($property_key) { |
|
364 | + case 'pretty': |
|
365 | + case 'rendered': |
|
366 | + $value_to_return[$property_key] = $this->prepare_for_pretty_echoing($this->prepare_for_set($default_value)); |
|
367 | + break; |
|
368 | + default: |
|
369 | + $value_to_return[$property_key] = $default_value; |
|
370 | + break; |
|
371 | + } |
|
372 | + } |
|
373 | + $default_value = $value_to_return; |
|
374 | + } |
|
375 | + return $default_value; |
|
376 | + } |
|
377 | + |
|
378 | + |
|
379 | + |
|
380 | + |
|
381 | + /** |
|
382 | + * If a child class has enum values, they should override this method and provide a simple array |
|
383 | + * of the enum values. |
|
384 | + * The reason this is not a property on the class is because there may be filterable enum values that |
|
385 | + * are set on the instantiated object that could be filtered after construct. |
|
386 | + * |
|
387 | + * @return array |
|
388 | + */ |
|
389 | + public function getSchemaEnum() |
|
390 | + { |
|
391 | + return array(); |
|
392 | + } |
|
393 | + |
|
394 | + |
|
395 | + /** |
|
396 | + * This returns the value of the $_schema_format property on the object. |
|
397 | + * @return string |
|
398 | + */ |
|
399 | + public function getSchemaFormat() |
|
400 | + { |
|
401 | + return $this->_schema_format; |
|
402 | + } |
|
403 | + |
|
404 | + |
|
405 | + /** |
|
406 | + * Sets the schema format property. |
|
407 | + * @throws InvalidArgumentException |
|
408 | + * @param string $format |
|
409 | + */ |
|
410 | + protected function setSchemaFormat($format) |
|
411 | + { |
|
412 | + $this->validateSchemaFormat($format); |
|
413 | + $this->_schema_format = $format; |
|
414 | + } |
|
415 | + |
|
416 | + |
|
417 | + /** |
|
418 | + * This returns the value of the $_schema_readonly property on the object. |
|
419 | + * @return bool |
|
420 | + */ |
|
421 | + public function getSchemaReadonly() |
|
422 | + { |
|
423 | + return $this->_schema_readonly; |
|
424 | + } |
|
425 | + |
|
426 | + |
|
427 | + /** |
|
428 | + * This sets the value for the $_schema_readonly property. |
|
429 | + * @param bool $readonly (only explicit boolean values are accepted) |
|
430 | + */ |
|
431 | + protected function setSchemaReadOnly($readonly) |
|
432 | + { |
|
433 | + if (! is_bool($readonly)) { |
|
434 | + throw new InvalidArgumentException( |
|
435 | + sprintf( |
|
436 | + esc_html__('The incoming argument (%s) must be a boolean.', 'event_espresso'), |
|
437 | + print_r($readonly, true) |
|
438 | + ) |
|
439 | + ); |
|
440 | + } |
|
441 | + |
|
442 | + $this->_schema_readonly = $readonly; |
|
443 | + } |
|
444 | + |
|
445 | + |
|
446 | + |
|
447 | + |
|
448 | + /** |
|
449 | + * Return `%d`, `%s` or `%f` to indicate the data type for the field. |
|
450 | + * @uses _get_wpdb_data_type() |
|
451 | + * |
|
452 | + * @return string |
|
453 | + */ |
|
454 | + public function get_wpdb_data_type() |
|
455 | + { |
|
456 | + return $this->_get_wpdb_data_type(); |
|
457 | + } |
|
458 | + |
|
459 | + |
|
460 | + /** |
|
461 | + * Return `%d`, `%s` or `%f` to indicate the data type for the field that should be indicated in wpdb queries. |
|
462 | + * @param string $type Included if a specific type is requested. |
|
463 | + * @uses get_schema_type() |
|
464 | + * @return string |
|
465 | + */ |
|
466 | + protected function _get_wpdb_data_type($type='') |
|
467 | + { |
|
468 | + $type = empty($type) ? $this->getSchemaType() : $type; |
|
469 | + |
|
470 | + //if type is an array, then different parsing is required. |
|
471 | + if (is_array($type)) { |
|
472 | + return $this->_get_wpdb_data_type_for_type_array($type); |
|
473 | + } |
|
474 | + |
|
475 | + $wpdb_type = '%s'; |
|
476 | + switch ($type) { |
|
477 | + case 'number': |
|
478 | + $wpdb_type = '%f'; |
|
479 | + break; |
|
480 | + case 'integer': |
|
481 | + case 'boolean': |
|
482 | + $wpdb_type = '%d'; |
|
483 | + break; |
|
484 | + case 'object': |
|
485 | + $properties = $this->getSchemaProperties(); |
|
486 | + if (isset($properties['raw'], $properties['raw']['type'])) { |
|
487 | + $wpdb_type = $this->_get_wpdb_data_type($properties['raw']['type']); |
|
488 | + } |
|
489 | + break; //leave at default |
|
490 | + } |
|
491 | + return $wpdb_type; |
|
492 | + } |
|
493 | + |
|
494 | + |
|
495 | + |
|
496 | + protected function _get_wpdb_data_type_for_type_array($type) |
|
497 | + { |
|
498 | + $type = (array) $type; |
|
499 | + //first let's flip because then we can do a faster key check |
|
500 | + $type = array_flip($type); |
|
501 | + |
|
502 | + //check for things that mean '%s' |
|
503 | + if (isset($type['string'],$type['object'],$type['array'])) { |
|
504 | + return '%s'; |
|
505 | + } |
|
506 | + |
|
507 | + //if makes it past the above condition and there's float in the array |
|
508 | + //then the type is %f |
|
509 | + if (isset($type['number'])) { |
|
510 | + return '%f'; |
|
511 | + } |
|
512 | + |
|
513 | + //if it makes it above the above conditions and there is an integer in the array |
|
514 | + //then the type is %d |
|
515 | + if (isset($type['integer'])) { |
|
516 | + return '%d'; |
|
517 | + } |
|
518 | + |
|
519 | + //anything else is a string |
|
520 | + return '%s'; |
|
521 | + } |
|
522 | + |
|
523 | + |
|
524 | + /** |
|
525 | + * This returns elements used to represent this field in the json schema. |
|
526 | + * |
|
527 | + * @link http://json-schema.org/ |
|
528 | + * @return array |
|
529 | + */ |
|
530 | + public function getSchema() |
|
531 | + { |
|
532 | + $schema = array( |
|
533 | + 'description' => $this->getSchemaDescription(), |
|
534 | + 'type' => $this->getSchemaType(), |
|
535 | + 'readonly' => $this->getSchemaReadonly(), |
|
536 | + 'default' => $this->getSchemaDefault() |
|
537 | + ); |
|
538 | + |
|
539 | + //optional properties of the schema |
|
540 | + $enum = $this->getSchemaEnum(); |
|
541 | + $properties = $this->getSchemaProperties(); |
|
542 | + $format = $this->getSchemaFormat(); |
|
543 | + if ($enum) { |
|
544 | + $schema['enum'] = $enum; |
|
545 | + } |
|
546 | + |
|
547 | + if ($properties) { |
|
548 | + $schema['properties'] = $properties; |
|
549 | + } |
|
550 | + |
|
551 | + if ($format) { |
|
552 | + $schema['format'] = $format; |
|
553 | + } |
|
554 | + return $schema; |
|
555 | + } |
|
556 | + |
|
557 | + /** |
|
558 | + * Some fields are in the database-only, (ie, used in queries etc), but shouldn't necessarily be part |
|
559 | + * of the model objects (ie, client code shouldn't care to ever see their value... if client code does |
|
560 | + * want to see their value, then they shouldn't be db-only fields!) |
|
561 | + * Eg, when doing events as custom post types, querying the post_type is essential, but |
|
562 | + * post_type is irrelevant for EE_Event objects (because they will ALL be of post_type 'esp_event'). |
|
563 | + * By default, all fields aren't db-only. |
|
564 | + * |
|
565 | + * @return boolean |
|
566 | + */ |
|
567 | + public function is_db_only_field() |
|
568 | + { |
|
569 | + return false; |
|
570 | + } |
|
571 | + |
|
572 | + |
|
573 | + /** |
|
574 | + * Validates the incoming string|array to ensure its an allowable type. |
|
575 | + * @throws InvalidArgumentException |
|
576 | + * @param string|array $type |
|
577 | + */ |
|
578 | + private function validateSchemaType($type) |
|
579 | + { |
|
580 | + if (! (is_string($type) || is_array($type))) { |
|
581 | + throw new InvalidArgumentException( |
|
582 | + sprintf( |
|
583 | + esc_html__('The incoming argument (%s) must be a string or an array.', 'event_espresso'), |
|
584 | + print_r($type, true) |
|
585 | + ) |
|
586 | + ); |
|
587 | + } |
|
588 | + |
|
589 | + //validate allowable types. |
|
590 | + //@link http://json-schema.org/latest/json-schema-core.html#rfc.section.4.2 |
|
591 | + $allowable_types = array_flip( |
|
592 | + array( |
|
593 | + 'string', |
|
594 | + 'number', |
|
595 | + 'null', |
|
596 | + 'object', |
|
597 | + 'array', |
|
598 | + 'boolean', |
|
599 | + 'integer' |
|
600 | + ) |
|
601 | + ); |
|
602 | + |
|
603 | + if (is_array($type)) { |
|
604 | + foreach ($type as $item_in_type) { |
|
605 | + $this->validateSchemaType($item_in_type); |
|
606 | + } |
|
607 | + return; |
|
608 | + } |
|
609 | + |
|
610 | + if (! isset($allowable_types[$type])) { |
|
611 | + throw new InvalidArgumentException( |
|
612 | + sprintf( |
|
613 | + esc_html__('The incoming argument (%1$s) must be one of the allowable types: %2$s', 'event_espresso'), |
|
614 | + $type, |
|
615 | + implode(',', array_flip($allowable_types)) |
|
616 | + ) |
|
617 | + ); |
|
618 | + } |
|
619 | + } |
|
620 | + |
|
621 | + |
|
622 | + /** |
|
623 | + * Validates that the incoming format is an allowable string to use for the _schema_format property |
|
624 | + * @throws InvalidArgumentException |
|
625 | + * @param $format |
|
626 | + */ |
|
627 | + private function validateSchemaFormat($format) |
|
628 | + { |
|
629 | + if (! is_string($format)) { |
|
630 | + throw new InvalidArgumentException( |
|
631 | + sprintf( |
|
632 | + esc_html__('The incoming argument (%s) must be a string.', 'event_espresso'), |
|
633 | + print_r($format, true) |
|
634 | + ) |
|
635 | + ); |
|
636 | + } |
|
637 | + |
|
638 | + //validate allowable format values |
|
639 | + //@link http://json-schema.org/latest/json-schema-validation.html#rfc.section.7 |
|
640 | + $allowable_formats = array_flip( |
|
641 | + array( |
|
642 | + 'date-time', |
|
643 | + 'email', |
|
644 | + 'hostname', |
|
645 | + 'ipv4', |
|
646 | + 'ipv6', |
|
647 | + 'uri', |
|
648 | + 'uriref' |
|
649 | + ) |
|
650 | + ); |
|
651 | + |
|
652 | + if (! isset($allowable_formats[$format])) { |
|
653 | + throw new InvalidArgumentException( |
|
654 | + sprintf( |
|
655 | + esc_html__('The incoming argument (%1$s) must be one of the allowable formats: %2$s', 'event_espresso'), |
|
656 | + $format, |
|
657 | + implode(',', array_flip($allowable_formats)) |
|
658 | + ) |
|
659 | + ); |
|
660 | + } |
|
661 | + } |
|
663 | 662 | } |
664 | 663 | \ No newline at end of file |
@@ -11,14 +11,14 @@ |
||
11 | 11 | |
12 | 12 | |
13 | 13 | |
14 | - /** |
|
15 | - * removes all tags which a WP Post wouldn't allow in its content normally |
|
16 | - * |
|
17 | - * @param string $value |
|
18 | - * @return string |
|
19 | - */ |
|
20 | - public function prepare_for_set($value) |
|
21 | - { |
|
22 | - return parent::prepare_for_set(wp_kses("$value", EEH_HTML::get_simple_tags())); |
|
23 | - } |
|
14 | + /** |
|
15 | + * removes all tags which a WP Post wouldn't allow in its content normally |
|
16 | + * |
|
17 | + * @param string $value |
|
18 | + * @return string |
|
19 | + */ |
|
20 | + public function prepare_for_set($value) |
|
21 | + { |
|
22 | + return parent::prepare_for_set(wp_kses("$value", EEH_HTML::get_simple_tags())); |
|
23 | + } |
|
24 | 24 | } |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | <label for="ATT_fname"><?php _e('First Name', 'event_espresso'); ?><span class="denotes-required-spn">*</span></label> |
21 | 21 | </th> |
22 | 22 | <td> |
23 | - <div class="validation-notice-dv"><?php _e( 'The following is a required field', 'event_espresso' );?></div> |
|
23 | + <div class="validation-notice-dv"><?php _e('The following is a required field', 'event_espresso'); ?></div> |
|
24 | 24 | <input class="regular-text required" type="text" id="ATT_fname" name="ATT_fname" value="<?php echo $attendee->fname(); ?>"/><br/> |
25 | 25 | <p class="description"><?php _e('The registrant\'s given name. ( required value )', 'event_espresso'); ?></p> |
26 | 26 | </td> |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | <label for="ATT_lname"><?php _e('Last Name', 'event_espresso'); ?><span class="denotes-required-spn">*</span></label> |
32 | 32 | </th> |
33 | 33 | <td> |
34 | - <div class="validation-notice-dv"><?php _e( 'The following is a required field', 'event_espresso' );?></div> |
|
34 | + <div class="validation-notice-dv"><?php _e('The following is a required field', 'event_espresso'); ?></div> |
|
35 | 35 | <input class="regular-text required" type="text" id="ATT_lname" name="ATT_lname" value="<?php echo $attendee->lname(); ?>"/><br/> |
36 | 36 | <p class="description"><?php _e('The registrant\'s family name. ( required value )', 'event_espresso'); ?></p> |
37 | 37 | </td> |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | <label for="ATT_email"><?php _e('Email Address', 'event_espresso'); ?><span class="denotes-required-spn">*</span></label> |
43 | 43 | </th> |
44 | 44 | <td> |
45 | - <div class="validation-notice-dv"><?php _e( 'The following is a required field', 'event_espresso' );?></div> |
|
45 | + <div class="validation-notice-dv"><?php _e('The following is a required field', 'event_espresso'); ?></div> |
|
46 | 46 | <input class="regular-text required" type="text" id="ATT_email" name="ATT_email" value="<?php $attendee->f('ATT_email'); ?>"/><br/> |
47 | 47 | <p class="description"><?php _e('( required value )', 'event_espresso'); ?></p> |
48 | 48 | </td> |
@@ -109,8 +109,8 @@ discard block |
||
109 | 109 | |
110 | 110 | |
111 | 111 | |
112 | - <?php do_action( 'AHEE__attendee_details_main_meta_box__template__table_body_end',$attendee );?> |
|
112 | + <?php do_action('AHEE__attendee_details_main_meta_box__template__table_body_end', $attendee); ?> |
|
113 | 113 | </tbody> |
114 | 114 | </table> |
115 | - <?php do_action( 'AHEE__attendee_details_main_meta_box__template__after_table',$attendee );?> |
|
115 | + <?php do_action('AHEE__attendee_details_main_meta_box__template__after_table', $attendee); ?> |
|
116 | 116 | </div> |
117 | 117 | \ No newline at end of file |
@@ -9,7 +9,7 @@ discard block |
||
9 | 9 | use EEH_DTT_Helper; |
10 | 10 | |
11 | 11 | if (! defined('EVENT_ESPRESSO_VERSION')) { |
12 | - exit('No direct script access allowed'); |
|
12 | + exit('No direct script access allowed'); |
|
13 | 13 | } |
14 | 14 | |
15 | 15 | |
@@ -25,85 +25,85 @@ discard block |
||
25 | 25 | class Read |
26 | 26 | { |
27 | 27 | |
28 | - /** |
|
29 | - * @param WP_REST_Request $request |
|
30 | - * @param string $version |
|
31 | - * @return EE_Config|WP_Error |
|
32 | - */ |
|
33 | - public static function handleRequest(WP_REST_Request $request, $version) |
|
34 | - { |
|
35 | - $cap = EE_Restriction_Generator_Base::get_default_restrictions_cap(); |
|
36 | - if (EE_Capabilities::instance()->current_user_can($cap, 'read_over_api')) { |
|
37 | - return EE_Config::instance(); |
|
38 | - } else { |
|
39 | - return new WP_Error( |
|
40 | - 'cannot_read_config', |
|
41 | - sprintf( |
|
42 | - __( |
|
43 | - 'You do not have the necessary capabilities (%s) to read Event Espresso Configuration data', |
|
44 | - 'event_espresso' |
|
45 | - ), |
|
46 | - $cap |
|
47 | - ), |
|
48 | - array('status' => 403) |
|
49 | - ); |
|
50 | - } |
|
51 | - } |
|
28 | + /** |
|
29 | + * @param WP_REST_Request $request |
|
30 | + * @param string $version |
|
31 | + * @return EE_Config|WP_Error |
|
32 | + */ |
|
33 | + public static function handleRequest(WP_REST_Request $request, $version) |
|
34 | + { |
|
35 | + $cap = EE_Restriction_Generator_Base::get_default_restrictions_cap(); |
|
36 | + if (EE_Capabilities::instance()->current_user_can($cap, 'read_over_api')) { |
|
37 | + return EE_Config::instance(); |
|
38 | + } else { |
|
39 | + return new WP_Error( |
|
40 | + 'cannot_read_config', |
|
41 | + sprintf( |
|
42 | + __( |
|
43 | + 'You do not have the necessary capabilities (%s) to read Event Espresso Configuration data', |
|
44 | + 'event_espresso' |
|
45 | + ), |
|
46 | + $cap |
|
47 | + ), |
|
48 | + array('status' => 403) |
|
49 | + ); |
|
50 | + } |
|
51 | + } |
|
52 | 52 | |
53 | 53 | |
54 | 54 | |
55 | - /** |
|
56 | - * Handles the request for public site info |
|
57 | - * |
|
58 | - * @global $wp_json_basic_auth_success boolean set by the basic auth plugin, indicates if the |
|
59 | - * current user could be authenticated using basic auth data |
|
60 | - * @global $wp_json_basic_auth_received_data boolean set by the basic auth plugin, indicates if |
|
61 | - * basic auth data was somehow received |
|
62 | - * @param WP_REST_Request $request |
|
63 | - * @param string $version |
|
64 | - * @return array|WP_Error |
|
65 | - */ |
|
66 | - public static function handleRequestSiteInfo(WP_REST_Request $request, $version) |
|
67 | - { |
|
68 | - global $wp_json_basic_auth_success, $wp_json_basic_auth_received_data; |
|
69 | - $insecure_usage_of_basic_auth = apply_filters( |
|
70 | - // @codingStandardsIgnoreStart |
|
71 | - 'EventEspresso__core__libraries__rest_api__controllers__config__handle_request_site_info__insecure_usage_of_basic_auth', |
|
72 | - // @codingStandardsIgnoreEnd |
|
73 | - $wp_json_basic_auth_success && ! is_ssl(), |
|
74 | - $request |
|
75 | - ); |
|
76 | - if ($insecure_usage_of_basic_auth) { |
|
77 | - $warning = sprintf( |
|
78 | - esc_html__( |
|
79 | - // @codingStandardsIgnoreStart |
|
80 | - 'Notice: We strongly recommend installing an SSL Certificate on your website to keep your data secure. %1$sPlease see our recommendations.%2$s', |
|
81 | - // @codingStandardsIgnoreEnd |
|
82 | - 'event_espresso' |
|
83 | - ), |
|
84 | - '<a href="https://eventespresso.com/wiki/rest-api-security-recommendations/">', |
|
85 | - '</a>' |
|
86 | - ); |
|
87 | - } else { |
|
88 | - $warning = ''; |
|
89 | - } |
|
90 | - return apply_filters( |
|
91 | - 'FHEE__EventEspresso_core_libraries_rest_api_controllers_config__handleRequestSiteInfo__return_val', |
|
92 | - array( |
|
93 | - 'default_timezone' => array( |
|
94 | - 'pretty' => EEH_DTT_Helper::get_timezone_string_for_display(), |
|
95 | - 'string' => get_option('timezone_string'), |
|
96 | - 'offset' => EEH_DTT_Helper::get_site_timezone_gmt_offset(), |
|
97 | - ), |
|
98 | - 'default_currency' => EE_Config::instance()->currency, |
|
99 | - 'authentication' => array( |
|
100 | - 'received_basic_auth_data' => (bool)$wp_json_basic_auth_received_data, |
|
101 | - 'insecure_usage_of_basic_auth' => (bool)$insecure_usage_of_basic_auth, |
|
102 | - 'warning' => $warning |
|
103 | - ) |
|
104 | - ) |
|
105 | - ); |
|
106 | - } |
|
55 | + /** |
|
56 | + * Handles the request for public site info |
|
57 | + * |
|
58 | + * @global $wp_json_basic_auth_success boolean set by the basic auth plugin, indicates if the |
|
59 | + * current user could be authenticated using basic auth data |
|
60 | + * @global $wp_json_basic_auth_received_data boolean set by the basic auth plugin, indicates if |
|
61 | + * basic auth data was somehow received |
|
62 | + * @param WP_REST_Request $request |
|
63 | + * @param string $version |
|
64 | + * @return array|WP_Error |
|
65 | + */ |
|
66 | + public static function handleRequestSiteInfo(WP_REST_Request $request, $version) |
|
67 | + { |
|
68 | + global $wp_json_basic_auth_success, $wp_json_basic_auth_received_data; |
|
69 | + $insecure_usage_of_basic_auth = apply_filters( |
|
70 | + // @codingStandardsIgnoreStart |
|
71 | + 'EventEspresso__core__libraries__rest_api__controllers__config__handle_request_site_info__insecure_usage_of_basic_auth', |
|
72 | + // @codingStandardsIgnoreEnd |
|
73 | + $wp_json_basic_auth_success && ! is_ssl(), |
|
74 | + $request |
|
75 | + ); |
|
76 | + if ($insecure_usage_of_basic_auth) { |
|
77 | + $warning = sprintf( |
|
78 | + esc_html__( |
|
79 | + // @codingStandardsIgnoreStart |
|
80 | + 'Notice: We strongly recommend installing an SSL Certificate on your website to keep your data secure. %1$sPlease see our recommendations.%2$s', |
|
81 | + // @codingStandardsIgnoreEnd |
|
82 | + 'event_espresso' |
|
83 | + ), |
|
84 | + '<a href="https://eventespresso.com/wiki/rest-api-security-recommendations/">', |
|
85 | + '</a>' |
|
86 | + ); |
|
87 | + } else { |
|
88 | + $warning = ''; |
|
89 | + } |
|
90 | + return apply_filters( |
|
91 | + 'FHEE__EventEspresso_core_libraries_rest_api_controllers_config__handleRequestSiteInfo__return_val', |
|
92 | + array( |
|
93 | + 'default_timezone' => array( |
|
94 | + 'pretty' => EEH_DTT_Helper::get_timezone_string_for_display(), |
|
95 | + 'string' => get_option('timezone_string'), |
|
96 | + 'offset' => EEH_DTT_Helper::get_site_timezone_gmt_offset(), |
|
97 | + ), |
|
98 | + 'default_currency' => EE_Config::instance()->currency, |
|
99 | + 'authentication' => array( |
|
100 | + 'received_basic_auth_data' => (bool)$wp_json_basic_auth_received_data, |
|
101 | + 'insecure_usage_of_basic_auth' => (bool)$insecure_usage_of_basic_auth, |
|
102 | + 'warning' => $warning |
|
103 | + ) |
|
104 | + ) |
|
105 | + ); |
|
106 | + } |
|
107 | 107 | } |
108 | 108 | |
109 | 109 | // End of file Read.php |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | use EE_Restriction_Generator_Base; |
9 | 9 | use EEH_DTT_Helper; |
10 | 10 | |
11 | -if (! defined('EVENT_ESPRESSO_VERSION')) { |
|
11 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
12 | 12 | exit('No direct script access allowed'); |
13 | 13 | } |
14 | 14 | |
@@ -97,8 +97,8 @@ discard block |
||
97 | 97 | ), |
98 | 98 | 'default_currency' => EE_Config::instance()->currency, |
99 | 99 | 'authentication' => array( |
100 | - 'received_basic_auth_data' => (bool)$wp_json_basic_auth_received_data, |
|
101 | - 'insecure_usage_of_basic_auth' => (bool)$insecure_usage_of_basic_auth, |
|
100 | + 'received_basic_auth_data' => (bool) $wp_json_basic_auth_received_data, |
|
101 | + 'insecure_usage_of_basic_auth' => (bool) $insecure_usage_of_basic_auth, |
|
102 | 102 | 'warning' => $warning |
103 | 103 | ) |
104 | 104 | ) |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php if (! defined('EVENT_ESPRESSO_VERSION')) { |
2 | - exit('No direct script access allowed'); |
|
2 | + exit('No direct script access allowed'); |
|
3 | 3 | } |
4 | 4 | |
5 | 5 | /** |
@@ -13,93 +13,93 @@ discard block |
||
13 | 13 | class EE_WP_User extends EE_Base_Class implements EEI_Admin_Links |
14 | 14 | { |
15 | 15 | |
16 | - /** |
|
17 | - * @var WP_User |
|
18 | - */ |
|
19 | - protected $_wp_user_obj; |
|
16 | + /** |
|
17 | + * @var WP_User |
|
18 | + */ |
|
19 | + protected $_wp_user_obj; |
|
20 | 20 | |
21 | - /** |
|
22 | - * @param array $props_n_values |
|
23 | - * @return EE_WP_User|mixed |
|
24 | - */ |
|
25 | - public static function new_instance($props_n_values = array()) |
|
26 | - { |
|
27 | - $has_object = parent::_check_for_object($props_n_values, __CLASS__); |
|
28 | - return $has_object ? $has_object : new self($props_n_values); |
|
29 | - } |
|
21 | + /** |
|
22 | + * @param array $props_n_values |
|
23 | + * @return EE_WP_User|mixed |
|
24 | + */ |
|
25 | + public static function new_instance($props_n_values = array()) |
|
26 | + { |
|
27 | + $has_object = parent::_check_for_object($props_n_values, __CLASS__); |
|
28 | + return $has_object ? $has_object : new self($props_n_values); |
|
29 | + } |
|
30 | 30 | |
31 | 31 | |
32 | - /** |
|
33 | - * @param array $props_n_values |
|
34 | - * @return EE_WP_User |
|
35 | - */ |
|
36 | - public static function new_instance_from_db($props_n_values = array()) |
|
37 | - { |
|
38 | - return new self($props_n_values, true); |
|
39 | - } |
|
32 | + /** |
|
33 | + * @param array $props_n_values |
|
34 | + * @return EE_WP_User |
|
35 | + */ |
|
36 | + public static function new_instance_from_db($props_n_values = array()) |
|
37 | + { |
|
38 | + return new self($props_n_values, true); |
|
39 | + } |
|
40 | 40 | |
41 | - /** |
|
42 | - * Return a normal WP_User object (caches the object for future calls) |
|
43 | - * |
|
44 | - * @return WP_User |
|
45 | - */ |
|
46 | - public function wp_user_obj() |
|
47 | - { |
|
48 | - if (! $this->_wp_user_obj) { |
|
49 | - $this->_wp_user_obj = get_user_by('ID', $this->ID()); |
|
50 | - } |
|
51 | - return $this->_wp_user_obj; |
|
52 | - } |
|
41 | + /** |
|
42 | + * Return a normal WP_User object (caches the object for future calls) |
|
43 | + * |
|
44 | + * @return WP_User |
|
45 | + */ |
|
46 | + public function wp_user_obj() |
|
47 | + { |
|
48 | + if (! $this->_wp_user_obj) { |
|
49 | + $this->_wp_user_obj = get_user_by('ID', $this->ID()); |
|
50 | + } |
|
51 | + return $this->_wp_user_obj; |
|
52 | + } |
|
53 | 53 | |
54 | - /** |
|
55 | - * Return the link to the admin details for the object. |
|
56 | - * |
|
57 | - * @return string |
|
58 | - */ |
|
59 | - public function get_admin_details_link() |
|
60 | - { |
|
61 | - return $this->get_admin_edit_link(); |
|
62 | - } |
|
54 | + /** |
|
55 | + * Return the link to the admin details for the object. |
|
56 | + * |
|
57 | + * @return string |
|
58 | + */ |
|
59 | + public function get_admin_details_link() |
|
60 | + { |
|
61 | + return $this->get_admin_edit_link(); |
|
62 | + } |
|
63 | 63 | |
64 | - /** |
|
65 | - * Returns the link to the editor for the object. Sometimes this is the same as the details. |
|
66 | - * |
|
67 | - * @return string |
|
68 | - */ |
|
69 | - public function get_admin_edit_link() |
|
70 | - { |
|
71 | - return esc_url( |
|
72 | - add_query_arg( |
|
73 | - 'wp_http_referer', |
|
74 | - urlencode( |
|
75 | - wp_unslash( |
|
76 | - $_SERVER['REQUEST_URI'] |
|
77 | - ) |
|
78 | - ), |
|
79 | - get_edit_user_link($this->ID()) |
|
80 | - ) |
|
81 | - ); |
|
82 | - } |
|
64 | + /** |
|
65 | + * Returns the link to the editor for the object. Sometimes this is the same as the details. |
|
66 | + * |
|
67 | + * @return string |
|
68 | + */ |
|
69 | + public function get_admin_edit_link() |
|
70 | + { |
|
71 | + return esc_url( |
|
72 | + add_query_arg( |
|
73 | + 'wp_http_referer', |
|
74 | + urlencode( |
|
75 | + wp_unslash( |
|
76 | + $_SERVER['REQUEST_URI'] |
|
77 | + ) |
|
78 | + ), |
|
79 | + get_edit_user_link($this->ID()) |
|
80 | + ) |
|
81 | + ); |
|
82 | + } |
|
83 | 83 | |
84 | - /** |
|
85 | - * Returns the link to a settings page for the object. |
|
86 | - * |
|
87 | - * @return string |
|
88 | - */ |
|
89 | - public function get_admin_settings_link() |
|
90 | - { |
|
91 | - return $this->get_admin_edit_link(); |
|
92 | - } |
|
84 | + /** |
|
85 | + * Returns the link to a settings page for the object. |
|
86 | + * |
|
87 | + * @return string |
|
88 | + */ |
|
89 | + public function get_admin_settings_link() |
|
90 | + { |
|
91 | + return $this->get_admin_edit_link(); |
|
92 | + } |
|
93 | 93 | |
94 | - /** |
|
95 | - * Returns the link to the "overview" for the object (typically the "list table" view). |
|
96 | - * |
|
97 | - * @return string |
|
98 | - */ |
|
99 | - public function get_admin_overview_link() |
|
100 | - { |
|
101 | - return admin_url('users.php'); |
|
102 | - } |
|
94 | + /** |
|
95 | + * Returns the link to the "overview" for the object (typically the "list table" view). |
|
96 | + * |
|
97 | + * @return string |
|
98 | + */ |
|
99 | + public function get_admin_overview_link() |
|
100 | + { |
|
101 | + return admin_url('users.php'); |
|
102 | + } |
|
103 | 103 | |
104 | 104 | |
105 | 105 | } |
@@ -1,4 +1,4 @@ discard block |
||
1 | -<?php if (! defined('EVENT_ESPRESSO_VERSION')) { |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
2 | 2 | exit('No direct script access allowed'); |
3 | 3 | } |
4 | 4 | |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | */ |
46 | 46 | public function wp_user_obj() |
47 | 47 | { |
48 | - if (! $this->_wp_user_obj) { |
|
48 | + if ( ! $this->_wp_user_obj) { |
|
49 | 49 | $this->_wp_user_obj = get_user_by('ID', $this->ID()); |
50 | 50 | } |
51 | 51 | return $this->_wp_user_obj; |
@@ -603,7 +603,7 @@ discard block |
||
603 | 603 | /** |
604 | 604 | * returns any events attached to this attendee ($_Event property); |
605 | 605 | * |
606 | - * @return array |
|
606 | + * @return EE_Base_Class[] |
|
607 | 607 | * @throws EE_Error |
608 | 608 | */ |
609 | 609 | public function events() |
@@ -618,7 +618,7 @@ discard block |
||
618 | 618 | * used to save the billing info |
619 | 619 | * |
620 | 620 | * @param EE_Payment_Method $payment_method the _gateway_name property on the gateway class |
621 | - * @return EE_Form_Section_Proper|null |
|
621 | + * @return null|EE_Billing_Info_Form |
|
622 | 622 | * @throws EE_Error |
623 | 623 | */ |
624 | 624 | public function billing_info_for_payment_method($payment_method) |
@@ -27,734 +27,734 @@ |
||
27 | 27 | class EE_Attendee extends EE_CPT_Base implements EEI_Contact, EEI_Address, EEI_Admin_Links, EEI_Attendee |
28 | 28 | { |
29 | 29 | |
30 | - /** |
|
31 | - * Sets some dynamic defaults |
|
32 | - * |
|
33 | - * @param array $fieldValues |
|
34 | - * @param bool $bydb |
|
35 | - * @param string $timezone |
|
36 | - * @param array $date_formats |
|
37 | - * @throws EE_Error |
|
38 | - */ |
|
39 | - protected function __construct($fieldValues = null, $bydb = false, $timezone = null, $date_formats = array()) |
|
40 | - { |
|
41 | - if (! isset($fieldValues['ATT_full_name'])) { |
|
42 | - $fname = isset($fieldValues['ATT_fname']) ? $fieldValues['ATT_fname'] . ' ' : ''; |
|
43 | - $lname = isset($fieldValues['ATT_lname']) ? $fieldValues['ATT_lname'] : ''; |
|
44 | - $fieldValues['ATT_full_name'] = $fname . $lname; |
|
45 | - } |
|
46 | - if (! isset($fieldValues['ATT_slug'])) { |
|
47 | - // $fieldValues['ATT_slug'] = sanitize_key(wp_generate_password(20)); |
|
48 | - $fieldValues['ATT_slug'] = sanitize_title($fieldValues['ATT_full_name']); |
|
49 | - } |
|
50 | - if (! isset($fieldValues['ATT_short_bio']) && isset($fieldValues['ATT_bio'])) { |
|
51 | - $fieldValues['ATT_short_bio'] = substr($fieldValues['ATT_bio'], 0, 50); |
|
52 | - } |
|
53 | - parent::__construct($fieldValues, $bydb, $timezone, $date_formats); |
|
54 | - } |
|
55 | - |
|
56 | - |
|
57 | - /** |
|
58 | - * @param array $props_n_values incoming values |
|
59 | - * @param string $timezone incoming timezone (if not set the timezone set for the website will be |
|
60 | - * used.) |
|
61 | - * @param array $date_formats incoming date_formats in an array where the first value is the |
|
62 | - * date_format and the second value is the time format |
|
63 | - * @return EE_Attendee |
|
64 | - * @throws EE_Error |
|
65 | - */ |
|
66 | - public static function new_instance($props_n_values = array(), $timezone = null, $date_formats = array()) |
|
67 | - { |
|
68 | - $has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone, $date_formats); |
|
69 | - return $has_object ? $has_object : new self($props_n_values, false, $timezone, $date_formats); |
|
70 | - } |
|
71 | - |
|
72 | - |
|
73 | - /** |
|
74 | - * @param array $props_n_values incoming values from the database |
|
75 | - * @param string $timezone incoming timezone as set by the model. If not set the timezone for |
|
76 | - * the website will be used. |
|
77 | - * @return EE_Attendee |
|
78 | - */ |
|
79 | - public static function new_instance_from_db($props_n_values = array(), $timezone = null) |
|
80 | - { |
|
81 | - return new self($props_n_values, true, $timezone); |
|
82 | - } |
|
83 | - |
|
84 | - |
|
85 | - /** |
|
86 | - * Set Attendee First Name |
|
87 | - * |
|
88 | - * @access public |
|
89 | - * @param string $fname |
|
90 | - * @throws EE_Error |
|
91 | - */ |
|
92 | - public function set_fname($fname = '') |
|
93 | - { |
|
94 | - $this->set('ATT_fname', $fname); |
|
95 | - } |
|
96 | - |
|
97 | - |
|
98 | - /** |
|
99 | - * Set Attendee Last Name |
|
100 | - * |
|
101 | - * @access public |
|
102 | - * @param string $lname |
|
103 | - * @throws EE_Error |
|
104 | - */ |
|
105 | - public function set_lname($lname = '') |
|
106 | - { |
|
107 | - $this->set('ATT_lname', $lname); |
|
108 | - } |
|
109 | - |
|
110 | - |
|
111 | - /** |
|
112 | - * Set Attendee Address |
|
113 | - * |
|
114 | - * @access public |
|
115 | - * @param string $address |
|
116 | - * @throws EE_Error |
|
117 | - */ |
|
118 | - public function set_address($address = '') |
|
119 | - { |
|
120 | - $this->set('ATT_address', $address); |
|
121 | - } |
|
122 | - |
|
123 | - |
|
124 | - /** |
|
125 | - * Set Attendee Address2 |
|
126 | - * |
|
127 | - * @access public |
|
128 | - * @param string $address2 |
|
129 | - * @throws EE_Error |
|
130 | - */ |
|
131 | - public function set_address2($address2 = '') |
|
132 | - { |
|
133 | - $this->set('ATT_address2', $address2); |
|
134 | - } |
|
135 | - |
|
136 | - |
|
137 | - /** |
|
138 | - * Set Attendee City |
|
139 | - * |
|
140 | - * @access public |
|
141 | - * @param string $city |
|
142 | - * @throws EE_Error |
|
143 | - */ |
|
144 | - public function set_city($city = '') |
|
145 | - { |
|
146 | - $this->set('ATT_city', $city); |
|
147 | - } |
|
148 | - |
|
149 | - |
|
150 | - /** |
|
151 | - * Set Attendee State ID |
|
152 | - * |
|
153 | - * @access public |
|
154 | - * @param int $STA_ID |
|
155 | - * @throws EE_Error |
|
156 | - */ |
|
157 | - public function set_state($STA_ID = 0) |
|
158 | - { |
|
159 | - $this->set('STA_ID', $STA_ID); |
|
160 | - } |
|
161 | - |
|
162 | - |
|
163 | - /** |
|
164 | - * Set Attendee Country ISO Code |
|
165 | - * |
|
166 | - * @access public |
|
167 | - * @param string $CNT_ISO |
|
168 | - * @throws EE_Error |
|
169 | - */ |
|
170 | - public function set_country($CNT_ISO = '') |
|
171 | - { |
|
172 | - $this->set('CNT_ISO', $CNT_ISO); |
|
173 | - } |
|
174 | - |
|
175 | - |
|
176 | - /** |
|
177 | - * Set Attendee Zip/Postal Code |
|
178 | - * |
|
179 | - * @access public |
|
180 | - * @param string $zip |
|
181 | - * @throws EE_Error |
|
182 | - */ |
|
183 | - public function set_zip($zip = '') |
|
184 | - { |
|
185 | - $this->set('ATT_zip', $zip); |
|
186 | - } |
|
187 | - |
|
188 | - |
|
189 | - /** |
|
190 | - * Set Attendee Email Address |
|
191 | - * |
|
192 | - * @access public |
|
193 | - * @param string $email |
|
194 | - * @throws EE_Error |
|
195 | - */ |
|
196 | - public function set_email($email = '') |
|
197 | - { |
|
198 | - $this->set('ATT_email', $email); |
|
199 | - } |
|
200 | - |
|
201 | - |
|
202 | - /** |
|
203 | - * Set Attendee Phone |
|
204 | - * |
|
205 | - * @access public |
|
206 | - * @param string $phone |
|
207 | - * @throws EE_Error |
|
208 | - */ |
|
209 | - public function set_phone($phone = '') |
|
210 | - { |
|
211 | - $this->set('ATT_phone', $phone); |
|
212 | - } |
|
213 | - |
|
214 | - |
|
215 | - /** |
|
216 | - * set deleted |
|
217 | - * |
|
218 | - * @access public |
|
219 | - * @param bool $ATT_deleted |
|
220 | - * @throws EE_Error |
|
221 | - */ |
|
222 | - public function set_deleted($ATT_deleted = false) |
|
223 | - { |
|
224 | - $this->set('ATT_deleted', $ATT_deleted); |
|
225 | - } |
|
226 | - |
|
227 | - |
|
228 | - /** |
|
229 | - * Returns the value for the post_author id saved with the cpt |
|
230 | - * |
|
231 | - * @since 4.5.0 |
|
232 | - * @return int |
|
233 | - * @throws EE_Error |
|
234 | - */ |
|
235 | - public function wp_user() |
|
236 | - { |
|
237 | - return $this->get('ATT_author'); |
|
238 | - } |
|
239 | - |
|
240 | - |
|
241 | - /** |
|
242 | - * get Attendee First Name |
|
243 | - * |
|
244 | - * @access public |
|
245 | - * @return string |
|
246 | - * @throws EE_Error |
|
247 | - */ |
|
248 | - public function fname() |
|
249 | - { |
|
250 | - return $this->get('ATT_fname'); |
|
251 | - } |
|
252 | - |
|
253 | - |
|
254 | - /** |
|
255 | - * echoes out the attendee's first name |
|
256 | - * |
|
257 | - * @return void |
|
258 | - * @throws EE_Error |
|
259 | - */ |
|
260 | - public function e_full_name() |
|
261 | - { |
|
262 | - echo $this->full_name(); |
|
263 | - } |
|
264 | - |
|
265 | - |
|
266 | - /** |
|
267 | - * Returns the first and last name concatenated together with a space. |
|
268 | - * |
|
269 | - * @param bool $apply_html_entities |
|
270 | - * @return string |
|
271 | - * @throws EE_Error |
|
272 | - */ |
|
273 | - public function full_name($apply_html_entities = false) |
|
274 | - { |
|
275 | - $full_name = array( |
|
276 | - $this->fname(), |
|
277 | - $this->lname(), |
|
278 | - ); |
|
279 | - $full_name = array_filter($full_name); |
|
280 | - $full_name = implode(' ', $full_name); |
|
281 | - return $apply_html_entities ? htmlentities($full_name, ENT_QUOTES, 'UTF-8') : $full_name; |
|
282 | - } |
|
283 | - |
|
284 | - |
|
285 | - /** |
|
286 | - * This returns the value of the `ATT_full_name` field which is usually equivalent to calling `full_name()` unless |
|
287 | - * the post_title field has been directly modified in the db for the post (espresso_attendees post type) for this |
|
288 | - * attendee. |
|
289 | - * |
|
290 | - * @param bool $apply_html_entities |
|
291 | - * @return string |
|
292 | - * @throws EE_Error |
|
293 | - */ |
|
294 | - public function ATT_full_name($apply_html_entities = false) |
|
295 | - { |
|
296 | - return $apply_html_entities |
|
297 | - ? htmlentities($this->get('ATT_full_name'), ENT_QUOTES, 'UTF-8') |
|
298 | - : $this->get('ATT_full_name'); |
|
299 | - } |
|
300 | - |
|
301 | - |
|
302 | - /** |
|
303 | - * get Attendee Last Name |
|
304 | - * |
|
305 | - * @access public |
|
306 | - * @return string |
|
307 | - * @throws EE_Error |
|
308 | - */ |
|
309 | - public function lname() |
|
310 | - { |
|
311 | - return $this->get('ATT_lname'); |
|
312 | - } |
|
313 | - |
|
314 | - |
|
315 | - /** |
|
316 | - * Gets the attendee's full address as an array so client code can decide hwo to display it |
|
317 | - * |
|
318 | - * @return array numerically indexed, with each part of the address that is known. |
|
319 | - * Eg, if the user only responded to state and country, |
|
320 | - * it would be array(0=>'Alabama',1=>'USA') |
|
321 | - * @return array |
|
322 | - * @throws EE_Error |
|
323 | - */ |
|
324 | - public function full_address_as_array() |
|
325 | - { |
|
326 | - $full_address_array = array(); |
|
327 | - $initial_address_fields = array('ATT_address', 'ATT_address2', 'ATT_city',); |
|
328 | - foreach ($initial_address_fields as $address_field_name) { |
|
329 | - $address_fields_value = $this->get($address_field_name); |
|
330 | - if (! empty($address_fields_value)) { |
|
331 | - $full_address_array[] = $address_fields_value; |
|
332 | - } |
|
333 | - } |
|
334 | - //now handle state and country |
|
335 | - $state_obj = $this->state_obj(); |
|
336 | - if ($state_obj instanceof EE_State) { |
|
337 | - $full_address_array[] = $state_obj->name(); |
|
338 | - } |
|
339 | - $country_obj = $this->country_obj(); |
|
340 | - if ($country_obj instanceof EE_Country) { |
|
341 | - $full_address_array[] = $country_obj->name(); |
|
342 | - } |
|
343 | - //lastly get the xip |
|
344 | - $zip_value = $this->zip(); |
|
345 | - if (! empty($zip_value)) { |
|
346 | - $full_address_array[] = $zip_value; |
|
347 | - } |
|
348 | - return $full_address_array; |
|
349 | - } |
|
350 | - |
|
351 | - |
|
352 | - /** |
|
353 | - * get Attendee Address |
|
354 | - * |
|
355 | - * @return string |
|
356 | - * @throws EE_Error |
|
357 | - */ |
|
358 | - public function address() |
|
359 | - { |
|
360 | - return $this->get('ATT_address'); |
|
361 | - } |
|
362 | - |
|
363 | - |
|
364 | - /** |
|
365 | - * get Attendee Address2 |
|
366 | - * |
|
367 | - * @return string |
|
368 | - * @throws EE_Error |
|
369 | - */ |
|
370 | - public function address2() |
|
371 | - { |
|
372 | - return $this->get('ATT_address2'); |
|
373 | - } |
|
374 | - |
|
375 | - |
|
376 | - /** |
|
377 | - * get Attendee City |
|
378 | - * |
|
379 | - * @return string |
|
380 | - * @throws EE_Error |
|
381 | - */ |
|
382 | - public function city() |
|
383 | - { |
|
384 | - return $this->get('ATT_city'); |
|
385 | - } |
|
386 | - |
|
387 | - |
|
388 | - /** |
|
389 | - * get Attendee State ID |
|
390 | - * |
|
391 | - * @return string |
|
392 | - * @throws EE_Error |
|
393 | - */ |
|
394 | - public function state_ID() |
|
395 | - { |
|
396 | - return $this->get('STA_ID'); |
|
397 | - } |
|
398 | - |
|
399 | - |
|
400 | - /** |
|
401 | - * @return string |
|
402 | - * @throws EE_Error |
|
403 | - */ |
|
404 | - public function state_abbrev() |
|
405 | - { |
|
406 | - return $this->state_obj() instanceof EE_State ? $this->state_obj()->abbrev() : ''; |
|
407 | - } |
|
408 | - |
|
409 | - |
|
410 | - /** |
|
411 | - * Gets the state set to this attendee |
|
412 | - * |
|
413 | - * @return EE_State |
|
414 | - * @throws EE_Error |
|
415 | - */ |
|
416 | - public function state_obj() |
|
417 | - { |
|
418 | - return $this->get_first_related('State'); |
|
419 | - } |
|
420 | - |
|
421 | - |
|
422 | - /** |
|
423 | - * Returns the state's name, otherwise 'Unknown' |
|
424 | - * |
|
425 | - * @return string |
|
426 | - * @throws EE_Error |
|
427 | - */ |
|
428 | - public function state_name() |
|
429 | - { |
|
430 | - if ($this->state_obj()) { |
|
431 | - return $this->state_obj()->name(); |
|
432 | - } else { |
|
433 | - return ''; |
|
434 | - } |
|
435 | - } |
|
436 | - |
|
437 | - |
|
438 | - /** |
|
439 | - * either displays the state abbreviation or the state name, as determined |
|
440 | - * by the "FHEE__EEI_Address__state__use_abbreviation" filter. |
|
441 | - * defaults to abbreviation |
|
442 | - * |
|
443 | - * @return string |
|
444 | - * @throws EE_Error |
|
445 | - */ |
|
446 | - public function state() |
|
447 | - { |
|
448 | - if (apply_filters('FHEE__EEI_Address__state__use_abbreviation', true, $this->state_obj())) { |
|
449 | - return $this->state_abbrev(); |
|
450 | - } |
|
451 | - return $this->state_name(); |
|
452 | - } |
|
453 | - |
|
454 | - |
|
455 | - /** |
|
456 | - * get Attendee Country ISO Code |
|
457 | - * |
|
458 | - * @return string |
|
459 | - * @throws EE_Error |
|
460 | - */ |
|
461 | - public function country_ID() |
|
462 | - { |
|
463 | - return $this->get('CNT_ISO'); |
|
464 | - } |
|
465 | - |
|
466 | - |
|
467 | - /** |
|
468 | - * Gets country set for this attendee |
|
469 | - * |
|
470 | - * @return EE_Country |
|
471 | - * @throws EE_Error |
|
472 | - */ |
|
473 | - public function country_obj() |
|
474 | - { |
|
475 | - return $this->get_first_related('Country'); |
|
476 | - } |
|
477 | - |
|
478 | - |
|
479 | - /** |
|
480 | - * Returns the country's name if known, otherwise 'Unknown' |
|
481 | - * |
|
482 | - * @return string |
|
483 | - * @throws EE_Error |
|
484 | - */ |
|
485 | - public function country_name() |
|
486 | - { |
|
487 | - if ($this->country_obj()) { |
|
488 | - return $this->country_obj()->name(); |
|
489 | - } |
|
490 | - return ''; |
|
491 | - } |
|
492 | - |
|
493 | - |
|
494 | - /** |
|
495 | - * either displays the country ISO2 code or the country name, as determined |
|
496 | - * by the "FHEE__EEI_Address__country__use_abbreviation" filter. |
|
497 | - * defaults to abbreviation |
|
498 | - * |
|
499 | - * @return string |
|
500 | - * @throws EE_Error |
|
501 | - */ |
|
502 | - public function country() |
|
503 | - { |
|
504 | - if (apply_filters('FHEE__EEI_Address__country__use_abbreviation', true, $this->country_obj())) { |
|
505 | - return $this->country_ID(); |
|
506 | - } |
|
507 | - return $this->country_name(); |
|
508 | - } |
|
509 | - |
|
510 | - |
|
511 | - /** |
|
512 | - * get Attendee Zip/Postal Code |
|
513 | - * |
|
514 | - * @return string |
|
515 | - * @throws EE_Error |
|
516 | - */ |
|
517 | - public function zip() |
|
518 | - { |
|
519 | - return $this->get('ATT_zip'); |
|
520 | - } |
|
521 | - |
|
522 | - |
|
523 | - /** |
|
524 | - * get Attendee Email Address |
|
525 | - * |
|
526 | - * @return string |
|
527 | - * @throws EE_Error |
|
528 | - */ |
|
529 | - public function email() |
|
530 | - { |
|
531 | - return $this->get('ATT_email'); |
|
532 | - } |
|
533 | - |
|
534 | - |
|
535 | - /** |
|
536 | - * get Attendee Phone # |
|
537 | - * |
|
538 | - * @return string |
|
539 | - * @throws EE_Error |
|
540 | - */ |
|
541 | - public function phone() |
|
542 | - { |
|
543 | - return $this->get('ATT_phone'); |
|
544 | - } |
|
545 | - |
|
546 | - |
|
547 | - /** |
|
548 | - * get deleted |
|
549 | - * |
|
550 | - * @return bool |
|
551 | - * @throws EE_Error |
|
552 | - */ |
|
553 | - public function deleted() |
|
554 | - { |
|
555 | - return $this->get('ATT_deleted'); |
|
556 | - } |
|
557 | - |
|
558 | - |
|
559 | - /** |
|
560 | - * Gets registrations of this attendee |
|
561 | - * |
|
562 | - * @param array $query_params |
|
563 | - * @return EE_Registration[] |
|
564 | - * @throws EE_Error |
|
565 | - */ |
|
566 | - public function get_registrations($query_params = array()) |
|
567 | - { |
|
568 | - return $this->get_many_related('Registration', $query_params); |
|
569 | - } |
|
570 | - |
|
571 | - |
|
572 | - /** |
|
573 | - * Gets the most recent registration of this attendee |
|
574 | - * |
|
575 | - * @return EE_Registration |
|
576 | - * @throws EE_Error |
|
577 | - */ |
|
578 | - public function get_most_recent_registration() |
|
579 | - { |
|
580 | - return $this->get_first_related( |
|
581 | - 'Registration', |
|
582 | - array('order_by' => array('REG_date' => 'DESC')) |
|
583 | - ); //null, 'REG_date', 'DESC', '=', 'OBJECT_K'); |
|
584 | - } |
|
585 | - |
|
586 | - |
|
587 | - /** |
|
588 | - * Gets the most recent registration for this attend at this event |
|
589 | - * |
|
590 | - * @param int $event_id |
|
591 | - * @return EE_Registration |
|
592 | - * @throws EE_Error |
|
593 | - */ |
|
594 | - public function get_most_recent_registration_for_event($event_id) |
|
595 | - { |
|
596 | - return $this->get_first_related( |
|
597 | - 'Registration', |
|
598 | - array(array('EVT_ID' => $event_id), 'order_by' => array('REG_date' => 'DESC')) |
|
599 | - ); |
|
600 | - } |
|
601 | - |
|
602 | - |
|
603 | - /** |
|
604 | - * returns any events attached to this attendee ($_Event property); |
|
605 | - * |
|
606 | - * @return array |
|
607 | - * @throws EE_Error |
|
608 | - */ |
|
609 | - public function events() |
|
610 | - { |
|
611 | - return $this->get_many_related('Event'); |
|
612 | - } |
|
613 | - |
|
614 | - |
|
615 | - /** |
|
616 | - * Gets the billing info array where keys match espresso_reg_page_billing_inputs(), |
|
617 | - * and keys are their cleaned values. @see EE_Attendee::save_and_clean_billing_info_for_payment_method() which was |
|
618 | - * used to save the billing info |
|
619 | - * |
|
620 | - * @param EE_Payment_Method $payment_method the _gateway_name property on the gateway class |
|
621 | - * @return EE_Form_Section_Proper|null |
|
622 | - * @throws EE_Error |
|
623 | - */ |
|
624 | - public function billing_info_for_payment_method($payment_method) |
|
625 | - { |
|
626 | - $pm_type = $payment_method->type_obj(); |
|
627 | - if (! $pm_type instanceof EE_PMT_Base) { |
|
628 | - return null; |
|
629 | - } |
|
630 | - $billing_info = $this->get_post_meta($this->get_billing_info_postmeta_name($payment_method), true); |
|
631 | - if (! $billing_info) { |
|
632 | - return null; |
|
633 | - } |
|
634 | - $billing_form = $pm_type->billing_form(); |
|
635 | - if ($billing_form instanceof EE_Form_Section_Proper) { |
|
636 | - $billing_form->receive_form_submission(array($billing_form->name() => $billing_info), false); |
|
637 | - } |
|
638 | - return $billing_form; |
|
639 | - } |
|
640 | - |
|
641 | - |
|
642 | - /** |
|
643 | - * Gets the postmeta key that holds this attendee's billing info for the |
|
644 | - * specified payment method |
|
645 | - * |
|
646 | - * @param EE_Payment_Method $payment_method |
|
647 | - * @return string |
|
648 | - * @throws EE_Error |
|
649 | - */ |
|
650 | - public function get_billing_info_postmeta_name($payment_method) |
|
651 | - { |
|
652 | - if ($payment_method->type_obj() instanceof EE_PMT_Base) { |
|
653 | - return 'billing_info_' . $payment_method->type_obj()->system_name(); |
|
654 | - } |
|
655 | - return null; |
|
656 | - } |
|
657 | - |
|
658 | - |
|
659 | - /** |
|
660 | - * Saves the billing info to the attendee. @see EE_Attendee::billing_info_for_payment_method() which is used to |
|
661 | - * retrieve it |
|
662 | - * |
|
663 | - * @param EE_Billing_Attendee_Info_Form $billing_form |
|
664 | - * @param EE_Payment_Method $payment_method |
|
665 | - * @return boolean |
|
666 | - * @throws EE_Error |
|
667 | - */ |
|
668 | - public function save_and_clean_billing_info_for_payment_method($billing_form, $payment_method) |
|
669 | - { |
|
670 | - if (! $billing_form instanceof EE_Billing_Attendee_Info_Form) { |
|
671 | - EE_Error::add_error(__('Cannot save billing info because there is none.', 'event_espresso')); |
|
672 | - return false; |
|
673 | - } |
|
674 | - $billing_form->clean_sensitive_data(); |
|
675 | - return update_post_meta( |
|
676 | - $this->ID(), |
|
677 | - $this->get_billing_info_postmeta_name($payment_method), |
|
678 | - $billing_form->input_values(true) |
|
679 | - ); |
|
680 | - } |
|
681 | - |
|
682 | - |
|
683 | - /** |
|
684 | - * Return the link to the admin details for the object. |
|
685 | - * |
|
686 | - * @return string |
|
687 | - * @throws EE_Error |
|
688 | - * @throws InvalidArgumentException |
|
689 | - * @throws InvalidDataTypeException |
|
690 | - * @throws InvalidInterfaceException |
|
691 | - * @throws ReflectionException |
|
692 | - */ |
|
693 | - public function get_admin_details_link() |
|
694 | - { |
|
695 | - return $this->get_admin_edit_link(); |
|
696 | - } |
|
697 | - |
|
698 | - |
|
699 | - /** |
|
700 | - * Returns the link to the editor for the object. Sometimes this is the same as the details. |
|
701 | - * |
|
702 | - * @return string |
|
703 | - * @throws EE_Error |
|
704 | - * @throws InvalidArgumentException |
|
705 | - * @throws ReflectionException |
|
706 | - * @throws InvalidDataTypeException |
|
707 | - * @throws InvalidInterfaceException |
|
708 | - */ |
|
709 | - public function get_admin_edit_link() |
|
710 | - { |
|
711 | - EE_Registry::instance()->load_helper('URL'); |
|
712 | - return EEH_URL::add_query_args_and_nonce( |
|
713 | - array( |
|
714 | - 'page' => 'espresso_registrations', |
|
715 | - 'action' => 'edit_attendee', |
|
716 | - 'post' => $this->ID(), |
|
717 | - ), |
|
718 | - admin_url('admin.php') |
|
719 | - ); |
|
720 | - } |
|
721 | - |
|
722 | - |
|
723 | - /** |
|
724 | - * Returns the link to a settings page for the object. |
|
725 | - * |
|
726 | - * @return string |
|
727 | - * @throws EE_Error |
|
728 | - * @throws InvalidArgumentException |
|
729 | - * @throws InvalidDataTypeException |
|
730 | - * @throws InvalidInterfaceException |
|
731 | - * @throws ReflectionException |
|
732 | - */ |
|
733 | - public function get_admin_settings_link() |
|
734 | - { |
|
735 | - return $this->get_admin_edit_link(); |
|
736 | - } |
|
737 | - |
|
738 | - |
|
739 | - /** |
|
740 | - * Returns the link to the "overview" for the object (typically the "list table" view). |
|
741 | - * |
|
742 | - * @return string |
|
743 | - * @throws EE_Error |
|
744 | - * @throws InvalidArgumentException |
|
745 | - * @throws ReflectionException |
|
746 | - * @throws InvalidDataTypeException |
|
747 | - * @throws InvalidInterfaceException |
|
748 | - */ |
|
749 | - public function get_admin_overview_link() |
|
750 | - { |
|
751 | - EE_Registry::instance()->load_helper('URL'); |
|
752 | - return EEH_URL::add_query_args_and_nonce( |
|
753 | - array( |
|
754 | - 'page' => 'espresso_registrations', |
|
755 | - 'action' => 'contact_list', |
|
756 | - ), |
|
757 | - admin_url('admin.php') |
|
758 | - ); |
|
759 | - } |
|
30 | + /** |
|
31 | + * Sets some dynamic defaults |
|
32 | + * |
|
33 | + * @param array $fieldValues |
|
34 | + * @param bool $bydb |
|
35 | + * @param string $timezone |
|
36 | + * @param array $date_formats |
|
37 | + * @throws EE_Error |
|
38 | + */ |
|
39 | + protected function __construct($fieldValues = null, $bydb = false, $timezone = null, $date_formats = array()) |
|
40 | + { |
|
41 | + if (! isset($fieldValues['ATT_full_name'])) { |
|
42 | + $fname = isset($fieldValues['ATT_fname']) ? $fieldValues['ATT_fname'] . ' ' : ''; |
|
43 | + $lname = isset($fieldValues['ATT_lname']) ? $fieldValues['ATT_lname'] : ''; |
|
44 | + $fieldValues['ATT_full_name'] = $fname . $lname; |
|
45 | + } |
|
46 | + if (! isset($fieldValues['ATT_slug'])) { |
|
47 | + // $fieldValues['ATT_slug'] = sanitize_key(wp_generate_password(20)); |
|
48 | + $fieldValues['ATT_slug'] = sanitize_title($fieldValues['ATT_full_name']); |
|
49 | + } |
|
50 | + if (! isset($fieldValues['ATT_short_bio']) && isset($fieldValues['ATT_bio'])) { |
|
51 | + $fieldValues['ATT_short_bio'] = substr($fieldValues['ATT_bio'], 0, 50); |
|
52 | + } |
|
53 | + parent::__construct($fieldValues, $bydb, $timezone, $date_formats); |
|
54 | + } |
|
55 | + |
|
56 | + |
|
57 | + /** |
|
58 | + * @param array $props_n_values incoming values |
|
59 | + * @param string $timezone incoming timezone (if not set the timezone set for the website will be |
|
60 | + * used.) |
|
61 | + * @param array $date_formats incoming date_formats in an array where the first value is the |
|
62 | + * date_format and the second value is the time format |
|
63 | + * @return EE_Attendee |
|
64 | + * @throws EE_Error |
|
65 | + */ |
|
66 | + public static function new_instance($props_n_values = array(), $timezone = null, $date_formats = array()) |
|
67 | + { |
|
68 | + $has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone, $date_formats); |
|
69 | + return $has_object ? $has_object : new self($props_n_values, false, $timezone, $date_formats); |
|
70 | + } |
|
71 | + |
|
72 | + |
|
73 | + /** |
|
74 | + * @param array $props_n_values incoming values from the database |
|
75 | + * @param string $timezone incoming timezone as set by the model. If not set the timezone for |
|
76 | + * the website will be used. |
|
77 | + * @return EE_Attendee |
|
78 | + */ |
|
79 | + public static function new_instance_from_db($props_n_values = array(), $timezone = null) |
|
80 | + { |
|
81 | + return new self($props_n_values, true, $timezone); |
|
82 | + } |
|
83 | + |
|
84 | + |
|
85 | + /** |
|
86 | + * Set Attendee First Name |
|
87 | + * |
|
88 | + * @access public |
|
89 | + * @param string $fname |
|
90 | + * @throws EE_Error |
|
91 | + */ |
|
92 | + public function set_fname($fname = '') |
|
93 | + { |
|
94 | + $this->set('ATT_fname', $fname); |
|
95 | + } |
|
96 | + |
|
97 | + |
|
98 | + /** |
|
99 | + * Set Attendee Last Name |
|
100 | + * |
|
101 | + * @access public |
|
102 | + * @param string $lname |
|
103 | + * @throws EE_Error |
|
104 | + */ |
|
105 | + public function set_lname($lname = '') |
|
106 | + { |
|
107 | + $this->set('ATT_lname', $lname); |
|
108 | + } |
|
109 | + |
|
110 | + |
|
111 | + /** |
|
112 | + * Set Attendee Address |
|
113 | + * |
|
114 | + * @access public |
|
115 | + * @param string $address |
|
116 | + * @throws EE_Error |
|
117 | + */ |
|
118 | + public function set_address($address = '') |
|
119 | + { |
|
120 | + $this->set('ATT_address', $address); |
|
121 | + } |
|
122 | + |
|
123 | + |
|
124 | + /** |
|
125 | + * Set Attendee Address2 |
|
126 | + * |
|
127 | + * @access public |
|
128 | + * @param string $address2 |
|
129 | + * @throws EE_Error |
|
130 | + */ |
|
131 | + public function set_address2($address2 = '') |
|
132 | + { |
|
133 | + $this->set('ATT_address2', $address2); |
|
134 | + } |
|
135 | + |
|
136 | + |
|
137 | + /** |
|
138 | + * Set Attendee City |
|
139 | + * |
|
140 | + * @access public |
|
141 | + * @param string $city |
|
142 | + * @throws EE_Error |
|
143 | + */ |
|
144 | + public function set_city($city = '') |
|
145 | + { |
|
146 | + $this->set('ATT_city', $city); |
|
147 | + } |
|
148 | + |
|
149 | + |
|
150 | + /** |
|
151 | + * Set Attendee State ID |
|
152 | + * |
|
153 | + * @access public |
|
154 | + * @param int $STA_ID |
|
155 | + * @throws EE_Error |
|
156 | + */ |
|
157 | + public function set_state($STA_ID = 0) |
|
158 | + { |
|
159 | + $this->set('STA_ID', $STA_ID); |
|
160 | + } |
|
161 | + |
|
162 | + |
|
163 | + /** |
|
164 | + * Set Attendee Country ISO Code |
|
165 | + * |
|
166 | + * @access public |
|
167 | + * @param string $CNT_ISO |
|
168 | + * @throws EE_Error |
|
169 | + */ |
|
170 | + public function set_country($CNT_ISO = '') |
|
171 | + { |
|
172 | + $this->set('CNT_ISO', $CNT_ISO); |
|
173 | + } |
|
174 | + |
|
175 | + |
|
176 | + /** |
|
177 | + * Set Attendee Zip/Postal Code |
|
178 | + * |
|
179 | + * @access public |
|
180 | + * @param string $zip |
|
181 | + * @throws EE_Error |
|
182 | + */ |
|
183 | + public function set_zip($zip = '') |
|
184 | + { |
|
185 | + $this->set('ATT_zip', $zip); |
|
186 | + } |
|
187 | + |
|
188 | + |
|
189 | + /** |
|
190 | + * Set Attendee Email Address |
|
191 | + * |
|
192 | + * @access public |
|
193 | + * @param string $email |
|
194 | + * @throws EE_Error |
|
195 | + */ |
|
196 | + public function set_email($email = '') |
|
197 | + { |
|
198 | + $this->set('ATT_email', $email); |
|
199 | + } |
|
200 | + |
|
201 | + |
|
202 | + /** |
|
203 | + * Set Attendee Phone |
|
204 | + * |
|
205 | + * @access public |
|
206 | + * @param string $phone |
|
207 | + * @throws EE_Error |
|
208 | + */ |
|
209 | + public function set_phone($phone = '') |
|
210 | + { |
|
211 | + $this->set('ATT_phone', $phone); |
|
212 | + } |
|
213 | + |
|
214 | + |
|
215 | + /** |
|
216 | + * set deleted |
|
217 | + * |
|
218 | + * @access public |
|
219 | + * @param bool $ATT_deleted |
|
220 | + * @throws EE_Error |
|
221 | + */ |
|
222 | + public function set_deleted($ATT_deleted = false) |
|
223 | + { |
|
224 | + $this->set('ATT_deleted', $ATT_deleted); |
|
225 | + } |
|
226 | + |
|
227 | + |
|
228 | + /** |
|
229 | + * Returns the value for the post_author id saved with the cpt |
|
230 | + * |
|
231 | + * @since 4.5.0 |
|
232 | + * @return int |
|
233 | + * @throws EE_Error |
|
234 | + */ |
|
235 | + public function wp_user() |
|
236 | + { |
|
237 | + return $this->get('ATT_author'); |
|
238 | + } |
|
239 | + |
|
240 | + |
|
241 | + /** |
|
242 | + * get Attendee First Name |
|
243 | + * |
|
244 | + * @access public |
|
245 | + * @return string |
|
246 | + * @throws EE_Error |
|
247 | + */ |
|
248 | + public function fname() |
|
249 | + { |
|
250 | + return $this->get('ATT_fname'); |
|
251 | + } |
|
252 | + |
|
253 | + |
|
254 | + /** |
|
255 | + * echoes out the attendee's first name |
|
256 | + * |
|
257 | + * @return void |
|
258 | + * @throws EE_Error |
|
259 | + */ |
|
260 | + public function e_full_name() |
|
261 | + { |
|
262 | + echo $this->full_name(); |
|
263 | + } |
|
264 | + |
|
265 | + |
|
266 | + /** |
|
267 | + * Returns the first and last name concatenated together with a space. |
|
268 | + * |
|
269 | + * @param bool $apply_html_entities |
|
270 | + * @return string |
|
271 | + * @throws EE_Error |
|
272 | + */ |
|
273 | + public function full_name($apply_html_entities = false) |
|
274 | + { |
|
275 | + $full_name = array( |
|
276 | + $this->fname(), |
|
277 | + $this->lname(), |
|
278 | + ); |
|
279 | + $full_name = array_filter($full_name); |
|
280 | + $full_name = implode(' ', $full_name); |
|
281 | + return $apply_html_entities ? htmlentities($full_name, ENT_QUOTES, 'UTF-8') : $full_name; |
|
282 | + } |
|
283 | + |
|
284 | + |
|
285 | + /** |
|
286 | + * This returns the value of the `ATT_full_name` field which is usually equivalent to calling `full_name()` unless |
|
287 | + * the post_title field has been directly modified in the db for the post (espresso_attendees post type) for this |
|
288 | + * attendee. |
|
289 | + * |
|
290 | + * @param bool $apply_html_entities |
|
291 | + * @return string |
|
292 | + * @throws EE_Error |
|
293 | + */ |
|
294 | + public function ATT_full_name($apply_html_entities = false) |
|
295 | + { |
|
296 | + return $apply_html_entities |
|
297 | + ? htmlentities($this->get('ATT_full_name'), ENT_QUOTES, 'UTF-8') |
|
298 | + : $this->get('ATT_full_name'); |
|
299 | + } |
|
300 | + |
|
301 | + |
|
302 | + /** |
|
303 | + * get Attendee Last Name |
|
304 | + * |
|
305 | + * @access public |
|
306 | + * @return string |
|
307 | + * @throws EE_Error |
|
308 | + */ |
|
309 | + public function lname() |
|
310 | + { |
|
311 | + return $this->get('ATT_lname'); |
|
312 | + } |
|
313 | + |
|
314 | + |
|
315 | + /** |
|
316 | + * Gets the attendee's full address as an array so client code can decide hwo to display it |
|
317 | + * |
|
318 | + * @return array numerically indexed, with each part of the address that is known. |
|
319 | + * Eg, if the user only responded to state and country, |
|
320 | + * it would be array(0=>'Alabama',1=>'USA') |
|
321 | + * @return array |
|
322 | + * @throws EE_Error |
|
323 | + */ |
|
324 | + public function full_address_as_array() |
|
325 | + { |
|
326 | + $full_address_array = array(); |
|
327 | + $initial_address_fields = array('ATT_address', 'ATT_address2', 'ATT_city',); |
|
328 | + foreach ($initial_address_fields as $address_field_name) { |
|
329 | + $address_fields_value = $this->get($address_field_name); |
|
330 | + if (! empty($address_fields_value)) { |
|
331 | + $full_address_array[] = $address_fields_value; |
|
332 | + } |
|
333 | + } |
|
334 | + //now handle state and country |
|
335 | + $state_obj = $this->state_obj(); |
|
336 | + if ($state_obj instanceof EE_State) { |
|
337 | + $full_address_array[] = $state_obj->name(); |
|
338 | + } |
|
339 | + $country_obj = $this->country_obj(); |
|
340 | + if ($country_obj instanceof EE_Country) { |
|
341 | + $full_address_array[] = $country_obj->name(); |
|
342 | + } |
|
343 | + //lastly get the xip |
|
344 | + $zip_value = $this->zip(); |
|
345 | + if (! empty($zip_value)) { |
|
346 | + $full_address_array[] = $zip_value; |
|
347 | + } |
|
348 | + return $full_address_array; |
|
349 | + } |
|
350 | + |
|
351 | + |
|
352 | + /** |
|
353 | + * get Attendee Address |
|
354 | + * |
|
355 | + * @return string |
|
356 | + * @throws EE_Error |
|
357 | + */ |
|
358 | + public function address() |
|
359 | + { |
|
360 | + return $this->get('ATT_address'); |
|
361 | + } |
|
362 | + |
|
363 | + |
|
364 | + /** |
|
365 | + * get Attendee Address2 |
|
366 | + * |
|
367 | + * @return string |
|
368 | + * @throws EE_Error |
|
369 | + */ |
|
370 | + public function address2() |
|
371 | + { |
|
372 | + return $this->get('ATT_address2'); |
|
373 | + } |
|
374 | + |
|
375 | + |
|
376 | + /** |
|
377 | + * get Attendee City |
|
378 | + * |
|
379 | + * @return string |
|
380 | + * @throws EE_Error |
|
381 | + */ |
|
382 | + public function city() |
|
383 | + { |
|
384 | + return $this->get('ATT_city'); |
|
385 | + } |
|
386 | + |
|
387 | + |
|
388 | + /** |
|
389 | + * get Attendee State ID |
|
390 | + * |
|
391 | + * @return string |
|
392 | + * @throws EE_Error |
|
393 | + */ |
|
394 | + public function state_ID() |
|
395 | + { |
|
396 | + return $this->get('STA_ID'); |
|
397 | + } |
|
398 | + |
|
399 | + |
|
400 | + /** |
|
401 | + * @return string |
|
402 | + * @throws EE_Error |
|
403 | + */ |
|
404 | + public function state_abbrev() |
|
405 | + { |
|
406 | + return $this->state_obj() instanceof EE_State ? $this->state_obj()->abbrev() : ''; |
|
407 | + } |
|
408 | + |
|
409 | + |
|
410 | + /** |
|
411 | + * Gets the state set to this attendee |
|
412 | + * |
|
413 | + * @return EE_State |
|
414 | + * @throws EE_Error |
|
415 | + */ |
|
416 | + public function state_obj() |
|
417 | + { |
|
418 | + return $this->get_first_related('State'); |
|
419 | + } |
|
420 | + |
|
421 | + |
|
422 | + /** |
|
423 | + * Returns the state's name, otherwise 'Unknown' |
|
424 | + * |
|
425 | + * @return string |
|
426 | + * @throws EE_Error |
|
427 | + */ |
|
428 | + public function state_name() |
|
429 | + { |
|
430 | + if ($this->state_obj()) { |
|
431 | + return $this->state_obj()->name(); |
|
432 | + } else { |
|
433 | + return ''; |
|
434 | + } |
|
435 | + } |
|
436 | + |
|
437 | + |
|
438 | + /** |
|
439 | + * either displays the state abbreviation or the state name, as determined |
|
440 | + * by the "FHEE__EEI_Address__state__use_abbreviation" filter. |
|
441 | + * defaults to abbreviation |
|
442 | + * |
|
443 | + * @return string |
|
444 | + * @throws EE_Error |
|
445 | + */ |
|
446 | + public function state() |
|
447 | + { |
|
448 | + if (apply_filters('FHEE__EEI_Address__state__use_abbreviation', true, $this->state_obj())) { |
|
449 | + return $this->state_abbrev(); |
|
450 | + } |
|
451 | + return $this->state_name(); |
|
452 | + } |
|
453 | + |
|
454 | + |
|
455 | + /** |
|
456 | + * get Attendee Country ISO Code |
|
457 | + * |
|
458 | + * @return string |
|
459 | + * @throws EE_Error |
|
460 | + */ |
|
461 | + public function country_ID() |
|
462 | + { |
|
463 | + return $this->get('CNT_ISO'); |
|
464 | + } |
|
465 | + |
|
466 | + |
|
467 | + /** |
|
468 | + * Gets country set for this attendee |
|
469 | + * |
|
470 | + * @return EE_Country |
|
471 | + * @throws EE_Error |
|
472 | + */ |
|
473 | + public function country_obj() |
|
474 | + { |
|
475 | + return $this->get_first_related('Country'); |
|
476 | + } |
|
477 | + |
|
478 | + |
|
479 | + /** |
|
480 | + * Returns the country's name if known, otherwise 'Unknown' |
|
481 | + * |
|
482 | + * @return string |
|
483 | + * @throws EE_Error |
|
484 | + */ |
|
485 | + public function country_name() |
|
486 | + { |
|
487 | + if ($this->country_obj()) { |
|
488 | + return $this->country_obj()->name(); |
|
489 | + } |
|
490 | + return ''; |
|
491 | + } |
|
492 | + |
|
493 | + |
|
494 | + /** |
|
495 | + * either displays the country ISO2 code or the country name, as determined |
|
496 | + * by the "FHEE__EEI_Address__country__use_abbreviation" filter. |
|
497 | + * defaults to abbreviation |
|
498 | + * |
|
499 | + * @return string |
|
500 | + * @throws EE_Error |
|
501 | + */ |
|
502 | + public function country() |
|
503 | + { |
|
504 | + if (apply_filters('FHEE__EEI_Address__country__use_abbreviation', true, $this->country_obj())) { |
|
505 | + return $this->country_ID(); |
|
506 | + } |
|
507 | + return $this->country_name(); |
|
508 | + } |
|
509 | + |
|
510 | + |
|
511 | + /** |
|
512 | + * get Attendee Zip/Postal Code |
|
513 | + * |
|
514 | + * @return string |
|
515 | + * @throws EE_Error |
|
516 | + */ |
|
517 | + public function zip() |
|
518 | + { |
|
519 | + return $this->get('ATT_zip'); |
|
520 | + } |
|
521 | + |
|
522 | + |
|
523 | + /** |
|
524 | + * get Attendee Email Address |
|
525 | + * |
|
526 | + * @return string |
|
527 | + * @throws EE_Error |
|
528 | + */ |
|
529 | + public function email() |
|
530 | + { |
|
531 | + return $this->get('ATT_email'); |
|
532 | + } |
|
533 | + |
|
534 | + |
|
535 | + /** |
|
536 | + * get Attendee Phone # |
|
537 | + * |
|
538 | + * @return string |
|
539 | + * @throws EE_Error |
|
540 | + */ |
|
541 | + public function phone() |
|
542 | + { |
|
543 | + return $this->get('ATT_phone'); |
|
544 | + } |
|
545 | + |
|
546 | + |
|
547 | + /** |
|
548 | + * get deleted |
|
549 | + * |
|
550 | + * @return bool |
|
551 | + * @throws EE_Error |
|
552 | + */ |
|
553 | + public function deleted() |
|
554 | + { |
|
555 | + return $this->get('ATT_deleted'); |
|
556 | + } |
|
557 | + |
|
558 | + |
|
559 | + /** |
|
560 | + * Gets registrations of this attendee |
|
561 | + * |
|
562 | + * @param array $query_params |
|
563 | + * @return EE_Registration[] |
|
564 | + * @throws EE_Error |
|
565 | + */ |
|
566 | + public function get_registrations($query_params = array()) |
|
567 | + { |
|
568 | + return $this->get_many_related('Registration', $query_params); |
|
569 | + } |
|
570 | + |
|
571 | + |
|
572 | + /** |
|
573 | + * Gets the most recent registration of this attendee |
|
574 | + * |
|
575 | + * @return EE_Registration |
|
576 | + * @throws EE_Error |
|
577 | + */ |
|
578 | + public function get_most_recent_registration() |
|
579 | + { |
|
580 | + return $this->get_first_related( |
|
581 | + 'Registration', |
|
582 | + array('order_by' => array('REG_date' => 'DESC')) |
|
583 | + ); //null, 'REG_date', 'DESC', '=', 'OBJECT_K'); |
|
584 | + } |
|
585 | + |
|
586 | + |
|
587 | + /** |
|
588 | + * Gets the most recent registration for this attend at this event |
|
589 | + * |
|
590 | + * @param int $event_id |
|
591 | + * @return EE_Registration |
|
592 | + * @throws EE_Error |
|
593 | + */ |
|
594 | + public function get_most_recent_registration_for_event($event_id) |
|
595 | + { |
|
596 | + return $this->get_first_related( |
|
597 | + 'Registration', |
|
598 | + array(array('EVT_ID' => $event_id), 'order_by' => array('REG_date' => 'DESC')) |
|
599 | + ); |
|
600 | + } |
|
601 | + |
|
602 | + |
|
603 | + /** |
|
604 | + * returns any events attached to this attendee ($_Event property); |
|
605 | + * |
|
606 | + * @return array |
|
607 | + * @throws EE_Error |
|
608 | + */ |
|
609 | + public function events() |
|
610 | + { |
|
611 | + return $this->get_many_related('Event'); |
|
612 | + } |
|
613 | + |
|
614 | + |
|
615 | + /** |
|
616 | + * Gets the billing info array where keys match espresso_reg_page_billing_inputs(), |
|
617 | + * and keys are their cleaned values. @see EE_Attendee::save_and_clean_billing_info_for_payment_method() which was |
|
618 | + * used to save the billing info |
|
619 | + * |
|
620 | + * @param EE_Payment_Method $payment_method the _gateway_name property on the gateway class |
|
621 | + * @return EE_Form_Section_Proper|null |
|
622 | + * @throws EE_Error |
|
623 | + */ |
|
624 | + public function billing_info_for_payment_method($payment_method) |
|
625 | + { |
|
626 | + $pm_type = $payment_method->type_obj(); |
|
627 | + if (! $pm_type instanceof EE_PMT_Base) { |
|
628 | + return null; |
|
629 | + } |
|
630 | + $billing_info = $this->get_post_meta($this->get_billing_info_postmeta_name($payment_method), true); |
|
631 | + if (! $billing_info) { |
|
632 | + return null; |
|
633 | + } |
|
634 | + $billing_form = $pm_type->billing_form(); |
|
635 | + if ($billing_form instanceof EE_Form_Section_Proper) { |
|
636 | + $billing_form->receive_form_submission(array($billing_form->name() => $billing_info), false); |
|
637 | + } |
|
638 | + return $billing_form; |
|
639 | + } |
|
640 | + |
|
641 | + |
|
642 | + /** |
|
643 | + * Gets the postmeta key that holds this attendee's billing info for the |
|
644 | + * specified payment method |
|
645 | + * |
|
646 | + * @param EE_Payment_Method $payment_method |
|
647 | + * @return string |
|
648 | + * @throws EE_Error |
|
649 | + */ |
|
650 | + public function get_billing_info_postmeta_name($payment_method) |
|
651 | + { |
|
652 | + if ($payment_method->type_obj() instanceof EE_PMT_Base) { |
|
653 | + return 'billing_info_' . $payment_method->type_obj()->system_name(); |
|
654 | + } |
|
655 | + return null; |
|
656 | + } |
|
657 | + |
|
658 | + |
|
659 | + /** |
|
660 | + * Saves the billing info to the attendee. @see EE_Attendee::billing_info_for_payment_method() which is used to |
|
661 | + * retrieve it |
|
662 | + * |
|
663 | + * @param EE_Billing_Attendee_Info_Form $billing_form |
|
664 | + * @param EE_Payment_Method $payment_method |
|
665 | + * @return boolean |
|
666 | + * @throws EE_Error |
|
667 | + */ |
|
668 | + public function save_and_clean_billing_info_for_payment_method($billing_form, $payment_method) |
|
669 | + { |
|
670 | + if (! $billing_form instanceof EE_Billing_Attendee_Info_Form) { |
|
671 | + EE_Error::add_error(__('Cannot save billing info because there is none.', 'event_espresso')); |
|
672 | + return false; |
|
673 | + } |
|
674 | + $billing_form->clean_sensitive_data(); |
|
675 | + return update_post_meta( |
|
676 | + $this->ID(), |
|
677 | + $this->get_billing_info_postmeta_name($payment_method), |
|
678 | + $billing_form->input_values(true) |
|
679 | + ); |
|
680 | + } |
|
681 | + |
|
682 | + |
|
683 | + /** |
|
684 | + * Return the link to the admin details for the object. |
|
685 | + * |
|
686 | + * @return string |
|
687 | + * @throws EE_Error |
|
688 | + * @throws InvalidArgumentException |
|
689 | + * @throws InvalidDataTypeException |
|
690 | + * @throws InvalidInterfaceException |
|
691 | + * @throws ReflectionException |
|
692 | + */ |
|
693 | + public function get_admin_details_link() |
|
694 | + { |
|
695 | + return $this->get_admin_edit_link(); |
|
696 | + } |
|
697 | + |
|
698 | + |
|
699 | + /** |
|
700 | + * Returns the link to the editor for the object. Sometimes this is the same as the details. |
|
701 | + * |
|
702 | + * @return string |
|
703 | + * @throws EE_Error |
|
704 | + * @throws InvalidArgumentException |
|
705 | + * @throws ReflectionException |
|
706 | + * @throws InvalidDataTypeException |
|
707 | + * @throws InvalidInterfaceException |
|
708 | + */ |
|
709 | + public function get_admin_edit_link() |
|
710 | + { |
|
711 | + EE_Registry::instance()->load_helper('URL'); |
|
712 | + return EEH_URL::add_query_args_and_nonce( |
|
713 | + array( |
|
714 | + 'page' => 'espresso_registrations', |
|
715 | + 'action' => 'edit_attendee', |
|
716 | + 'post' => $this->ID(), |
|
717 | + ), |
|
718 | + admin_url('admin.php') |
|
719 | + ); |
|
720 | + } |
|
721 | + |
|
722 | + |
|
723 | + /** |
|
724 | + * Returns the link to a settings page for the object. |
|
725 | + * |
|
726 | + * @return string |
|
727 | + * @throws EE_Error |
|
728 | + * @throws InvalidArgumentException |
|
729 | + * @throws InvalidDataTypeException |
|
730 | + * @throws InvalidInterfaceException |
|
731 | + * @throws ReflectionException |
|
732 | + */ |
|
733 | + public function get_admin_settings_link() |
|
734 | + { |
|
735 | + return $this->get_admin_edit_link(); |
|
736 | + } |
|
737 | + |
|
738 | + |
|
739 | + /** |
|
740 | + * Returns the link to the "overview" for the object (typically the "list table" view). |
|
741 | + * |
|
742 | + * @return string |
|
743 | + * @throws EE_Error |
|
744 | + * @throws InvalidArgumentException |
|
745 | + * @throws ReflectionException |
|
746 | + * @throws InvalidDataTypeException |
|
747 | + * @throws InvalidInterfaceException |
|
748 | + */ |
|
749 | + public function get_admin_overview_link() |
|
750 | + { |
|
751 | + EE_Registry::instance()->load_helper('URL'); |
|
752 | + return EEH_URL::add_query_args_and_nonce( |
|
753 | + array( |
|
754 | + 'page' => 'espresso_registrations', |
|
755 | + 'action' => 'contact_list', |
|
756 | + ), |
|
757 | + admin_url('admin.php') |
|
758 | + ); |
|
759 | + } |
|
760 | 760 | } |
@@ -38,16 +38,16 @@ discard block |
||
38 | 38 | */ |
39 | 39 | protected function __construct($fieldValues = null, $bydb = false, $timezone = null, $date_formats = array()) |
40 | 40 | { |
41 | - if (! isset($fieldValues['ATT_full_name'])) { |
|
42 | - $fname = isset($fieldValues['ATT_fname']) ? $fieldValues['ATT_fname'] . ' ' : ''; |
|
41 | + if ( ! isset($fieldValues['ATT_full_name'])) { |
|
42 | + $fname = isset($fieldValues['ATT_fname']) ? $fieldValues['ATT_fname'].' ' : ''; |
|
43 | 43 | $lname = isset($fieldValues['ATT_lname']) ? $fieldValues['ATT_lname'] : ''; |
44 | - $fieldValues['ATT_full_name'] = $fname . $lname; |
|
44 | + $fieldValues['ATT_full_name'] = $fname.$lname; |
|
45 | 45 | } |
46 | - if (! isset($fieldValues['ATT_slug'])) { |
|
46 | + if ( ! isset($fieldValues['ATT_slug'])) { |
|
47 | 47 | // $fieldValues['ATT_slug'] = sanitize_key(wp_generate_password(20)); |
48 | 48 | $fieldValues['ATT_slug'] = sanitize_title($fieldValues['ATT_full_name']); |
49 | 49 | } |
50 | - if (! isset($fieldValues['ATT_short_bio']) && isset($fieldValues['ATT_bio'])) { |
|
50 | + if ( ! isset($fieldValues['ATT_short_bio']) && isset($fieldValues['ATT_bio'])) { |
|
51 | 51 | $fieldValues['ATT_short_bio'] = substr($fieldValues['ATT_bio'], 0, 50); |
52 | 52 | } |
53 | 53 | parent::__construct($fieldValues, $bydb, $timezone, $date_formats); |
@@ -327,7 +327,7 @@ discard block |
||
327 | 327 | $initial_address_fields = array('ATT_address', 'ATT_address2', 'ATT_city',); |
328 | 328 | foreach ($initial_address_fields as $address_field_name) { |
329 | 329 | $address_fields_value = $this->get($address_field_name); |
330 | - if (! empty($address_fields_value)) { |
|
330 | + if ( ! empty($address_fields_value)) { |
|
331 | 331 | $full_address_array[] = $address_fields_value; |
332 | 332 | } |
333 | 333 | } |
@@ -342,7 +342,7 @@ discard block |
||
342 | 342 | } |
343 | 343 | //lastly get the xip |
344 | 344 | $zip_value = $this->zip(); |
345 | - if (! empty($zip_value)) { |
|
345 | + if ( ! empty($zip_value)) { |
|
346 | 346 | $full_address_array[] = $zip_value; |
347 | 347 | } |
348 | 348 | return $full_address_array; |
@@ -624,11 +624,11 @@ discard block |
||
624 | 624 | public function billing_info_for_payment_method($payment_method) |
625 | 625 | { |
626 | 626 | $pm_type = $payment_method->type_obj(); |
627 | - if (! $pm_type instanceof EE_PMT_Base) { |
|
627 | + if ( ! $pm_type instanceof EE_PMT_Base) { |
|
628 | 628 | return null; |
629 | 629 | } |
630 | 630 | $billing_info = $this->get_post_meta($this->get_billing_info_postmeta_name($payment_method), true); |
631 | - if (! $billing_info) { |
|
631 | + if ( ! $billing_info) { |
|
632 | 632 | return null; |
633 | 633 | } |
634 | 634 | $billing_form = $pm_type->billing_form(); |
@@ -650,7 +650,7 @@ discard block |
||
650 | 650 | public function get_billing_info_postmeta_name($payment_method) |
651 | 651 | { |
652 | 652 | if ($payment_method->type_obj() instanceof EE_PMT_Base) { |
653 | - return 'billing_info_' . $payment_method->type_obj()->system_name(); |
|
653 | + return 'billing_info_'.$payment_method->type_obj()->system_name(); |
|
654 | 654 | } |
655 | 655 | return null; |
656 | 656 | } |
@@ -667,7 +667,7 @@ discard block |
||
667 | 667 | */ |
668 | 668 | public function save_and_clean_billing_info_for_payment_method($billing_form, $payment_method) |
669 | 669 | { |
670 | - if (! $billing_form instanceof EE_Billing_Attendee_Info_Form) { |
|
670 | + if ( ! $billing_form instanceof EE_Billing_Attendee_Info_Form) { |
|
671 | 671 | EE_Error::add_error(__('Cannot save billing info because there is none.', 'event_espresso')); |
672 | 672 | return false; |
673 | 673 | } |
@@ -14,36 +14,36 @@ |
||
14 | 14 | */ |
15 | 15 | interface CapabilitiesActionRestrictionInterface |
16 | 16 | { |
17 | - /** |
|
18 | - * Return whether the item can be edited for the given context. |
|
19 | - * @param Context $context |
|
20 | - * @return bool |
|
21 | - */ |
|
22 | - public function canEdit(Context $context); |
|
17 | + /** |
|
18 | + * Return whether the item can be edited for the given context. |
|
19 | + * @param Context $context |
|
20 | + * @return bool |
|
21 | + */ |
|
22 | + public function canEdit(Context $context); |
|
23 | 23 | |
24 | 24 | |
25 | - /** |
|
26 | - * Return whether the item can be read for the given context. |
|
27 | - * @param Context $context |
|
28 | - * @return bool |
|
29 | - */ |
|
30 | - public function canRead(Context $context); |
|
25 | + /** |
|
26 | + * Return whether the item can be read for the given context. |
|
27 | + * @param Context $context |
|
28 | + * @return bool |
|
29 | + */ |
|
30 | + public function canRead(Context $context); |
|
31 | 31 | |
32 | 32 | |
33 | 33 | |
34 | 34 | |
35 | - /** |
|
36 | - * Return whether the item can be deleted for the given context. |
|
37 | - * @param Context $context |
|
38 | - * @return bool |
|
39 | - */ |
|
40 | - public function canDelete(Context $context); |
|
35 | + /** |
|
36 | + * Return whether the item can be deleted for the given context. |
|
37 | + * @param Context $context |
|
38 | + * @return bool |
|
39 | + */ |
|
40 | + public function canDelete(Context $context); |
|
41 | 41 | |
42 | 42 | |
43 | - /** |
|
44 | - * Return whether the item can be created for the given context |
|
45 | - * @param Context $context |
|
46 | - * @return bool |
|
47 | - */ |
|
48 | - public function canCreate(Context $context); |
|
43 | + /** |
|
44 | + * Return whether the item can be created for the given context |
|
45 | + * @param Context $context |
|
46 | + * @return bool |
|
47 | + */ |
|
48 | + public function canCreate(Context $context); |
|
49 | 49 | } |
50 | 50 | \ No newline at end of file |
@@ -30,7 +30,7 @@ |
||
30 | 30 | public function prepare_for_pretty_echoing($value_on_field_to_be_outputted, $schema = null) |
31 | 31 | { |
32 | 32 | if ($schema === 'form_input') { |
33 | - $value_on_field_to_be_outputted = (string)htmlentities( |
|
33 | + $value_on_field_to_be_outputted = (string) htmlentities( |
|
34 | 34 | $value_on_field_to_be_outputted, |
35 | 35 | ENT_QUOTES, |
36 | 36 | 'UTF-8' |
@@ -7,49 +7,49 @@ |
||
7 | 7 | abstract class EE_Text_Field_Base extends EE_Model_Field_Base |
8 | 8 | { |
9 | 9 | |
10 | - /** |
|
11 | - * Gets the value in the format expected when being set. |
|
12 | - * For display on the front-end, usually you would use prepare_for_pretty_echoing() instead. |
|
13 | - * @param mixed $value_of_field_on_model_object |
|
14 | - * @return mixed|string |
|
15 | - */ |
|
16 | - public function prepare_for_get($value_of_field_on_model_object) |
|
17 | - { |
|
18 | - return $value_of_field_on_model_object; |
|
19 | - } |
|
10 | + /** |
|
11 | + * Gets the value in the format expected when being set. |
|
12 | + * For display on the front-end, usually you would use prepare_for_pretty_echoing() instead. |
|
13 | + * @param mixed $value_of_field_on_model_object |
|
14 | + * @return mixed|string |
|
15 | + */ |
|
16 | + public function prepare_for_get($value_of_field_on_model_object) |
|
17 | + { |
|
18 | + return $value_of_field_on_model_object; |
|
19 | + } |
|
20 | 20 | |
21 | - /** |
|
22 | - * Accepts schema of 'form_input' which formats the string for echoing in form input's value. |
|
23 | - * |
|
24 | - * @param string $value_on_field_to_be_outputted |
|
25 | - * @param string $schema |
|
26 | - * @return string |
|
27 | - */ |
|
28 | - public function prepare_for_pretty_echoing($value_on_field_to_be_outputted, $schema = null) |
|
29 | - { |
|
30 | - if ($schema === 'form_input') { |
|
31 | - $value_on_field_to_be_outputted = (string)htmlentities( |
|
32 | - $value_on_field_to_be_outputted, |
|
33 | - ENT_QUOTES, |
|
34 | - 'UTF-8' |
|
35 | - ); |
|
36 | - } |
|
37 | - return parent::prepare_for_pretty_echoing($value_on_field_to_be_outputted); |
|
38 | - } |
|
21 | + /** |
|
22 | + * Accepts schema of 'form_input' which formats the string for echoing in form input's value. |
|
23 | + * |
|
24 | + * @param string $value_on_field_to_be_outputted |
|
25 | + * @param string $schema |
|
26 | + * @return string |
|
27 | + */ |
|
28 | + public function prepare_for_pretty_echoing($value_on_field_to_be_outputted, $schema = null) |
|
29 | + { |
|
30 | + if ($schema === 'form_input') { |
|
31 | + $value_on_field_to_be_outputted = (string)htmlentities( |
|
32 | + $value_on_field_to_be_outputted, |
|
33 | + ENT_QUOTES, |
|
34 | + 'UTF-8' |
|
35 | + ); |
|
36 | + } |
|
37 | + return parent::prepare_for_pretty_echoing($value_on_field_to_be_outputted); |
|
38 | + } |
|
39 | 39 | |
40 | - /** |
|
41 | - * Data received from the user should be exactly as they hope to save it in the DB, with the exception that |
|
42 | - * quotes need to have slashes added to it. This method takes care of removing the slashes added by WP |
|
43 | - * in magic-quotes fashion. We used to call html_entity_decode on the value here, |
|
44 | - * because we called htmlentities when in EE_Text_Field_Base::prepare_for_pretty_echoing, but that's not necessary |
|
45 | - * because web browsers always decode HTML entities in element attributes, like a form element's value attribute. |
|
46 | - * So if we do it again here, we'll be removing HTML entities the user intended to have.) |
|
47 | - * |
|
48 | - * @param string $value_inputted_for_field_on_model_object |
|
49 | - * @return string |
|
50 | - */ |
|
51 | - public function prepare_for_set($value_inputted_for_field_on_model_object) |
|
52 | - { |
|
53 | - return stripslashes(parent::prepare_for_set($value_inputted_for_field_on_model_object)); |
|
54 | - } |
|
40 | + /** |
|
41 | + * Data received from the user should be exactly as they hope to save it in the DB, with the exception that |
|
42 | + * quotes need to have slashes added to it. This method takes care of removing the slashes added by WP |
|
43 | + * in magic-quotes fashion. We used to call html_entity_decode on the value here, |
|
44 | + * because we called htmlentities when in EE_Text_Field_Base::prepare_for_pretty_echoing, but that's not necessary |
|
45 | + * because web browsers always decode HTML entities in element attributes, like a form element's value attribute. |
|
46 | + * So if we do it again here, we'll be removing HTML entities the user intended to have.) |
|
47 | + * |
|
48 | + * @param string $value_inputted_for_field_on_model_object |
|
49 | + * @return string |
|
50 | + */ |
|
51 | + public function prepare_for_set($value_inputted_for_field_on_model_object) |
|
52 | + { |
|
53 | + return stripslashes(parent::prepare_for_set($value_inputted_for_field_on_model_object)); |
|
54 | + } |
|
55 | 55 | } |
56 | 56 | \ No newline at end of file |
@@ -69,10 +69,10 @@ discard block |
||
69 | 69 | * @return string |
70 | 70 | * @todo: at some point we can break this down into other static methods to abstract it a bit better. |
71 | 71 | */ |
72 | - static public function get_form_fields( $input_vars = array(), $id = FALSE ) { |
|
72 | + static public function get_form_fields($input_vars = array(), $id = FALSE) { |
|
73 | 73 | |
74 | - if ( empty($input_vars) ) { |
|
75 | - EE_Error::add_error( __('missing required variables for the form field generator', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
74 | + if (empty($input_vars)) { |
|
75 | + EE_Error::add_error(__('missing required variables for the form field generator', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
76 | 76 | return FALSE; |
77 | 77 | } |
78 | 78 | |
@@ -98,25 +98,25 @@ discard block |
||
98 | 98 | 'append_content' => '' |
99 | 99 | ); |
100 | 100 | |
101 | - $input_value = wp_parse_args( $input_value, $defaults ); |
|
101 | + $input_value = wp_parse_args($input_value, $defaults); |
|
102 | 102 | |
103 | 103 | // required fields get a * |
104 | 104 | $required = isset($input_value['required']) && $input_value['required'] ? ' <span>*</span>: ' : ': '; |
105 | 105 | // and the css class "required" |
106 | - $css_class = isset( $input_value['css_class'] ) ? $input_value['css_class'] : ''; |
|
107 | - $styles = $input_value['required'] ? 'required ' . $css_class : $css_class; |
|
106 | + $css_class = isset($input_value['css_class']) ? $input_value['css_class'] : ''; |
|
107 | + $styles = $input_value['required'] ? 'required '.$css_class : $css_class; |
|
108 | 108 | |
109 | - $field_id = ($id) ? $id . '-' . $input_key : $input_key; |
|
110 | - $tabindex = !empty($input_value['tabindex']) ? ' tabindex="' . $input_value['tabindex'] . '"' : ''; |
|
109 | + $field_id = ($id) ? $id.'-'.$input_key : $input_key; |
|
110 | + $tabindex = ! empty($input_value['tabindex']) ? ' tabindex="'.$input_value['tabindex'].'"' : ''; |
|
111 | 111 | |
112 | 112 | //rows or cols? |
113 | - $rows = isset($input_value['rows'] ) ? $input_value['rows'] : '10'; |
|
114 | - $cols = isset($input_value['cols'] ) ? $input_value['cols'] : '80'; |
|
113 | + $rows = isset($input_value['rows']) ? $input_value['rows'] : '10'; |
|
114 | + $cols = isset($input_value['cols']) ? $input_value['cols'] : '80'; |
|
115 | 115 | |
116 | 116 | //any content? |
117 | 117 | $append_content = $input_value['append_content']; |
118 | 118 | |
119 | - $output .= (!$close) ? '<ul>' : ''; |
|
119 | + $output .= ( ! $close) ? '<ul>' : ''; |
|
120 | 120 | $output .= '<li>'; |
121 | 121 | |
122 | 122 | // what type of input are we dealing with ? |
@@ -124,15 +124,15 @@ discard block |
||
124 | 124 | |
125 | 125 | // text inputs |
126 | 126 | case 'text' : |
127 | - $output .= "\n\t\t\t" . '<label for="' . $field_id . '">' . $input_value['label'] . $required . '</label>'; |
|
128 | - $output .= "\n\t\t\t" . '<input id="' . $field_id . '" class="' . $styles . '" type="text" value="' . esc_textarea($input_value['value']) . '" name="' . $input_value['name'] . '"' . $tabindex . '>'; |
|
127 | + $output .= "\n\t\t\t".'<label for="'.$field_id.'">'.$input_value['label'].$required.'</label>'; |
|
128 | + $output .= "\n\t\t\t".'<input id="'.$field_id.'" class="'.$styles.'" type="text" value="'.esc_textarea($input_value['value']).'" name="'.$input_value['name'].'"'.$tabindex.'>'; |
|
129 | 129 | break; |
130 | 130 | |
131 | 131 | // dropdowns |
132 | 132 | case 'select' : |
133 | 133 | |
134 | - $output .= "\n\t\t\t" . '<label for="' . $field_id . '">' . $input_value['label'] . $required . '</label>'; |
|
135 | - $output .= "\n\t\t\t" . '<select id="' . $field_id . '" class="' . $styles . '" name="' . $input_value['name'] . '"' . $tabindex . '>'; |
|
134 | + $output .= "\n\t\t\t".'<label for="'.$field_id.'">'.$input_value['label'].$required.'</label>'; |
|
135 | + $output .= "\n\t\t\t".'<select id="'.$field_id.'" class="'.$styles.'" name="'.$input_value['name'].'"'.$tabindex.'>'; |
|
136 | 136 | |
137 | 137 | if (is_array($input_value['options'])) { |
138 | 138 | $options = $input_value['options']; |
@@ -141,30 +141,30 @@ discard block |
||
141 | 141 | } |
142 | 142 | |
143 | 143 | foreach ($options as $key => $value) { |
144 | - $selected = isset( $input_value['value'] ) && $input_value['value'] == $key ? 'selected=selected' : ''; |
|
144 | + $selected = isset($input_value['value']) && $input_value['value'] == $key ? 'selected=selected' : ''; |
|
145 | 145 | //$key = str_replace( ' ', '_', sanitize_key( $value )); |
146 | - $output .= "\n\t\t\t\t" . '<option '. $selected . ' value="' . $key . '">' . $value . '</option>'; |
|
146 | + $output .= "\n\t\t\t\t".'<option '.$selected.' value="'.$key.'">'.$value.'</option>'; |
|
147 | 147 | } |
148 | - $output .= "\n\t\t\t" . '</select>'; |
|
148 | + $output .= "\n\t\t\t".'</select>'; |
|
149 | 149 | |
150 | 150 | break; |
151 | 151 | |
152 | 152 | case 'textarea' : |
153 | 153 | |
154 | - $output .= "\n\t\t\t" . '<label for="' . $field_id . '">' . $input_value['label'] . $required . '</label>'; |
|
155 | - $output .= "\n\t\t\t" . '<textarea id="' . $field_id . '" class="' . $styles . '" rows="'.$rows.'" cols="'.$cols.'" name="' . $input_value['name'] . '"' . $tabindex . '>' . esc_textarea($input_value['value']) . '</textarea>'; |
|
154 | + $output .= "\n\t\t\t".'<label for="'.$field_id.'">'.$input_value['label'].$required.'</label>'; |
|
155 | + $output .= "\n\t\t\t".'<textarea id="'.$field_id.'" class="'.$styles.'" rows="'.$rows.'" cols="'.$cols.'" name="'.$input_value['name'].'"'.$tabindex.'>'.esc_textarea($input_value['value']).'</textarea>'; |
|
156 | 156 | break; |
157 | 157 | |
158 | 158 | case 'hidden' : |
159 | 159 | $close = false; |
160 | 160 | $output .= "</li></ul>"; |
161 | - $output .= "\n\t\t\t" . '<input id="' . $field_id . '" type="hidden" name="' . $input_value['name'] . '" value="' . $input_value['value'] . '">'; |
|
161 | + $output .= "\n\t\t\t".'<input id="'.$field_id.'" type="hidden" name="'.$input_value['name'].'" value="'.$input_value['value'].'">'; |
|
162 | 162 | break; |
163 | 163 | |
164 | 164 | case 'checkbox' : |
165 | - $checked = ( $input_value['value'] == 1 ) ? 'checked="checked"' : ''; |
|
166 | - $output .= "\n\t\t\t" . '<label for="' . $field_id . '">' . $input_value['label'] . $required . '</label>'; |
|
167 | - $output .= "\n\t\t\t" . '<input id="' . $field_id. '" type="checkbox" name="' . $input_value['name'] . '" value="1"' . $checked . $tabindex . ' />'; |
|
165 | + $checked = ($input_value['value'] == 1) ? 'checked="checked"' : ''; |
|
166 | + $output .= "\n\t\t\t".'<label for="'.$field_id.'">'.$input_value['label'].$required.'</label>'; |
|
167 | + $output .= "\n\t\t\t".'<input id="'.$field_id.'" type="checkbox" name="'.$input_value['name'].'" value="1"'.$checked.$tabindex.' />'; |
|
168 | 168 | break; |
169 | 169 | |
170 | 170 | case 'wp_editor' : |
@@ -177,19 +177,19 @@ discard block |
||
177 | 177 | ); |
178 | 178 | $output .= '</li>'; |
179 | 179 | $output .= '</ul>'; |
180 | - $output .= '<h4>' . $input_value['label'] . '</h4>'; |
|
181 | - if ( $append_content ) { |
|
180 | + $output .= '<h4>'.$input_value['label'].'</h4>'; |
|
181 | + if ($append_content) { |
|
182 | 182 | $output .= $append_content; |
183 | 183 | } |
184 | 184 | ob_start(); |
185 | - wp_editor( $input_value['value'], $field_id, $editor_settings); |
|
185 | + wp_editor($input_value['value'], $field_id, $editor_settings); |
|
186 | 186 | $editor = ob_get_contents(); |
187 | 187 | ob_end_clean(); |
188 | 188 | $output .= $editor; |
189 | 189 | break; |
190 | 190 | |
191 | 191 | } |
192 | - if ( $append_content && $input_value['input'] !== 'wp_editor' ) { |
|
192 | + if ($append_content && $input_value['input'] !== 'wp_editor') { |
|
193 | 193 | $output .= $append_content; |
194 | 194 | } |
195 | 195 | $output .= ($close) ? '</li>' : ''; |
@@ -230,7 +230,7 @@ discard block |
||
230 | 230 | $form_fields = array(); |
231 | 231 | $fields = (array) $fields; |
232 | 232 | |
233 | - foreach ( $fields as $field_name => $field_atts ) { |
|
233 | + foreach ($fields as $field_name => $field_atts) { |
|
234 | 234 | //defaults: |
235 | 235 | $defaults = array( |
236 | 236 | 'label' => '', |
@@ -248,67 +248,67 @@ discard block |
||
248 | 248 | 'wpeditor_args' => array() |
249 | 249 | ); |
250 | 250 | // merge defaults with passed arguments |
251 | - $_fields = wp_parse_args( $field_atts, $defaults); |
|
252 | - extract( $_fields ); |
|
251 | + $_fields = wp_parse_args($field_atts, $defaults); |
|
252 | + extract($_fields); |
|
253 | 253 | // generate label |
254 | - $label = empty($label) ? '' : '<label for="' . $id . '">' . $label . '</label>'; |
|
254 | + $label = empty($label) ? '' : '<label for="'.$id.'">'.$label.'</label>'; |
|
255 | 255 | // generate field name |
256 | - $f_name = !empty($unique_id) ? $field_name . '[' . $unique_id . ']' : $field_name; |
|
256 | + $f_name = ! empty($unique_id) ? $field_name.'['.$unique_id.']' : $field_name; |
|
257 | 257 | |
258 | 258 | //tabindex |
259 | - $tabindex_str = !empty( $tabindex ) ? ' tabindex="' . $tabindex . '"' : ''; |
|
259 | + $tabindex_str = ! empty($tabindex) ? ' tabindex="'.$tabindex.'"' : ''; |
|
260 | 260 | |
261 | 261 | //we determine what we're building based on the type |
262 | - switch ( $type ) { |
|
262 | + switch ($type) { |
|
263 | 263 | |
264 | 264 | case 'textarea' : |
265 | - $fld = '<textarea id="' . $id . '" class="' . $class . '" rows="' . $dimensions[1] . '" cols="' . $dimensions[0] . '" name="' . $f_name . '"' . $tabindex_str . '>' . $value . '</textarea>'; |
|
265 | + $fld = '<textarea id="'.$id.'" class="'.$class.'" rows="'.$dimensions[1].'" cols="'.$dimensions[0].'" name="'.$f_name.'"'.$tabindex_str.'>'.$value.'</textarea>'; |
|
266 | 266 | $fld .= $extra_desc; |
267 | 267 | break; |
268 | 268 | |
269 | 269 | case 'checkbox' : |
270 | 270 | $c_input = ''; |
271 | - if ( is_array($value) ) { |
|
272 | - foreach ( $value as $key => $val ) { |
|
273 | - $c_id = $field_name . '_' . $value; |
|
274 | - $c_class = isset($classes[$key]) ? ' class="' . $classes[$key] . '" ' : ''; |
|
275 | - $c_label = isset($labels[$key]) ? '<label for="' . $c_id . '">' . $labels[$key] . '</label>' : ''; |
|
276 | - $checked = !empty($default) && $default == $val ? ' checked="checked" ' : ''; |
|
277 | - $c_input .= '<input name="' . $f_name . '[]" type="checkbox" id="' . $c_id . '"' . $c_class . 'value="' . $val . '"' . $checked . $tabindex_str . ' />' . "\n" . $c_label; |
|
271 | + if (is_array($value)) { |
|
272 | + foreach ($value as $key => $val) { |
|
273 | + $c_id = $field_name.'_'.$value; |
|
274 | + $c_class = isset($classes[$key]) ? ' class="'.$classes[$key].'" ' : ''; |
|
275 | + $c_label = isset($labels[$key]) ? '<label for="'.$c_id.'">'.$labels[$key].'</label>' : ''; |
|
276 | + $checked = ! empty($default) && $default == $val ? ' checked="checked" ' : ''; |
|
277 | + $c_input .= '<input name="'.$f_name.'[]" type="checkbox" id="'.$c_id.'"'.$c_class.'value="'.$val.'"'.$checked.$tabindex_str.' />'."\n".$c_label; |
|
278 | 278 | } |
279 | 279 | $fld = $c_input; |
280 | 280 | } else { |
281 | - $checked = !empty($default) && $default == $val ? 'checked="checked" ' : ''; |
|
282 | - $fld = '<input name="'. $f_name . '" type="checkbox" id="' . $id . '" class="' . $class . '" value="' . $value . '"' . $checked . $tabindex_str . ' />' . "\n"; |
|
281 | + $checked = ! empty($default) && $default == $val ? 'checked="checked" ' : ''; |
|
282 | + $fld = '<input name="'.$f_name.'" type="checkbox" id="'.$id.'" class="'.$class.'" value="'.$value.'"'.$checked.$tabindex_str.' />'."\n"; |
|
283 | 283 | } |
284 | 284 | break; |
285 | 285 | |
286 | 286 | case 'radio' : |
287 | 287 | $c_input = ''; |
288 | - if ( is_array($value) ) { |
|
289 | - foreach ( $value as $key => $val ) { |
|
290 | - $c_id = $field_name . '_' . $value; |
|
291 | - $c_class = isset($classes[$key]) ? 'class="' . $classes[$key] . '" ' : ''; |
|
292 | - $c_label = isset($labels[$key]) ? '<label for="' . $c_id . '">' . $labels[$key] . '</label>' : ''; |
|
293 | - $checked = !empty($default) && $default == $val ? ' checked="checked" ' : ''; |
|
294 | - $c_input .= '<input name="' . $f_name . '" type="checkbox" id="' . $c_id . '"' . $c_class . 'value="' . $val . '"' . $checked . $tabindex_str . ' />' . "\n" . $c_label; |
|
288 | + if (is_array($value)) { |
|
289 | + foreach ($value as $key => $val) { |
|
290 | + $c_id = $field_name.'_'.$value; |
|
291 | + $c_class = isset($classes[$key]) ? 'class="'.$classes[$key].'" ' : ''; |
|
292 | + $c_label = isset($labels[$key]) ? '<label for="'.$c_id.'">'.$labels[$key].'</label>' : ''; |
|
293 | + $checked = ! empty($default) && $default == $val ? ' checked="checked" ' : ''; |
|
294 | + $c_input .= '<input name="'.$f_name.'" type="checkbox" id="'.$c_id.'"'.$c_class.'value="'.$val.'"'.$checked.$tabindex_str.' />'."\n".$c_label; |
|
295 | 295 | } |
296 | 296 | $fld = $c_input; |
297 | 297 | } else { |
298 | - $checked = !empty($default) && $default == $val ? 'checked="checked" ' : ''; |
|
299 | - $fld = '<input name="'. $f_name . '" type="checkbox" id="' . $id . '" class="' . $class . '" value="' . $value . '"' . $checked . $tabindex_str . ' />' . "\n"; |
|
298 | + $checked = ! empty($default) && $default == $val ? 'checked="checked" ' : ''; |
|
299 | + $fld = '<input name="'.$f_name.'" type="checkbox" id="'.$id.'" class="'.$class.'" value="'.$value.'"'.$checked.$tabindex_str.' />'."\n"; |
|
300 | 300 | } |
301 | 301 | break; |
302 | 302 | |
303 | 303 | case 'hidden' : |
304 | - $fld = '<input name="' . $f_name . '" type="hidden" id="' . $id . '" class="' . $class . '" value="' . $value . '" />' . "\n"; |
|
304 | + $fld = '<input name="'.$f_name.'" type="hidden" id="'.$id.'" class="'.$class.'" value="'.$value.'" />'."\n"; |
|
305 | 305 | break; |
306 | 306 | |
307 | 307 | case 'select' : |
308 | - $fld = '<select name="' . $f_name . '" class="' . $class . '" id="' . $id . '"' . $tabindex_str . '>' . "\n"; |
|
309 | - foreach ( $value as $key => $val ) { |
|
310 | - $checked = !empty($default) && $default == $val ? ' selected="selected"' : ''; |
|
311 | - $fld .= "\t" . '<option value="' . $val . '"' . $checked . '>' . $labels[$key] . '</option>' . "\n"; |
|
308 | + $fld = '<select name="'.$f_name.'" class="'.$class.'" id="'.$id.'"'.$tabindex_str.'>'."\n"; |
|
309 | + foreach ($value as $key => $val) { |
|
310 | + $checked = ! empty($default) && $default == $val ? ' selected="selected"' : ''; |
|
311 | + $fld .= "\t".'<option value="'.$val.'"'.$checked.'>'.$labels[$key].'</option>'."\n"; |
|
312 | 312 | } |
313 | 313 | $fld .= '</select>'; |
314 | 314 | break; |
@@ -320,21 +320,21 @@ discard block |
||
320 | 320 | 'editor_class' => $class, |
321 | 321 | 'tabindex' => $tabindex |
322 | 322 | ); |
323 | - $editor_settings = array_merge( $wpeditor_args, $editor_settings ); |
|
323 | + $editor_settings = array_merge($wpeditor_args, $editor_settings); |
|
324 | 324 | ob_start(); |
325 | - wp_editor( $value, $id, $editor_settings ); |
|
325 | + wp_editor($value, $id, $editor_settings); |
|
326 | 326 | $editor = ob_get_contents(); |
327 | 327 | ob_end_clean(); |
328 | 328 | $fld = $editor; |
329 | 329 | break; |
330 | 330 | |
331 | 331 | default : //'text fields' |
332 | - $fld = '<input name="' . $f_name . '" type="text" id="' . $id . '" class="' . $class . '" value="' . $value . '"' . $tabindex_str . ' />' . "\n"; |
|
332 | + $fld = '<input name="'.$f_name.'" type="text" id="'.$id.'" class="'.$class.'" value="'.$value.'"'.$tabindex_str.' />'."\n"; |
|
333 | 333 | $fld .= $extra_desc; |
334 | 334 | |
335 | 335 | } |
336 | 336 | |
337 | - $form_fields[ $field_name ] = array( 'label' => $label, 'field' => $fld ); |
|
337 | + $form_fields[$field_name] = array('label' => $label, 'field' => $fld); |
|
338 | 338 | } |
339 | 339 | |
340 | 340 | return $form_fields; |
@@ -363,19 +363,19 @@ discard block |
||
363 | 363 | */ |
364 | 364 | static public function select_input($name, $values, $default = '', $parameters = '', $class = '', $autosize = true) { |
365 | 365 | //if $values was submitted in the wrong format, convert it over |
366 | - if(!empty($values) && (!array_key_exists(0,$values) || !is_array($values[0]))){ |
|
367 | - $converted_values=array(); |
|
368 | - foreach($values as $id=>$text){ |
|
369 | - $converted_values[]=array('id'=>$id,'text'=>$text); |
|
366 | + if ( ! empty($values) && ( ! array_key_exists(0, $values) || ! is_array($values[0]))) { |
|
367 | + $converted_values = array(); |
|
368 | + foreach ($values as $id=>$text) { |
|
369 | + $converted_values[] = array('id'=>$id, 'text'=>$text); |
|
370 | 370 | } |
371 | - $values=$converted_values; |
|
371 | + $values = $converted_values; |
|
372 | 372 | } |
373 | 373 | |
374 | - $field = '<select id="' . EEH_Formatter::ee_tep_output_string($name) . '" name="' . EEH_Formatter::ee_tep_output_string($name) . '"'; |
|
374 | + $field = '<select id="'.EEH_Formatter::ee_tep_output_string($name).'" name="'.EEH_Formatter::ee_tep_output_string($name).'"'; |
|
375 | 375 | //Debug |
376 | 376 | //EEH_Debug_Tools::printr( $values, '$values <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); |
377 | - if ( EEH_Formatter::ee_tep_not_null($parameters)) |
|
378 | - $field .= ' ' . $parameters; |
|
377 | + if (EEH_Formatter::ee_tep_not_null($parameters)) |
|
378 | + $field .= ' '.$parameters; |
|
379 | 379 | if ($autosize) { |
380 | 380 | $size = 'med'; |
381 | 381 | for ($ii = 0, $ni = sizeof($values); $ii < $ni; $ii++) { |
@@ -388,21 +388,21 @@ discard block |
||
388 | 388 | $size = ''; |
389 | 389 | } |
390 | 390 | |
391 | - $field .= ' class="' . $class . ' ' . $size . '">'; |
|
391 | + $field .= ' class="'.$class.' '.$size.'">'; |
|
392 | 392 | |
393 | 393 | if (empty($default) && isset($GLOBALS[$name])) |
394 | 394 | $default = stripslashes($GLOBALS[$name]); |
395 | 395 | |
396 | 396 | |
397 | 397 | for ($i = 0, $n = sizeof($values); $i < $n; $i++) { |
398 | - $field .= '<option value="' . $values[$i]['id'] . '"'; |
|
398 | + $field .= '<option value="'.$values[$i]['id'].'"'; |
|
399 | 399 | if ($default == $values[$i]['id']) { |
400 | 400 | $field .= ' selected = "selected"'; |
401 | 401 | } |
402 | - if ( isset( $values[$i]['class'] ) ) { |
|
403 | - $field .= ' class="' . $values[$i]['class'] . '"'; |
|
402 | + if (isset($values[$i]['class'])) { |
|
403 | + $field .= ' class="'.$values[$i]['class'].'"'; |
|
404 | 404 | } |
405 | - $field .= '>' . $values[$i]['text'] . '</option>'; |
|
405 | + $field .= '>'.$values[$i]['text'].'</option>'; |
|
406 | 406 | } |
407 | 407 | $field .= '</select>'; |
408 | 408 | |
@@ -420,38 +420,38 @@ discard block |
||
420 | 420 | * @param string $question_groups |
421 | 421 | * @return string HTML |
422 | 422 | */ |
423 | - static function generate_question_groups_html( $question_groups = array(), $group_wrapper = 'fieldset' ) { |
|
423 | + static function generate_question_groups_html($question_groups = array(), $group_wrapper = 'fieldset') { |
|
424 | 424 | |
425 | 425 | $html = ''; |
426 | - $before_question_group_questions = apply_filters( 'FHEE__EEH_Form_Fields__generate_question_groups_html__before_question_group_questions', '' ); |
|
427 | - $after_question_group_questions = apply_filters( 'FHEE__EEH_Form_Fields__generate_question_groups_html__after_question_group_questions', '' ); |
|
426 | + $before_question_group_questions = apply_filters('FHEE__EEH_Form_Fields__generate_question_groups_html__before_question_group_questions', ''); |
|
427 | + $after_question_group_questions = apply_filters('FHEE__EEH_Form_Fields__generate_question_groups_html__after_question_group_questions', ''); |
|
428 | 428 | |
429 | - if ( ! empty( $question_groups )) { |
|
429 | + if ( ! empty($question_groups)) { |
|
430 | 430 | //EEH_Debug_Tools::printr( $question_groups, '$question_groups <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); |
431 | 431 | // loop thru question groups |
432 | - foreach ( $question_groups as $QSG ) { |
|
432 | + foreach ($question_groups as $QSG) { |
|
433 | 433 | // check that questions exist |
434 | - if ( ! empty( $QSG['QSG_questions'] )) { |
|
434 | + if ( ! empty($QSG['QSG_questions'])) { |
|
435 | 435 | // use fieldsets |
436 | - $html .= "\n\t" . '<' . $group_wrapper . ' class="espresso-question-group-wrap" id="' . $QSG['QSG_identifier'] . '">'; |
|
436 | + $html .= "\n\t".'<'.$group_wrapper.' class="espresso-question-group-wrap" id="'.$QSG['QSG_identifier'].'">'; |
|
437 | 437 | // group_name |
438 | - $html .= $QSG['QSG_show_group_name'] ? "\n\t\t" . '<h5 class="espresso-question-group-title-h5 section-title">' . self::prep_answer( $QSG['QSG_name'] ) . '</h5>' : ''; |
|
438 | + $html .= $QSG['QSG_show_group_name'] ? "\n\t\t".'<h5 class="espresso-question-group-title-h5 section-title">'.self::prep_answer($QSG['QSG_name']).'</h5>' : ''; |
|
439 | 439 | // group_desc |
440 | - $html .= $QSG['QSG_show_group_desc'] && ! empty( $QSG['QSG_desc'] ) ? '<div class="espresso-question-group-desc-pg">' . self::prep_answer( $QSG['QSG_desc'] ) . '</div>' : ''; |
|
440 | + $html .= $QSG['QSG_show_group_desc'] && ! empty($QSG['QSG_desc']) ? '<div class="espresso-question-group-desc-pg">'.self::prep_answer($QSG['QSG_desc']).'</div>' : ''; |
|
441 | 441 | |
442 | 442 | $html .= $before_question_group_questions; |
443 | 443 | // loop thru questions |
444 | - foreach ( $QSG['QSG_questions'] as $question ) { |
|
444 | + foreach ($QSG['QSG_questions'] as $question) { |
|
445 | 445 | // EEH_Debug_Tools::printr( $question, '$question <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); |
446 | 446 | $QFI = new EE_Question_Form_Input( |
447 | 447 | $question['qst_obj'], |
448 | 448 | $question['ans_obj'], |
449 | 449 | $question |
450 | 450 | ); |
451 | - $html .= self::generate_form_input( $QFI ); |
|
451 | + $html .= self::generate_form_input($QFI); |
|
452 | 452 | } |
453 | 453 | $html .= $after_question_group_questions; |
454 | - $html .= "\n\t" . '</' . $group_wrapper . '>'; |
|
454 | + $html .= "\n\t".'</'.$group_wrapper.'>'; |
|
455 | 455 | } |
456 | 456 | } |
457 | 457 | } |
@@ -471,11 +471,11 @@ discard block |
||
471 | 471 | * @param string $group_wrapper |
472 | 472 | * @return string HTML |
473 | 473 | */ |
474 | - static function generate_question_groups_html2( $question_groups = array(), $q_meta = array(), $from_admin = FALSE, $group_wrapper = 'fieldset' ) { |
|
474 | + static function generate_question_groups_html2($question_groups = array(), $q_meta = array(), $from_admin = FALSE, $group_wrapper = 'fieldset') { |
|
475 | 475 | |
476 | 476 | $html = ''; |
477 | - $before_question_group_questions = apply_filters( 'FHEE__EEH_Form_Fields__generate_question_groups_html__before_question_group_questions', '' ); |
|
478 | - $after_question_group_questions = apply_filters( 'FHEE__EEH_Form_Fields__generate_question_groups_html__after_question_group_questions', '' ); |
|
477 | + $before_question_group_questions = apply_filters('FHEE__EEH_Form_Fields__generate_question_groups_html__before_question_group_questions', ''); |
|
478 | + $after_question_group_questions = apply_filters('FHEE__EEH_Form_Fields__generate_question_groups_html__after_question_group_questions', ''); |
|
479 | 479 | |
480 | 480 | $default_q_meta = array( |
481 | 481 | 'att_nmbr' => 1, |
@@ -484,55 +484,55 @@ discard block |
||
484 | 484 | 'input_id' => '', |
485 | 485 | 'input_class' => '' |
486 | 486 | ); |
487 | - $q_meta = array_merge( $default_q_meta, $q_meta ); |
|
487 | + $q_meta = array_merge($default_q_meta, $q_meta); |
|
488 | 488 | //EEH_Debug_Tools::printr( $q_meta, '$q_meta <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); |
489 | 489 | |
490 | - if ( ! empty( $question_groups )) { |
|
490 | + if ( ! empty($question_groups)) { |
|
491 | 491 | // EEH_Debug_Tools::printr( $question_groups, '$question_groups <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); |
492 | 492 | // loop thru question groups |
493 | - foreach ( $question_groups as $QSG ) { |
|
494 | - if ( $QSG instanceof EE_Question_Group ) { |
|
493 | + foreach ($question_groups as $QSG) { |
|
494 | + if ($QSG instanceof EE_Question_Group) { |
|
495 | 495 | // check that questions exist |
496 | 496 | |
497 | - $where = array( 'QST_deleted' => 0 ); |
|
498 | - if ( ! $from_admin ) { |
|
497 | + $where = array('QST_deleted' => 0); |
|
498 | + if ( ! $from_admin) { |
|
499 | 499 | $where['QST_admin_only'] = 0; |
500 | 500 | } |
501 | - $questions = $QSG->questions( array( $where, 'order_by' => array( 'Question_Group_Question.QGQ_order' => 'ASC' ))); |
|
502 | - if ( ! empty( $questions )) { |
|
501 | + $questions = $QSG->questions(array($where, 'order_by' => array('Question_Group_Question.QGQ_order' => 'ASC'))); |
|
502 | + if ( ! empty($questions)) { |
|
503 | 503 | // use fieldsets |
504 | - $html .= "\n\t" . '<' . $group_wrapper . ' class="espresso-question-group-wrap" id="' . $QSG->get( 'QSG_identifier' ) . '">'; |
|
504 | + $html .= "\n\t".'<'.$group_wrapper.' class="espresso-question-group-wrap" id="'.$QSG->get('QSG_identifier').'">'; |
|
505 | 505 | // group_name |
506 | - if ( $QSG->show_group_name() ) { |
|
507 | - $html .= "\n\t\t" . '<h5 class="espresso-question-group-title-h5 section-title">' . $QSG->get_pretty( 'QSG_name' ) . '</h5>'; |
|
506 | + if ($QSG->show_group_name()) { |
|
507 | + $html .= "\n\t\t".'<h5 class="espresso-question-group-title-h5 section-title">'.$QSG->get_pretty('QSG_name').'</h5>'; |
|
508 | 508 | } |
509 | 509 | // group_desc |
510 | - if ( $QSG->show_group_desc() ) { |
|
511 | - $html .= '<div class="espresso-question-group-desc-pg">' . $QSG->get_pretty( 'QSG_desc' ) . '</div>'; |
|
510 | + if ($QSG->show_group_desc()) { |
|
511 | + $html .= '<div class="espresso-question-group-desc-pg">'.$QSG->get_pretty('QSG_desc').'</div>'; |
|
512 | 512 | } |
513 | 513 | |
514 | 514 | $html .= $before_question_group_questions; |
515 | 515 | // loop thru questions |
516 | - foreach ( $questions as $QST ) { |
|
516 | + foreach ($questions as $QST) { |
|
517 | 517 | $qstn_id = $QST->is_system_question() ? $QST->system_ID() : $QST->ID(); |
518 | 518 | |
519 | 519 | $answer = NULL; |
520 | 520 | |
521 | - if ( isset( $_GET['qstn'] ) && isset( $q_meta['input_id'] ) && isset( $q_meta['att_nmbr'] )) { |
|
521 | + if (isset($_GET['qstn']) && isset($q_meta['input_id']) && isset($q_meta['att_nmbr'])) { |
|
522 | 522 | // check for answer in $_GET in case we are reprocessing a form after an error |
523 | - if ( isset( $_GET['qstn'][ $q_meta['input_id'] ][ $qstn_id ] )) { |
|
524 | - $answer = is_array( $_GET['qstn'][ $q_meta['input_id'] ][ $qstn_id ] ) ? $_GET['qstn'][ $q_meta['input_id'] ][ $qstn_id ] : sanitize_text_field( $_GET['qstn'][ $q_meta['input_id'] ][ $qstn_id ] ); |
|
523 | + if (isset($_GET['qstn'][$q_meta['input_id']][$qstn_id])) { |
|
524 | + $answer = is_array($_GET['qstn'][$q_meta['input_id']][$qstn_id]) ? $_GET['qstn'][$q_meta['input_id']][$qstn_id] : sanitize_text_field($_GET['qstn'][$q_meta['input_id']][$qstn_id]); |
|
525 | 525 | } |
526 | - } else if ( isset( $q_meta['attendee'] ) && $q_meta['attendee'] ) { |
|
526 | + } else if (isset($q_meta['attendee']) && $q_meta['attendee']) { |
|
527 | 527 | //attendee data from the session |
528 | - $answer = isset( $q_meta['attendee'][ $qstn_id ] ) ? $q_meta['attendee'][ $qstn_id ] : NULL; |
|
528 | + $answer = isset($q_meta['attendee'][$qstn_id]) ? $q_meta['attendee'][$qstn_id] : NULL; |
|
529 | 529 | } |
530 | 530 | |
531 | 531 | |
532 | 532 | |
533 | 533 | $QFI = new EE_Question_Form_Input( |
534 | 534 | $QST, |
535 | - EE_Answer::new_instance ( array( |
|
535 | + EE_Answer::new_instance(array( |
|
536 | 536 | 'ANS_ID'=> 0, |
537 | 537 | 'QST_ID'=> 0, |
538 | 538 | 'REG_ID'=> 0, |
@@ -541,10 +541,10 @@ discard block |
||
541 | 541 | $q_meta |
542 | 542 | ); |
543 | 543 | //EEH_Debug_Tools::printr( $QFI, '$QFI <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); |
544 | - $html .= self::generate_form_input( $QFI ); |
|
544 | + $html .= self::generate_form_input($QFI); |
|
545 | 545 | } |
546 | 546 | $html .= $after_question_group_questions; |
547 | - $html .= "\n\t" . '</' . $group_wrapper . '>'; |
|
547 | + $html .= "\n\t".'</'.$group_wrapper.'>'; |
|
548 | 548 | } |
549 | 549 | } |
550 | 550 | } |
@@ -564,63 +564,63 @@ discard block |
||
564 | 564 | * @param EE_Question_Form_Input $QFI |
565 | 565 | * @return string HTML |
566 | 566 | */ |
567 | - static function generate_form_input( EE_Question_Form_Input $QFI ) { |
|
568 | - if ( isset( $QFI->QST_admin_only) && $QFI->QST_admin_only && ! is_admin() ) { |
|
567 | + static function generate_form_input(EE_Question_Form_Input $QFI) { |
|
568 | + if (isset($QFI->QST_admin_only) && $QFI->QST_admin_only && ! is_admin()) { |
|
569 | 569 | return ''; |
570 | 570 | } |
571 | 571 | |
572 | - $QFI = self::_load_system_dropdowns( $QFI ); |
|
573 | - $QFI = self::_load_specialized_dropdowns( $QFI ); |
|
572 | + $QFI = self::_load_system_dropdowns($QFI); |
|
573 | + $QFI = self::_load_specialized_dropdowns($QFI); |
|
574 | 574 | |
575 | 575 | //we also need to verify |
576 | 576 | |
577 | 577 | $display_text = $QFI->get('QST_display_text'); |
578 | 578 | $input_name = $QFI->get('QST_input_name'); |
579 | - $answer = EE_Registry::instance()->REQ->is_set( $input_name ) ? EE_Registry::instance()->REQ->get( $input_name ) : $QFI->get('ANS_value'); |
|
579 | + $answer = EE_Registry::instance()->REQ->is_set($input_name) ? EE_Registry::instance()->REQ->get($input_name) : $QFI->get('ANS_value'); |
|
580 | 580 | $input_id = $QFI->get('QST_input_id'); |
581 | 581 | $input_class = $QFI->get('QST_input_class'); |
582 | 582 | // $disabled = $QFI->get('QST_disabled') ? ' disabled="disabled"' : ''; |
583 | 583 | $disabled = $QFI->get('QST_disabled') ? TRUE : FALSE; |
584 | - $required_label = apply_filters(' FHEE__EEH_Form_Fields__generate_form_input__required_label', '<em>*</em>' ); |
|
584 | + $required_label = apply_filters(' FHEE__EEH_Form_Fields__generate_form_input__required_label', '<em>*</em>'); |
|
585 | 585 | $QST_required = $QFI->get('QST_required'); |
586 | - $required = $QST_required ? array( 'label' => $required_label, 'class' => 'required needs-value', 'title' => $QST_required ) : array(); |
|
587 | - $use_html_entities = $QFI->get_meta( 'htmlentities' ); |
|
588 | - $required_text = $QFI->get('QST_required_text') != '' ? $QFI->get('QST_required_text') : __( 'This field is required', 'event_espresso' ); |
|
589 | - $required_text = $QST_required ? "\n\t\t\t" . '<div class="required-text hidden">' . self::prep_answer( $required_text, $use_html_entities ) . '</div>' : ''; |
|
586 | + $required = $QST_required ? array('label' => $required_label, 'class' => 'required needs-value', 'title' => $QST_required) : array(); |
|
587 | + $use_html_entities = $QFI->get_meta('htmlentities'); |
|
588 | + $required_text = $QFI->get('QST_required_text') != '' ? $QFI->get('QST_required_text') : __('This field is required', 'event_espresso'); |
|
589 | + $required_text = $QST_required ? "\n\t\t\t".'<div class="required-text hidden">'.self::prep_answer($required_text, $use_html_entities).'</div>' : ''; |
|
590 | 590 | $label_class = 'espresso-form-input-lbl'; |
591 | - $QST_options = $QFI->options(true,$answer); |
|
592 | - $options = is_array( $QST_options ) ? self::prep_answer_options( $QST_options ) : array(); |
|
591 | + $QST_options = $QFI->options(true, $answer); |
|
592 | + $options = is_array($QST_options) ? self::prep_answer_options($QST_options) : array(); |
|
593 | 593 | $system_ID = $QFI->get('QST_system'); |
594 | - $label_b4 = $QFI->get_meta( 'label_b4' ); |
|
595 | - $use_desc_4_label = $QFI->get_meta( 'use_desc_4_label' ); |
|
594 | + $label_b4 = $QFI->get_meta('label_b4'); |
|
595 | + $use_desc_4_label = $QFI->get_meta('use_desc_4_label'); |
|
596 | 596 | |
597 | 597 | |
598 | - switch ( $QFI->get('QST_type') ){ |
|
598 | + switch ($QFI->get('QST_type')) { |
|
599 | 599 | |
600 | 600 | case 'TEXTAREA' : |
601 | - return EEH_Form_Fields::textarea( $display_text, $answer, $input_name, $input_id, $input_class, array(), $required, $required_text, $label_class, $disabled, $system_ID, $use_html_entities ); |
|
601 | + return EEH_Form_Fields::textarea($display_text, $answer, $input_name, $input_id, $input_class, array(), $required, $required_text, $label_class, $disabled, $system_ID, $use_html_entities); |
|
602 | 602 | break; |
603 | 603 | |
604 | 604 | case 'DROPDOWN' : |
605 | - return EEH_Form_Fields::select( $display_text, $answer, $options, $input_name, $input_id, $input_class, $required, $required_text, $label_class, $disabled, $system_ID, $use_html_entities, TRUE ); |
|
605 | + return EEH_Form_Fields::select($display_text, $answer, $options, $input_name, $input_id, $input_class, $required, $required_text, $label_class, $disabled, $system_ID, $use_html_entities, TRUE); |
|
606 | 606 | break; |
607 | 607 | |
608 | 608 | |
609 | 609 | case 'RADIO_BTN' : |
610 | - return EEH_Form_Fields::radio( $display_text, $answer, $options, $input_name, $input_id, $input_class, $required, $required_text, $label_class, $disabled, $system_ID, $use_html_entities, $label_b4, $use_desc_4_label ); |
|
610 | + return EEH_Form_Fields::radio($display_text, $answer, $options, $input_name, $input_id, $input_class, $required, $required_text, $label_class, $disabled, $system_ID, $use_html_entities, $label_b4, $use_desc_4_label); |
|
611 | 611 | break; |
612 | 612 | |
613 | 613 | case 'CHECKBOX' : |
614 | - return EEH_Form_Fields::checkbox( $display_text, $answer, $options, $input_name, $input_id, $input_class, $required, $required_text, $label_class, $disabled, $label_b4, $system_ID, $use_html_entities ); |
|
614 | + return EEH_Form_Fields::checkbox($display_text, $answer, $options, $input_name, $input_id, $input_class, $required, $required_text, $label_class, $disabled, $label_b4, $system_ID, $use_html_entities); |
|
615 | 615 | break; |
616 | 616 | |
617 | 617 | case 'DATE' : |
618 | - return EEH_Form_Fields::datepicker( $display_text, $answer, $input_name, $input_id, $input_class, $required, $required_text, $label_class, $disabled, $system_ID, $use_html_entities ); |
|
618 | + return EEH_Form_Fields::datepicker($display_text, $answer, $input_name, $input_id, $input_class, $required, $required_text, $label_class, $disabled, $system_ID, $use_html_entities); |
|
619 | 619 | break; |
620 | 620 | |
621 | 621 | case 'TEXT' : |
622 | 622 | default: |
623 | - return EEH_Form_Fields::text( $display_text, $answer, $input_name, $input_id, $input_class, $required, $required_text, $label_class, $disabled, $system_ID, $use_html_entities ); |
|
623 | + return EEH_Form_Fields::text($display_text, $answer, $input_name, $input_id, $input_class, $required, $required_text, $label_class, $disabled, $system_ID, $use_html_entities); |
|
624 | 624 | break; |
625 | 625 | |
626 | 626 | } |
@@ -646,31 +646,31 @@ discard block |
||
646 | 646 | * @param string $disabled disabled="disabled" or null |
647 | 647 | * @return string HTML |
648 | 648 | */ |
649 | - static function text( $question = FALSE, $answer = NULL, $name = FALSE, $id = '', $class = '', $required = FALSE, $required_text = '', $label_class = '', $disabled = FALSE, $system_ID = FALSE, $use_html_entities = TRUE ) { |
|
649 | + static function text($question = FALSE, $answer = NULL, $name = FALSE, $id = '', $class = '', $required = FALSE, $required_text = '', $label_class = '', $disabled = FALSE, $system_ID = FALSE, $use_html_entities = TRUE) { |
|
650 | 650 | // need these |
651 | - if ( ! $question || ! $name ) { |
|
651 | + if ( ! $question || ! $name) { |
|
652 | 652 | return NULL; |
653 | 653 | } |
654 | 654 | // prep the answer |
655 | - $answer = is_array( $answer ) ? '' : self::prep_answer( $answer, $use_html_entities ); |
|
655 | + $answer = is_array($answer) ? '' : self::prep_answer($answer, $use_html_entities); |
|
656 | 656 | // prep the required array |
657 | - $required = self::prep_required( $required ); |
|
657 | + $required = self::prep_required($required); |
|
658 | 658 | // set disabled tag |
659 | - $disabled = $answer === NULL || ! $disabled ? '' : ' disabled="disabled"'; |
|
659 | + $disabled = $answer === NULL || ! $disabled ? '' : ' disabled="disabled"'; |
|
660 | 660 | // ya gots ta have style man!!! |
661 | 661 | $txt_class = is_admin() ? 'regular-text' : 'espresso-text-inp'; |
662 | - $class = empty( $class ) ? $txt_class : $class; |
|
663 | - $class .= ! empty( $system_ID ) ? ' ' . $system_ID : ''; |
|
664 | - $extra = apply_filters( 'FHEE__EEH_Form_Fields__additional_form_field_attributes', '' ); |
|
662 | + $class = empty($class) ? $txt_class : $class; |
|
663 | + $class .= ! empty($system_ID) ? ' '.$system_ID : ''; |
|
664 | + $extra = apply_filters('FHEE__EEH_Form_Fields__additional_form_field_attributes', ''); |
|
665 | 665 | |
666 | - $label_html = $required_text . "\n\t\t\t" . '<label for="' . $name . '" class="' . $label_class . '">' . self::prep_question( $question ) . $required['label'] . '</label><br/>'; |
|
666 | + $label_html = $required_text."\n\t\t\t".'<label for="'.$name.'" class="'.$label_class.'">'.self::prep_question($question).$required['label'].'</label><br/>'; |
|
667 | 667 | // filter label but ensure required text comes before it |
668 | - $label_html = apply_filters( 'FHEE__EEH_Form_Fields__label_html', $label_html, $required_text ); |
|
668 | + $label_html = apply_filters('FHEE__EEH_Form_Fields__label_html', $label_html, $required_text); |
|
669 | 669 | |
670 | - $input_html = "\n\t\t\t" . '<input type="text" name="' . $name . '" id="' . $id . '" class="' . $class . ' ' . $required['class'] . '" value="' . esc_attr( $answer ) . '" title="' . esc_attr( $required['msg'] ) . '" ' . $disabled .' ' . $extra . '/>'; |
|
670 | + $input_html = "\n\t\t\t".'<input type="text" name="'.$name.'" id="'.$id.'" class="'.$class.' '.$required['class'].'" value="'.esc_attr($answer).'" title="'.esc_attr($required['msg']).'" '.$disabled.' '.$extra.'/>'; |
|
671 | 671 | |
672 | - $input_html = apply_filters( 'FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id ); |
|
673 | - return $label_html . $input_html; |
|
672 | + $input_html = apply_filters('FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id); |
|
673 | + return $label_html.$input_html; |
|
674 | 674 | |
675 | 675 | } |
676 | 676 | |
@@ -692,35 +692,35 @@ discard block |
||
692 | 692 | * @param string $disabled disabled="disabled" or null |
693 | 693 | * @return string HTML |
694 | 694 | */ |
695 | - static function textarea( $question = FALSE, $answer = NULL, $name = FALSE, $id = '', $class = '', $dimensions = FALSE, $required = FALSE, $required_text = '', $label_class = '', $disabled = FALSE, $system_ID = FALSE, $use_html_entities = TRUE ) { |
|
695 | + static function textarea($question = FALSE, $answer = NULL, $name = FALSE, $id = '', $class = '', $dimensions = FALSE, $required = FALSE, $required_text = '', $label_class = '', $disabled = FALSE, $system_ID = FALSE, $use_html_entities = TRUE) { |
|
696 | 696 | // need these |
697 | - if ( ! $question || ! $name ) { |
|
697 | + if ( ! $question || ! $name) { |
|
698 | 698 | return NULL; |
699 | 699 | } |
700 | 700 | // prep the answer |
701 | - $answer = is_array( $answer ) ? '' : self::prep_answer( $answer, $use_html_entities ); |
|
701 | + $answer = is_array($answer) ? '' : self::prep_answer($answer, $use_html_entities); |
|
702 | 702 | // prep the required array |
703 | - $required = self::prep_required( $required ); |
|
703 | + $required = self::prep_required($required); |
|
704 | 704 | // make sure $dimensions is an array |
705 | - $dimensions = is_array( $dimensions ) ? $dimensions : array(); |
|
705 | + $dimensions = is_array($dimensions) ? $dimensions : array(); |
|
706 | 706 | // and set some defaults |
707 | - $dimensions = array_merge( array( 'rows' => 3, 'cols' => 40 ), $dimensions ); |
|
707 | + $dimensions = array_merge(array('rows' => 3, 'cols' => 40), $dimensions); |
|
708 | 708 | // set disabled tag |
709 | - $disabled = $answer === NULL || ! $disabled ? '' : ' disabled="disabled"'; |
|
709 | + $disabled = $answer === NULL || ! $disabled ? '' : ' disabled="disabled"'; |
|
710 | 710 | // ya gots ta have style man!!! |
711 | 711 | $txt_class = is_admin() ? 'regular-text' : 'espresso-textarea-inp'; |
712 | - $class = empty( $class ) ? $txt_class : $class; |
|
713 | - $class .= ! empty( $system_ID ) ? ' ' . $system_ID : ''; |
|
714 | - $extra = apply_filters( 'FHEE__EEH_Form_Fields__additional_form_field_attributes', '' ); |
|
712 | + $class = empty($class) ? $txt_class : $class; |
|
713 | + $class .= ! empty($system_ID) ? ' '.$system_ID : ''; |
|
714 | + $extra = apply_filters('FHEE__EEH_Form_Fields__additional_form_field_attributes', ''); |
|
715 | 715 | |
716 | - $label_html = $required_text . "\n\t\t\t" . '<label for="' . $name . '" class="' . $label_class . '">' . self::prep_question( $question ) . $required['label'] . '</label><br/>'; |
|
716 | + $label_html = $required_text."\n\t\t\t".'<label for="'.$name.'" class="'.$label_class.'">'.self::prep_question($question).$required['label'].'</label><br/>'; |
|
717 | 717 | // filter label but ensure required text comes before it |
718 | - $label_html = apply_filters( 'FHEE__EEH_Form_Fields__label_html', $label_html, $required_text ); |
|
718 | + $label_html = apply_filters('FHEE__EEH_Form_Fields__label_html', $label_html, $required_text); |
|
719 | 719 | |
720 | - $input_html = "\n\t\t\t" . '<textarea name="' . $name . '" id="' . $id . '" class="' . $class . ' ' . $required['class'] . '" rows="' . $dimensions['rows'] . '" cols="' . $dimensions['cols'] . '" title="' . $required['msg'] . '" ' . $disabled . ' ' . $extra . '>' . $answer . '</textarea>'; |
|
720 | + $input_html = "\n\t\t\t".'<textarea name="'.$name.'" id="'.$id.'" class="'.$class.' '.$required['class'].'" rows="'.$dimensions['rows'].'" cols="'.$dimensions['cols'].'" title="'.$required['msg'].'" '.$disabled.' '.$extra.'>'.$answer.'</textarea>'; |
|
721 | 721 | |
722 | - $input_html = apply_filters( 'FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id ); |
|
723 | - return $label_html . $input_html; |
|
722 | + $input_html = apply_filters('FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id); |
|
723 | + return $label_html.$input_html; |
|
724 | 724 | |
725 | 725 | } |
726 | 726 | |
@@ -743,47 +743,47 @@ discard block |
||
743 | 743 | * @param string $disabled disabled="disabled" or null |
744 | 744 | * @return string HTML |
745 | 745 | */ |
746 | - static function select( $question = FALSE, $answer = NULL, $options = FALSE, $name = FALSE, $id = '', $class = '', $required = FALSE, $required_text = '', $label_class = '', $disabled = FALSE, $system_ID = FALSE, $use_html_entities = TRUE, $add_please_select_option = FALSE ) { |
|
746 | + static function select($question = FALSE, $answer = NULL, $options = FALSE, $name = FALSE, $id = '', $class = '', $required = FALSE, $required_text = '', $label_class = '', $disabled = FALSE, $system_ID = FALSE, $use_html_entities = TRUE, $add_please_select_option = FALSE) { |
|
747 | 747 | |
748 | 748 | // need these |
749 | - if ( ! $question || ! $name || ! $options || empty( $options ) || ! is_array( $options )) { |
|
749 | + if ( ! $question || ! $name || ! $options || empty($options) || ! is_array($options)) { |
|
750 | 750 | return NULL; |
751 | 751 | } |
752 | 752 | // prep the answer |
753 | - $answer = is_array( $answer ) ? self::prep_answer( array_shift( $answer ), $use_html_entities) : self::prep_answer( $answer, $use_html_entities ); |
|
753 | + $answer = is_array($answer) ? self::prep_answer(array_shift($answer), $use_html_entities) : self::prep_answer($answer, $use_html_entities); |
|
754 | 754 | // prep the required array |
755 | - $required = self::prep_required( $required ); |
|
755 | + $required = self::prep_required($required); |
|
756 | 756 | // set disabled tag |
757 | - $disabled = $answer === NULL || ! $disabled ? '' : ' disabled="disabled"'; |
|
757 | + $disabled = $answer === NULL || ! $disabled ? '' : ' disabled="disabled"'; |
|
758 | 758 | // ya gots ta have style man!!! |
759 | 759 | $txt_class = is_admin() ? 'wide' : 'espresso-select-inp'; |
760 | - $class = empty( $class ) ? $txt_class : $class; |
|
761 | - $class .= ! empty( $system_ID ) ? ' ' . $system_ID : ''; |
|
762 | - $extra = apply_filters( 'FHEE__EEH_Form_Fields__additional_form_field_attributes', '' ); |
|
760 | + $class = empty($class) ? $txt_class : $class; |
|
761 | + $class .= ! empty($system_ID) ? ' '.$system_ID : ''; |
|
762 | + $extra = apply_filters('FHEE__EEH_Form_Fields__additional_form_field_attributes', ''); |
|
763 | 763 | |
764 | - $label_html = $required_text . "\n\t\t\t" . '<label for="' . $name . '" class="' . $label_class . '">' . self::prep_question( $question ) . $required['label'] . '</label><br/>'; |
|
764 | + $label_html = $required_text."\n\t\t\t".'<label for="'.$name.'" class="'.$label_class.'">'.self::prep_question($question).$required['label'].'</label><br/>'; |
|
765 | 765 | // filter label but ensure required text comes before it |
766 | - $label_html = apply_filters( 'FHEE__EEH_Form_Fields__label_html', $label_html, $required_text ); |
|
766 | + $label_html = apply_filters('FHEE__EEH_Form_Fields__label_html', $label_html, $required_text); |
|
767 | 767 | |
768 | - $input_html = "\n\t\t\t" . '<select name="' . $name . '" id="' . $id . '" class="' . $class . ' ' . $required['class'] . '" title="' . esc_attr( $required['msg'] ) . '"' . $disabled . ' ' . $extra . '>'; |
|
768 | + $input_html = "\n\t\t\t".'<select name="'.$name.'" id="'.$id.'" class="'.$class.' '.$required['class'].'" title="'.esc_attr($required['msg']).'"'.$disabled.' '.$extra.'>'; |
|
769 | 769 | // recursively count array elements, to determine total number of options |
770 | - $only_option = count( $options, 1 ) == 1 ? TRUE : FALSE; |
|
771 | - if ( ! $only_option ) { |
|
770 | + $only_option = count($options, 1) == 1 ? TRUE : FALSE; |
|
771 | + if ( ! $only_option) { |
|
772 | 772 | // if there is NO answer set and there are multiple options to choose from, then set the "please select" message as selected |
773 | 773 | $selected = $answer === NULL ? ' selected="selected"' : ''; |
774 | - $input_html .= $add_please_select_option ? "\n\t\t\t\t" . '<option value=""' . $selected . '>' . __(' - please select - ', 'event_espresso') . '</option>' : ''; |
|
774 | + $input_html .= $add_please_select_option ? "\n\t\t\t\t".'<option value=""'.$selected.'>'.__(' - please select - ', 'event_espresso').'</option>' : ''; |
|
775 | 775 | } |
776 | - foreach ( $options as $key => $value ) { |
|
776 | + foreach ($options as $key => $value) { |
|
777 | 777 | // if value is an array, then create option groups, else create regular ol' options |
778 | - $input_html .= is_array( $value ) ? self::_generate_select_option_group( $key, $value, $answer, $use_html_entities ) : self::_generate_select_option( $value->value(), $value->desc(), $answer, $only_option, $use_html_entities ); |
|
778 | + $input_html .= is_array($value) ? self::_generate_select_option_group($key, $value, $answer, $use_html_entities) : self::_generate_select_option($value->value(), $value->desc(), $answer, $only_option, $use_html_entities); |
|
779 | 779 | } |
780 | 780 | |
781 | - $input_html .= "\n\t\t\t" . '</select>'; |
|
781 | + $input_html .= "\n\t\t\t".'</select>'; |
|
782 | 782 | |
783 | - $input_html = apply_filters( 'FHEE__EEH_Form_Fields__select__before_end_wrapper', $input_html, $question, $answer, $name, $id, $class, $system_ID ); |
|
783 | + $input_html = apply_filters('FHEE__EEH_Form_Fields__select__before_end_wrapper', $input_html, $question, $answer, $name, $id, $class, $system_ID); |
|
784 | 784 | |
785 | - $input_html = apply_filters( 'FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id ); |
|
786 | - return $label_html . $input_html; |
|
785 | + $input_html = apply_filters('FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id); |
|
786 | + return $label_html.$input_html; |
|
787 | 787 | |
788 | 788 | } |
789 | 789 | |
@@ -801,12 +801,12 @@ discard block |
||
801 | 801 | * @param boolean $use_html_entities |
802 | 802 | * @return string |
803 | 803 | */ |
804 | - private static function _generate_select_option_group( $opt_group, $QSOs, $answer, $use_html_entities = true ){ |
|
805 | - $html = "\n\t\t\t\t" . '<optgroup label="' . self::prep_option_value( $opt_group ) . '">'; |
|
806 | - foreach ( $QSOs as $QSO ) { |
|
807 | - $html .= self::_generate_select_option( $QSO->value(), $QSO->desc(), $answer, false, $use_html_entities ); |
|
804 | + private static function _generate_select_option_group($opt_group, $QSOs, $answer, $use_html_entities = true) { |
|
805 | + $html = "\n\t\t\t\t".'<optgroup label="'.self::prep_option_value($opt_group).'">'; |
|
806 | + foreach ($QSOs as $QSO) { |
|
807 | + $html .= self::_generate_select_option($QSO->value(), $QSO->desc(), $answer, false, $use_html_entities); |
|
808 | 808 | } |
809 | - $html .= "\n\t\t\t\t" . '</optgroup>'; |
|
809 | + $html .= "\n\t\t\t\t".'</optgroup>'; |
|
810 | 810 | return $html; |
811 | 811 | } |
812 | 812 | |
@@ -821,12 +821,12 @@ discard block |
||
821 | 821 | * @param boolean $use_html_entities |
822 | 822 | * @return string |
823 | 823 | */ |
824 | - private static function _generate_select_option( $key, $value, $answer, $only_option = FALSE, $use_html_entities = true ){ |
|
825 | - $key = self::prep_answer( $key, $use_html_entities ); |
|
826 | - $value = self::prep_answer( $value, $use_html_entities ); |
|
827 | - $value = ! empty( $value ) ? $value : $key; |
|
828 | - $selected = ( $answer == $key || $only_option ) ? ' selected="selected"' : ''; |
|
829 | - return "\n\t\t\t\t" . '<option value="' . self::prep_option_value( $key ) . '"' . $selected . '> ' . $value . ' </option>'; |
|
824 | + private static function _generate_select_option($key, $value, $answer, $only_option = FALSE, $use_html_entities = true) { |
|
825 | + $key = self::prep_answer($key, $use_html_entities); |
|
826 | + $value = self::prep_answer($value, $use_html_entities); |
|
827 | + $value = ! empty($value) ? $value : $key; |
|
828 | + $selected = ($answer == $key || $only_option) ? ' selected="selected"' : ''; |
|
829 | + return "\n\t\t\t\t".'<option value="'.self::prep_option_value($key).'"'.$selected.'> '.$value.' </option>'; |
|
830 | 830 | } |
831 | 831 | |
832 | 832 | |
@@ -850,56 +850,56 @@ discard block |
||
850 | 850 | * @param bool $use_desc_4_label |
851 | 851 | * @return string HTML |
852 | 852 | */ |
853 | - static function radio( $question = FALSE, $answer = NULL, $options = FALSE, $name = FALSE, $id = '', $class = '', $required = FALSE, $required_text = '', $label_class = '', $disabled = FALSE, $system_ID = FALSE, $use_html_entities = TRUE, $label_b4 = FALSE, $use_desc_4_label = FALSE ) { |
|
853 | + static function radio($question = FALSE, $answer = NULL, $options = FALSE, $name = FALSE, $id = '', $class = '', $required = FALSE, $required_text = '', $label_class = '', $disabled = FALSE, $system_ID = FALSE, $use_html_entities = TRUE, $label_b4 = FALSE, $use_desc_4_label = FALSE) { |
|
854 | 854 | // need these |
855 | - if ( ! $question || ! $name || ! $options || empty( $options ) || ! is_array( $options )) { |
|
855 | + if ( ! $question || ! $name || ! $options || empty($options) || ! is_array($options)) { |
|
856 | 856 | return NULL; |
857 | 857 | } |
858 | 858 | // prep the answer |
859 | - $answer = is_array( $answer ) ? '' : self::prep_answer( $answer, $use_html_entities ); |
|
859 | + $answer = is_array($answer) ? '' : self::prep_answer($answer, $use_html_entities); |
|
860 | 860 | // prep the required array |
861 | - $required = self::prep_required( $required ); |
|
861 | + $required = self::prep_required($required); |
|
862 | 862 | // set disabled tag |
863 | - $disabled = $answer === NULL || ! $disabled ? '' : ' disabled="disabled"'; |
|
863 | + $disabled = $answer === NULL || ! $disabled ? '' : ' disabled="disabled"'; |
|
864 | 864 | // ya gots ta have style man!!! |
865 | 865 | $radio_class = is_admin() ? 'ee-admin-radio-lbl' : $label_class; |
866 | - $class = ! empty( $class ) ? $class : 'espresso-radio-btn-inp'; |
|
867 | - $extra = apply_filters( 'FHEE__EEH_Form_Fields__additional_form_field_attributes', '' ); |
|
866 | + $class = ! empty($class) ? $class : 'espresso-radio-btn-inp'; |
|
867 | + $extra = apply_filters('FHEE__EEH_Form_Fields__additional_form_field_attributes', ''); |
|
868 | 868 | |
869 | - $label_html = $required_text . "\n\t\t\t" . '<label class="' . $label_class . '">' . self::prep_question( $question ) . $required['label'] . '</label> '; |
|
869 | + $label_html = $required_text."\n\t\t\t".'<label class="'.$label_class.'">'.self::prep_question($question).$required['label'].'</label> '; |
|
870 | 870 | // filter label but ensure required text comes before it |
871 | - $label_html = apply_filters( 'FHEE__EEH_Form_Fields__label_html', $label_html, $required_text ); |
|
871 | + $label_html = apply_filters('FHEE__EEH_Form_Fields__label_html', $label_html, $required_text); |
|
872 | 872 | |
873 | - $input_html = "\n\t\t\t" . '<ul id="' . $id . '-ul" class="espresso-radio-btn-options-ul ' . $label_class . ' ' . $class . '-ul">'; |
|
873 | + $input_html = "\n\t\t\t".'<ul id="'.$id.'-ul" class="espresso-radio-btn-options-ul '.$label_class.' '.$class.'-ul">'; |
|
874 | 874 | |
875 | - $class .= ! empty( $system_ID ) ? ' ' . $system_ID : ''; |
|
876 | - $class .= ! empty( $required['class'] ) ? ' ' . $required['class'] : ''; |
|
875 | + $class .= ! empty($system_ID) ? ' '.$system_ID : ''; |
|
876 | + $class .= ! empty($required['class']) ? ' '.$required['class'] : ''; |
|
877 | 877 | |
878 | - foreach ( $options as $OPT ) { |
|
879 | - if ( $OPT instanceof EE_Question_Option ) { |
|
880 | - $value = self::prep_option_value( $OPT->value() ); |
|
878 | + foreach ($options as $OPT) { |
|
879 | + if ($OPT instanceof EE_Question_Option) { |
|
880 | + $value = self::prep_option_value($OPT->value()); |
|
881 | 881 | $label = $use_desc_4_label ? $OPT->desc() : $OPT->value(); |
882 | - $size = $use_desc_4_label ? self::get_label_size_class( $OPT->value() . ' ' . $OPT->desc() ) : self::get_label_size_class( $OPT->value() ); |
|
883 | - $desc = $OPT->desc();//no self::prep_answer |
|
884 | - $answer = is_numeric( $value ) && empty( $answer ) ? 0 : $answer; |
|
885 | - $checked = (string)$value == (string)$answer ? ' checked="checked"' : ''; |
|
886 | - $opt = '-' . sanitize_key( $value ); |
|
887 | - |
|
888 | - $input_html .= "\n\t\t\t\t" . '<li' . $size . '>'; |
|
889 | - $input_html .= "\n\t\t\t\t\t" . '<label class="' . $radio_class . ' espresso-radio-btn-lbl">'; |
|
890 | - $input_html .= $label_b4 ? "\n\t\t\t\t\t\t" . '<span>' . $label . '</span>' : ''; |
|
891 | - $input_html .= "\n\t\t\t\t\t\t" . '<input type="radio" name="' . $name . '" id="' . $id . $opt . '" class="' . $class . '" value="' . $value . '" title="' . esc_attr( $required['msg'] ) . '" ' . $disabled . $checked . ' ' . $extra . '/>'; |
|
892 | - $input_html .= ! $label_b4 ? "\n\t\t\t\t\t\t" . '<span class="espresso-radio-btn-desc">' . $label . '</span>' : ''; |
|
893 | - $input_html .= "\n\t\t\t\t\t" . '</label>'; |
|
894 | - $input_html .= $use_desc_4_label ? '' : '<span class="espresso-radio-btn-option-desc small-text grey-text">' . $desc . '</span>'; |
|
895 | - $input_html .= "\n\t\t\t\t" . '</li>'; |
|
882 | + $size = $use_desc_4_label ? self::get_label_size_class($OPT->value().' '.$OPT->desc()) : self::get_label_size_class($OPT->value()); |
|
883 | + $desc = $OPT->desc(); //no self::prep_answer |
|
884 | + $answer = is_numeric($value) && empty($answer) ? 0 : $answer; |
|
885 | + $checked = (string) $value == (string) $answer ? ' checked="checked"' : ''; |
|
886 | + $opt = '-'.sanitize_key($value); |
|
887 | + |
|
888 | + $input_html .= "\n\t\t\t\t".'<li'.$size.'>'; |
|
889 | + $input_html .= "\n\t\t\t\t\t".'<label class="'.$radio_class.' espresso-radio-btn-lbl">'; |
|
890 | + $input_html .= $label_b4 ? "\n\t\t\t\t\t\t".'<span>'.$label.'</span>' : ''; |
|
891 | + $input_html .= "\n\t\t\t\t\t\t".'<input type="radio" name="'.$name.'" id="'.$id.$opt.'" class="'.$class.'" value="'.$value.'" title="'.esc_attr($required['msg']).'" '.$disabled.$checked.' '.$extra.'/>'; |
|
892 | + $input_html .= ! $label_b4 ? "\n\t\t\t\t\t\t".'<span class="espresso-radio-btn-desc">'.$label.'</span>' : ''; |
|
893 | + $input_html .= "\n\t\t\t\t\t".'</label>'; |
|
894 | + $input_html .= $use_desc_4_label ? '' : '<span class="espresso-radio-btn-option-desc small-text grey-text">'.$desc.'</span>'; |
|
895 | + $input_html .= "\n\t\t\t\t".'</li>'; |
|
896 | 896 | } |
897 | 897 | } |
898 | 898 | |
899 | - $input_html .= "\n\t\t\t" . '</ul>'; |
|
899 | + $input_html .= "\n\t\t\t".'</ul>'; |
|
900 | 900 | |
901 | - $input_html = apply_filters( 'FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id ); |
|
902 | - return $label_html . $input_html; |
|
901 | + $input_html = apply_filters('FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id); |
|
902 | + return $label_html.$input_html; |
|
903 | 903 | |
904 | 904 | } |
905 | 905 | |
@@ -922,65 +922,65 @@ discard block |
||
922 | 922 | * @param string $disabled disabled="disabled" or null |
923 | 923 | * @return string HTML |
924 | 924 | */ |
925 | - static function checkbox( $question = FALSE, $answer = NULL, $options = FALSE, $name = FALSE, $id = '', $class = '', $required = FALSE, $required_text = '', $label_class = '', $disabled = FALSE, $label_b4 = FALSE, $system_ID = FALSE, $use_html_entities = TRUE ) { |
|
925 | + static function checkbox($question = FALSE, $answer = NULL, $options = FALSE, $name = FALSE, $id = '', $class = '', $required = FALSE, $required_text = '', $label_class = '', $disabled = FALSE, $label_b4 = FALSE, $system_ID = FALSE, $use_html_entities = TRUE) { |
|
926 | 926 | // need these |
927 | - if ( ! $question || ! $name || ! $options || empty( $options ) || ! is_array( $options )) { |
|
927 | + if ( ! $question || ! $name || ! $options || empty($options) || ! is_array($options)) { |
|
928 | 928 | return NULL; |
929 | 929 | } |
930 | - $answer = maybe_unserialize( $answer ); |
|
930 | + $answer = maybe_unserialize($answer); |
|
931 | 931 | |
932 | 932 | // prep the answer(s) |
933 | - $answer = is_array( $answer ) ? $answer : array( sanitize_key( $answer ) => $answer ); |
|
933 | + $answer = is_array($answer) ? $answer : array(sanitize_key($answer) => $answer); |
|
934 | 934 | |
935 | - foreach ( $answer as $key => $value ) { |
|
936 | - $key = self::prep_option_value( $key ); |
|
937 | - $answer[$key] = self::prep_answer( $value, $use_html_entities ); |
|
935 | + foreach ($answer as $key => $value) { |
|
936 | + $key = self::prep_option_value($key); |
|
937 | + $answer[$key] = self::prep_answer($value, $use_html_entities); |
|
938 | 938 | } |
939 | 939 | |
940 | 940 | // prep the required array |
941 | - $required = self::prep_required( $required ); |
|
941 | + $required = self::prep_required($required); |
|
942 | 942 | // set disabled tag |
943 | - $disabled = $answer === NULL || ! $disabled ? '' : ' disabled="disabled"'; |
|
943 | + $disabled = $answer === NULL || ! $disabled ? '' : ' disabled="disabled"'; |
|
944 | 944 | // ya gots ta have style man!!! |
945 | 945 | $radio_class = is_admin() ? 'ee-admin-radio-lbl' : $label_class; |
946 | - $class = empty( $class ) ? 'espresso-radio-btn-inp' : $class; |
|
947 | - $extra = apply_filters( 'FHEE__EEH_Form_Fields__additional_form_field_attributes', '' ); |
|
946 | + $class = empty($class) ? 'espresso-radio-btn-inp' : $class; |
|
947 | + $extra = apply_filters('FHEE__EEH_Form_Fields__additional_form_field_attributes', ''); |
|
948 | 948 | |
949 | - $label_html = $required_text . "\n\t\t\t" . '<label class="' . $label_class . '">' . self::prep_question( $question ) . $required['label'] . '</label> '; |
|
949 | + $label_html = $required_text."\n\t\t\t".'<label class="'.$label_class.'">'.self::prep_question($question).$required['label'].'</label> '; |
|
950 | 950 | // filter label but ensure required text comes before it |
951 | - $label_html = apply_filters( 'FHEE__EEH_Form_Fields__label_html', $label_html, $required_text ); |
|
952 | - |
|
953 | - $input_html = "\n\t\t\t" . '<ul id="' . $id . '-ul" class="espresso-checkbox-options-ul ' . $label_class . ' ' . $class . '-ul">'; |
|
954 | - |
|
955 | - $class .= ! empty( $system_ID ) ? ' ' . $system_ID : ''; |
|
956 | - $class .= ! empty( $required['class'] ) ? ' ' . $required['class'] : ''; |
|
957 | - |
|
958 | - foreach ( $options as $OPT ) { |
|
959 | - $value = $OPT->value();//self::prep_option_value( $OPT->value() ); |
|
960 | - $size = self::get_label_size_class( $OPT->value() . ' ' . $OPT->desc() ); |
|
961 | - $text = self::prep_answer( $OPT->value() ); |
|
962 | - $desc = $OPT->desc() ; |
|
963 | - $opt = '-' . sanitize_key( $value ); |
|
964 | - |
|
965 | - $checked = is_array( $answer ) && in_array( $text, $answer ) ? ' checked="checked"' : ''; |
|
966 | - |
|
967 | - $input_html .= "\n\t\t\t\t" . '<li' . $size . '>'; |
|
968 | - $input_html .= "\n\t\t\t\t\t" . '<label class="' . $radio_class . ' espresso-checkbox-lbl">'; |
|
969 | - $input_html .= $label_b4 ? "\n\t\t\t\t\t\t" . '<span>' . $text . '</span>' : ''; |
|
970 | - $input_html .= "\n\t\t\t\t\t\t" . '<input type="checkbox" name="' . $name . '[' . $OPT->ID() . ']" id="' . $id . $opt . '" class="' . $class . '" value="' . $value . '" title="' . esc_attr( $required['msg'] ) . '" ' . $disabled . $checked . ' ' . $extra . '/>'; |
|
971 | - $input_html .= ! $label_b4 ? "\n\t\t\t\t\t\t" . '<span>' . $text . '</span>' : ''; |
|
972 | - $input_html .= "\n\t\t\t\t\t" . '</label>'; |
|
973 | - if ( ! empty( $desc ) && $desc != $text ) { |
|
974 | - $input_html .= "\n\t\t\t\t\t" . ' <br/><div class="espresso-checkbox-option-desc small-text grey-text">' . $desc . '</div>'; |
|
951 | + $label_html = apply_filters('FHEE__EEH_Form_Fields__label_html', $label_html, $required_text); |
|
952 | + |
|
953 | + $input_html = "\n\t\t\t".'<ul id="'.$id.'-ul" class="espresso-checkbox-options-ul '.$label_class.' '.$class.'-ul">'; |
|
954 | + |
|
955 | + $class .= ! empty($system_ID) ? ' '.$system_ID : ''; |
|
956 | + $class .= ! empty($required['class']) ? ' '.$required['class'] : ''; |
|
957 | + |
|
958 | + foreach ($options as $OPT) { |
|
959 | + $value = $OPT->value(); //self::prep_option_value( $OPT->value() ); |
|
960 | + $size = self::get_label_size_class($OPT->value().' '.$OPT->desc()); |
|
961 | + $text = self::prep_answer($OPT->value()); |
|
962 | + $desc = $OPT->desc(); |
|
963 | + $opt = '-'.sanitize_key($value); |
|
964 | + |
|
965 | + $checked = is_array($answer) && in_array($text, $answer) ? ' checked="checked"' : ''; |
|
966 | + |
|
967 | + $input_html .= "\n\t\t\t\t".'<li'.$size.'>'; |
|
968 | + $input_html .= "\n\t\t\t\t\t".'<label class="'.$radio_class.' espresso-checkbox-lbl">'; |
|
969 | + $input_html .= $label_b4 ? "\n\t\t\t\t\t\t".'<span>'.$text.'</span>' : ''; |
|
970 | + $input_html .= "\n\t\t\t\t\t\t".'<input type="checkbox" name="'.$name.'['.$OPT->ID().']" id="'.$id.$opt.'" class="'.$class.'" value="'.$value.'" title="'.esc_attr($required['msg']).'" '.$disabled.$checked.' '.$extra.'/>'; |
|
971 | + $input_html .= ! $label_b4 ? "\n\t\t\t\t\t\t".'<span>'.$text.'</span>' : ''; |
|
972 | + $input_html .= "\n\t\t\t\t\t".'</label>'; |
|
973 | + if ( ! empty($desc) && $desc != $text) { |
|
974 | + $input_html .= "\n\t\t\t\t\t".' <br/><div class="espresso-checkbox-option-desc small-text grey-text">'.$desc.'</div>'; |
|
975 | 975 | } |
976 | - $input_html .= "\n\t\t\t\t" . '</li>'; |
|
976 | + $input_html .= "\n\t\t\t\t".'</li>'; |
|
977 | 977 | |
978 | 978 | } |
979 | 979 | |
980 | - $input_html .= "\n\t\t\t" . '</ul>'; |
|
980 | + $input_html .= "\n\t\t\t".'</ul>'; |
|
981 | 981 | |
982 | - $input_html = apply_filters( 'FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id ); |
|
983 | - return $label_html . $input_html; |
|
982 | + $input_html = apply_filters('FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id); |
|
983 | + return $label_html.$input_html; |
|
984 | 984 | |
985 | 985 | } |
986 | 986 | |
@@ -1002,36 +1002,36 @@ discard block |
||
1002 | 1002 | * @param string $disabled disabled="disabled" or null |
1003 | 1003 | * @return string HTML |
1004 | 1004 | */ |
1005 | - static function datepicker( $question = FALSE, $answer = NULL, $name = FALSE, $id = '', $class = '', $required = FALSE, $required_text = '', $label_class = '', $disabled = FALSE, $system_ID = FALSE, $use_html_entities = TRUE ) { |
|
1005 | + static function datepicker($question = FALSE, $answer = NULL, $name = FALSE, $id = '', $class = '', $required = FALSE, $required_text = '', $label_class = '', $disabled = FALSE, $system_ID = FALSE, $use_html_entities = TRUE) { |
|
1006 | 1006 | // need these |
1007 | - if ( ! $question || ! $name ) { |
|
1007 | + if ( ! $question || ! $name) { |
|
1008 | 1008 | return NULL; |
1009 | 1009 | } |
1010 | 1010 | // prep the answer |
1011 | - $answer = is_array( $answer ) ? '' : self::prep_answer( $answer, $use_html_entities ); |
|
1011 | + $answer = is_array($answer) ? '' : self::prep_answer($answer, $use_html_entities); |
|
1012 | 1012 | // prep the required array |
1013 | - $required = self::prep_required( $required ); |
|
1013 | + $required = self::prep_required($required); |
|
1014 | 1014 | // set disabled tag |
1015 | - $disabled = $answer === NULL || ! $disabled ? '' : ' disabled="disabled"'; |
|
1015 | + $disabled = $answer === NULL || ! $disabled ? '' : ' disabled="disabled"'; |
|
1016 | 1016 | // ya gots ta have style man!!! |
1017 | 1017 | $txt_class = is_admin() ? 'regular-text' : 'espresso-datepicker-inp'; |
1018 | - $class = empty( $class ) ? $txt_class : $class; |
|
1019 | - $class .= ! empty( $system_ID ) ? ' ' . $system_ID : ''; |
|
1020 | - $extra = apply_filters( 'FHEE__EEH_Form_Fields__additional_form_field_attributes', '' ); |
|
1018 | + $class = empty($class) ? $txt_class : $class; |
|
1019 | + $class .= ! empty($system_ID) ? ' '.$system_ID : ''; |
|
1020 | + $extra = apply_filters('FHEE__EEH_Form_Fields__additional_form_field_attributes', ''); |
|
1021 | 1021 | |
1022 | - $label_html = $required_text . "\n\t\t\t" . '<label for="' . $name . '" class="' . $label_class . '">' . self::prep_question( $question ) . $required['label'] . '</label><br/>'; |
|
1022 | + $label_html = $required_text."\n\t\t\t".'<label for="'.$name.'" class="'.$label_class.'">'.self::prep_question($question).$required['label'].'</label><br/>'; |
|
1023 | 1023 | // filter label but ensure required text comes before it |
1024 | - $label_html = apply_filters( 'FHEE__EEH_Form_Fields__label_html', $label_html, $required_text ); |
|
1024 | + $label_html = apply_filters('FHEE__EEH_Form_Fields__label_html', $label_html, $required_text); |
|
1025 | 1025 | |
1026 | - $input_html = "\n\t\t\t" . '<input type="text" name="' . $name . '" id="' . $id . '" class="' . $class . ' ' . $required['class'] . ' datepicker" value="' . $answer . '" title="' . esc_attr( $required['msg'] ) . '" ' . $disabled . ' ' . $extra . '/>'; |
|
1026 | + $input_html = "\n\t\t\t".'<input type="text" name="'.$name.'" id="'.$id.'" class="'.$class.' '.$required['class'].' datepicker" value="'.$answer.'" title="'.esc_attr($required['msg']).'" '.$disabled.' '.$extra.'/>'; |
|
1027 | 1027 | |
1028 | 1028 | // enqueue scripts |
1029 | - wp_register_style( 'espresso-ui-theme', EE_GLOBAL_ASSETS_URL . 'css/espresso-ui-theme/jquery-ui-1.10.3.custom.min.css', array(), EVENT_ESPRESSO_VERSION ); |
|
1030 | - wp_enqueue_style( 'espresso-ui-theme'); |
|
1031 | - wp_enqueue_script( 'jquery-ui-datepicker' ); |
|
1029 | + wp_register_style('espresso-ui-theme', EE_GLOBAL_ASSETS_URL.'css/espresso-ui-theme/jquery-ui-1.10.3.custom.min.css', array(), EVENT_ESPRESSO_VERSION); |
|
1030 | + wp_enqueue_style('espresso-ui-theme'); |
|
1031 | + wp_enqueue_script('jquery-ui-datepicker'); |
|
1032 | 1032 | |
1033 | - $input_html = apply_filters( 'FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id ); |
|
1034 | - return $label_html . $input_html; |
|
1033 | + $input_html = apply_filters('FHEE__EEH_Form_Fields__input_html', $input_html, $label_html, $id); |
|
1034 | + return $label_html.$input_html; |
|
1035 | 1035 | |
1036 | 1036 | } |
1037 | 1037 | |
@@ -1043,7 +1043,7 @@ discard block |
||
1043 | 1043 | * @access public |
1044 | 1044 | * @return string |
1045 | 1045 | */ |
1046 | - public static function remove_label_keep_required_msg( $label_html, $required_text ) { |
|
1046 | + public static function remove_label_keep_required_msg($label_html, $required_text) { |
|
1047 | 1047 | return $required_text; |
1048 | 1048 | } |
1049 | 1049 | |
@@ -1057,9 +1057,9 @@ discard block |
||
1057 | 1057 | * @param string $value |
1058 | 1058 | * @return string HTML |
1059 | 1059 | */ |
1060 | - static function hidden_input( $name, $value, $id = '' ){ |
|
1061 | - $id = ! empty( $id ) ? $id : $name; |
|
1062 | - return '<input id="' . $id . '" type="hidden" name="'.$name.'" value="' . $value . '"/>'; |
|
1060 | + static function hidden_input($name, $value, $id = '') { |
|
1061 | + $id = ! empty($id) ? $id : $name; |
|
1062 | + return '<input id="'.$id.'" type="hidden" name="'.$name.'" value="'.$value.'"/>'; |
|
1063 | 1063 | } |
1064 | 1064 | |
1065 | 1065 | |
@@ -1071,7 +1071,7 @@ discard block |
||
1071 | 1071 | * @param string $question |
1072 | 1072 | * @return string |
1073 | 1073 | */ |
1074 | - static function prep_question( $question ){ |
|
1074 | + static function prep_question($question) { |
|
1075 | 1075 | return $question; |
1076 | 1076 | // $link = ''; |
1077 | 1077 | // // does this label have a help link attached ? |
@@ -1094,13 +1094,13 @@ discard block |
||
1094 | 1094 | * @param mixed $answer |
1095 | 1095 | * @return string |
1096 | 1096 | */ |
1097 | - static function prep_answer( $answer, $use_html_entities = TRUE ){ |
|
1097 | + static function prep_answer($answer, $use_html_entities = TRUE) { |
|
1098 | 1098 | //make sure we convert bools first. Otherwise (bool) false becomes an empty string which is NOT desired, we want "0". |
1099 | - if ( is_bool( $answer ) ) { |
|
1099 | + if (is_bool($answer)) { |
|
1100 | 1100 | $answer = $answer ? 1 : 0; |
1101 | 1101 | } |
1102 | - $answer = trim( stripslashes( str_replace( ''', "'", $answer ))); |
|
1103 | - return $use_html_entities ? htmlentities( $answer, ENT_QUOTES, 'UTF-8' ) : $answer; |
|
1102 | + $answer = trim(stripslashes(str_replace(''', "'", $answer))); |
|
1103 | + return $use_html_entities ? htmlentities($answer, ENT_QUOTES, 'UTF-8') : $answer; |
|
1104 | 1104 | } |
1105 | 1105 | |
1106 | 1106 | |
@@ -1110,18 +1110,18 @@ discard block |
||
1110 | 1110 | * @param array $QSOs array of EE_Question_Option objects |
1111 | 1111 | * @return array |
1112 | 1112 | */ |
1113 | - public static function prep_answer_options( $QSOs = array() ){ |
|
1113 | + public static function prep_answer_options($QSOs = array()) { |
|
1114 | 1114 | $prepped_answer_options = array(); |
1115 | - if ( is_array( $QSOs ) && ! empty( $QSOs )) { |
|
1116 | - foreach( $QSOs as $key => $QSO ) { |
|
1117 | - if ( ! $QSO instanceof EE_Question_Option ) { |
|
1118 | - $QSO = EE_Question_Option::new_instance( array( |
|
1119 | - 'QSO_value' => is_array( $QSO ) && isset( $QSO['id'] ) ? (string)$QSO['id'] : (string)$key, |
|
1120 | - 'QSO_desc' => is_array( $QSO ) && isset( $QSO['text'] ) ? (string)$QSO['text'] : (string)$QSO |
|
1115 | + if (is_array($QSOs) && ! empty($QSOs)) { |
|
1116 | + foreach ($QSOs as $key => $QSO) { |
|
1117 | + if ( ! $QSO instanceof EE_Question_Option) { |
|
1118 | + $QSO = EE_Question_Option::new_instance(array( |
|
1119 | + 'QSO_value' => is_array($QSO) && isset($QSO['id']) ? (string) $QSO['id'] : (string) $key, |
|
1120 | + 'QSO_desc' => is_array($QSO) && isset($QSO['text']) ? (string) $QSO['text'] : (string) $QSO |
|
1121 | 1121 | )); |
1122 | 1122 | } |
1123 | - if ( $QSO->opt_group() ) { |
|
1124 | - $prepped_answer_options[ $QSO->opt_group() ][] = $QSO; |
|
1123 | + if ($QSO->opt_group()) { |
|
1124 | + $prepped_answer_options[$QSO->opt_group()][] = $QSO; |
|
1125 | 1125 | } else { |
1126 | 1126 | $prepped_answer_options[] = $QSO; |
1127 | 1127 | } |
@@ -1137,8 +1137,8 @@ discard block |
||
1137 | 1137 | * @param string $option_value |
1138 | 1138 | * @return string |
1139 | 1139 | */ |
1140 | - static function prep_option_value( $option_value ){ |
|
1141 | - return esc_attr( trim( stripslashes( $option_value ) ) ); |
|
1140 | + static function prep_option_value($option_value) { |
|
1141 | + return esc_attr(trim(stripslashes($option_value))); |
|
1142 | 1142 | } |
1143 | 1143 | |
1144 | 1144 | |
@@ -1149,11 +1149,11 @@ discard block |
||
1149 | 1149 | * @param string|array $required |
1150 | 1150 | * @return array |
1151 | 1151 | */ |
1152 | - static function prep_required( $required = array() ){ |
|
1152 | + static function prep_required($required = array()) { |
|
1153 | 1153 | // make sure required is an array |
1154 | - $required = is_array( $required ) ? $required : array(); |
|
1154 | + $required = is_array($required) ? $required : array(); |
|
1155 | 1155 | // and set some defaults |
1156 | - $required = array_merge( array( 'label' => '', 'class' => '', 'msg' => '' ), $required ); |
|
1156 | + $required = array_merge(array('label' => '', 'class' => '', 'msg' => ''), $required); |
|
1157 | 1157 | return $required; |
1158 | 1158 | } |
1159 | 1159 | |
@@ -1164,30 +1164,30 @@ discard block |
||
1164 | 1164 | * @param string $value |
1165 | 1165 | * @return string |
1166 | 1166 | */ |
1167 | - static function get_label_size_class( $value = FALSE ){ |
|
1168 | - if ( $value === FALSE || $value == '' ) { |
|
1167 | + static function get_label_size_class($value = FALSE) { |
|
1168 | + if ($value === FALSE || $value == '') { |
|
1169 | 1169 | return ' class="medium-lbl"'; |
1170 | 1170 | } |
1171 | 1171 | // determine length of option value |
1172 | - $val_size = strlen( $value ); |
|
1173 | - switch( $val_size ){ |
|
1172 | + $val_size = strlen($value); |
|
1173 | + switch ($val_size) { |
|
1174 | 1174 | case $val_size < 3 : |
1175 | - $size = ' class="nano-lbl"'; |
|
1175 | + $size = ' class="nano-lbl"'; |
|
1176 | 1176 | break; |
1177 | 1177 | case $val_size < 6 : |
1178 | - $size = ' class="micro-lbl"'; |
|
1178 | + $size = ' class="micro-lbl"'; |
|
1179 | 1179 | break; |
1180 | 1180 | case $val_size < 12 : |
1181 | - $size = ' class="tiny-lbl"'; |
|
1181 | + $size = ' class="tiny-lbl"'; |
|
1182 | 1182 | break; |
1183 | 1183 | case $val_size < 25 : |
1184 | - $size = ' class="small-lbl"'; |
|
1184 | + $size = ' class="small-lbl"'; |
|
1185 | 1185 | break; |
1186 | 1186 | case $val_size > 100 : |
1187 | - $size = ' class="big-lbl"'; |
|
1187 | + $size = ' class="big-lbl"'; |
|
1188 | 1188 | break; |
1189 | 1189 | default: |
1190 | - $size = ' class="medium-lbl"'; |
|
1190 | + $size = ' class="medium-lbl"'; |
|
1191 | 1191 | break; |
1192 | 1192 | } |
1193 | 1193 | return $size; |
@@ -1201,20 +1201,20 @@ discard block |
||
1201 | 1201 | * @param array $QFI |
1202 | 1202 | * @return array |
1203 | 1203 | */ |
1204 | - private static function _load_system_dropdowns( $QFI ){ |
|
1204 | + private static function _load_system_dropdowns($QFI) { |
|
1205 | 1205 | $QST_system = $QFI->get('QST_system'); |
1206 | - switch ( $QST_system ) { |
|
1206 | + switch ($QST_system) { |
|
1207 | 1207 | case 'state' : |
1208 | - $QFI = self::generate_state_dropdown( $QFI ); |
|
1208 | + $QFI = self::generate_state_dropdown($QFI); |
|
1209 | 1209 | break; |
1210 | 1210 | case 'country' : |
1211 | - $QFI = self::generate_country_dropdown( $QFI ); |
|
1211 | + $QFI = self::generate_country_dropdown($QFI); |
|
1212 | 1212 | break; |
1213 | 1213 | case 'admin-state' : |
1214 | - $QFI = self::generate_state_dropdown( $QFI, TRUE ); |
|
1214 | + $QFI = self::generate_state_dropdown($QFI, TRUE); |
|
1215 | 1215 | break; |
1216 | 1216 | case 'admin-country' : |
1217 | - $QFI = self::generate_country_dropdown( $QFI, TRUE ); |
|
1217 | + $QFI = self::generate_country_dropdown($QFI, TRUE); |
|
1218 | 1218 | break; |
1219 | 1219 | } |
1220 | 1220 | return $QFI; |
@@ -1231,13 +1231,13 @@ discard block |
||
1231 | 1231 | * |
1232 | 1232 | * @return EE_Question_Form_Input |
1233 | 1233 | */ |
1234 | - protected static function _load_specialized_dropdowns( $QFI ) { |
|
1235 | - switch( $QFI->get( 'QST_type' ) ) { |
|
1234 | + protected static function _load_specialized_dropdowns($QFI) { |
|
1235 | + switch ($QFI->get('QST_type')) { |
|
1236 | 1236 | case 'STATE' : |
1237 | - $QFI = self::generate_state_dropdown( $QFI ); |
|
1237 | + $QFI = self::generate_state_dropdown($QFI); |
|
1238 | 1238 | break; |
1239 | 1239 | case 'COUNTRY' : |
1240 | - $QFI = self::generate_country_dropdown( $QFI ); |
|
1240 | + $QFI = self::generate_country_dropdown($QFI); |
|
1241 | 1241 | break; |
1242 | 1242 | } |
1243 | 1243 | return $QFI; |
@@ -1251,23 +1251,23 @@ discard block |
||
1251 | 1251 | * @param bool $get_all |
1252 | 1252 | * @return array |
1253 | 1253 | */ |
1254 | - public static function generate_state_dropdown( $QST, $get_all = FALSE ){ |
|
1254 | + public static function generate_state_dropdown($QST, $get_all = FALSE) { |
|
1255 | 1255 | $states = $get_all ? EEM_State::instance()->get_all_states() : EEM_State::instance()->get_all_states_of_active_countries(); |
1256 | - if ( $states && count( $states ) != count( $QST->options() )) { |
|
1257 | - $QST->set( 'QST_type', 'DROPDOWN' ); |
|
1256 | + if ($states && count($states) != count($QST->options())) { |
|
1257 | + $QST->set('QST_type', 'DROPDOWN'); |
|
1258 | 1258 | // if multiple countries, we'll create option groups within the dropdown |
1259 | - foreach ( $states as $state ) { |
|
1260 | - if ( $state instanceof EE_State ) { |
|
1261 | - $QSO = EE_Question_Option::new_instance ( array ( |
|
1259 | + foreach ($states as $state) { |
|
1260 | + if ($state instanceof EE_State) { |
|
1261 | + $QSO = EE_Question_Option::new_instance(array( |
|
1262 | 1262 | 'QSO_value' => $state->ID(), |
1263 | 1263 | 'QSO_desc' => $state->name(), |
1264 | - 'QST_ID' => $QST->get( 'QST_ID' ), |
|
1264 | + 'QST_ID' => $QST->get('QST_ID'), |
|
1265 | 1265 | 'QSO_deleted' => FALSE |
1266 | 1266 | )); |
1267 | 1267 | // set option group |
1268 | - $QSO->set_opt_group( $state->country()->name() ); |
|
1268 | + $QSO->set_opt_group($state->country()->name()); |
|
1269 | 1269 | // add option to question |
1270 | - $QST->add_temp_option( $QSO ); |
|
1270 | + $QST->add_temp_option($QSO); |
|
1271 | 1271 | } |
1272 | 1272 | } |
1273 | 1273 | } |
@@ -1283,20 +1283,20 @@ discard block |
||
1283 | 1283 | * @internal param array $question |
1284 | 1284 | * @return array |
1285 | 1285 | */ |
1286 | - public static function generate_country_dropdown( $QST, $get_all = FALSE ){ |
|
1286 | + public static function generate_country_dropdown($QST, $get_all = FALSE) { |
|
1287 | 1287 | $countries = $get_all ? EEM_Country::instance()->get_all_countries() : EEM_Country::instance()->get_all_active_countries(); |
1288 | - if ( $countries && count( $countries ) != count( $QST->options() ) ) { |
|
1289 | - $QST->set( 'QST_type', 'DROPDOWN' ); |
|
1288 | + if ($countries && count($countries) != count($QST->options())) { |
|
1289 | + $QST->set('QST_type', 'DROPDOWN'); |
|
1290 | 1290 | // now add countries |
1291 | - foreach ( $countries as $country ) { |
|
1292 | - if ( $country instanceof EE_Country ) { |
|
1293 | - $QSO = EE_Question_Option::new_instance ( array ( |
|
1291 | + foreach ($countries as $country) { |
|
1292 | + if ($country instanceof EE_Country) { |
|
1293 | + $QSO = EE_Question_Option::new_instance(array( |
|
1294 | 1294 | 'QSO_value' => $country->ID(), |
1295 | 1295 | 'QSO_desc' => $country->name(), |
1296 | - 'QST_ID' => $QST->get( 'QST_ID' ), |
|
1296 | + 'QST_ID' => $QST->get('QST_ID'), |
|
1297 | 1297 | 'QSO_deleted' => FALSE |
1298 | 1298 | )); |
1299 | - $QST->add_temp_option( $QSO ); |
|
1299 | + $QST->add_temp_option($QSO); |
|
1300 | 1300 | } |
1301 | 1301 | } |
1302 | 1302 | } |
@@ -1313,11 +1313,11 @@ discard block |
||
1313 | 1313 | */ |
1314 | 1314 | public static function two_digit_months_dropdown_options() { |
1315 | 1315 | $options = array(); |
1316 | - for ( $x = 1; $x <= 12; $x++ ) { |
|
1317 | - $mm = str_pad( $x, 2, '0', STR_PAD_LEFT ); |
|
1318 | - $options[ (string)$mm ] = (string)$mm; |
|
1316 | + for ($x = 1; $x <= 12; $x++) { |
|
1317 | + $mm = str_pad($x, 2, '0', STR_PAD_LEFT); |
|
1318 | + $options[(string) $mm] = (string) $mm; |
|
1319 | 1319 | } |
1320 | - return EEH_Form_Fields::prep_answer_options( $options ); |
|
1320 | + return EEH_Form_Fields::prep_answer_options($options); |
|
1321 | 1321 | } |
1322 | 1322 | |
1323 | 1323 | |
@@ -1332,11 +1332,11 @@ discard block |
||
1332 | 1332 | $options = array(); |
1333 | 1333 | $current_year = date('y'); |
1334 | 1334 | $next_decade = $current_year + 10; |
1335 | - for ( $x = $current_year; $x <= $next_decade; $x++ ) { |
|
1336 | - $yy = str_pad( $x, 2, '0', STR_PAD_LEFT ); |
|
1337 | - $options[ (string)$yy ] = (string)$yy; |
|
1335 | + for ($x = $current_year; $x <= $next_decade; $x++) { |
|
1336 | + $yy = str_pad($x, 2, '0', STR_PAD_LEFT); |
|
1337 | + $options[(string) $yy] = (string) $yy; |
|
1338 | 1338 | } |
1339 | - return EEH_Form_Fields::prep_answer_options( $options ); |
|
1339 | + return EEH_Form_Fields::prep_answer_options($options); |
|
1340 | 1340 | } |
1341 | 1341 | |
1342 | 1342 | |
@@ -1350,17 +1350,17 @@ discard block |
||
1350 | 1350 | * @param integer $evt_category Event Category ID if the Event Category filter is selected |
1351 | 1351 | * @return string html |
1352 | 1352 | */ |
1353 | - public static function generate_registration_months_dropdown( $cur_date = '', $status = '', $evt_category = 0 ) { |
|
1353 | + public static function generate_registration_months_dropdown($cur_date = '', $status = '', $evt_category = 0) { |
|
1354 | 1354 | $_where = array(); |
1355 | - if ( !empty( $status ) ) { |
|
1355 | + if ( ! empty($status)) { |
|
1356 | 1356 | $_where['STS_ID'] = $status; |
1357 | 1357 | } |
1358 | 1358 | |
1359 | - if ( $evt_category > 0 ) { |
|
1359 | + if ($evt_category > 0) { |
|
1360 | 1360 | $_where['Event.Term_Taxonomy.term_id'] = $evt_category; |
1361 | 1361 | } |
1362 | 1362 | |
1363 | - $regdtts = EEM_Registration::instance()->get_reg_months_and_years( $_where ); |
|
1363 | + $regdtts = EEM_Registration::instance()->get_reg_months_and_years($_where); |
|
1364 | 1364 | |
1365 | 1365 | //setup vals for select input helper |
1366 | 1366 | $options = array( |
@@ -1370,15 +1370,15 @@ discard block |
||
1370 | 1370 | ) |
1371 | 1371 | ); |
1372 | 1372 | |
1373 | - foreach ( $regdtts as $regdtt ) { |
|
1374 | - $date = $regdtt->reg_month. ' ' . $regdtt->reg_year; |
|
1373 | + foreach ($regdtts as $regdtt) { |
|
1374 | + $date = $regdtt->reg_month.' '.$regdtt->reg_year; |
|
1375 | 1375 | $options[] = array( |
1376 | 1376 | 'text' => $date, |
1377 | 1377 | 'id' => $date |
1378 | 1378 | ); |
1379 | 1379 | } |
1380 | 1380 | |
1381 | - return self::select_input('month_range', $options, $cur_date, '', 'wide' ); |
|
1381 | + return self::select_input('month_range', $options, $cur_date, '', 'wide'); |
|
1382 | 1382 | } |
1383 | 1383 | |
1384 | 1384 | |
@@ -1392,18 +1392,18 @@ discard block |
||
1392 | 1392 | * @param string $evt_active_status "upcoming", "expired", "active", or "inactive" |
1393 | 1393 | * @return string html |
1394 | 1394 | */ |
1395 | - public static function generate_event_months_dropdown( $cur_date = '', $status = NULL, $evt_category = NULL, $evt_active_status = NULL ) { |
|
1395 | + public static function generate_event_months_dropdown($cur_date = '', $status = NULL, $evt_category = NULL, $evt_active_status = NULL) { |
|
1396 | 1396 | //determine what post_status our condition will have for the query. |
1397 | - switch ( $status ) { |
|
1397 | + switch ($status) { |
|
1398 | 1398 | case 'month' : |
1399 | 1399 | case 'today' : |
1400 | 1400 | case NULL : |
1401 | 1401 | case 'all' : |
1402 | - $where['Event.status'] = array( 'NOT IN', array('trash') ); |
|
1402 | + $where['Event.status'] = array('NOT IN', array('trash')); |
|
1403 | 1403 | break; |
1404 | 1404 | |
1405 | 1405 | case 'draft' : |
1406 | - $where['Event.status'] = array( 'IN', array('draft', 'auto-draft') ); |
|
1406 | + $where['Event.status'] = array('IN', array('draft', 'auto-draft')); |
|
1407 | 1407 | |
1408 | 1408 | default : |
1409 | 1409 | $where['Event.status'] = $status; |
@@ -1412,7 +1412,7 @@ discard block |
||
1412 | 1412 | //categories? |
1413 | 1413 | |
1414 | 1414 | |
1415 | - if ( !empty ( $evt_category ) ) { |
|
1415 | + if ( ! empty ($evt_category)) { |
|
1416 | 1416 | $where['Event.Term_Taxonomy.taxonomy'] = 'espresso_event_categories'; |
1417 | 1417 | $where['Event.Term_Taxonomy.term_id'] = $evt_category; |
1418 | 1418 | } |
@@ -1420,7 +1420,7 @@ discard block |
||
1420 | 1420 | |
1421 | 1421 | // $where['DTT_is_primary'] = 1; |
1422 | 1422 | |
1423 | - $DTTS = EE_Registry::instance()->load_model('Datetime')->get_dtt_months_and_years($where, $evt_active_status ); |
|
1423 | + $DTTS = EE_Registry::instance()->load_model('Datetime')->get_dtt_months_and_years($where, $evt_active_status); |
|
1424 | 1424 | |
1425 | 1425 | //let's setup vals for select input helper |
1426 | 1426 | $options = array( |
@@ -1435,9 +1435,9 @@ discard block |
||
1435 | 1435 | //translate month and date |
1436 | 1436 | global $wp_locale; |
1437 | 1437 | |
1438 | - foreach ( $DTTS as $DTT ) { |
|
1439 | - $localized_date = $wp_locale->get_month( $DTT->dtt_month_num ) . ' ' . $DTT->dtt_year; |
|
1440 | - $id = $DTT->dtt_month . ' ' . $DTT->dtt_year; |
|
1438 | + foreach ($DTTS as $DTT) { |
|
1439 | + $localized_date = $wp_locale->get_month($DTT->dtt_month_num).' '.$DTT->dtt_year; |
|
1440 | + $id = $DTT->dtt_month.' '.$DTT->dtt_year; |
|
1441 | 1441 | $options[] = array( |
1442 | 1442 | 'text' => $localized_date, |
1443 | 1443 | 'id' => $id |
@@ -1445,7 +1445,7 @@ discard block |
||
1445 | 1445 | } |
1446 | 1446 | |
1447 | 1447 | |
1448 | - return self::select_input( 'month_range', $options, $cur_date, '', 'wide' ); |
|
1448 | + return self::select_input('month_range', $options, $cur_date, '', 'wide'); |
|
1449 | 1449 | } |
1450 | 1450 | |
1451 | 1451 | |
@@ -1456,7 +1456,7 @@ discard block |
||
1456 | 1456 | * @param integer $current_cat currently selected category |
1457 | 1457 | * @return string html for dropdown |
1458 | 1458 | */ |
1459 | - public static function generate_event_category_dropdown( $current_cat = -1 ) { |
|
1459 | + public static function generate_event_category_dropdown($current_cat = -1) { |
|
1460 | 1460 | $categories = EEM_Term::instance()->get_all_ee_categories(TRUE); |
1461 | 1461 | $options = array( |
1462 | 1462 | '0' => array( |
@@ -1466,14 +1466,14 @@ discard block |
||
1466 | 1466 | ); |
1467 | 1467 | |
1468 | 1468 | //setup categories for dropdown |
1469 | - foreach ( $categories as $category ) { |
|
1469 | + foreach ($categories as $category) { |
|
1470 | 1470 | $options[] = array( |
1471 | 1471 | 'text' => $category->get('name'), |
1472 | 1472 | 'id' => $category->ID() |
1473 | 1473 | ); |
1474 | 1474 | } |
1475 | 1475 | |
1476 | - return self::select_input( 'EVT_CAT', $options, $current_cat ); |
|
1476 | + return self::select_input('EVT_CAT', $options, $current_cat); |
|
1477 | 1477 | } |
1478 | 1478 | |
1479 | 1479 | |
@@ -1492,20 +1492,20 @@ discard block |
||
1492 | 1492 | * @param string $extra_attributes - any extra attributes that need to be attached to the form input |
1493 | 1493 | * @return void |
1494 | 1494 | */ |
1495 | - public static function submit_button( $url = '', $ID = '', $class = '', $text = '', $nonce_action = '', $input_only = FALSE, $extra_attributes = '' ) { |
|
1495 | + public static function submit_button($url = '', $ID = '', $class = '', $text = '', $nonce_action = '', $input_only = FALSE, $extra_attributes = '') { |
|
1496 | 1496 | $btn = ''; |
1497 | - if ( empty( $url ) || empty( $ID )) { |
|
1497 | + if (empty($url) || empty($ID)) { |
|
1498 | 1498 | return $btn; |
1499 | 1499 | } |
1500 | - $text = ! empty( $text ) ? $text : __('Submit', 'event_espresso' ); |
|
1501 | - $btn .= '<input id="' . $ID . '-btn" class="' . $class . '" type="submit" value="' . $text . '" ' . $extra_attributes . '/>'; |
|
1502 | - if ( ! $input_only ) { |
|
1503 | - $btn_frm = '<form id="' . $ID . '-frm" method="POST" action="' . $url . '">'; |
|
1504 | - $btn_frm .= ! empty( $nonce_action ) ? wp_nonce_field( $nonce_action, $nonce_action . '_nonce', TRUE, FALSE ) : ''; |
|
1500 | + $text = ! empty($text) ? $text : __('Submit', 'event_espresso'); |
|
1501 | + $btn .= '<input id="'.$ID.'-btn" class="'.$class.'" type="submit" value="'.$text.'" '.$extra_attributes.'/>'; |
|
1502 | + if ( ! $input_only) { |
|
1503 | + $btn_frm = '<form id="'.$ID.'-frm" method="POST" action="'.$url.'">'; |
|
1504 | + $btn_frm .= ! empty($nonce_action) ? wp_nonce_field($nonce_action, $nonce_action.'_nonce', TRUE, FALSE) : ''; |
|
1505 | 1505 | $btn_frm .= $btn; |
1506 | 1506 | $btn_frm .= '</form>'; |
1507 | 1507 | $btn = $btn_frm; |
1508 | - unset ( $btn_frm ); |
|
1508 | + unset ($btn_frm); |
|
1509 | 1509 | } |
1510 | 1510 | return $btn; |
1511 | 1511 | } |