/
Template.php
971 lines (807 loc) · 23.9 KB
/
Template.php
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
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
<?php
/**
* @package Aspen_Framework
* @subpackage System
* @author Michael Botsko
* @copyright 2009 Trellis Development, LLC
* @since 1.0
*/
/**
* Shortcut to return an instance of our original app
* @return object
*/
function &template(){
return app()->template;
}
/**
* Shortcut for the language support method
* @param string $type
* @return string
*/
function text(){
// pass any additional arguments straight to text
$args = func_get_args();
return call_user_func_array(array(app()->template,'text'),$args);
}
/**
* This class manages our templates and loads them for display
* @package Aspen_Framework
*/
class Template {
/**
* @var string Holds the page template name
* @access public
*/
public $page;
/**
* @var string Holds the layout template name
* @access public
*/
public $layout = 'default';
/**
* @var string Holds the display template of the page title
* @access public
*/
public $page_title = '{lang_title}';
/**
* @var array An array of variables to pass through to the object
* @access private
*/
private $_data = array();
/**
* @var array Holds custom css styles for printing in the header
* @access private
*/
private $_css_styles = array();
/**
* @var array An array of css files queued for loading in the header
* @access private
*/
private $_load_css = array();
/**
* @var array An array of javascript files queued for loading in the header
* @access private
*/
private $_load_js = array();
/**
* @var array An array of javascript variables queued for loading in the header
* @access private
*/
private $_load_js_vars = array();
/**
* @var array $lang Holds the current language values
* @access private
*/
private $terms;
/**
* Holds the current template file path
* @var type
*/
private $template;
/**
* Returns the layouts directory
* @return string
* @access public
*/
public function getLayoutDir(){
return INTERFACE_PATH . DS. 'layouts';
}
/**
* Returns the template directory for our module
* @return string
* @access public
*/
public function getModuleTemplateDir($module = false, $interface = false){
$orig_interface = $interface;
$interface = $interface ? strtolower($interface) : LS;
$module = router()->cleanModule($module);
return router()->getModulePath($module, $orig_interface) . DS . 'templates' . ($interface == '' ? false : '_' . $interface);
}
/**
* This method allows you to add resources to the page. Every resource
* should be passed here, as an appropriate object. The template will
* print/use the resource depending its type.
*/
public function add_resource( $resource ){
if( is_object($resource) ){
// Handle javascript objects by printing their script elements
if( $resource instanceof Aspen_JavaScript){
$this->_load_js[] = $resource;
}
// Handle css objects by printing their link/style elements
if( $resource instanceof Aspen_Css){
$this->_load_css[] = $resource;
}
}
}
/**
* Allows the user to add custom styles which will be printed with module header
* @param string $selector
* @param string $attr
* @param string $value
*/
public function setCssStyle($selector, $attr, $value){
$this->_css_styles[] = array('selector'=>$selector,'attr'=>$attr,'value'=>$value);
}
/**
* Sorts and re-arranges css/javascript includes
*/
public function prepareMediaIncludes(){
// if(!empty($this->_load_css)){
// ksort($this->_load_css, SORT_STRING);
// }
// // append any js files for loading
// if(!empty($this->_load_js)){
// ksort($this->_load_js, SORT_STRING);
// }
}
/**
* Loads a header file for the currently loaded module, if that file exists
* @access public
*/
public function loadModuleHeader(){
$this->prepareMediaIncludes();
// append any css files for loading
if(!empty($this->_load_css)){
foreach($this->_load_css as $css){
print $css;
}
}
// append any custom css styles
if(!empty($this->_css_styles)){
print '<style>'."\n";
foreach($this->_css_styles as $style){
printf('%s { %s: %s }'."\n", $style['selector'], $style['attr'], $style['value']);
}
print '</style>'."\n";
}
// append any js files for loading
if(config()->get('print_js_variables')){
print '<script>'."\n";
print 'var INTERFACE_URL = "'.router()->interfaceUrl().'";'."\n";
if(is_array($this->_load_js_vars)){
foreach($this->_load_js_vars as $var => $value){
if(is_array($value)){
print 'var '. strtoupper($var).' = '.json_encode($value).';'."\n";
} else {
print 'var '. strtoupper($var).' = "'.addslashes($value).'";'."\n";
}
}
}
print '</script>'."\n";
}
if(!empty($this->_load_js)){
foreach($this->_load_js as $js){
if($js->getLoadIn() == 'header'){
print $js;
}
}
}
}
/**
* Loads a header file for the currently loaded module, if that file exists
* @access public
*/
public function loadModuleFooter(){
$this->prepareMediaIncludes();
if(!empty($this->_load_js)){
foreach($this->_load_js as $js){
if($js->getLoadIn() == 'footer'){
$this->printJs($js);
}
}
}
}
/**
* Adds a javascript variable to the header
* @param string $key
* @param mixed $value
* @access public
*/
public function addJsVar($key, $value){
$this->_load_js_vars[$key] = $value;
}
/**
* Base static url build for the addJs/addCss methods
* @param array $args
* @return string
* @access private
*/
private function staticUrl($args){
$basepath = $filename = '';
if($args['url']){
$file = $args['url'];
}
else if($args['from'] == 'm'){
$filename = $args['file'] ? $args['file'] : strtolower(router()->method()).'.'.$args['ext'];
$basepath = $args['basepath'] ? $args['basepath'] : router()->moduleUrl() . '/'.$args['ext'];
$file = $basepath . '/' . $filename;
}
else if($args['from'] == 'i'){
$interface = !empty($args['interface']) ? $args['interface'] : false;
$filename = $args['file'] ? $args['file'] : strtolower(LS).'.'.$args['ext'];
$basepath = $args['basepath'] ? $args['basepath'] : router()->staticUrl($interface) . '/'.$args['ext'];
$file = $basepath . '/' . $filename;
}
return $file;
}
/**
*
* @param type $path
* @return type
*/
public function parseMediaFilePath($path){
$base = array();
$path_arr = explode('/', $path);
if(is_array($path_arr) && count($path_arr) > 1){
$i = count($path_arr) - 1;
$path_arr = array_reverse($path_arr);
$base['from'] = (isset($path_arr[$i]) ? 'i' : 'm');
$base['interface'] = (isset($path_arr[$i]) ? $path_arr[$i] : false);
$base['file'] = (isset($path_arr[$i]) ? str_replace($path_arr[$i].'/', '', $path) : $path);
} else {
$base['file'] = $path;
}
return $base;
}
/**
* Sets the language text array from the router
* @param array $terms
* @access private
*/
public function loadLanguageTerms($terms = false){
if(is_array($this->terms) && is_array($terms)){
$this->terms = array_merge($this->terms, $terms);
} else {
$this->terms = $terms;
}
}
/**
* Returns the text value for a key from the selected language
* @param string $key
* @return string
* @access public
*/
public function text($key){
$text = isset($this->terms[$key]) ? $this->terms[$key] : '';
// If non-empty, pass any additional arguments straight to sprintf
if(!empty($text)){
$args = func_get_args();
if(count($args) > 1){
$args[0] = $text;
$text = call_user_func_array('sprintf',$args);
}
}
return $text;
}
/**
* Assigns an array of data to pass through to the templates
* @param <type> $data
* @access public
*/
public function set($data){
if(is_array($data)){
$this->_data = array_merge($this->_data, $data);
}
}
/**
* Display all templates that have been primed for output
* @param $data Array of data to be passed
* @access public
*/
public function page(){
if(!$this->template){
$this->setPage();
}
if(file_exists($this->template) && strpos($this->template, APPLICATION_PATH) !== false){
// pass through variables
if(is_array($this->_data)){
foreach($this->_data as $var => $value){
$$var = $value;
}
}
app()->log->write('Including template ' . $this->template);
include($this->template);
}
}
/**
* Display our layout that has been primed for output
* @param $data Array of data to be passed
* @access public
*/
public function display($data = false){
$this->set($data);
// if token auth on, we need to generate a token
if(config()->get('require_form_token_auth')){
$token = app()->security->generateFormToken();
}
$layout = $this->getLayoutDir().DS.$this->layout.'.tpl.php';
if(file_exists($layout)){
// pass through variables
if(is_array($this->_data)){
foreach($this->_data as $var => $value){
$$var = $value;
}
}
app()->log->write('Including layout ' . $layout);
include($layout);
}
$this->resetTemplateQueue();
}
/**
* Set the current layout.
* @param string $layout
*/
public function setLayout($layout){
$this->layout = $layout;
}
/**
* Set the current page template.
* @param string $page
*/
public function setPage( $page = false, $module = false ){
$this->page = $page;
$page = $this->page ? $this->page : router()->method();
if(router()->method() == 'add'){
if(!file_exists($this->getModuleTemplateDir( $module ).DS.'add.tpl.php')){
$page = 'edit';
}
}
$this->template = $this->getModuleTemplateDir( $module ).DS.$page.'.tpl.php';
}
/**
* Resets the template queue
* @access public
*/
public function resetTemplateQueue(){
$this->_data = array();
$this->_load_css = array();
$this->_load_js = array();
}
/**
* Returns class attribute if the user is at the selected location
* @param string $module
* @param string $method
* @param string $interface
* @return string
*/
public function at($path = false, $type = 'method'){
return (router()->here($path,$type) ? ' class="'.config()->get('active_link_class_name').'"' : '');
}
/**
* Generates an interface/module/method path string
* @param string $method
* @param string $module
* @param string $interface
* @return string
*/
public function getNamespacePath($method, $module = false, $interface = false){
$path = '';
if(!empty($interface)){
$path .= $interface.'/';
}
if(!empty($module)){
$path .= strtolower($module).'/';
}
$path .= $method;
return $path;
}
/**
* Returns a properly-encoded URL using a module and method
* @param string $module
* @param array $bits Additional arguments to pass through the url
* @param string $method
* @return string
* @access public
*/
public function ajaxUrl($path = false, $bits = false){
$orig_config = config()->get('enable_mod_rewrite');
app()->setConfig('enable_mod_rewrite', false); // turn off rewrite urls
$url = Url::path($path, $bits);
app()->setConfig('enable_mod_rewrite', $orig_config); // turn them back to what they were
return $url;
}
/**
* Creates a link to the current page with params, replacing any existing params
* @param array $bits
* @param string $method
* @param string $method
* @return string
* @access public
*/
public function selfLink($text, $bits = false, $path = false){
$new_params = router()->getMappedArguments();
// remove any options from the url that are in our new params
if(is_array($bits) && count($bits)){
foreach($bits as $key => $value){
$new_params[$key] = $value;
}
}
return Link::path($text, $path, $new_params);
}
/**
* Creates an xhtml valid url to the current page with params, replacing any existing params
* @param array $params
* @param string $method
* @return string
* @access public
*/
public function xhtmlSelfUrl($bits = false, $path = false){
$new_params = router()->getMappedArguments();
// remove any options from the url that are in our new params
if(is_array($bits) && count($bits)){
foreach($bits as $key => $value){
$new_params[$key] = $value;
}
}
if(!$path){
$map = router()->getOriginalMap();
$path = $map['module'].'/'.$map['method'];
}
return $this->xhtmlUrl($path, $new_params);
}
/**
* Creates a url to the current page with params, replacing any existing params
* @param array $params
* @param string $method
* @return string
* @access public
*/
public function selfUrl($bits = false, $path = false){
$new_params = router()->getMappedArguments();
// remove any options from the url that are in our new params
if(is_array($bits) && count($bits)){
foreach($bits as $key => $value){
$new_params[$key] = $value;
}
}
if(!$path){
$map = router()->getOriginalMap();
$path = $map['module'].'/'.$map['method'];
}
return Url::path($path, $new_params);
}
/**
* Creates a link for sorting a result set
* @param string $title
* @param string $location
* @param string $sort_by
* @return string
*/
public function sortLink($title, $location, $sort_by, $add_class = false){
$base = $this->xhtmlSelfUrl();
$sort = app()->prefs->getSort($location, $sort_by);
// determine the sort direction
$new_direction = $sort['sort_direction'] == "ASC" ? "DESC" : "ASC";
// add class
$add_class = $add_class ? ' '.$add_class : '';
// determine the proper class, if any
$class = 'sortable';
if($sort['sort_by'] == $sort_by){
$class = strtolower($new_direction);
}
// build proper url
$url = $base.'?'.http_build_query(array(
'sort_location'=>$location,
'sort_by'=>$sort_by,
'sort_direction'=>$new_direction), '', '&');
// create the link
$html = sprintf('<a href="%s" title="%s" class="%s">%s</a>',
$url,
'Sort ' . Link::encodeTextEntities($title) . ' column ' . ($new_direction == 'ASC' ? 'ascending' : 'descending'),
$class.$add_class,
Link::encodeTextEntities($title)
);
return $html;
}
/**
* Generate a basic LI set of pagination links
* @param array $pages
* @return string
*/
public function paginateLinks($pages){
$current_page = $pages['current_page'];
$per_page = $pages['per_page'];
$total_pages = $pages['total_pages'];
$url = $this->selfUrl().'?';
// build the html list item
$html = '';
if($total_pages > 1){
$link_limit = config()->get('pagination_link_limit');
$limit_balance = ceil(($link_limit / 2));
// previous
if($current_page > 1){
$html .= sprintf('<li><a href="%spage=%d" class="page-prev">«</a></li>', $url, ($current_page-1));
}
// if we need to display the other page numbers
if(config()->get('pagination_show_page_numbers')){
// add in the first page
$selected = $current_page == 1 ? ' at' : '';
$html .= sprintf('<li class="page-first%s"><a href="%spage=%d">%3$d</a></li>', $selected, $url, 1);
// if more than 15 results, show 15 page numbers closest to our current page
$p = 2;
$limit = $total_pages;
if($total_pages > $link_limit){
$p = $current_page;
// start loop at 7 pages prior to current, if possible
if($p > 7){
$tmp_start = $p - $limit_balance;
if($tmp_start > 0){
$p = $tmp_start;
}
if($current_page >= ($total_pages - $limit_balance)){
$p = $total_pages - $link_limit;
}
} else {
$p = 2;
}
$p = $p == 1 ? 2 : $p;
$limit = $p + $link_limit;
}
// add elipse if > 15 pages
if($total_pages > $link_limit && $current_page > ($limit_balance+2)){
$html .= '<li>…</li>';
}
// add in the numeric links
while($p < $limit){
$selected = $current_page == $p ? ' class="at"' : '';
$html .= sprintf('<li%s><a href="%spage=%d">%3$d</a></li>', $selected, $url, $p);
$p++;
}
// add elipsis if > 15 pages
if($total_pages > $link_limit && $current_page < ($total_pages - $limit_balance)){
$html .= '<li>…</li>';
}
// add in the last page
$p = $total_pages;
$selected = $current_page == $p ? ' at' : '';
$html .= sprintf('<li class="page-last%s"><a href="%spage=%d">%3$d</a></li>', $selected, $url, $p);
} else {
// Otherwise, just add the current page
$html .= sprintf('<li class="at"><a href="%spage=%d">%2$d</a></li>', $url, $current_page);
}
// next
if($current_page < $total_pages){
$html .= sprintf('<li><a href="%spage=%d" class="page-next">»</a></li>', $url, ($current_page+1));
}
}
return $html;
}
/**
* Generates an html-safe element id using a string
* @param string $text
* @return string
* @access protected
*/
public function elemId($text){
if(is_string($text)){
return strtolower( preg_replace("/[^A-Za-z0-9_]/", "", str_replace(" ", "_", $text) ) );
}
return false;
}
/**
* Returns a body id of the module/method
* @return string
* @access public
*/
public function body_id(){
return strtolower(router()->module().'_'.router()->method());
}
/**
* Returns a formatted page title for the current page
* @return string
* @access public
*/
public function page_title(){
$module = router()->cleanModule(router()->module());
$method = router()->method();
$this->page_title = str_replace('{lang_title}', text(strtolower($module).':'.$method.':head-title'), $this->page_title);
$this->page_title = str_replace('{module}', ucwords($module), $this->page_title);
$this->page_title = str_replace('{method}', ucwords(router()->method()), $this->page_title);
$this->page_title .= ' – '.config()->get('application_name');
return $this->page_title;
}
/**
* Returns a specific filter value from the GET params
* @param string $key The key of the filter value you want
* @return mixed
* @access public
*/
public function filterValue($key = false){
$filters = array();
if(get()->isArray('filter')){
$filters = get()->getArray('filter');
} else {
$sess_filters = session()->getArray('filter');
if(isset($sess_filters[router()->module() . ':' . router()->method()])){
$filters = $sess_filters[router()->module() . ':' . router()->method()];
}
}
return isset($filters[$key]) ? $filters[$key] : false;
}
/**
*
* @param <type> $gmdate
* @param <type> $format
* @param <type> $timezone
* @return <type>
*/
public function pref_date($gmdate, $format = false, $timezone = false){
$timezone = $timezone ? $timezone : config()->get('timezone');
$format = $format ? $format : config()->get('date_format');
// try to get a user timezone setting
if($user_id = session()->getInt('user_id')){
$timezone = app()->settings->getConfig('timezone', $user_id);
}
return Date::tzFormatDate($gmdate, $format, $timezone);
}
/**
* Generate an html SELECT element with values from a database
* @param string $selectTable
* @param string $selectField
* @param string $method
* @param string $orderby
* @param string $select_id
* @param string $where
* @return array
* @access public
*/
public function selectArray(
$selectTable, $selectField, $method = "ENUM",
$orderby = 'id', $select_id = false, $where = false, $text_as_vals = false){
$return_select_array = array();
if(!$select_id){
$tbl = model()->open($selectTable);
$select_id = $tbl->getPrimaryKey();
}
// If the type is ENUM, we'll get the possible values from
// the database
if($method == "ENUM"){
$schema = app()->getDatabaseSchema($selectTable);
foreach($my_enums as $value){
if($value->name == $selectField){
foreach($value->enums as $choice){
$choice = str_replace("'", "", $choice);
$return_select_array[$choice] = $choice;
}
}
}
} else {
// If the type is not enum, we'll get the possible values
// from using a DISTINCT query
$sql = "SELECT DISTINCT ".($select_id ? $select_id . ', ' : false)
."$selectField FROM $selectTable $where ORDER BY $orderby";
$getArray = model()->query($sql);
if($getArray->num_rows){
while($getArrayRow = mysqli_fetch_assoc($getArray)){
if($select_id){
if($select_id == $selectField){
$val = $getArrayRow[$selectField];
$return_select_array[$val] = $val;
} else {
$return_select_array[] = array($select_id=>$getArrayRow[$select_id], $selectField=>$getArrayRow[$selectField]);
}
} else {
$return_select_array[] = array('key'=>$getArrayRow[$selectField], $selectField=>$getArrayRow[$selectField]);
}
}
}
}
return $return_select_array;
}
/**
* Prints out select box options using selectArray
* @param array $selectArray
* @param mixed $match_value
* @param boolean $prepend_blank
* @param string $blank_text
* @uses selectArray
* @access public
*/
public function optionArray($selectArray = false, $match_value = false, $prepend_blank = false, $blank_text = false){
print $prepend_blank ? '<option value="">'.$blank_text.'</option>' . "\n" : '';
if(is_array($selectArray)){
foreach($selectArray as $key => $option){
// if it's an array, we have values from DISTINCT
if(is_array($option)){
// get array keys
$keys = array_keys($option);
// if array has value different from text or not
$value = empty($option[$keys[0]]) ? $option[$keys[1]] : $option[$keys[0]];
// match
$match = '';
if(is_array($match_value)){
$match = (in_array($value, $match_value) ? ' selected="selected"' : '');
} else {
$match = ($value == $match_value ? ' selected="selected"' : '');
}
printf('<option value="%s"%s>%s</option>' . "\n",
Link::encodeTextEntities($value),
$match,
Link::encodeTextEntities($option[$keys[1]]));
} else {
// match
$match = '';
if(is_array($match_value)){
$match = (in_array($key, $match_value) ? ' selected="selected"' : '');
} else {
$match = ($key == $match_value ? ' selected="selected"' : '');
}
printf('<option value="%s"%s>%s</option>' . "\n",
Link::encodeTextEntities($key),
$match,
Link::encodeTextEntities($option));
}
}
}
}
/**
* Hides values using html comments
* @param mixed $val
* @return string
* @access public
*/
public function htmlHide($val = false){
return '<!--' . $val . '-->' . "\n";
}
/**
* Return an array of US states
* @return array
* @access public
*/
public function stateList(){
return array(
'AL'=>"Alabama",
'AK'=>"Alaska",
'AZ'=>"Arizona",
'AR'=>"Arkansas",
'CA'=>"California",
'CO'=>"Colorado",
'CT'=>"Connecticut",
'DE'=>"Delaware",
'DC'=>"District Of Columbia",
'FL'=>"Florida",
'GA'=>"Georgia",
'HI'=>"Hawaii",
'ID'=>"Idaho",
'IL'=>"Illinois",
'IN'=>"Indiana",
'IA'=>"Iowa",
'KS'=>"Kansas",
'KY'=>"Kentucky",
'LA'=>"Louisiana",
'ME'=>"Maine",
'MD'=>"Maryland",
'MA'=>"Massachusetts",
'MI'=>"Michigan",
'MN'=>"Minnesota",
'MS'=>"Mississippi",
'MO'=>"Missouri",
'MT'=>"Montana",
'NE'=>"Nebraska",
'NV'=>"Nevada",
'NH'=>"New Hampshire",
'NJ'=>"New Jersey",
'NM'=>"New Mexico",
'NY'=>"New York",
'NC'=>"North Carolina",
'ND'=>"North Dakota",
'OH'=>"Ohio",
'OK'=>"Oklahoma",
'OR'=>"Oregon",
'PA'=>"Pennsylvania",
'RI'=>"Rhode Island",
'SC'=>"South Carolina",
'SD'=>"South Dakota",
'TN'=>"Tennessee",
'TX'=>"Texas",
'UT'=>"Utah",
'VT'=>"Vermont",
'VA'=>"Virginia",
'WA'=>"Washington",
'WV'=>"West Virginia",
'WI'=>"Wisconsin",
'WY'=>"Wyoming");
}
}
?>