This repository has been archived by the owner on Oct 12, 2020. It is now read-only.
forked from NoahY/q2a-embed
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathqa-embed-admin.php
179 lines (152 loc) · 4.62 KB
/
qa-embed-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
<?php
class qa_embed_admin {
function option_default($option) {
switch($option) {
case 'embed_video_width':
case 'embed_image_width':
case 'embed_gmap_width':
return 425;
case 'embed_video_height':
case 'embed_image_height':
case 'embed_gmap_height':
return 349;
case 'embed_thickbox_thumb':
return 64;
case 'embed_mp3_player_code':
return '<audio controls src="$1">Your browser does not support the <code>audio</code> element.</audio>';
default:
return null;
}
}
function allow_template($template)
{
return ($template!='admin');
}
function admin_form(&$qa_content)
{
// Process form input
$ok = null;
if (qa_clicked('embed_save')) {
qa_opt('embed_enable',(bool)qa_post_text('embed_enable'));
qa_opt('embed_video_width',qa_post_text('embed_video_width'));
qa_opt('embed_video_height',qa_post_text('embed_video_height'));
qa_opt('embed_enable_img',(bool)qa_post_text('embed_enable_img'));
qa_opt('embed_image_width',qa_post_text('embed_image_width'));
qa_opt('embed_image_height',qa_post_text('embed_image_height'));
qa_opt('embed_enable_thickbox',(bool)qa_post_text('embed_enable_thickbox'));
qa_opt('embed_enable_mp3',(bool)qa_post_text('embed_enable_mp3'));
qa_opt('embed_enable_gmap',(bool)qa_post_text('embed_enable_gmap'));
qa_opt('embed_mp3_player_code', qa_post_text('embed_mp3_player_code'));
$ok = qa_lang('admin/options_saved');
}
else if (qa_clicked('embed_reset')) {
foreach($_POST as $i => $v) {
$def = $this->option_default($i);
if($def !== null) qa_opt($i,$def);
}
$ok = qa_lang('admin/options_reset');
}
qa_set_display_rules($qa_content, array(
'embed_video_height' => 'embed_enable',
'embed_video_width' => 'embed_enable',
));
// Create the form for display
$fields = array();
$fields[] = array(
'label' => 'Enable video embedding',
'tags' => 'NAME="embed_enable"',
'value' => qa_opt('embed_enable'),
'type' => 'checkbox',
);
$fields[] = array(
'label' => 'Embeded video width',
'type' => 'number',
'value' => qa_opt('embed_video_width'),
'tags' => 'NAME="embed_video_width"',
);
$fields[] = array(
'label' => 'Embeded video height',
'type' => 'number',
'value' => qa_opt('embed_video_height'),
'tags' => 'NAME="embed_video_height"',
);
$fields[] = array(
'type' => 'blank',
);
$fields[] = array(
'label' => 'Enable image embedding',
'tags' => 'NAME="embed_enable_img"',
'value' => qa_opt('embed_enable_img'),
'type' => 'checkbox',
);
$fields[] = array(
'label' => 'Image width',
'type' => 'number',
'value' => qa_opt('embed_image_width'),
'tags' => 'NAME="embed_image_width"',
);
$fields[] = array(
'label' => 'Image height',
'type' => 'number',
'value' => qa_opt('embed_image_height'),
'tags' => 'NAME="embed_image_height"',
);
$fields[] = array(
'label' => 'Enable thickbox image effect',
'tags' => 'NAME="embed_enable_thickbox"',
'value' => qa_opt('embed_enable_thickbox'),
'type' => 'checkbox',
);
$fields[] = array(
'type' => 'blank',
);
$fields[] = array(
'label' => 'Enable mp3 embedding',
'tags' => 'NAME="embed_enable_mp3"',
'value' => qa_opt('embed_enable_mp3'),
'type' => 'checkbox',
);
$fields[] = array(
'label' => 'HTML5 audio player code',
'tags' => 'NAME="embed_mp3_player_code"',
'value' => qa_opt('embed_mp3_player_code'),
'type' => 'textarea',
'rows' => '5',
);
$fields[] = array(
'type' => 'blank',
);
$fields[] = array(
'label' => 'Enable Google maps embedding',
'tags' => 'NAME="embed_enable_gmap"',
'value' => qa_opt('embed_enable_gmap'),
'type' => 'checkbox',
);
$fields[] = array(
'label' => 'Map width',
'type' => 'number',
'value' => qa_opt('embed_gmap_width'),
'tags' => 'NAME="embed_gmap_width"',
);
$fields[] = array(
'label' => 'Map height',
'type' => 'number',
'value' => qa_opt('embed_gmap_height'),
'tags' => 'NAME="embed_gmap_height"',
);
return array(
'ok' => ($ok && !isset($error)) ? $ok : null,
'fields' => $fields,
'buttons' => array(
array(
'label' => qa_lang_html('main/save_button'),
'tags' => 'NAME="embed_save"',
),
array(
'label' => qa_lang_html('admin/reset_options_button'),
'tags' => 'NAME="embed_reset"',
)
),
);
}
}