-
Notifications
You must be signed in to change notification settings - Fork 0
/
qa-tag-desc-widget.php
127 lines (103 loc) · 3.61 KB
/
qa-tag-desc-widget.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
<?php
class qa_tag_descriptions_widget {
function allow_template($template)
{
return ($template=='tag');
}
function allow_region($region)
{
return true;
}
function output_widget($region, $place, $themeobject, $template, $request, $qa_content)
{
require_once QA_INCLUDE_DIR.'qa-db-metas.php';
$parts=explode('/', $request);
$tag=$parts[1];
$description=qa_db_tagmeta_get($tag, 'description');
$editurlhtml=qa_path_html('tag-edit/'.$tag);
$allowediting=!qa_user_permit_error('plugin_tag_desc_permit_edit');
if (strlen($description)) {
echo '<SPAN STYLE="font-size:'.(int)qa_opt('plugin_tag_desc_font_size').'px;">';
echo $description;
echo '</SPAN>';
if ($allowediting)
echo ' - <A HREF="'.$editurlhtml.'">edit</A>';
} elseif ($allowediting){
echo '<A HREF="'.$editurlhtml.'">'.qa_lang_html('plugin_tag_desc/create_desc_link').'</A>';
} else{
echo '<SPAN STYLE="font-size:'.(int)qa_opt('plugin_tag_desc_font_size').'px;">';
echo str_replace('[baseurl]',qa_opt('site_url'), str_replace('^', qa_html($tag), qa_lang('plugin_tag_desc/no_desc')));
echo '</SPAN>';
}
if((int)qa_opt('enable_ask_with_tags')){
echo '<DIV STYLE="font-size:'.(int)qa_opt('plugin_tag_desc_font_size').'px;">';
echo str_replace('[baseurl]',qa_opt('site_url'), str_replace('^', qa_html($tag), qa_lang('plugin_tag_desc/ask_with_tag')));
echo '</DIV>';
}
//qa_lang_html_sub('plugin_tag_desc/no_desc', qa_html($tag));
}
function option_default($option)
{
if ($option=='plugin_tag_desc_max_len')
return 250;
if ($option=='plugin_tag_desc_font_size')
return 18;
if ($option=='plugin_tag_desc_permit_edit') {
require_once QA_INCLUDE_DIR.'qa-app-options.php';
return QA_PERMIT_EXPERTS;
}
return null;
}
function admin_form(&$qa_content)
{
require_once QA_INCLUDE_DIR.'qa-app-admin.php';
require_once QA_INCLUDE_DIR.'qa-app-options.php';
$permitoptions=qa_admin_permit_options(QA_PERMIT_USERS, QA_PERMIT_SUPERS, false, false);
$saved=false;
if (qa_clicked('plugin_tag_desc_save_button')) {
qa_opt('plugin_tag_desc_max_len', (int)qa_post_text('plugin_tag_desc_ml_field'));
qa_opt('plugin_tag_desc_font_size', (int)qa_post_text('plugin_tag_desc_fs_field'));
qa_opt('plugin_tag_desc_permit_edit', (int)qa_post_text('plugin_tag_desc_pe_field'));
qa_opt('enable_ask_with_tags',(int)qa_post_text('enable_ask_with_tags_cb'));
$saved=true;
}
return array(
'ok' => $saved ? 'Tag descriptions settings saved' : null,
'fields' => array(
array(
'label' => 'Maximum length of tooltips:',
'type' => 'number',
'value' => (int)qa_opt('plugin_tag_desc_max_len'),
'suffix' => 'characters',
'tags' => 'NAME="plugin_tag_desc_ml_field"',
),
array(
'label' => 'Starting font size:',
'type' => 'number',
'value' => (int)qa_opt('plugin_tag_desc_font_size'),
'suffix' => 'pixels',
'tags' => 'NAME="plugin_tag_desc_fs_field"',
),
array(
'label' => 'Allow editing:',
'type' => 'select',
'value' => @$permitoptions[qa_opt('plugin_tag_desc_permit_edit')],
'options' => $permitoptions,
'tags' => 'NAME="plugin_tag_desc_pe_field"',
),
array(
'label' => 'Show "Ask with the tag" link. Needs <a href="https://github.com/PublicityPort/q2a-ask-with-tags-list">Ask with tags plugin</a>:',
'type' => 'checkbox',
'value' => (int)qa_opt('enable_ask_with_tags'),
'tags' => 'NAME="enable_ask_with_tags_cb"',
),
),
'buttons' => array(
array(
'label' => 'Save Changes',
'tags' => 'NAME="plugin_tag_desc_save_button"',
),
),
);
}
}