Mercurial > hg > vamp-website
comparison forum/Themes/default/GenericControls.template.php @ 76:e3e11437ecea website
Add forum code
author | Chris Cannam |
---|---|
date | Sun, 07 Jul 2013 11:25:48 +0200 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
75:72f59aa7e503 | 76:e3e11437ecea |
---|---|
1 <?php | |
2 /** | |
3 * Simple Machines Forum (SMF) | |
4 * | |
5 * @package SMF | |
6 * @author Simple Machines | |
7 * @copyright 2011 Simple Machines | |
8 * @license http://www.simplemachines.org/about/smf/license.php BSD | |
9 * | |
10 * @version 2.0 | |
11 */ | |
12 | |
13 // This function displays all the stuff you get with a richedit box - BBC, smileys etc. | |
14 function template_control_richedit($editor_id, $smileyContainer = null, $bbcContainer = null) | |
15 { | |
16 global $context, $settings, $options, $txt, $modSettings, $scripturl; | |
17 | |
18 $editor_context = &$context['controls']['richedit'][$editor_id]; | |
19 | |
20 echo ' | |
21 <div> | |
22 <div style="width: 98.8%;"> | |
23 <div> | |
24 <textarea class="editor" name="', $editor_id, '" id="', $editor_id, '" rows="', $editor_context['rows'], '" cols="600" onselect="storeCaret(this);" onclick="storeCaret(this);" onkeyup="storeCaret(this);" onchange="storeCaret(this);" tabindex="', $context['tabindex']++, '" style="height: ', $editor_context['height'], '; ', isset($context['post_error']['no_message']) || isset($context['post_error']['long_message']) ? 'border: 1px solid red;' : '', '">', $editor_context['value'], '</textarea> | |
25 </div> | |
26 <div id="', $editor_id, '_resizer" class="richedit_resize"></div> | |
27 </div> | |
28 </div> | |
29 <input type="hidden" name="', $editor_id, '_mode" id="', $editor_id, '_mode" value="0" /> | |
30 <script type="text/javascript"><!-- // --><![CDATA['; | |
31 | |
32 // Show the smileys. | |
33 if ((!empty($context['smileys']['postform']) || !empty($context['smileys']['popup'])) && !$editor_context['disable_smiley_box'] && $smileyContainer !== null) | |
34 { | |
35 echo ' | |
36 var oSmileyBox_', $editor_id, ' = new smc_SmileyBox({ | |
37 sUniqueId: ', JavaScriptEscape('smileyBox_' . $editor_id), ', | |
38 sContainerDiv: ', JavaScriptEscape($smileyContainer), ', | |
39 sClickHandler: ', JavaScriptEscape('oEditorHandle_' . $editor_id . '.insertSmiley'), ', | |
40 oSmileyLocations: {'; | |
41 | |
42 foreach ($context['smileys'] as $location => $smileyRows) | |
43 { | |
44 echo ' | |
45 ', $location, ': ['; | |
46 foreach ($smileyRows as $smileyRow) | |
47 { | |
48 echo ' | |
49 ['; | |
50 foreach ($smileyRow['smileys'] as $smiley) | |
51 echo ' | |
52 { | |
53 sCode: ', JavaScriptEscape($smiley['code']), ', | |
54 sSrc: ', JavaScriptEscape($settings['smileys_url'] . '/' . $smiley['filename']), ', | |
55 sDescription: ', JavaScriptEscape($smiley['description']), ' | |
56 }', empty($smiley['isLast']) ? ',' : ''; | |
57 | |
58 echo ' | |
59 ]', empty($smileyRow['isLast']) ? ',' : ''; | |
60 } | |
61 echo ' | |
62 ]', $location === 'postform' ? ',' : ''; | |
63 } | |
64 echo ' | |
65 }, | |
66 sSmileyBoxTemplate: ', JavaScriptEscape(' | |
67 %smileyRows% %moreSmileys% | |
68 '), ', | |
69 sSmileyRowTemplate: ', JavaScriptEscape(' | |
70 <div>%smileyRow%</div> | |
71 '), ', | |
72 sSmileyTemplate: ', JavaScriptEscape(' | |
73 <img src="%smileySource%" align="bottom" alt="%smileyDescription%" title="%smileyDescription%" id="%smileyId%" /> | |
74 '), ', | |
75 sMoreSmileysTemplate: ', JavaScriptEscape(' | |
76 <a href="#" id="%moreSmileysId%">[' . (!empty($context['smileys']['postform']) ? $txt['more_smileys'] : $txt['more_smileys_pick']) . ']</a> | |
77 '), ', | |
78 sMoreSmileysLinkId: ', JavaScriptEscape('moreSmileys_' . $editor_id), ', | |
79 sMoreSmileysPopupTemplate: ', JavaScriptEscape('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> | |
80 <html> | |
81 <head> | |
82 <title>' . $txt['more_smileys_title'] . '</title> | |
83 <link rel="stylesheet" type="text/css" href="' . $settings['theme_url'] . '/css/index' . $context['theme_variant'] . '.css?fin20" /> | |
84 </head> | |
85 <body id="help_popup"> | |
86 <div class="padding windowbg"> | |
87 <div class="cat_bar"> | |
88 <h3 class="catbg"> | |
89 ' . $txt['more_smileys_pick'] . ' | |
90 </h3> | |
91 </div> | |
92 <div class="padding"> | |
93 %smileyRows% | |
94 </div> | |
95 <div class="smalltext centertext"> | |
96 <a href="#" id="%moreSmileysCloseLinkId%">' . $txt['more_smileys_close_window'] . '</a> | |
97 </div> | |
98 </div> | |
99 </body> | |
100 </html>'), ' | |
101 });'; | |
102 } | |
103 | |
104 if ($context['show_bbc'] && $bbcContainer !== null) | |
105 { | |
106 echo ' | |
107 var oBBCBox_', $editor_id, ' = new smc_BBCButtonBox({ | |
108 sUniqueId: ', JavaScriptEscape('BBCBox_' . $editor_id), ', | |
109 sContainerDiv: ', JavaScriptEscape($bbcContainer), ', | |
110 sButtonClickHandler: ', JavaScriptEscape('oEditorHandle_' . $editor_id . '.handleButtonClick'), ', | |
111 sSelectChangeHandler: ', JavaScriptEscape('oEditorHandle_' . $editor_id . '.handleSelectChange'), ', | |
112 aButtonRows: ['; | |
113 | |
114 // Here loop through the array, printing the images/rows/separators! | |
115 foreach ($context['bbc_tags'] as $i => $buttonRow) | |
116 { | |
117 echo ' | |
118 ['; | |
119 foreach ($buttonRow as $tag) | |
120 { | |
121 // Is there a "before" part for this bbc button? If not, it can't be a button!! | |
122 if (isset($tag['before'])) | |
123 echo ' | |
124 { | |
125 sType: \'button\', | |
126 bEnabled: ', empty($context['disabled_tags'][$tag['code']]) ? 'true' : 'false', ', | |
127 sImage: ', JavaScriptEscape($settings['images_url'] . '/bbc/' . $tag['image'] . '.gif'), ', | |
128 sCode: ', JavaScriptEscape($tag['code']), ', | |
129 sBefore: ', JavaScriptEscape($tag['before']), ', | |
130 sAfter: ', isset($tag['after']) ? JavaScriptEscape($tag['after']) : 'null', ', | |
131 sDescription: ', JavaScriptEscape($tag['description']), ' | |
132 }', empty($tag['isLast']) ? ',' : ''; | |
133 | |
134 // Must be a divider then. | |
135 else | |
136 echo ' | |
137 { | |
138 sType: \'divider\' | |
139 }', empty($tag['isLast']) ? ',' : ''; | |
140 } | |
141 | |
142 // Add the select boxes to the first row. | |
143 if ($i == 0) | |
144 { | |
145 // Show the font drop down... | |
146 if (!isset($context['disabled_tags']['font'])) | |
147 echo ', | |
148 { | |
149 sType: \'select\', | |
150 sName: \'sel_face\', | |
151 oOptions: { | |
152 \'\': ', JavaScriptEscape($txt['font_face']), ', | |
153 \'courier\': \'Courier\', | |
154 \'arial\': \'Arial\', | |
155 \'arial black\': \'Arial Black\', | |
156 \'impact\': \'Impact\', | |
157 \'verdana\': \'Verdana\', | |
158 \'times new roman\': \'Times New Roman\', | |
159 \'georgia\': \'Georgia\', | |
160 \'andale mono\': \'Andale Mono\', | |
161 \'trebuchet ms\': \'Trebuchet MS\', | |
162 \'comic sans ms\': \'Comic Sans MS\' | |
163 } | |
164 }'; | |
165 | |
166 // Font sizes anyone? | |
167 if (!isset($context['disabled_tags']['size'])) | |
168 echo ', | |
169 { | |
170 sType: \'select\', | |
171 sName: \'sel_size\', | |
172 oOptions: { | |
173 \'\': ', JavaScriptEscape($txt['font_size']), ', | |
174 \'1\': \'8pt\', | |
175 \'2\': \'10pt\', | |
176 \'3\': \'12pt\', | |
177 \'4\': \'14pt\', | |
178 \'5\': \'18pt\', | |
179 \'6\': \'24pt\', | |
180 \'7\': \'36pt\' | |
181 } | |
182 }'; | |
183 | |
184 // Print a drop down list for all the colors we allow! | |
185 if (!isset($context['disabled_tags']['color'])) | |
186 echo ', | |
187 { | |
188 sType: \'select\', | |
189 sName: \'sel_color\', | |
190 oOptions: { | |
191 \'\': ', JavaScriptEscape($txt['change_color']), ', | |
192 \'black\': ', JavaScriptEscape($txt['black']), ', | |
193 \'red\': ', JavaScriptEscape($txt['red']), ', | |
194 \'yellow\': ', JavaScriptEscape($txt['yellow']), ', | |
195 \'pink\': ', JavaScriptEscape($txt['pink']), ', | |
196 \'green\': ', JavaScriptEscape($txt['green']), ', | |
197 \'orange\': ', JavaScriptEscape($txt['orange']), ', | |
198 \'purple\': ', JavaScriptEscape($txt['purple']), ', | |
199 \'blue\': ', JavaScriptEscape($txt['blue']), ', | |
200 \'beige\': ', JavaScriptEscape($txt['beige']), ', | |
201 \'brown\': ', JavaScriptEscape($txt['brown']), ', | |
202 \'teal\': ', JavaScriptEscape($txt['teal']), ', | |
203 \'navy\': ', JavaScriptEscape($txt['navy']), ', | |
204 \'maroon\': ', JavaScriptEscape($txt['maroon']), ', | |
205 \'limegreen\': ', JavaScriptEscape($txt['lime_green']), ', | |
206 \'white\': ', JavaScriptEscape($txt['white']), ' | |
207 } | |
208 }'; | |
209 } | |
210 echo ' | |
211 ]', $i == count($context['bbc_tags']) - 1 ? '' : ','; | |
212 } | |
213 echo ' | |
214 ], | |
215 sButtonTemplate: ', JavaScriptEscape(' | |
216 <img id="%buttonId%" src="%buttonSrc%" align="bottom" width="23" height="22" alt="%buttonDescription%" title="%buttonDescription%" /> | |
217 '), ', | |
218 sButtonBackgroundImage: ', JavaScriptEscape($settings['images_url'] . '/bbc/bbc_bg.gif'), ', | |
219 sButtonBackgroundImageHover: ', JavaScriptEscape($settings['images_url'] . '/bbc/bbc_hoverbg.gif'), ', | |
220 sActiveButtonBackgroundImage: ', JavaScriptEscape($settings['images_url'] . '/bbc/bbc_hoverbg.gif'), ', | |
221 sDividerTemplate: ', JavaScriptEscape(' | |
222 <img src="' . $settings['images_url'] . '/bbc/divider.gif" alt="|" style="margin: 0 3px 0 3px;" /> | |
223 '), ', | |
224 sSelectTemplate: ', JavaScriptEscape(' | |
225 <select name="%selectName%" id="%selectId%" style="margin-bottom: 1ex; font-size: x-small;"> | |
226 %selectOptions% | |
227 </select> | |
228 '), ', | |
229 sButtonRowTemplate: ', JavaScriptEscape(' | |
230 <div>%buttonRow%</div> | |
231 '), ' | |
232 });'; | |
233 } | |
234 | |
235 // Now it's all drawn out we'll actually setup the box. | |
236 echo ' | |
237 var oEditorHandle_', $editor_id, ' = new smc_Editor({ | |
238 sSessionId: ', JavaScriptEscape($context['session_id']), ', | |
239 sSessionVar: ', JavaScriptEscape($context['session_var']), ', | |
240 sFormId: ', JavaScriptEscape($editor_context['form']), ', | |
241 sUniqueId: ', JavaScriptEscape($editor_id), ', | |
242 bRTL: ', $txt['lang_rtl'] ? 'true' : 'false', ', | |
243 bWysiwyg: ', $editor_context['rich_active'] ? 'true' : 'false', ', | |
244 sText: ', JavaScriptEscape($editor_context['rich_active'] ? $editor_context['rich_value'] : ''), ', | |
245 sEditWidth: ', JavaScriptEscape($editor_context['width']), ', | |
246 sEditHeight: ', JavaScriptEscape($editor_context['height']), ', | |
247 bRichEditOff: ', empty($modSettings['disable_wysiwyg']) ? 'false' : 'true', ', | |
248 oSmileyBox: ', !empty($context['smileys']['postform']) && !$editor_context['disable_smiley_box'] && $smileyContainer !== null ? 'oSmileyBox_' . $editor_id : 'null', ', | |
249 oBBCBox: ', $context['show_bbc'] && $bbcContainer !== null ? 'oBBCBox_' . $editor_id : 'null', ' | |
250 }); | |
251 smf_editorArray[smf_editorArray.length] = oEditorHandle_', $editor_id, ';'; | |
252 | |
253 echo ' | |
254 // ]]></script>'; | |
255 } | |
256 | |
257 function template_control_richedit_buttons($editor_id) | |
258 { | |
259 global $context, $settings, $options, $txt, $modSettings, $scripturl; | |
260 | |
261 $editor_context = &$context['controls']['richedit'][$editor_id]; | |
262 | |
263 echo ' | |
264 <input type="submit" value="', isset($editor_context['labels']['post_button']) ? $editor_context['labels']['post_button'] : $txt['post'], '" tabindex="', $context['tabindex']++, '" onclick="return submitThisOnce(this);" accesskey="s" class="button_submit" />'; | |
265 | |
266 if ($editor_context['preview_type']) | |
267 echo ' | |
268 <input type="submit" name="preview" value="', isset($editor_context['labels']['preview_button']) ? $editor_context['labels']['preview_button'] : $txt['preview'], '" tabindex="', $context['tabindex']++, '" onclick="', $editor_context['preview_type'] == 2 ? 'return event.ctrlKey || previewPost();' : 'return submitThisOnce(this);', '" accesskey="p" class="button_submit" />'; | |
269 | |
270 if ($context['show_spellchecking']) | |
271 echo ' | |
272 <input type="button" value="', $txt['spell_check'], '" tabindex="', $context['tabindex']++, '" onclick="oEditorHandle_', $editor_id, '.spellCheckStart();" class="button_submit" />'; | |
273 } | |
274 | |
275 // What's this, verification?! | |
276 function template_control_verification($verify_id, $display_type = 'all', $reset = false) | |
277 { | |
278 global $context, $settings, $options, $txt, $modSettings; | |
279 | |
280 $verify_context = &$context['controls']['verification'][$verify_id]; | |
281 | |
282 // Keep track of where we are. | |
283 if (empty($verify_context['tracking']) || $reset) | |
284 $verify_context['tracking'] = 0; | |
285 | |
286 // How many items are there to display in total. | |
287 $total_items = count($verify_context['questions']) + ($verify_context['show_visual'] ? 1 : 0); | |
288 | |
289 // If we've gone too far, stop. | |
290 if ($verify_context['tracking'] > $total_items) | |
291 return false; | |
292 | |
293 // Loop through each item to show them. | |
294 for ($i = 0; $i < $total_items; $i++) | |
295 { | |
296 // If we're after a single item only show it if we're in the right place. | |
297 if ($display_type == 'single' && $verify_context['tracking'] != $i) | |
298 continue; | |
299 | |
300 if ($display_type != 'single') | |
301 echo ' | |
302 <div id="verification_control_', $i, '" class="verification_control">'; | |
303 | |
304 // Do the actual stuff - image first? | |
305 if ($i == 0 && $verify_context['show_visual']) | |
306 { | |
307 if ($context['use_graphic_library']) | |
308 echo ' | |
309 <img src="', $verify_context['image_href'], '" alt="', $txt['visual_verification_description'], '" id="verification_image_', $verify_id, '" />'; | |
310 else | |
311 echo ' | |
312 <img src="', $verify_context['image_href'], ';letter=1" alt="', $txt['visual_verification_description'], '" id="verification_image_', $verify_id, '_1" /> | |
313 <img src="', $verify_context['image_href'], ';letter=2" alt="', $txt['visual_verification_description'], '" id="verification_image_', $verify_id, '_2" /> | |
314 <img src="', $verify_context['image_href'], ';letter=3" alt="', $txt['visual_verification_description'], '" id="verification_image_', $verify_id, '_3" /> | |
315 <img src="', $verify_context['image_href'], ';letter=4" alt="', $txt['visual_verification_description'], '" id="verification_image_', $verify_id, '_4" /> | |
316 <img src="', $verify_context['image_href'], ';letter=5" alt="', $txt['visual_verification_description'], '" id="verification_image_', $verify_id, '_5" /> | |
317 <img src="', $verify_context['image_href'], ';letter=6" alt="', $txt['visual_verification_description'], '" id="verification_image_', $verify_id, '_6" />'; | |
318 | |
319 if (WIRELESS) | |
320 echo '<br /> | |
321 <input type="text" name="', $verify_id, '_vv[code]" value="', !empty($verify_context['text_value']) ? $verify_context['text_value'] : '', '" size="30" tabindex="', $context['tabindex']++, '" class="input_text" />'; | |
322 else | |
323 echo ' | |
324 <div class="smalltext" style="margin: 4px 0 8px 0;"> | |
325 <a href="', $verify_context['image_href'], ';sound" id="visual_verification_', $verify_id, '_sound" rel="nofollow">', $txt['visual_verification_sound'], '</a> / <a href="#" id="visual_verification_', $verify_id, '_refresh">', $txt['visual_verification_request_new'], '</a>', $display_type != 'quick_reply' ? '<br />' : '', '<br /> | |
326 ', $txt['visual_verification_description'], ':', $display_type != 'quick_reply' ? '<br />' : '', ' | |
327 <input type="text" name="', $verify_id, '_vv[code]" value="', !empty($verify_context['text_value']) ? $verify_context['text_value'] : '', '" size="30" tabindex="', $context['tabindex']++, '" class="input_text" /> | |
328 </div>'; | |
329 } | |
330 else | |
331 { | |
332 // Where in the question array is this question? | |
333 $qIndex = $verify_context['show_visual'] ? $i - 1 : $i; | |
334 | |
335 echo ' | |
336 <div class="smalltext"> | |
337 ', $verify_context['questions'][$qIndex]['q'], ':<br /> | |
338 <input type="text" name="', $verify_id, '_vv[q][', $verify_context['questions'][$qIndex]['id'], ']" size="30" value="', $verify_context['questions'][$qIndex]['a'], '" ', $verify_context['questions'][$qIndex]['is_error'] ? 'style="border: 1px red solid;"' : '', ' tabindex="', $context['tabindex']++, '" class="input_text" /> | |
339 </div>'; | |
340 } | |
341 | |
342 if ($display_type != 'single') | |
343 echo ' | |
344 </div>'; | |
345 | |
346 // If we were displaying just one and we did it, break. | |
347 if ($display_type == 'single' && $verify_context['tracking'] == $i) | |
348 break; | |
349 } | |
350 | |
351 // Assume we found something, always, | |
352 $verify_context['tracking']++; | |
353 | |
354 // Tell something displaying piecemeal to keep going. | |
355 if ($display_type == 'single') | |
356 return true; | |
357 } | |
358 | |
359 ?> |