1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
|
<?php
/* pluginbuddy class * * Form framework for handling all forms, validation, and their display. * * @author Dustin Bolton */ class pb_backupbuddy_form { // ********** PUBLIC PROPERTIES ********** // ********** PRIVATE PROPERTIES ********** private $_form_name = ''; private $_save_point = ''; private $_inputs = array(); private $_prefix = 'DEFAULT'; private $_started = false; private $_ended = false; private $_additional_query_string = ''; private $_loaded_color = false; // ********** FUNCTIONS ********** /* pluginbuddy_form->_construct() * * Default constructor. Sets up the form. * * @param string $form_name Name / slug of the form. * @param string $save_point Save point to save form; Currently only used for settings form. @see pluginbuddy_settings->__construct(). * @param string $additional_query_string Additional querystring to append to end of form action URL. * @return null */ function __construct( $form_name, $save_point = '', $additional_query_string = '' ) { $this->_form_name = $form_name; $this->_save_point = $save_point; $this->_additional_query_string = $additional_query_string; $this->_prefix = 'pb_' . pb_backupbuddy::settings( 'slug' ) . '_'; } // End __construct(). /* pluginbuddy_form->text() * * Add a text input. * * @param string $name Name / slug for this form item. * @param string $value Value for this form item. * @param string $rules (optional) Rules to validate this form item against. * @return null */ public function text( $name, $value, $rules = '' ) { $this->_inputs[$name] = array( 'type' => __FUNCTION__, 'value' => $value, 'rules' => $rules, ); } // End text(). /* pluginbuddy_form->plaintext() * * Add a text input. * * @param string $name Name / slug for this form item. * @param string $value Value for this form item. * @return null */ public function plaintext( $name, $value ) { $this->_inputs[$name] = array( 'type' => __FUNCTION__, 'value' => $value, ); } // End text(). /* pluginbuddy_form->color() * * Add a color input; this is a text input that has a color selector. * * @param string $name Name / slug for this form item. * @param string $value Value for this form item. * @param string $rules (optional) Rules to validate this form item against. * @return null */ public function color( $name, $value, $rules = '' ) { $this->_inputs[$name] = array( 'type' => __FUNCTION__, 'value' => $value, 'rules' => $rules, ); } // End color(). /* pluginbuddy_form->hidden() * * Add a hidden input. * * @param string $name Name / slug for this form item. * @param string $value Value for this form item. * @param string $rules (optional) Rules to validate this form item against. * @return null */ public function hidden( $name, $value, $rules = '' ) { $this->_inputs[$name] = array( 'type' => __FUNCTION__, 'value' => $value, 'rules' => $rules, ); } // End hidden(). /* pluginbuddy_form->wysiwyg() * * Adds a text box wysiwyg. * @see wp_editor() in WordPress core. * * @param string $name Name / slug for this form item. * @param string $value Value for this form item. * @param string $rules (optional) Rules to validate this form item against. * @param array $settings WordPress settings array to pass to wp_editor(). @see wp_editor(). * @return null */ public function wysiwyg( $name, $value, $rules = '', $settings ) { $this->_inputs[$name] = array( 'type' => __FUNCTION__, 'value' => $value, 'rules' => $rules, 'settings' => $settings, ); } // End wysiwyg(). /* pluginbuddy_form->textarea() * * Add a textarea input. * * @param string $name Name / slug for this form item. * @param string $value Value for this form item. * @param string $rules (optional) Rules to validate this form item against. * @return null */ public function textarea( $name, $value, $rules = '' ) { $this->_inputs[$name] = array( 'type' => __FUNCTION__, 'value' => $value, 'rules' => $rules, ); } // End textarea(). /* pluginbuddy_form->select() * * Add a select input. * * @param string $name Name / slug for this form item. * @param array $options Array of options for the dropdown. The key is the slug and the value is the pretty user-displayed part. <option value="array_key">array_value</option>. * @param string $value Value for this form item. * @param string $rules (optional) Rules to validate this form item against. * @return null */ public function select( $name, $options, $value, $rules = '' ) { $this->_inputs[$name] = array( 'type' => __FUNCTION__, 'options' => $options, 'value' => $value, 'rules' => $rules, ); } // End select(). /* pluginbuddy_form->radio() * * Add a radio input. * * @param string $name Name / slug for this form item. * @param array $options Array of options for the radio inputs. The key is the slug and the value is the pretty user-displayed part. <input type="radio" value="array_key">array_value. * @param string $value Value for this form item. * @param string $rules (optional) Rules to validate this form item against. * @return null */ public function radio( $name, $options, $value, $rules = '' ) { $this->_inputs[$name] = array( 'type' => __FUNCTION__, 'options' => $options, 'value' => $value, 'rules' => $rules, ); } // End radio(). /* pluginbuddy_form->title() * * Add a radio input. * * @param string $name Name / slug for this form item. * @param string $value Value for this form item. * @param string $rules (optional) Rules to validate this form item against. * @return null */ public function title( $name, $value, $rules = '' ) { $this->_inputs[$name] = array( 'type' => __FUNCTION__, 'value' => $value, 'rules' => $rules, ); } // End radio(). /* pluginbuddy_form->checkbox() * * Add a checkbox input. * * @param string $name Name / slug for this form item. * @param array $options Array format: array( 'unchecked' => 'unchecked_value', 'checked' => 'checked_value' ); * @param string $value Value for this form item. * @param string $rules (optional) Rules to validate this form item against. * @return null */ public function checkbox( $name, $options, $value, $rules = '' ) { $this->_inputs[$name] = array( 'type' => __FUNCTION__, 'options' => $options, 'value' => $value, 'rules' => $rules, ); } // End checkbox(). /* pluginbuddy_form->password() * * Add a password input. * * @param string $name Name / slug for this form item. * @param string $value Value for this form item. * @param string $rules (optional) Rules to validate this form item against. * @return null */ public function password( $name, $value, $rules = '' ) { $this->_inputs[$name] = array( 'type' => __FUNCTION__, 'value' => $value, 'rules' => $rules, ); } // End password(). /* pluginbuddy_form->submit() * * Add a submit input. * * @param string $name Name / slug for this form item. * @param string $value Value for this form item. This is the text in the displayed button. * @return null */ public function submit( $name, $value = '' ) { $this->_inputs[$name] = array( 'type' => __FUNCTION__, 'value' => $value, ); } // End submit(). /* pluginbuddy_form->start() * * Starts the form output. Automatically runs under normal circumstances so usually should not need to be called directly. * * @param string $name Name / slug for this form item. * @param string $value Value for this form item. * @param string $rules (optional) Rules to validate this form item against. * @return null */ public function start() { $this->_started = true; if ( false !== stristr( $this->_additional_query_string, 'http' ) ) { $action_url = $this->_additional_query_string; } else { if ( pb_backupbuddy::page_url() != '' ) { $action_url = pb_backupbuddy::page_url() . '&' . $this->_additional_query_string; } else { $action_url = '?' . $this->_additional_query_string; } } $return = '<form method="post" action="' . $action_url . '" class="pb_form" id="' . $this->_prefix . $this->_form_name . '_form">'; $return .= '<input type="hidden" name="' . $this->_prefix . '" value="' . $this->_form_name . '">'; return $return; } // End start(). /* pluginbuddy_form->end() * * Ends the form setting nonce and closing </form>. NOT automatically run except in pluginbuddy_settings class. * * @param string $name Name / slug for this form item. * @param string $value Value for this form item. * @param string $rules (optional) Rules to validate this form item against. * @return null */ public function end( $echo = false ) { $this->_ended = true;
// TODO: fields maybe? //$return = pb_backupbuddy::nonce( $this->_form_name ); $return = pb_backupbuddy::nonce( false ); // Do not echo. $return .= '</form>'; if ( $echo === true ) { echo $return; } else { return $return; } } // End end(). /* pluginbuddy_form->display() * * Displays (echos) a form item and all its code/HTML. * @see pluginbuddy_form->get(). * * @param string $name Name / slug for this form item. * @param string $value Value for this form item. * @param string $rules (optional) Rules to validate this form item against. * @return null */ public function display( $name, $css = '' ) { echo $this->get( $name, $css ); } // End display(). /* pluginbuddy_form->get() * * Returns a form item and all its code/HTML. * Left column is hidden if an object's title = ''. * title object type colspans 2. * * @param string $name Name / slug for this form item. * @param string $css Additional CSS to apply to form item. * @return string All HTML, etc for this form item. */ public function get( $name, $css = '', $classes = '', $orientation = 'horizontal' ) { if ( $this->_ended === true ) { // Form already closed and ended. Fatal problem. return '{Error: Form already closed with end function so cannot add more fields. Only end in view after all displays are done.}'; } if ( isset( $this->_inputs[$name] ) ) { $prefix = $this->_prefix; if ( $this->_started === false ) { // Form output has not started. Start it. $return = $this->start(); } else { $return = ''; } $input = &$this->_inputs[$name]; if ( $css != '' ) { $css = ' style="' . $css . '"'; } /********** TEXT **********/ if ( $input['type'] == 'text' ) { $return .= '<input type="text" class="' . $classes . '" name="' . $prefix . $name . '" value="' . $input['value'] . '" id="' . $prefix . str_replace( '#', '__', $name ) . '"' . $css . '>'; /********** PLAINTEXT **********/ } elseif ( $input['type'] == 'plaintext' ) { $return .= '<span class="' . $classes . '" ' . $css . '>' . $input['value'] . '</span>'; /********** COLOR **********/ } elseif ( $input['type'] == 'color' ) { // TODO: this actually should only run once per PAGE load. add a function is_script and is_style into framework to see if loaded into framework yet or not. if ( $this->_loaded_color === false ) { // Only load the javascript, CSS, etc once per instance. pb_backupbuddy::load_script( 'jquery.miniColors.min.js', true ); pb_backupbuddy::load_style( 'jquery.miniColors.css', true ); echo '<script type="text/javascript"> jQuery(document).ready( function() { jQuery( ".pb_colorpicker" ).miniColors({ letterCase: "uppercase" }); }); </script> <style type="text/css"> .miniColors-trigger { background: url( ' . pb_backupbuddy::plugin_url() . '/pluginbuddy/images/minicolors/trigger.png ) center no-repeat; } .miniColors-colors { background: url( ' . pb_backupbuddy::plugin_url() . '/pluginbuddy/images/minicolors/gradient.png ) center no-repeat; } .miniColors-hues { background: url( ' . pb_backupbuddy::plugin_url() . '/pluginbuddy/images/minicolors/rainbow.png ) center no-repeat; } .miniColors-colorPicker { background: url( ' . pb_backupbuddy::plugin_url() . '/pluginbuddy/images/minicolors/circle.gif ) center no-repeat; } .miniColors-huePicker { background: url( ' . pb_backupbuddy::plugin_url() . '/pluginbuddy/images/minicolors/line.gif ) center no-repeat; } </style>'; $this->_loaded_color = true; } if ( $css == '' ) { // default width. $css = ' style="width: 60px;"'; } $return .= '<input class="pb_colorpicker ' . $classes . '" type="text" name="' . $prefix . $name . '" value="' . $input['value'] . '" id="' . $prefix . str_replace( '#', '__', $name ) . '"' . $css . '>'; /********** HIDDEN **********/ } elseif ( $input['type'] == 'hidden' ) { $return .= '<input type="hidden" name="' . $prefix . $name . '" value="' . $input['value'] . '" class="' . $classes . '" id="' . $prefix . str_replace( '#', '__', $name ) . '"' . $css . '>'; /********** WYSIWYG **********/ } elseif ( $input['type'] == 'wysiwyg' ) { $wysiwyg_settings = array_merge( $input['settings'], array( 'textarea_name' => $prefix . $name ) ); //$return .= '<input type="text" name="' . . '" value="' . . '" id="' . $prefix . $name . '"' . $css . '>'; ob_start(); wp_editor( $input['value'], $prefix . $name, $wysiwyg_settings ); $return .= ob_get_contents(); ob_end_clean(); /********** TITLE **********/ } elseif ( $input['type'] == 'title' ) { // All handled by settings class currently. Showing in the th not the td. //$return .= '<h4 id="' . $prefix . $name . '"' . $css . '>' . $input['value'] . '</h4>'; /********** TEXTAREA **********/ } elseif ( $input['type'] == 'textarea' ) { $return .= '<textarea name="' . $prefix . $name . '" class="' . $classes . '" id="' . $prefix . str_replace( '#', '__', $name ) . '"' . $css . '>' . $input['value'] . '</textarea>'; /********** PASSWORD **********/ } elseif ( $input['type'] == 'password' ) { $return .= '<input type="password" name="' . $prefix . $name . '" value="' . $input['value'] . '" class="' . $classes . '" id="' . $prefix . str_replace( '#', '__', $name ) . '"' . $css . '>'; /********** SELECT **********/ } elseif ( $input['type'] == 'select' ) { $return .= '<select name="' . $prefix . $name . '" class="' . $classes . '" id="' . $prefix . str_replace( '#', '__', $name ) . '"' . $css . '>'; foreach ( $input['options'] as $option_value => $option_title ) { $return .= '<option value="' . $option_value . '"'; if ( $option_value == $input['value'] ) { $return .= ' selected="selected"'; } $return .= '>' . $option_title . '</option>'; } $return .= '</select>'; /********** RADIO **********/ } elseif ( $input['type'] == 'radio' ) { $return .= '<input type="hidden" name="' . $prefix . $name . '" value="">'; // default if no radio checked $i = 0; foreach ( $input['options'] as $option_value => $option_title ) { $i++; $return .= '<input type="radio" name="' . $prefix . $name . '" class="' . $classes . '" id="' . $prefix . str_replace( '#', '__', $name ) . '" value="' . $option_value . '"' . $css; if ( $option_value == $input['value'] ) { // Check if this item is selected. $return .= ' checked="checked"'; } $return .= '> ' . $option_title; if ( $i < count( $input['options'] ) ) { // spacer between each one. if ( $orientation == 'horizontal' ) { // Horizonal display. $return .= ' '; } else { // Vertical display. $return .= '<br>'; } } } /********** CHECKBOX **********/ } elseif ( $input['type'] == 'checkbox' ) { $return .= '<input type="hidden" name="' . $prefix . $name . '" value="' . $input['options']['unchecked'] . '">'; $return .= '<input type="checkbox" name="' . $prefix . $name . '" class="' . $classes . '" id="' . $prefix . str_replace( '#', '__', $name ) . '" value="' . $input['options']['checked'] . '"' . $css; if ( $input['options']['checked'] == $input['value'] ) { $return .= ' checked'; } $return .= '>'; // TODO: conditional to see if this needes to be default selected based on options. /********** SUBMIT **********/ } elseif ( $input['type'] == 'submit' ) { $return .= '<input class="button-primary ' . $classes . '" type="submit" name="' . $prefix . $name . '" value="' . $input['value'] . '" id="' . $prefix . str_replace( '#', '__', $name ) . '"' . $css . '>'; /********** ~UNKNOWN TYPE~ **********/ } else { $return .= '{Unknown form item type: `' . $input['type'] . '`.}'; }
return $return; } else { return '{Invalid form field: `' . $name . '`.}'; } } // End get(). /* pluginbuddy_form->set_value() * * Updates the value of an existing form item. * * @param string $name Name of the item in the form to update. Ex: text * @param string $value Value to apply to the form item. * @return null */ public function set_value( $name, $value ) { $this->_inputs[$name]['value'] = $value; } // End set_value(). /* pluginbuddy_form->get_value() * * Get the submitted (POSTed) value of this form item. * * @param string $name Name / slug for this form item. * @param string $value Value for this form item. * @param string $rules (optional) Rules to validate this form item against. * @return null */ // Get the submitted value of a form item. false if not found. Strips WP slashes. function get_value( $name ) { if ( pb_backupbuddy::_POST( $this->_prefix . $name ) != '' ) { // Submitted value exists, use it. return stripslashes_deep( pb_backupbuddy::_POST( $this->_prefix . $name ) ); } else { // Nothing submitted, fail. return false; } } // End get_value(). /* pb_backupbuddy::test() * * Tests whether a form item's rules on a provided value. If no value is provided then will try to get the POST'ed value. * @see pb_backupbuddy::test_rule() * * @param string $name * @param mixed $value Optional: This will be tested with the rule assigned to the form item with the provided name. * If empty we will try to test based on a submitted post value if it exists. * @return true/array true if the value passes; array of error messages on failure. */ public function test( $name, $value = '' ) { if ( $value == '' ) { // No value, try to get it. if ( pb_backupbuddy::_POST( $this->_prefix . $name ) != '' ) { // Submitted value exists, use it. $value = pb_backupbuddy::_POST( $this->_prefix . $name ); //} else { // Nothing submitted, fail. // return false; } } if ( isset( $this->_inputs[$name]['rules'] ) ) { return self::test_rule( $this->_inputs[$name]['rules'], $value ); } else { // No tests. Passed. return true; } } // End test(). /* pluginbuddy_form->test_rule() * * Tests a provided ruleset against a value to verify whether it complies or not. * @author Dan Harzheim * @see pluginbuddy_form->test() * * @param string $rule Rule(s) to validate against. See codex for details. TODO: document rulesets here. * @param string $value Value to validate. * @param array $callbacks NOT YET IMPLEMENTED. Array of callbacks for custom * verification methods. Each item in array is a * rule_name => callback_array pair. * Ex: $callbacks = array( 'phone' => array( $this, 'my_phone_validator' ) ); * @return true/array true on success; array of error(s) encountered on failure. */ function test_rule( $ruleset, $value ) { $errors = array(); if ( $ruleset == '' ) { return true; } $rules = explode( '|', $ruleset ); // Create array of rules. foreach( $rules as $rule ) { // Iterate through each rule. // ***** GET RULE TYPE ***** // Grab the type of the rule; ex: string, int, set, etc via regex. $rule_type_pos = strpos( $rule, '[' ); if ( $rule_type_pos === false ) { $rule_type = $rule; } else { $rule_type = substr( $rule, 0, $rule_type_pos ); } /* ***** REQUIRED ***** * Rule is required. * Fail if $value is empty. * if fails: $errors[] = 'Value is not a string.'; * */ if ( $rule_type == 'required' ) { // Required rule. if( $value == '' ) { $errors[] = 'This value is required.'; return $errors; // No more checking if left blank. } /* ***** STRING ***** * check to make sure that the string is the appropriate length. * */ } elseif ( $rule_type == 'string' ) { // String rule. $subrule = strstr( $rule, '[' ); $hyphen_pos = strpos( $subrule, '-' ); if( $hyphen_pos != '' ) { $first_number = substr( $subrule, 1, $hyphen_pos - 1 ); $second_number = substr( $subrule, $hyphen_pos + 1, -1 ); $val_length = strlen( $value ); if( $val_length < $first_number || $val_length > $second_number ){ $errors[] = 'Length of value `' . htmlentities( $value ) . '` is invalid.'; } } /* ***** INT TYPE ***** * make sure that the value fits inside of bounds * make sure it doesn't include a decimal * accepts blank value * */ } elseif ( $rule_type == 'int' ) { if ( '' != $value ) { if( !is_numeric( $value ) || strpos($value, '.') !== false ) { $errors[] = '`' . htmlentities( $value ) . '` is not a valid number.'; } else { $subrule = strstr( $rule, '[' ); $hyphen_pos = strpos( $subrule, '-' ); if( $hyphen_pos != '' ) { $first_number = substr( $subrule, 1, $hyphen_pos - 1 ); $second_number = substr( $subrule, $hyphen_pos + 1, -1 ); if( $value < $first_number || $value > $second_number ) { $errors[] = 'Value `' . htmlentities( $value ) . '` is outside of the set bounds.'; } } } } /* ***** EMAIL TYPE ***** * validate to make sure the e-mail address is actually an e-mail address. * */ } elseif ( $rule_type == 'email' ) { if ( '' != $value ) { // TODO: Add custom callback functionality here. if( !filter_var( $value, FILTER_VALIDATE_EMAIL ) ) { $errors[] = 'Value `' . htmlentities( $value ) . '` is not a valid e-mail address.'; } } /* ***** SET TYPE ***** * make sure that $value falls into one of the types. * */ } elseif ( $rule_type == 'set' ) { //set[string,string,string,] $is_there = false; $substring = strstr( $rule, '[' ); $substring = substr( $substring, $substring + 1, $substring - 1 ); $parts = explode( ',', $substring ); foreach( $parts as $part ) { if( $value == $part ) { $is_there = true; } } if( $is_there == false ) { $errors[] = 'Value `' . htmlentities( $value ) . '` is not a valid value.'; } /* ***** NUM TYPE ***** * make sure that $value is numeric, if so, make sure it fits inside of bounds * */ } elseif ( $rule_type == 'number' ) { if( !is_numeric( $value ) ) { $errors[] = $value . ' is not a number.'; } $subrule = strstr( $rule, '[' ); $hyphen_pos = strpos( $subrule, '-' ); if( $hyphen_pos != '' ) { $first_number = substr( $subrule, 1, $hyphen_pos - 1 ); $second_number = substr( $subrule, $hyphen_pos + 1, -1 ); if( $value < $first_number || $value > $second_number ) { $errors[] = 'Value `' . htmlentities( $value ) . '` is outside of the set bounds.'; } } } else { // TODO: Add custom callback functionality here. // Unknown rule so notify the developer. $errors[] = '{Error #54589. Unknown rule `' . $rule_type . '`.}'; } } if ( count( $errors ) === 0 ) { // No errors; success! return true; } else { // One or more errors encountered; return array of errors. return $errors; } } // End test_rule(). /* clear_values() * * Clears the value of all form items setting the value to an empty string ''. * * @return null */ public function clear_values() { foreach( $this->_inputs as &$input ) { $input['value'] = '';; } return; } // End clear_values(). } // End class pluginbuddy_form
?>
|