/
qa-obvious-admin-form.php
95 lines (87 loc) · 2.51 KB
/
qa-obvious-admin-form.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
<?php
if (!defined('QA_VERSION')) { // don't allow this page to be requested directly from browser
header('Location: ../');
exit;
}
class qa_obvious_admin_form{
function option_default($option) {
switch($option)
{
case 'obvious_content_color':
return '#FFEFC6';
case 'obvious_max_tags':
return '10';
case 'obvious_content_category_color':
return '#FFEFC6';
default:
return null;
}
}
function admin_form(&$qa_content)
{
$ok=null;
if (qa_clicked('obvious_save_button')) {
qa_opt('obvious_content_on', (bool)qa_post_text('obvious_content_on'));
qa_opt('obvious_content_color', (string)qa_post_text('obvious_content_color'));
qa_opt('obvious_max_tags', (int)qa_post_text('obvious_max_tags'));
qa_opt('obvious_content_category_on', (bool)qa_post_text('obvious_content_category_on'));
qa_opt('obvious_content_category_color', (string)qa_post_text('obvious_content_category_color'));
$ok = qa_lang('admin/options_saved');
}
else if (qa_clicked('obvious_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');
}
$fields = array();
$fields[] = array(
'label' => 'Enable Obvious Favorite Tags',
'tags' => 'NAME="obvious_content_on"',
'value' => qa_opt('obvious_content_on'),
'type' => 'checkbox',
);
$fields[] = array(
'label' => 'Your color in Hex',
'tags' => 'NAME="obvious_content_color"',
'value' => qa_opt('obvious_content_color'),
'type' => 'string',
);
$fields[] = array(
'label' => 'Enable Obvious Favorite Category',
'tags' => 'NAME="obvious_content_category_on"',
'value' => qa_opt('obvious_content_category_on'),
'type' => 'checkbox',
);
$fields[] = array(
'label' => 'Your color in Hex',
'tags' => 'NAME="obvious_content_category_color"',
'value' => qa_opt('obvious_content_category_color'),
'type' => 'string',
);
$fields[] = array(
'type' => 'blank',
);
$fields[] = array(
'label' => 'Maximum tags for the Widget',
'tags' => 'NAME="obvious_max_tags"',
'value' => qa_opt('obvious_max_tags'),
'type' => 'int',
);
return array(
'ok' => ($ok && !isset($error)) ? $ok : null,
'fields' => $fields,
'buttons' => array(
array(
'label' => qa_lang_html('main/save_button'),
'tags' => 'NAME="obvious_save_button"',
),
array(
'label' => qa_lang_html('admin/reset_options_button'),
'tags' => 'NAME="obvious_reset_button"',
),
),
);
}
}