comparison forum/Themes/default/Search.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 function template_main()
14 {
15 global $context, $settings, $options, $txt, $scripturl, $modSettings;
16
17 echo '
18 <form action="', $scripturl, '?action=search2" method="post" accept-charset="', $context['character_set'], '" name="searchform" id="searchform">
19 <div class="cat_bar">
20 <h3 class="catbg">
21 <span class="ie6_header floatleft">', !empty($settings['use_buttons']) ? '<img src="' . $settings['images_url'] . '/buttons/search.gif" alt="" class="icon" />' : ' ', $txt['set_parameters'], '</span>
22 </h3>
23 </div>';
24
25 if (!empty($context['search_errors']))
26 echo '
27 <p id="search_error" class="error">', implode('<br />', $context['search_errors']['messages']), '</p>';
28
29 // Simple Search?
30 if ($context['simple_search'])
31 {
32 echo '
33 <fieldset id="simple_search">
34 <span class="upperframe"><span></span></span>
35 <div class="roundframe">
36 <div id="search_term_input">
37 <strong>', $txt['search_for'], ':</strong>
38 <input type="text" name="search"', !empty($context['search_params']['search']) ? ' value="' . $context['search_params']['search'] . '"' : '', ' maxlength="', $context['search_string_limit'], '" size="40" class="input_text" />
39 ', $context['require_verification'] ? '' : '&nbsp;<input type="submit" name="submit" value="' . $txt['search'] . '" class="button_submit" />
40 </div>';
41
42 if (empty($modSettings['search_simple_fulltext']))
43 echo '
44 <p class="smalltext">', $txt['search_example'], '</p>';
45
46 if ($context['require_verification'])
47 echo '
48 <div class="verification>
49 <strong>', $txt['search_visual_verification_label'], ':</strong>
50 <br />', template_control_verification($context['visual_verification_id'], 'all'), '<br />
51 <input id="submit" type="submit" name="submit" value="' . $txt['search'] . '" class="button_submit" />
52 </div>';
53
54 echo '
55 <a href="', $scripturl, '?action=search;advanced" onclick="this.href += \';search=\' + escape(document.forms.searchform.search.value);">', $txt['search_advanced'], '</a>
56 <input type="hidden" name="advanced" value="0" />
57 </div>
58 <span class="lowerframe"><span></span></span>
59 </fieldset>';
60 }
61
62 // Advanced search!
63 else
64 {
65 echo '
66 <fieldset id="advanced_search">
67 <span class="upperframe"><span></span></span>
68 <div class="roundframe">
69 <input type="hidden" name="advanced" value="1" />
70 <span class="enhanced">
71 <strong>', $txt['search_for'], ':</strong>
72 <input type="text" name="search"', !empty($context['search_params']['search']) ? ' value="' . $context['search_params']['search'] . '"' : '', ' maxlength="', $context['search_string_limit'], '" size="40" class="input_text" />
73 <script type="text/javascript"><!-- // --><![CDATA[
74 function initSearch()
75 {
76 if (document.forms.searchform.search.value.indexOf("%u") != -1)
77 document.forms.searchform.search.value = unescape(document.forms.searchform.search.value);
78 }
79 createEventListener(window);
80 window.addEventListener("load", initSearch, false);
81 // ]]></script>
82 <select name="searchtype">
83 <option value="1"', empty($context['search_params']['searchtype']) ? ' selected="selected"' : '', '>', $txt['all_words'], '</option>
84 <option value="2"', !empty($context['search_params']['searchtype']) ? ' selected="selected"' : '', '>', $txt['any_words'], '</option>
85 </select>
86 </span>';
87
88 if (empty($modSettings['search_simple_fulltext']))
89 echo '
90 <em class="smalltext">', $txt['search_example'], '</em>';
91
92 echo '
93 <dl id="search_options">
94 <dt>', $txt['by_user'], ':</dt>
95 <dd><input id="userspec" type="text" name="userspec" value="', empty($context['search_params']['userspec']) ? '*' : $context['search_params']['userspec'], '" size="40" class="input_text" /></dd>
96 <dt>', $txt['search_order'], ':</dt>
97 <dd>
98 <select id="sort" name="sort">
99 <option value="relevance|desc">', $txt['search_orderby_relevant_first'], '</option>
100 <option value="num_replies|desc">', $txt['search_orderby_large_first'], '</option>
101 <option value="num_replies|asc">', $txt['search_orderby_small_first'], '</option>
102 <option value="id_msg|desc">', $txt['search_orderby_recent_first'], '</option>
103 <option value="id_msg|asc">', $txt['search_orderby_old_first'], '</option>
104 </select>
105 </dd>
106 <dt class="options">', $txt['search_options'], ':</dt>
107 <dd class="options">
108 <label for="show_complete"><input type="checkbox" name="show_complete" id="show_complete" value="1"', !empty($context['search_params']['show_complete']) ? ' checked="checked"' : '', ' class="input_check" /> ', $txt['search_show_complete_messages'], '</label><br />
109 <label for="subject_only"><input type="checkbox" name="subject_only" id="subject_only" value="1"', !empty($context['search_params']['subject_only']) ? ' checked="checked"' : '', ' class="input_check" /> ', $txt['search_subject_only'], '</label>
110 </dd>
111 <dt class="between">', $txt['search_post_age'], ': </dt>
112 <dd>', $txt['search_between'], ' <input type="text" name="minage" value="', empty($context['search_params']['minage']) ? '0' : $context['search_params']['minage'], '" size="5" maxlength="4" class="input_text" />&nbsp;', $txt['search_and'], '&nbsp;<input type="text" name="maxage" value="', empty($context['search_params']['maxage']) ? '9999' : $context['search_params']['maxage'], '" size="5" maxlength="4" class="input_text" /> ', $txt['days_word'], '</dd>
113 </dl>';
114
115 // Require an image to be typed to save spamming?
116 if ($context['require_verification'])
117 {
118 echo '
119 <p>
120 <strong>', $txt['verification'], ':</strong>
121 ', template_control_verification($context['visual_verification_id'], 'all'), '
122 </p>';
123 }
124
125 // If $context['search_params']['topic'] is set, that means we're searching just one topic.
126 if (!empty($context['search_params']['topic']))
127 echo '
128 <p>', $txt['search_specific_topic'], ' &quot;', $context['search_topic']['link'], '&quot;.</p>
129 <input type="hidden" name="topic" value="', $context['search_topic']['id'], '" />';
130
131 echo '
132 </div>
133 <span class="lowerframe"><span></span></span>
134 </fieldset>';
135
136 if (empty($context['search_params']['topic']))
137 {
138 echo '
139 <fieldset class="flow_hidden">
140 <span class="upperframe"><span></span></span>
141 <div class="roundframe">
142 <div class="title_bar">
143 <h4 class="titlebg">
144 <a href="javascript:void(0);" onclick="expandCollapseBoards(); return false;"><img src="', $settings['images_url'], '/expand.gif" id="expandBoardsIcon" alt="" /></a> <a href="javascript:void(0);" onclick="expandCollapseBoards(); return false;"><strong>', $txt['choose_board'], '</strong></a>
145 </h4>
146 </div>
147 <div class="flow_auto" id="searchBoardsExpand"', $context['boards_check_all'] ? ' style="display: none;"' : '', '>
148 <ul class="ignoreboards floatleft">';
149
150 $i = 0;
151 $limit = ceil($context['num_boards'] / 2);
152 foreach ($context['categories'] as $category)
153 {
154 echo '
155 <li class="category">
156 <a href="javascript:void(0);" onclick="selectBoards([', implode(', ', $category['child_ids']), ']); return false;">', $category['name'], '</a>
157 <ul>';
158
159 foreach ($category['boards'] as $board)
160 {
161 if ($i == $limit)
162 echo '
163 </ul>
164 </li>
165 </ul>
166 <ul class="ignoreboards floatright">
167 <li class="category">
168 <ul>';
169
170 echo '
171 <li class="board" style="margin-', $context['right_to_left'] ? 'right' : 'left', ': ', $board['child_level'], 'em;">
172 <label for="brd', $board['id'], '"><input type="checkbox" id="brd', $board['id'], '" name="brd[', $board['id'], ']" value="', $board['id'], '"', $board['selected'] ? ' checked="checked"' : '', ' class="input_check" /> ', $board['name'], '</label>
173 </li>';
174
175 $i ++;
176 }
177
178 echo '
179 </ul>
180 </li>';
181 }
182
183 echo '
184 </ul>
185 </div>
186 <br class="clear" />';
187
188 echo '
189 <div class="padding">
190 <input type="checkbox" name="all" id="check_all" value=""', $context['boards_check_all'] ? ' checked="checked"' : '', ' onclick="invertAll(this, this.form, \'brd\');" class="input_check floatleft" />
191 <label for="check_all" class="floatleft">', $txt['check_all'], '</label>
192 <input type="submit" name="submit" value="', $txt['search'], '" class="button_submit floatright" />
193 </div>
194 <br class="clear" />
195 </div>
196 <span class="lowerframe"><span></span></span>
197 </fieldset>';
198 }
199
200 }
201
202 echo '
203 </form>
204
205 <script type="text/javascript"><!-- // --><![CDATA[
206 function selectBoards(ids)
207 {
208 var toggle = true;
209
210 for (i = 0; i < ids.length; i++)
211 toggle = toggle & document.forms.searchform["brd" + ids[i]].checked;
212
213 for (i = 0; i < ids.length; i++)
214 document.forms.searchform["brd" + ids[i]].checked = !toggle;
215 }
216
217 function expandCollapseBoards()
218 {
219 var current = document.getElementById("searchBoardsExpand").style.display != "none";
220
221 document.getElementById("searchBoardsExpand").style.display = current ? "none" : "";
222 document.getElementById("expandBoardsIcon").src = smf_images_url + (current ? "/expand.gif" : "/collapse.gif");
223 }';
224
225 echo '
226 // ]]></script>';
227 }
228
229 function template_results()
230 {
231 global $context, $settings, $options, $txt, $scripturl, $message;
232
233 if (isset($context['did_you_mean']) || empty($context['topics']))
234 {
235 echo '
236 <div id="search_results">
237 <div class="cat_bar">
238 <h3 class="catbg">
239 ', $txt['search_adjust_query'], '
240 </h3>
241 </div>
242 <span class="upperframe"><span></span></span>
243 <div class="roundframe">';
244
245 // Did they make any typos or mistakes, perhaps?
246 if (isset($context['did_you_mean']))
247 echo '
248 <p>', $txt['search_did_you_mean'], ' <a href="', $scripturl, '?action=search2;params=', $context['did_you_mean_params'], '">', $context['did_you_mean'], '</a>.</p>';
249
250 echo '
251 <form action="', $scripturl, '?action=search2" method="post" accept-charset="', $context['character_set'], '">
252 <strong>', $txt['search_for'], ':</strong>
253 <input type="text" name="search"', !empty($context['search_params']['search']) ? ' value="' . $context['search_params']['search'] . '"' : '', ' maxlength="', $context['search_string_limit'], '" size="40" class="input_text" />
254 <input type="submit" name="submit" value="', $txt['search_adjust_submit'], '" class="button_submit" />
255 <input type="hidden" name="searchtype" value="', !empty($context['search_params']['searchtype']) ? $context['search_params']['searchtype'] : 0, '" />
256 <input type="hidden" name="userspec" value="', !empty($context['search_params']['userspec']) ? $context['search_params']['userspec'] : '', '" />
257 <input type="hidden" name="show_complete" value="', !empty($context['search_params']['show_complete']) ? 1 : 0, '" />
258 <input type="hidden" name="subject_only" value="', !empty($context['search_params']['subject_only']) ? 1 : 0, '" />
259 <input type="hidden" name="minage" value="', !empty($context['search_params']['minage']) ? $context['search_params']['minage'] : '0', '" />
260 <input type="hidden" name="maxage" value="', !empty($context['search_params']['maxage']) ? $context['search_params']['maxage'] : '9999', '" />
261 <input type="hidden" name="sort" value="', !empty($context['search_params']['sort']) ? $context['search_params']['sort'] : 'relevance', '" />';
262
263 if (!empty($context['search_params']['brd']))
264 foreach ($context['search_params']['brd'] as $board_id)
265 echo '
266 <input type="hidden" name="brd[', $board_id, ']" value="', $board_id, '" />';
267
268 echo '
269 </form>
270 </div>
271 <span class="lowerframe"><span></span></span>
272 </div><br />';
273 }
274
275 if ($context['compact'])
276 {
277 // Quick moderation set to checkboxes? Oh, how fun :/.
278 if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1)
279 echo '
280 <form action="', $scripturl, '?action=quickmod" method="post" accept-charset="', $context['character_set'], '" name="topicForm">';
281
282 echo '
283 <div class="cat_bar">
284 <h3 class="catbg">
285 <span class="floatright">';
286 if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1)
287 echo '
288 <input type="checkbox" onclick="invertAll(this, this.form, \'topics[]\');" class="input_check" />';
289 echo '
290 </span>
291 <span class="ie6_header floatleft"><img src="' . $settings['images_url'] . '/buttons/search.gif" alt="" />&nbsp;', $txt['mlist_search_results'],':&nbsp;',$context['search_params']['search'],'</span>
292 </h3>
293 </div>
294 <div class="pagesection">
295 <span>', $txt['pages'], ': ', $context['page_index'], '</span>
296 </div>';
297
298 while ($topic = $context['get_topics']())
299 {
300 $color_class = '';
301 if ($topic['is_sticky'])
302 $color_class = 'stickybg';
303 if ($topic['is_locked'])
304 $color_class .= 'lockedbg';
305
306 echo '
307 <div class="search_results_posts">
308 <div class="', $message['alternate'] == 0 ? 'windowbg' : 'windowbg2', ' core_posts">
309 <span class="topslice"><span></span></span>
310 <div class="content flow_auto">';
311
312 foreach ($topic['matches'] as $message)
313 {
314 echo '
315 <div class="topic_details floatleft" style="width: 94%">
316 <div class="counter">', $message['counter'], '</div>
317 <h5>', $topic['board']['link'], ' / <a href="', $scripturl, '?topic=', $topic['id'], '.msg', $message['id'], '#msg', $message['id'], '">', $message['subject_highlighted'], '</a></h5>
318 <span class="smalltext">&#171;&nbsp;',$txt['by'],'&nbsp;<strong>', $message['member']['link'], '</strong>&nbsp;',$txt['on'],'&nbsp;<em>', $message['time'], '</em>&nbsp;&#187;</span>
319 </div>';
320
321 if (!empty($options['display_quick_mod']))
322 {
323 echo '
324 <div class="floatright">';
325
326 if ($options['display_quick_mod'] == 1)
327 {
328 echo '
329 <input type="checkbox" name="topics[]" value="', $topic['id'], '" class="input_check" />';
330 }
331 else
332 {
333 if ($topic['quick_mod']['remove'])
334 echo '
335 <a href="', $scripturl, '?action=quickmod;actions[', $topic['id'], ']=remove;', $context['session_var'], '=', $context['session_id'], '" onclick="return confirm(\'', $txt['quickmod_confirm'], '\');"><img src="', $settings['images_url'], '/icons/quick_remove.gif" width="16" alt="', $txt['remove_topic'], '" title="', $txt['remove_topic'], '" /></a>';
336
337 if ($topic['quick_mod']['lock'])
338 echo '
339 <a href="', $scripturl, '?action=quickmod;actions[', $topic['id'], ']=lock;', $context['session_var'], '=', $context['session_id'], '" onclick="return confirm(\'', $txt['quickmod_confirm'], '\');"><img src="', $settings['images_url'], '/icons/quick_lock.gif" width="16" alt="', $txt['set_lock'], '" title="', $txt['set_lock'], '" /></a>';
340
341 if ($topic['quick_mod']['lock'] || $topic['quick_mod']['remove'])
342 echo '
343 <br />';
344
345 if ($topic['quick_mod']['sticky'])
346 echo '
347 <a href="', $scripturl, '?action=quickmod;actions[', $topic['id'], ']=sticky;', $context['session_var'], '=', $context['session_id'], '" onclick="return confirm(\'', $txt['quickmod_confirm'], '\');"><img src="', $settings['images_url'], '/icons/quick_sticky.gif" width="16" alt="', $txt['set_sticky'], '" title="', $txt['set_sticky'], '" /></a>';
348
349 if ($topic['quick_mod']['move'])
350 echo '
351 <a href="', $scripturl, '?action=movetopic;topic=', $topic['id'], '.0"><img src="', $settings['images_url'], '/icons/quick_move.gif" width="16" alt="', $txt['move_topic'], '" title="', $txt['move_topic'], '" /></a>';
352 }
353
354 echo '
355 </div>';
356 }
357
358 if ($message['body_highlighted'] != '')
359 echo '
360 <br class="clear" />
361 <div class="list_posts double_height">', $message['body_highlighted'], '</div>';
362 }
363
364 echo '
365 </div>
366 <span class="botslice"><span></span></span>
367 </div>
368 </div>';
369
370 }
371 if (!empty($context['topics']))
372 echo '
373 <div class="pagesection">
374 <span>', $txt['pages'], ': ', $context['page_index'], '</span>
375 </div>';
376
377 if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1 && !empty($context['topics']))
378 {
379 echo '
380 <div class="middletext titlebg2" style="padding: 4px;">
381 <div class="floatright">
382 <select name="qaction"', $context['can_move'] ? ' onchange="this.form.moveItTo.disabled = (this.options[this.selectedIndex].value != \'move\');"' : '', '>
383 <option value="">--------</option>', $context['can_remove'] ? '
384 <option value="remove">' . $txt['quick_mod_remove'] . '</option>' : '', $context['can_lock'] ? '
385 <option value="lock">' . $txt['quick_mod_lock'] . '</option>' : '', $context['can_sticky'] ? '
386 <option value="sticky">' . $txt['quick_mod_sticky'] . '</option>' : '', $context['can_move'] ? '
387 <option value="move">' . $txt['quick_mod_move'] . ': </option>' : '', $context['can_merge'] ? '
388 <option value="merge">' . $txt['quick_mod_merge'] . '</option>' : '', '
389 <option value="markread">', $txt['quick_mod_markread'], '</option>
390 </select>';
391
392 if ($context['can_move'])
393 {
394 echo '
395 <select id="moveItTo" name="move_to" disabled="disabled">';
396
397 foreach ($context['move_to_boards'] as $category)
398 {
399 echo '
400 <optgroup label="', $category['name'], '">';
401 foreach ($category['boards'] as $board)
402 echo '
403 <option value="', $board['id'], '"', $board['selected'] ? ' selected="selected"' : '', '>', $board['child_level'] > 0 ? str_repeat('==', $board['child_level'] - 1) . '=&gt;' : '', ' ', $board['name'], '</option>';
404 echo '
405 </optgroup>';
406 }
407 echo '
408 </select>';
409 }
410
411 echo '
412 <input type="hidden" name="redirect_url" value="', $scripturl . '?action=search2;params=' . $context['params'], '" />
413 <input type="submit" style="font-size: 0.8em;" value="', $txt['quick_mod_go'], '" onclick="return this.form.qaction.value != \'\' &amp;&amp; confirm(\'', $txt['quickmod_confirm'], '\');" class="button_submit" />
414 </div>
415 <br class="clear" />
416 </div>';
417 }
418
419
420 if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1 && !empty($context['topics']))
421 echo '
422 <input type="hidden" name="' . $context['session_var'] . '" value="' . $context['session_id'] . '" />
423 </form>';
424
425 }
426 else
427 {
428 echo '
429 <div class="cat_bar">
430 <h3 class="catbg">
431 <span class="ie6_header floatleft"><img src="' . $settings['images_url'] . '/buttons/search.gif" alt="" />&nbsp;', $txt['mlist_search_results'],':&nbsp;',$context['search_params']['search'],'</span>
432 </h3>
433 </div>
434 <div class="pagesection">
435 <span>', $txt['pages'], ': ', $context['page_index'], '</span>
436 </div>';
437
438 if (empty($context['topics']))
439 echo '
440 <div class="information">(', $txt['search_no_results'], ')</div>';
441
442 while ($topic = $context['get_topics']())
443 {
444 foreach ($topic['matches'] as $message)
445 {
446 echo '
447 <div class="search_results_posts">
448 <div class="', $message['alternate'] == 0 ? 'windowbg' : 'windowbg2', ' core_posts">
449 <span class="topslice"><span></span></span>
450 <div class="content">
451 <div class="counter">', $message['counter'], '</div>
452 <div class="topic_details">
453 <h5>', $topic['board']['link'], ' / <a href="', $scripturl, '?topic=', $topic['id'], '.', $message['start'], ';topicseen#msg', $message['id'], '">', $message['subject_highlighted'], '</a></h5>
454 <span class="smalltext">&#171;&nbsp;', $txt['message'], ' ', $txt['by'], ' <strong>', $message['member']['link'], ' </strong>', $txt['on'], '&nbsp;<em>', $message['time'], '</em>&nbsp;&#187;</span>
455 </div>
456 <div class="list_posts">', $message['body_highlighted'], '</div>';
457
458 if ($topic['can_reply'] || $topic['can_mark_notify'])
459 echo '
460 <div class="quickbuttons_wrap">
461 <ul class="reset smalltext quickbuttons">';
462
463 // If they *can* reply?
464 if ($topic['can_reply'])
465 echo '
466 <li class="reply_button"><a href="', $scripturl . '?action=post;topic=' . $topic['id'] . '.' . $message['start'], '">', $txt['reply'], '</a></li>';
467
468 // If they *can* quote?
469 if ($topic['can_quote'])
470 echo '
471 <li class="quote_button"><a href="', $scripturl . '?action=post;topic=' . $topic['id'] . '.' . $message['start'] . ';quote=' . $message['id'] . '">', $txt['quote'], '</a></li>';
472
473 // Can we request notification of topics?
474 if ($topic['can_mark_notify'])
475 echo '
476 <li class="notify_button"><a href="', $scripturl . '?action=notify;topic=' . $topic['id'] . '.' . $message['start'], '">', $txt['notify'], '</a></li>';
477
478 if ($topic['can_reply'] || $topic['can_mark_notify'])
479 echo '
480 </ul>
481 </div>';
482 echo '
483 <br class="clear" />
484 </div>
485 <span class="botslice"><span></span></span>
486 </div>
487 </div>';
488 }
489 }
490
491 echo '
492 <div class="pagesection">
493 <span>', $txt['pages'], ': ', $context['page_index'], '</span>
494 </div>';
495 }
496
497 // Show a jump to box for easy navigation.
498 echo '
499 <br class="clear" />
500 <div class="smalltext righttext" id="search_jump_to">&nbsp;</div>
501 <script type="text/javascript"><!-- // --><![CDATA[
502 if (typeof(window.XMLHttpRequest) != "undefined")
503 aJumpTo[aJumpTo.length] = new JumpTo({
504 sContainerId: "search_jump_to",
505 sJumpToTemplate: "<label class=\"smalltext\" for=\"%select_id%\">', $context['jump_to']['label'], ':<" + "/label> %dropdown_list%",
506 iCurBoardId: 0,
507 iCurBoardChildLevel: 0,
508 sCurBoardName: "', $context['jump_to']['board_name'], '",
509 sBoardChildLevelIndicator: "==",
510 sBoardPrefix: "=> ",
511 sCatSeparator: "-----------------------------",
512 sCatPrefix: "",
513 sGoButtonLabel: "', $txt['quick_mod_go'], '"
514 });
515 // ]]></script>';
516
517 }
518
519 ?>