/
qa-prevnav-admin.php
103 lines (81 loc) · 2.16 KB
/
qa-prevnav-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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
<?php
class qa_prevnav_admin {
function allow_template($template)
{
return ($template!='admin');
}
function option_default($option) {
switch($option) {
case 'prevnav_plugin_widget_title':
return 'Previous questions';
case 'prevnav_plugin_css':
return '#qa-prevnav-buttons-container {
background: none repeat scroll 0 0 #DDDDDD;
font-size: 125%;
font-weight: bold;
margin: 20px 0;
padding: 20px;
text-align: center;
}
.prevnav-widget-container {
display:inline-block;
position:relative;
}';
}
}
function admin_form(&$qa_content)
{
// Process form input
$ok = null;
if (qa_clicked('prevnav_save_button')) {
qa_opt('prevnav_plugin_css',qa_post_text('prevnav_plugin_css'));
qa_opt('prevnav_plugin_widget_only',(bool)qa_post_text('prevnav_plugin_widget_only'));
qa_opt('prevnav_plugin_widget_title',qa_post_text('prevnav_plugin_widget_title'));
$ok = qa_lang('admin/options_saved');
}
else if (qa_clicked('prevnav_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(
'type' => 'blank',
);
$fields[] = array(
'label' => 'PrevNav buttons custom css',
'tags' => 'NAME="prevnav_plugin_css"',
'value' => qa_opt('prevnav_plugin_css'),
'type' => 'textarea',
'rows' => 20
);
$fields[] = array(
'label' => 'Widget Title',
'tags' => 'NAME="prevnav_plugin_widget_title"',
'value' => qa_opt('prevnav_plugin_widget_title'),
);
$fields[] = array(
'type' => 'blank',
);
$fields[] = array(
'type' => 'blank',
);
return array(
'ok' => ($ok && !isset($error)) ? $ok : null,
'fields' => $fields,
'buttons' => array(
array(
'label' => qa_lang_html('main/save_button'),
'tags' => 'NAME="prevnav_save_button"',
),
array(
'label' => qa_lang_html('admin/reset_options_button'),
'tags' => 'NAME="prevnav_reset_button"',
),
),
);
}
}