-
Notifications
You must be signed in to change notification settings - Fork 144
/
output_modules.php
1613 lines (1526 loc) · 59.1 KB
/
output_modules.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
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?php
/**
* Core modules
* @package modules
* @subpackage core
*/
/**
* Simple search form for the folder list
* @subpackage core/output
*/
class Hm_Output_search_from_folder_list extends Hm_Output_Module {
/**
* Add a search form to the top of the folder list
*/
protected function output() {
$res = '<li class="menu_search"><form method="get">';
if (!$this->get('hide_folder_icons')) {
$res .= '<a class="unread_link" href="?page=search">';
$res .= '<img class="account_icon" src="'.$this->html_safe(Hm_Image_Sources::$search);
$res .= '" alt="'.$this->trans('Search').'" width="16" height="16" /></a>';
}
$res .= '<input type="hidden" name="page" value="search" />'.
'<label class="screen_reader" for="search_terms">'.$this->trans('Search').'</label><input type="search" id="search_terms" class="search_terms" name="search_terms" placeholder="'.
$this->trans('Search').'" /></form></li>';
if ($this->format == 'HTML5') {
return $res;
}
$this->concat('formatted_folder_list', $res);
}
}
/**
* Start the search results content section
* @subpackage core/output
*/
class Hm_Output_search_content_start extends Hm_Output_Module {
/**
* Leaves two open div tags that are closed in Hm_Output_search_content_end and Hm_Output_search_form
*/
protected function output() {
return '<div class="search_content"><div class="content_title">'.
message_controls($this).$this->trans('Search');
}
}
/**
* End of the search results content section
* @subpackage core/output
*/
class Hm_Output_search_content_end extends Hm_Output_Module {
/**
* Closes a div opened in Hm_Output_search_content_start
*/
protected function output() {
return '</div>';
}
}
/**
* Unsaved data reminder
* @subpackage core/output
*/
class Hm_Output_save_reminder extends Hm_Output_Module {
protected function output() {
if ($this->get('single_server_mode')) {
return '';
}
$changed = $this->get('changed_settings', array());
if (!empty($changed)) {
return '<div class="save_reminder"><a title="'.$this->trans('You have unsaved changes').
'" href="?page=save"><img alt="'.$this->trans('Save').'" src="'.Hm_Image_Sources::$save.'" width="20" height="20" /></a></div>';
}
return '';
}
}
/**
* Start the search form
* @subpackage core/output
*/
class Hm_Output_search_form_start extends Hm_Output_Module {
protected function output() {
return '<div class="search_form"><form method="get">';
}
}
/**
* Search form content
* @subpackage core/output
*/
class Hm_Output_search_form_content extends Hm_Output_Module {
protected function output() {
$terms = $this->get('search_terms', '');
return '<input type="hidden" name="page" value="search" />'.
' <label class="screen_reader" for="search_terms">'.$this->trans('Search Terms').'</label>'.
'<input required placeholder="'.$this->trans('Search Terms').
'" id="search_terms" type="search" class="search_terms" name="search_terms" value="'.$this->html_safe($terms).'" />'.
' <label class="screen_reader" for="search_fld">'.$this->trans('Search Field').'</label>'.
search_field_selection($this->get('search_fld', DEFAULT_SEARCH_FLD), $this).
' <label class="screen_reader" for="search_since">'.$this->trans('Search Since').'</label>'.
message_since_dropdown($this->get('search_since', DEFAULT_SINCE), 'search_since', $this).
' <input type="submit" class="search_update" value="'.$this->trans('Update').'" />'.
' <input type="button" class="search_reset" value="'.$this->trans('Reset').'" />';
}
}
/**
* Finish the search form
* @subpackage core/output
*/
class Hm_Output_search_form_end extends Hm_Output_Module {
protected function output() {
$source_link = '<a href="#" title="'.$this->trans('Sources').'" class="source_link"><img alt="Sources" class="refresh_list" src="'.Hm_Image_Sources::$folder.'" width="20" height="20" /></a>';
$refresh_link = '<a class="refresh_link" title="'.$this->trans('Refresh').'" href="#"><img alt="'.
$this->trans('Refresh').'" class="refresh_list" src="'.Hm_Image_Sources::$refresh.
'" width="20" height="20" /></a>';
return '</form></div>'.
list_controls($refresh_link, false, $source_link).list_sources($this->get('data_sources', array()), $this).'</div>';
}
}
/**
* Closes the search results table
* @subpackage core/output
*/
class Hm_Output_search_results_table_end extends Hm_Output_Module {
/**
*/
protected function output() {
return '</tbody></table>';
}
}
/**
* Some inline JS used by the search page
* @subpackage core/output
*/
class Hm_Output_js_search_data extends Hm_Output_Module {
/**
* adds two JS functions used on the search page
*/
protected function output() {
return '<script type="text/javascript">'.
'var hm_search_terms = function() { return "'.$this->html_safe($this->get('search_terms', ''), true).'"; };'.
'var hm_run_search = function() { return "'.$this->html_safe($this->get('run_search', 0)).'"; };'.
'</script>';
}
}
/**
* Outputs the end of the login or logout form
* @subpackage core/output
*/
class Hm_Output_login_end extends Hm_Output_Module {
/**
* Closes the login form
*/
protected function output() {
return '</form>';
}
}
/**
* Outputs the start of the login or logout form
* @subpackage core/output
*/
class Hm_Output_login_start extends Hm_Output_Module {
/**
* Looks at the current login state and outputs the correct form
*/
protected function output() {
if (!$this->get('router_login_state')) {
return '<form class="login_form" method="POST">';
}
else {
return '<form class="logout_form" method="POST">';
}
}
}
/**
* Outputs the login or logout form
* @subpackage core/output
*/
class Hm_Output_login extends Hm_Output_Module {
/**
* Looks at the current login state and outputs the correct form
*/
protected function output() {
$stay_logged_in = '';
if ($this->get('allow_long_session')) {
$stay_logged_in = '<div class="long_session"><input type="checkbox" id="stay_logged_in" value="1" name="stay_logged_in" />'.
' <label for="stay_logged_in">'.$this->trans('Stay logged in').'</label></div>';
}
if (!$this->get('router_login_state')) {
return '<h1 class="title">'.$this->html_safe($this->get('router_app_name', '')).'</h1>'.
' <input type="hidden" name="hm_page_key" value="'.Hm_Request_Key::generate().'" />'.
' <label class="screen_reader" for="username">'.$this->trans('Username').'</label>'.
'<input autofocus required type="text" placeholder="'.$this->trans('Username').'" id="username" name="username" value="">'.
' <label class="screen_reader" for="password">'.$this->trans('Password').'</label>'.
'<input required type="password" id="password" placeholder="'.$this->trans('Password').'" name="password">'.
$stay_logged_in.' <input type="submit" id="login" value="'.$this->trans('Login').'" />';
}
else {
$settings = $this->get('changed_settings', array());
$single = $this->get('single_server_mode');
$changed = 0;
if (!$single && count($settings) > 0) {
$changed = 1;
}
return '<input type="hidden" id="unsaved_changes" value="'.$changed.'" />'.
'<input type="hidden" name="hm_page_key" value="'.$this->html_safe(Hm_Request_Key::generate()).'" />'.
'<div class="confirm_logout"><div class="confirm_text">'.
$this->trans('Unsaved changes will be lost! Re-enter your password to save and exit.').' '.
'<a href="?page=save">'.$this->trans('More info').'</a></div>'.
'<label class="screen_reader" for="logout_password">'.$this->trans('Password').'</label>'.
'<input id="logout_password" name="password" class="save_settings_password" type="password" placeholder="'.$this->trans('Password').'" />'.
'<input class="save_settings" type="submit" name="save_and_logout" value="'.$this->trans('Save and Logout').'" />'.
'<input class="save_settings" id="logout_without_saving" type="submit" name="logout" value="'.$this->trans('Just Logout').'" />'.
'<input class="cancel_logout save_settings" type="button" value="'.$this->trans('Cancel').'" />'.
'</div>';
}
}
}
/**
* Start the content section for the servers page
* @subpackage core/output
*/
class Hm_Output_server_content_start extends Hm_Output_Module {
/**
* The server_content div is closed in Hm_Output_server_content_end
*/
protected function output() {
return '<div class="content_title">'.$this->trans('Servers').
'<div class="list_controls"></div>'.
'</div><div class="server_content">';
}
}
/**
* Close the server content section
* @subpackage core/output
*/
class Hm_Output_server_content_end extends Hm_Output_Module {
/**
* Closes the div tag opened in Hm_Output_server_content_start
*/
protected function output() {
return '</div>';
}
}
/**
* Output a date
* @subpackage core/output
*/
class Hm_Output_date extends Hm_Output_Module {
/**
* Currently not show in the display (hidden with CSS)
*/
protected function output() {
return '<div class="date">'.$this->html_safe($this->get('date')).'</div>';
}
}
/**
* Display system messages
* @subpackage core/output
*/
class Hm_Output_msgs extends Hm_Output_Module {
/**
* Error level messages start with ERR and will be shown in red
*/
protected function output() {
$res = '';
$msgs = Hm_Msgs::get();
$logged_out_class = '';
if (!$this->get('router_login_state') && !empty($msgs)) {
$logged_out_class = ' logged_out';
}
$res .= '<div class="sys_messages'.$logged_out_class.'">';
if (!empty($msgs)) {
$res .= implode(',', array_map(function($v) {
if (preg_match("/ERR/", $v)) {
return sprintf('<span class="err">%s</span>', $this->trans(substr($v, 3)));
}
else {
return $this->trans($v);
}
}, $msgs));
}
$res .= '</div>';
return $res;
}
}
/**
* Start the HTML5 document
* @subpackage core/output
*/
class Hm_Output_header_start extends Hm_Output_Module {
/**
* Doctype, html, head, and a meta tag for charset. The head section is not closed yet
*/
protected function output() {
$lang = 'en';
$dir = 'ltr';
if ($this->lang) {
$lang = strtolower(str_replace('_', '-', $this->lang));
}
if ($this->dir) {
$dir = $this->dir;
}
$class = $dir."_page";
return '<!DOCTYPE html><html dir="'.$this->html_safe($dir).'" class="'.
$this->html_safe($class).'" lang='.$this->html_safe($lang).'><head>'.
'<meta name="theme-color" content="#888888" /><meta charset="utf-8" />';
}
}
/**
* Close the HTML5 head tag
* @subpackage core/output
*/
class Hm_Output_header_end extends Hm_Output_Module {
/**
* Close the head tag opened in Hm_Output_header_start
*/
protected function output() {
return '</head>';
}
}
/**
* Start the content section
* @subpackage core/output
*/
class Hm_Output_content_start extends Hm_Output_Module {
/**
* Outputs the starting body tag and a noscript warning. Clears the local session cache
* if not logged in, or adds a page wide key used by ajax requests
*/
protected function output() {
$res = '<body><noscript class="noscript">'.
sprintf($this->trans('You need to have Javascript enabled to use %s, sorry about that!'),
$this->html_safe($this->get('router_app_name'))).'</noscript>';
if (!$this->get('router_login_state')) {
$res .= '<script type="text/javascript">sessionStorage.clear();</script>';
}
else {
$res .= '<input type="hidden" id="hm_page_key" value="'.$this->html_safe(Hm_Request_Key::generate()).'" />';
}
if (!$this->get('single_server_mode') && count($this->get('changed_settings', array())) > 0) {
$res .= '<a href="?page=save" title="'.$this->trans('Unsaved Changes').
'"><img src="'.Hm_Image_Sources::$save_reminder.
'" alt="'.$this->trans('Unsaved changes').
'" class="unsaved_reminder" /></a>';
}
return $res;
}
}
/**
* Outputs HTML5 head tag content
* @subpackage core/output
*/
class Hm_Output_header_content extends Hm_Output_Module {
/**
* Setup a title, base URL, a tab icon, and viewport settings
*/
protected function output() {
$title = '';
if (!$this->get('router_login_state')) {
$title = $this->get('router_app_name');
}
elseif ($this->exists('page_title')) {
$title .= $this->get('page_title');
}
elseif ($this->exists('mailbox_list_title')) {
$title .= ' '.implode('-', $this->get('mailbox_list_title', array()));
}
if (!trim($title) && $this->exists('router_page_name')) {
$title = '';
if ($this->get('list_path') == 'message_list') {
$title .= ' '.ucwords(str_replace('_', ' ', $this->get('list_path')));
}
elseif ($this->get('router_page_name') == 'notfound') {
$title .= ' Nope';
}
else {
$title .= ' '.ucwords(str_replace('_', ' ', $this->get('router_page_name')));
}
}
return '<title>'.$this->trans(trim($title)).'</title>'.
'<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=5.0">'.
'<link rel="icon" class="tab_icon" type="image/png" href="data:image/png;base64,iVBORw0KGgo'.
'AAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEwAACxMBAJqcGAAAAFVJR'.
'EFUOI3NkkEKACEMA2d92fpzfVn3oHhYqAF7qIFeSpImUMjGA1jEoEQTFKAC/UDbp3bhBRqj0m7a5C78F56Rx5MEdUB'.
'HFMlkV09ogN3xB7kG+fgA0tc160Jy09wAAAAASUVORK5CYII=" >'.
'<base href="'.$this->html_safe($this->get('router_url_path')).'" />';
}
}
/**
* Output CSS
* @subpackage core/output
*/
class Hm_Output_header_css extends Hm_Output_Module {
/**
* In debug mode adds each module css file to the page, otherwise uses the combined version
*/
protected function output() {
$res = '';
$mods = $this->get('router_module_list');
if (DEBUG_MODE) {
foreach (glob(APP_PATH.'modules/**', GLOB_ONLYDIR | GLOB_MARK) as $name) {
$name = str_replace(APP_PATH, '', $name);
$mod = str_replace(array('modules/', '/'), '', $name);
if (in_array($mod, $mods, true) && is_readable(sprintf("%ssite.css", $name))) {
$res .= '<link href="'.sprintf("%ssite.css", $name).'" media="all" rel="stylesheet" type="text/css" />';
}
}
}
else {
$res .= '<link href="site.css?v='.CACHE_ID.'" media="all" rel="stylesheet" type="text/css" />';
}
return $res;
}
}
/**
* Output JS
* @subpackage core/output
*/
class Hm_Output_page_js extends Hm_Output_Module {
/**
* In debug mode adds each module js file to the page, otherwise uses the combined version.
* Includes the zepto library, and the forge lib if it's needed.
*/
protected function output() {
if (DEBUG_MODE) {
$res = '';
$js_lib = '<script type="text/javascript" src="third_party/zepto.min.js"></script>';
if ($this->get('encrypt_ajax_requests', '') || $this->get('encrypt_local_storage', '')) {
$js_lib .= '<script type="text/javascript" src="third_party/forge.min.js"></script>';
}
$core = false;
$mods = $this->get('router_module_list');
foreach (glob(APP_PATH.'modules/**', GLOB_ONLYDIR | GLOB_MARK) as $name) {
$name = str_replace(APP_PATH, '', $name);
if ($name == 'modules/core/') {
$core = $name;
continue;
}
$mod = str_replace(array('modules/', '/'), '', $name);
if (in_array($mod, $mods, true) && is_readable(sprintf("%ssite.js", $name))) {
$res .= '<script type="text/javascript" src="'.sprintf("%ssite.js", $name).'"></script>';
}
}
if ($core) {
$res = '<script type="text/javascript" src="'.sprintf("%ssite.js", $core).'"></script>'.$res;
}
return $js_lib.$res;
}
else {
return '<script type="text/javascript" src="site.js?v='.CACHE_ID.'"></script>';
}
}
}
/**
* End the page content
* @subpackage core/output
*/
class Hm_Output_content_end extends Hm_Output_Module {
/**
* Closes the body and html tags
*/
protected function output() {
return '</body></html>';
}
}
/**
* Outputs page details for the JS
* @subpackage core/output
*/
class Hm_Output_js_data extends Hm_Output_Module {
/**
* Uses function wrappers to make the data immutable from JS
*/
protected function output() {
$res = '<script type="text/javascript">'.
'var globals = {};'.
'var hm_empty_folder = function() { return "'.$this->trans('So alone').'"; };'.
'var hm_mobile = function() { return '.($this->get('is_mobile') ? '1' : '0').'; };'.
'var hm_debug = function() { return "'.(DEBUG_MODE ? '1' : '0').'"; };'.
'var hm_page_name = function() { return "'.$this->html_safe($this->get('router_page_name')).'"; };'.
'var hm_list_path = function() { return "'.$this->html_safe($this->get('list_path', '')).'"; };'.
'var hm_list_parent = function() { return "'.$this->html_safe($this->get('list_parent', '')).'"; };'.
'var hm_msg_uid = function() { return "'.$this->html_safe($this->get('uid', '')).'"; };'.
'var hm_encrypt_ajax_requests = function() { return "'.$this->html_safe($this->get('encrypt_ajax_requests', '')).'"; };'.
'var hm_encrypt_local_storage = function() { return "'.$this->html_safe($this->get('encrypt_local_storage', '')).'"; };'.
'var hm_flag_image_src = function() { return "'.Hm_Image_Sources::$star.'"; };'.
format_data_sources($this->get('data_sources', array()), $this);
if (!$this->get('disable_delete_prompt')) {
$res .= 'var hm_delete_prompt = function() { return confirm("'.$this->trans('Are you sure?').'"); };';
}
else {
$res .= 'var hm_delete_prompt = function() { return true; };';
}
$res .= '</script>';
return $res;
}
}
/**
* Outputs a load icon
* @subpackage core/output
*/
class Hm_Output_loading_icon extends Hm_Output_Module {
/**
* Sort of ugly loading icon animated with js/css
*/
protected function output() {
return '<div class="loading_icon"></div>';
}
}
/**
* Start the main form on the settings page
* @subpackage core/output
*/
class Hm_Output_start_settings_form extends Hm_Output_Module {
/**
* Opens a div, form and table
*/
protected function output() {
return '<div class="user_settings"><div class="content_title">'.$this->trans('Site Settings').'</div>'.
'<form method="POST"><input type="hidden" name="hm_page_key" value="'.$this->html_safe(Hm_Request_Key::generate()).'" />'.
'<table class="settings_table"><colgroup>'.
'<col class="label_col"><col class="setting_col"></colgroup>';
}
}
/**
* Outputs the start page option on the settings page
* @subpackage core/output
*/
class Hm_Output_start_page_setting extends Hm_Output_Module {
/**
* Can be any of the main combined pages
*/
protected function output() {
$options = start_page_opts();
$settings = $this->get('user_settings', array());
if (array_key_exists('start_page', $settings)) {
$start_page = $settings['start_page'];
}
else {
$start_page = false;
}
$res = '<tr class="general_setting"><td><label for="start_page">'.
$this->trans('First page after login').'</label></td>'.
'<td><select id="start_page" name="start_page">';
foreach ($options as $label => $val) {
$res .= '<option ';
if ($start_page == $val) {
$res .= 'selected="selected" ';
}
$res .= 'value="'.$val.'">'.$this->trans($label).'</option>';
}
$res .= '</select></td></tr>';
return $res;
}
}
/**
* Outputs the list style option on the settings page
* @subpackage core/output
*/
class Hm_Output_list_style_setting extends Hm_Output_Module {
/**
* Can be either "news style" or the default "email style"
*/
protected function output() {
$options = array('email_style' => 'Email', 'news_style' => 'News');
$settings = $this->get('user_settings', array());
if (array_key_exists('list_style', $settings)) {
$list_style = $settings['list_style'];
}
else {
$list_style = false;
}
$res = '<tr class="general_setting"><td><label for="list_style">'.
$this->trans('Message list style').'</label></td>'.
'<td><select id="list_style" name="list_style">';
foreach ($options as $val => $label) {
$res .= '<option ';
if ($list_style == $val) {
$res .= 'selected="selected" ';
}
$res .= 'value="'.$val.'">'.$this->trans($label).'</option>';
}
$res .= '</select></td></tr>';
return $res;
}
}
/**
* @subpackage core/output
*/
class Hm_Output_no_folder_icon_setting extends Hm_Output_Module {
protected function output() {
$settings = $this->get('user_settings');
if (array_key_exists('no_folder_icons', $settings) && $settings['no_folder_icons']) {
$checked = ' checked="checked"';
}
else {
$checked = '';
}
return '<tr class="general_setting"><td><label for="no_folder_icons">'.$this->trans('Hide folder list icons').'</label></td>'.
'<td><input type="checkbox" '.$checked.' value="1" id="no_folder_icons" name="no_folder_icons" /></td></tr>';
}
}
/**
* @subpackage core/output
*/
class Hm_Output_no_password_setting extends Hm_Output_Module {
protected function output() {
$settings = $this->get('user_settings');
if (array_key_exists('no_password_save', $settings) && $settings['no_password_save']) {
$checked = ' checked="checked"';
}
else {
$checked = '';
}
return '<tr class="general_setting"><td><label for="no_password_save">'.$this->trans('Don\'t save account passwords between logins').'</label></td>'.
'<td><input type="checkbox" '.$checked.' value="1" id="no_password_save" name="no_password_save" /></td></tr>';
}
}
/**
* @subpackage core/output
*/
class Hm_Output_delete_prompt_setting extends Hm_Output_Module {
protected function output() {
$settings = $this->get('user_settings');
if (array_key_exists('disable_delete_prompt', $settings) && $settings['disable_delete_prompt']) {
$checked = ' checked="checked"';
}
else {
$checked = '';
}
return '<tr class="general_setting"><td><label for="disable_delete_prompt">'.$this->trans('Disable prompts when deleting').'</label></td>'.
'<td><input type="checkbox" '.$checked.' value="1" id="disable_delete_prompt" name="disable_delete_prompt" /></td></tr>';
}
}
/**
* Starts the Flagged section on the settings page
* @subpackage core/output
*/
class Hm_Output_start_flagged_settings extends Hm_Output_Module {
/**
* Settings in this section control the flagged messages view
*/
protected function output() {
return '<tr><td data-target=".flagged_setting" colspan="2" class="settings_subtitle">'.
'<img alt="" src="'.Hm_Image_Sources::$star.'" width="16" height="16" />'.
$this->trans('Flagged').'</td></tr>';
}
}
/**
* Start the Everything section on the settings page
* @subpackage core/output
*/
class Hm_Output_start_everything_settings extends Hm_Output_Module {
/**
* Setttings in this section control the Everything view
*/
protected function output() {
if ($this->get('single_server_mode')) {
return '';
}
return '<tr><td data-target=".all_setting" colspan="2" class="settings_subtitle">'.
'<img alt="" src="'.Hm_Image_Sources::$box.'" width="16" height="16" />'.
$this->trans('Everything').'</td></tr>';
}
}
/**
* Start the Unread section on the settings page
* @subpackage core/output
*/
class Hm_Output_start_unread_settings extends Hm_Output_Module {
/**
* Settings in this section control the Unread view
*/
protected function output() {
return '<tr><td data-target=".unread_setting" colspan="2" class="settings_subtitle">'.
'<img alt="" src="'.Hm_Image_Sources::$env_closed.'" width="16" height="16" />'.
$this->trans('Unread').'</td></tr>';
}
}
/**
* Start the E-mail section on the settings page.
* @subpackage core/output
*/
class Hm_Output_start_all_email_settings extends Hm_Output_Module {
/**
* Settings in this section control the All E-mail view. Skipped if there are no
* E-mail enabled module sets.
*/
protected function output() {
if (!email_is_active($this->get('router_module_list'))) {
return '';
}
if ($this->get('single_server_mode')) {
return '';
}
return '<tr><td data-target=".email_setting" colspan="2" class="settings_subtitle">'.
'<img alt="" src="'.Hm_Image_Sources::$env_closed.'" width="16" height="16" />'.
$this->trans('All Email').'</td></tr>';
}
}
/**
* Start the general settings section
* @subpackage core/output
*/
class Hm_Output_start_general_settings extends Hm_Output_Module {
/**
* General settings like langauge and timezone will go here
*/
protected function output() {
return '<tr><td data-target=".general_setting" colspan="2" class="settings_subtitle">'.
'<img alt="" src="'.Hm_Image_Sources::$cog.'" width="16" height="16" />'.
$this->trans('General').'</td></tr>';
}
}
/**
* Option for the maximum number of messages per source for the Unread page
* @subpackage core/output
*/
class Hm_Output_unread_source_max_setting extends Hm_Output_Module {
/**
* Processed by Hm_Handler_process_unread_source_max_setting
*/
protected function output() {
$sources = DEFAULT_PER_SOURCE;
$settings = $this->get('user_settings', array());
if (array_key_exists('unread_per_source', $settings)) {
$sources = $settings['unread_per_source'];
}
return '<tr class="unread_setting"><td><label for="unread_per_source">'.
$this->trans('Max messages per source').'</label></td>'.
'<td><input type="text" size="2" id="unread_per_source" name="unread_per_source" value="'.$this->html_safe($sources).'" /></td></tr>';
}
}
/**
* Option for the "received since" date range for the Unread page
* @subpackage core/output
*/
class Hm_Output_unread_since_setting extends Hm_Output_Module {
/**
* Processed by Hm_Handler_process_unread_since_setting
*/
protected function output() {
$since = DEFAULT_SINCE;
$settings = $this->get('user_settings', array());
if (array_key_exists('unread_since', $settings) && $settings['unread_since']) {
$since = $settings['unread_since'];
}
return '<tr class="unread_setting"><td><label for="unread_since">'.
$this->trans('Show messages received since').'</label></td>'.
'<td>'.message_since_dropdown($since, 'unread_since', $this).'</td></tr>';
}
}
/**
* Option for the maximum number of messages per source for the Flagged page
* @subpackage core/output
*/
class Hm_Output_flagged_source_max_setting extends Hm_Output_Module {
/**
* Processed by Hm_Handler_process_flagged_source_max_setting
*/
protected function output() {
$sources = DEFAULT_PER_SOURCE;
$settings = $this->get('user_settings', array());
if (array_key_exists('flagged_per_source', $settings)) {
$sources = $settings['flagged_per_source'];
}
return '<tr class="flagged_setting"><td><label for="flagged_per_source">'.
$this->trans('Max messages per source').'</label></td>'.
'<td><input type="text" size="2" id="flagged_per_source" name="flagged_per_source" value="'.$this->html_safe($sources).'" /></td></tr>';
}
}
/**
* Option for the "received since" date range for the Flagged page
* @subpackage core/output
*/
class Hm_Output_flagged_since_setting extends Hm_Output_Module {
protected function output() {
/**
* Processed by Hm_Handler_process_flagged_since_setting
*/
$since = DEFAULT_SINCE;
$settings = $this->get('user_settings', array());
if (array_key_exists('flagged_since', $settings) && $settings['flagged_since']) {
$since = $settings['flagged_since'];
}
return '<tr class="flagged_setting"><td><label for="flagged_since">'.
$this->trans('Show messages received since').'</label></td>'.
'<td>'.message_since_dropdown($since, 'flagged_since', $this).'</td></tr>';
}
}
/**
* Option for the maximum number of messages per source for the All E-mail page
* @subpackage core/output
*/
class Hm_Output_all_email_source_max_setting extends Hm_Output_Module {
/**
* Processed by Hm_Handler_process_all_email_source_max_setting
*/
protected function output() {
if (!email_is_active($this->get('router_module_list'))) {
return '';
}
$sources = DEFAULT_PER_SOURCE;
$settings = $this->get('user_settings', array());
if (array_key_exists('all_email_per_source', $settings)) {
$sources = $settings['all_email_per_source'];
}
return '<tr class="email_setting"><td><label for="all_email_per_source">'.
$this->trans('Max messages per source').'</label></td>'.
'<td><input type="text" size="2" id="all_email_per_source" name="all_email_per_source" value="'.$this->html_safe($sources).'" /></td></tr>';
}
}
/**
* Option for the maximum number of messages per source for the Everything page
* @subpackage core/output
*/
class Hm_Output_all_source_max_setting extends Hm_Output_Module {
/**
* Processed by Hm_Handler_process_all_source_max_setting
*/
protected function output() {
$sources = DEFAULT_PER_SOURCE;
$settings = $this->get('user_settings', array());
if (array_key_exists('all_per_source', $settings)) {
$sources = $settings['all_per_source'];
}
return '<tr class="all_setting"><td><label for="all_per_source">'.
$this->trans('Max messages per source').'</label></td>'.
'<td><input type="text" size="2" id="all_per_source" name="all_per_source" value="'.$this->html_safe($sources).'" /></td></tr>';
}
}
/**
* Option for the "received since" date range for the All E-mail page
* @subpackage core/output
*/
class Hm_Output_all_email_since_setting extends Hm_Output_Module {
/**
* Processed by Hm_Handler_process_all_email_since_setting
*/
protected function output() {
if (!email_is_active($this->get('router_module_list'))) {
return '';
}
$since = DEFAULT_SINCE;
$settings = $this->get('user_settings', array());
if (array_key_exists('all_email_since', $settings) && $settings['all_email_since']) {
$since = $settings['all_email_since'];
}
return '<tr class="email_setting"><td><label for="all_email_since">'.
$this->trans('Show messages received since').'</label></td>'.
'<td>'.message_since_dropdown($since, 'all_email_since', $this).'</td></tr>';
}
}
/**
* Option for the "received since" date range for the Everything page
* @subpackage core/output
*/
class Hm_Output_all_since_setting extends Hm_Output_Module {
/**
* Processed by Hm_Handler_process_all_since_setting
*/
protected function output() {
$since = DEFAULT_SINCE;
$settings = $this->get('user_settings', array());
if (array_key_exists('all_since', $settings) && $settings['all_since']) {
$since = $settings['all_since'];
}
return '<tr class="all_setting"><td><label for="all_since">'.
$this->trans('Show messages received since').'</label></td>'.
'<td>'.message_since_dropdown($since, 'all_since', $this).'</td></tr>';
}
}
/**
* Option for the language setting
* @subpackage core/output
*/
class Hm_Output_language_setting extends Hm_Output_Module {
/**
* Processed by Hm_Handler_process_language_setting
*/
protected function output() {
$langs = interface_langs();
$translated = array();
foreach ($langs as $code => $name) {
$translated[$code] = $this->trans($name);
}
asort($translated);
$mylang = $this->get('language', '');
$res = '<tr class="general_setting"><td><label for="language">'.
$this->trans('Language').'</label></td>'.
'<td><select id="language" name="language">';
foreach ($translated as $id => $lang) {
$res .= '<option ';
if ($id == $mylang) {
$res .= 'selected="selected" ';
}
$res .= 'value="'.$id.'">'.$lang.'</option>';
}
$res .= '</select></td></tr>';
return $res;
}
}
/**
* Option for the timezone setting
* @subpackage core/output
*/
class Hm_Output_timezone_setting extends Hm_Output_Module {
/**
* Processed by Hm_Handler_process_timezone_setting
*/
protected function output() {
$zones = timezone_identifiers_list();
$settings = $this->get('user_settings', array());
if (array_key_exists('timezone', $settings)) {
$myzone = $settings['timezone'];
}
else {
$myzone = false;
}
$res = '<tr class="general_setting"><td><label for="timezone">'.
$this->trans('Timezone').'</label></td><td><select id="timezone" name="timezone">';
foreach ($zones as $zone) {
$res .= '<option ';
if ($zone == $myzone) {
$res .= 'selected="selected" ';
}
$res .= 'value="'.$zone.'">'.$zone.'</option>';
}
$res .= '</select></td></tr>';
return $res;
}
}
/**
* Option to enable/disable message list icons
* @subpackage core/output
*/
class Hm_Output_msg_list_icons_setting extends Hm_Output_Module {
protected function output() {
$checked = '';
$settings = $this->get('user_settings', array());
if (array_key_exists('show_list_icons', $settings) && $settings['show_list_icons']) {
$checked = ' checked="checked"';
}
return '<tr class="general_setting"><td><label for="show_list_icons">'.
$this->trans('Show icons in message lists').'</label></td>'.
'<td><input type="checkbox" '.$checked.' id="show_list_icons" name="show_list_icons" value="1" /></td></tr>';
}
}
/**
* Ends the settings table
* @subpackage core/output
*/