-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathqa_hashtagger_admin.php
72 lines (65 loc) · 1.88 KB
/
qa_hashtagger_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
<?php
class qa_hashtagger_admin
{
/**
* The list of options names (these options have boolean values)
*
* @var array
*/
private static $bool_options = array(
'plugin_hashtagger/filter_questions',
'plugin_hashtagger/filter_comments',
'plugin_hashtagger/filter_answers',
'plugin_hashtagger/convert_hashtags',
'plugin_hashtagger/keep_hash_symbol',
'plugin_hashtagger/convert_usernames',
'plugin_hashtagger/notify_users',
);
/**
* Get the default option value
*
* @param string $option
*
* @return boolean
*/
public function option_default($option)
{
return in_array($option, self::$bool_options);
}
/**
* Configuration of plugin for admin form
*
* @param array $qa_content
*
* @return array
*/
public function admin_form(&$qa_content)
{
// Check if we should save options
$save_options = qa_clicked('plugin_hashtagger_save_button');
// Define default form variables
$config = array(
'buttons' => array(
array(
'label' => qa_lang('plugin_hashtagger/save_changes'),
'tags' => 'NAME="plugin_hashtagger_save_button"',
),
),
'fields' => array(),
'ok' => $save_options ? qa_lang('plugin_hashtagger/options_saved') : null,
);
// Build and save options
foreach (self::$bool_options as $name) {
if ($save_options) {
qa_opt($name, (bool)qa_post_text($name));
}
$config['fields'][] = array(
'label' => qa_lang($name),
'type' => 'checkbox',
'value' => qa_opt($name),
'tags' => "NAME='{$name}'",
);
}
return $config;
}
}