-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathq2apro-recent-events-admin.php
More file actions
71 lines (65 loc) · 1.87 KB
/
Copy pathq2apro-recent-events-admin.php
File metadata and controls
71 lines (65 loc) · 1.87 KB
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
<?php
/*
Question2Answer Plugin: Recent Events Widget
Author: http://www.q2apro.com/
*/
class q2apro_recent_events
{
function init_queries($tableslc)
{
return null;
}
// option's value is requested but the option has not yet been set
function option_default($option)
{
switch($option) {
case 'q2apro_recent_events_counts':
return 5;
case 'q2apro_recent_events_time_format':
return '0';
default:
return null;
}
}
function allow_template($template)
{
return ($template!='admin');
}
function admin_form(&$qa_content)
{
// process the admin form if admin hit Save-Changes-button
$ok = null;
if(qa_clicked('q2apro_recent_events_save'))
{
qa_opt('q2apro_recent_events_counts', (int)qa_post_text('q2apro_recent_events_counts'));
qa_opt('q2apro_recent_events_time_format', qa_post_text('q2apro_recent_events_time_format'));
$ok = qa_lang('admin/options_saved');
}
// form fields to display frontend for admin
$fields = array();
$fields[] = array(
'type' => 'number',
'label' => qa_lang_html('qa_recent_events_widget_lang/admin_count'),
'tags' => 'name="q2apro_recent_events_counts"',
'value' => qa_opt('q2apro_recent_events_counts'),
);
$time_format_options = array('absolute', 'relative');
$fields[] = array(
'type' => 'select',
'label' => qa_lang_html('qa_recent_events_widget_lang/admin_time_format'),
'tags' => 'name="q2apro_recent_events_time_format"',
'value' => $time_format_options[qa_opt('q2apro_recent_events_time_format')],
'options' => $time_format_options,
);
return array(
'ok' => ($ok && !isset($error)) ? $ok : null,
'fields' => $fields,
'buttons' => array(
array(
'label' => 'save',
'tags' => 'name="q2apro_recent_events_save"',
),
),
);
} // end admin_form
} // end class