-
Notifications
You must be signed in to change notification settings - Fork 1
/
qa-accept-admin.php
88 lines (74 loc) · 2 KB
/
qa-accept-admin.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
<?php
class qa_accept_admin {
function allow_template($template)
{
return ($template!='admin');
}
function option_default($option) {
switch($option) {
case 'accept_plugin_css':
return '.accept-rate {
color: #999999 !important;
}';
default:
return null;
}
}
function admin_form(&$qa_content)
{
// Process form input
$ok = null;
if (qa_clicked('accept_save_button')) {
qa_opt('accept_plugin_css',qa_post_text('accept_plugin_css'));
qa_opt('accept_plugin_show',(bool)qa_post_text('accept_plugin_show'));
qa_opt('accept_plugin_shade',(bool)qa_post_text('accept_plugin_shade'));
$ok = qa_lang('admin/options_saved');
}
else if (qa_clicked('accept_reset_button')) {
foreach($_POST as $i => $v) {
$def = $this->option_default($i);
if($def !== null) qa_opt($i,$def);
}
$ok = qa_lang('admin/options_reset');
}
// Create the form for display
$fields = array();
$fields[] = array(
'label' => 'Show accept rate below user meta',
'tags' => 'NAME="accept_plugin_show"',
'value' => qa_opt('accept_plugin_show'),
'type' => 'checkbox',
);
$fields[] = array(
'label' => 'Color accept rate according to percentage',
'tags' => 'NAME="accept_plugin_shade"',
'value' => qa_opt('accept_plugin_shade'),
'note' => 'goes from red (0%) to green (100%)',
'type' => 'checkbox',
);
$fields[] = array(
'type' => 'blank',
);
$fields[] = array(
'label' => 'Custom css',
'tags' => 'NAME="accept_plugin_css"',
'value' => qa_opt('accept_plugin_css'),
'type' => 'textarea',
'rows' => 20
);
return array(
'ok' => ($ok && !isset($error)) ? $ok : null,
'fields' => $fields,
'buttons' => array(
array(
'label' => qa_lang_html('main/save_button'),
'tags' => 'NAME="accept_save_button"',
),
array(
'label' => qa_lang_html('admin/reset_options_button'),
'tags' => 'NAME="accept_reset_button"',
),
),
);
}
}