forked from NoahY/q2a-role-markers
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathqa-marker-admin.php
188 lines (162 loc) · 4.94 KB
/
qa-marker-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
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
<?php
class qa_marker_admin {
function allow_template($template)
{
return ($template!='admin');
}
function option_default($option) {
switch($option) {
case 'marker_plugin_who_text_admin':
return '<i class="fa fa-shield" aria-hidden="true"></i>';
case 'marker_plugin_who_text_moderator':
return '<i class="fa fa-bolt" aria-hidden="true"></i>';
case 'marker_plugin_who_text_editor':
return '<i class="fa fa-wrench" aria-hidden="true"></i>';
case 'marker_plugin_who_text_expert':
return '<i class="fa fa-heart" aria-hidden="true"></i>';
case 'marker_plugin_css_2':
return '
.qa-q-item-avatar,.qa-q-view-avatar,.qa-a-item-avatar,.qa-c-item-avatar {
position:relative;
}
.qa-who-marker i {
font-size: 110%;
}
.qa-who-marker {
cursor: pointer;
margin: 0px 2px;
}
.qa-who-marker{
vertical-align: middle;
}
.qa-who-marker-expert {
color: #34495e;
}
.qa-who-marker-editor {
color: #34495e;
}
.qa-who-marker-moderator {
color: #34495e;
}
.qa-who-marker-admin {
color: #34495e;
}
.qa-avatar-marker {
left:0;
bottom:0;
position:absolute;
}';
default:
return null;
}
}
function admin_form(&$qa_content)
{
// Process form input
$ok = null;
if (qa_clicked('marker_save_button')) {
qa_opt('marker_plugin_css_2',qa_post_text('marker_plugin_css_2'));
qa_opt('marker_plugin_who_text_admin',qa_post_text('marker_plugin_who_text_admin'));
qa_opt('marker_plugin_who_text_moderator',qa_post_text('marker_plugin_who_text_moderator'));
qa_opt('marker_plugin_who_text_editor',qa_post_text('marker_plugin_who_text_editor'));
qa_opt('marker_plugin_who_text_expert',qa_post_text('marker_plugin_who_text_expert'));
qa_opt('marker_plugin_w_users',(bool)qa_post_text('marker_plugin_w_users'));
qa_opt('marker_plugin_w_qv',(bool)qa_post_text('marker_plugin_w_qv'));
qa_opt('marker_plugin_w_qi',(bool)qa_post_text('marker_plugin_w_qi'));
qa_opt('marker_plugin_w_a',(bool)qa_post_text('marker_plugin_w_a'));
qa_opt('marker_plugin_w_c',(bool)qa_post_text('marker_plugin_w_c'));
$ok = qa_lang('admin/options_saved');
}
else if (qa_clicked('marker_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' => 'Marker custom css',
'tags' => 'NAME="marker_plugin_css_2"',
'value' => qa_opt('marker_plugin_css_2'),
'type' => 'textarea',
'rows' => 20
);
$fields[] = array(
'type' => 'blank',
);
$fields[] = array(
'label' => 'Marker text to show after Admin names',
'tags' => 'NAME="marker_plugin_who_text_admin"',
'value' => qa_opt('marker_plugin_who_text_admin'),
'type' => 'textarea',
'rows' => 1
);
$fields[] = array(
'label' => 'Marker text to show after Moderator names',
'tags' => 'NAME="marker_plugin_who_text_moderator"',
'value' => qa_opt('marker_plugin_who_text_moderator'),
'type' => 'textarea',
'rows' => 1
);
$fields[] = array(
'label' => 'Marker text to show after Editor names',
'tags' => 'NAME="marker_plugin_who_text_editor"',
'value' => qa_opt('marker_plugin_who_text_editor'),
'type' => 'textarea',
'rows' => 1
);
$fields[] = array(
'label' => 'Marker text to show after Expert names',
'tags' => 'NAME="marker_plugin_who_text_expert"',
'value' => qa_opt('marker_plugin_who_text_expert'),
'type' => 'textarea',
'rows' => 1
);
$fields[] = array(
'label' => 'Show marker after names in questions on pages',
'tags' => 'NAME="marker_plugin_w_qv"',
'value' => qa_opt('marker_plugin_w_qv'),
'type' => 'checkbox',
);
$fields[] = array(
'label' => 'Show marker after names in questions in lists',
'tags' => 'NAME="marker_plugin_w_qi"',
'value' => qa_opt('marker_plugin_w_qi'),
'type' => 'checkbox',
);
$fields[] = array(
'label' => 'Show marker after names in answers',
'tags' => 'NAME="marker_plugin_w_a"',
'value' => qa_opt('marker_plugin_w_a'),
'type' => 'checkbox',
);
$fields[] = array(
'label' => 'Show marker after names in comments',
'tags' => 'NAME="marker_plugin_w_c"',
'value' => qa_opt('marker_plugin_w_c'),
'type' => 'checkbox',
);
$fields[] = array(
'label' => 'Show marker after names in users list',
'tags' => 'NAME="marker_plugin_w_users"',
'value' => qa_opt('marker_plugin_w_users'),
'type' => 'checkbox',
);
return array(
'ok' => ($ok && !isset($error)) ? $ok : null,
'fields' => $fields,
'buttons' => array(
array(
'label' => qa_lang_html('main/save_button'),
'tags' => 'NAME="marker_save_button"',
),
array(
'label' => qa_lang_html('admin/reset_options_button'),
'tags' => 'NAME="marker_reset_button"',
),
),
);
}
}