<commit_before><?php
/**
 * Simple Machines Forum (SMF)
 *
 * @package SMF
 * @author Simple Machines http://www.simplemachines.org
 * @copyright 2018 Simple Machines and individual contributors
 * @license http://www.simplemachines.org/about/smf/license.php BSD
 *
 * @version 2.1 Beta 4
 */

/**
 * The main search form
 */
function template_main()
{
	global $context, $txt, $scripturl, $modSettings;

	echo '
	<form action="', $scripturl, '?action=search2" method="post" accept-charset="', $context['character_set'], '" name="searchform" id="searchform">';

	if (!empty($context['search_errors']))
		echo '
		<div class="errorbox">
			', implode('<br>', $context['search_errors']['messages']), '
		</div>';

	if (!empty($context['search_ignored']))
		echo '
		<div class="noticebox">
			', $txt['search_warning_ignored_word' . (count($context['search_ignored']) == 1 ? '' : 's')], ': ', implode(', ', $context['search_ignored']), '
		</div>';

	echo '
		<div class="cat_bar">
			<h3 class="catbg">
				<span class="generic_icons filter"></span>', $txt['set_parameters'], '
			</h3>
		</div>';

	echo '
		<div id="advanced_search" class="roundframe">
			<dl class="settings" id="search_options">
				<dt class="righttext">
					<strong><label for="searchfor">', $txt['search_for'], ':</label></strong>
				</dt>
				<dd>
					<input type="search" name="search" id="searchfor" ', !empty($context['search_params']['search']) ? ' value="' . $context['search_params']['search'] . '"' : '', ' maxlength="', $context['search_string_limit'], '" size="40">';

	if (empty($modSettings['search_simple_fulltext']))
		echo '
					<br><em class="smalltext">', $txt['search_example'], '</em>';

	echo '
				</dd>

				<dt class="righttext">
					<label for="searchtype">', $txt['search_match'], ':</label>
				</dt>
				<dd>
					<select name="searchtype" id="searchtype">
						<option value="1"', empty($context['search_params']['searchtype']) ? ' selected' : '', '>', $txt['all_words'], '</option>
						<option value="2"', !empty($context['search_params']['searchtype']) ? ' selected' : '', '>', $txt['any_words'], '</option>
					</select>
				</dd>
				<dt class="righttext">
					<label for="userspec">', $txt['by_user'], ':</label>
				</dt>
				<dd>
					<input id="userspec" type="text" name="userspec" value="', empty($context['search_params']['userspec']) ? '*' : $context['search_params']['userspec'], '" size="40">
				</dd>
				<dt class="righttext">
					<label for="sort">', $txt['search_order'], ':</label>
				</dt>
				<dd>
					<select id="sort" name="sort">
						<option value="relevance|desc">', $txt['search_orderby_relevant_first'], '</option>
						<option value="num_replies|desc">', $txt['search_orderby_large_first'], '</option>
						<option value="num_replies|asc">', $txt['search_orderby_small_first'], '</option>
						<option value="id_msg|desc">', $txt['search_orderby_recent_first'], '</option>
						<option value="id_msg|asc">', $txt['search_orderby_old_first'], '</option>
					</select>
				</dd>
				<dt class="righttext options">',
					$txt['search_options'], ':
				</dt>
				<dd class="options">
					<ul>
						<li>
							<input type="checkbox" name="show_complete" id="show_complete" value="1"', !empty($context['search_params']['show_complete']) ? ' checked' : '', '>
							<label for="show_complete">', $txt['search_show_complete_messages'], '</label>
						</li>
						<li>
							<input type="checkbox" name="subject_only" id="subject_only" value="1"', !empty($context['search_params']['subject_only']) ? ' checked' : '', '>
							<label for="subject_only">', $txt['search_subject_only'], '</label>
						</li>
					</ul>
				</dd>
				<dt class="righttext between">',
					$txt['search_post_age'], ':
				</dt>
				<dd>
					<label for="minage">',$txt['search_between'], ' </label>
					<input type="number" name="minage" id="minage" value="', empty($context['search_params']['minage']) ? '0' : $context['search_params']['minage'], '" size="5" maxlength="4">
					<label for="maxage"> ', $txt['search_and'], ' </label>
					<input type="number" name="maxage" id="maxage" value="', empty($context['search_params']['maxage']) ? '9999' : $context['search_params']['maxage'], '" size="5" maxlength="4"> ', $txt['days_word'], '
				</dd>
			</dl>
			<script>
				createEventListener(window);
				window.addEventListener("load", initSearch, false);
			</script>
			<input type="hidden" name="advanced" value="1">';

	// Require an image to be typed to save spamming?
	if ($context['require_verification'])
		echo '
			<p>
				<strong>', $txt['verification'], ':</strong>
				', template_control_verification($context['visual_verification_id'], 'all'), '
			</p>';

	// If $context['search_params']['topic'] is set, that means we're searching just one topic.
	if (!empty($context['search_params']['topic']))
		echo '
			<p>
				', $txt['search_specific_topic'], ' &quot;', $context['search_topic']['link'], '&quot;.
			</p>
			<input type="hidden" name="topic" value="', $context['search_topic']['id'], '">
			<input type="submit" name="b_search" value="', $txt['search'], '" class="button">';

	echo '
		</div>';

	if (empty($context['search_params']['topic']))
	{
		echo '
		<fieldset class="flow_hidden">
			<div class="roundframe alt">
				<div class="title_bar">
					<h4 class="titlebg">
						<span id="advanced_panel_toggle" class="toggle_down floatright" style="display: none;"></span>
						<a href="#" id="advanced_panel_link">', $txt['choose_board'], '</a>
					</h4>
				</div>
				<div class="flow_auto" id="advanced_panel_div"', $context['boards_check_all'] ? ' style="display: none;"' : '', '>
					<ul class="ignoreboards floatleft">';

		$i = 0;
		$limit = ceil($context['num_boards'] / 2);
		foreach ($context['categories'] as $category)
		{
			echo '
						<li class="category">
							<a href="javascript:void(0);" onclick="selectBoards([', implode(', ', $category['child_ids']), '], \'searchform\'); return false;">', $category['name'], '</a>
							<ul>';

			foreach ($category['boards'] as $board)
			{
				if ($i == $limit)
					echo '
							</ul>
						</li>
					</ul>
					<ul class="ignoreboards floatright">
						<li class="category">
							<ul>';

				echo '
								<li class="board">
									<label for="brd', $board['id'], '" style="margin-', $context['right_to_left'] ? 'right' : 'left', ': ', $board['child_level'], 'em;">
										<input type="checkbox" id="brd', $board['id'], '" name="brd[', $board['id'], ']" value="', $board['id'], '"', $board['selected'] ? ' checked' : '', '> ', $board['name'], '
									</label>
								</li>';

				$i++;
			}

			echo '
							</ul>
						</li>';
		}

		echo '
					</ul>
				</div><!-- #advanced_panel_div -->
				<br class="clear">
				<div class="padding">
					<input type="checkbox" name="all" id="check_all" value=""', $context['boards_check_all'] ? ' checked' : '', ' onclick="invertAll(this, this.form, \'brd\');">
					<label for="check_all"><em>', $txt['check_all'], '</em></label>
					<input type="submit" name="b_search" value="', $txt['search'], '" class="button floatright">
				</div>
			</div><!-- .roundframe -->
		</fieldset>';

		echo '
		<script>
			var oAdvancedPanelToggle = new smc_Toggle({
				bToggleEnabled: true,
				bCurrentlyCollapsed: ', $context['boards_check_all'] ? 'true' : 'false', ',
				aSwappableContainers: [
					\'advanced_panel_div\'
				],<commit_msg>Simplify and fix the Search ignore boards HTML<commit_after><?php
/**
 * Simple Machines Forum (SMF)
 *
 * @package SMF
 * @author Simple Machines http://www.simplemachines.org
 * @copyright 2018 Simple Machines and individual contributors
 * @license http://www.simplemachines.org/about/smf/license.php BSD
 *
 * @version 2.1 Beta 4
 */

/**
 * The main search form
 */
function template_main()
{
	global $context, $txt, $scripturl, $modSettings;

	echo '
	<form action="', $scripturl, '?action=search2" method="post" accept-charset="', $context['character_set'], '" name="searchform" id="searchform">';

	if (!empty($context['search_errors']))
		echo '
		<div class="errorbox">
			', implode('<br>', $context['search_errors']['messages']), '
		</div>';

	if (!empty($context['search_ignored']))
		echo '
		<div class="noticebox">
			', $txt['search_warning_ignored_word' . (count($context['search_ignored']) == 1 ? '' : 's')], ': ', implode(', ', $context['search_ignored']), '
		</div>';

	echo '
		<div class="cat_bar">
			<h3 class="catbg">
				<span class="generic_icons filter"></span>', $txt['set_parameters'], '
			</h3>
		</div>';

	echo '
		<div id="advanced_search" class="roundframe">
			<dl class="settings" id="search_options">
				<dt class="righttext">
					<strong><label for="searchfor">', $txt['search_for'], ':</label></strong>
				</dt>
				<dd>
					<input type="search" name="search" id="searchfor" ', !empty($context['search_params']['search']) ? ' value="' . $context['search_params']['search'] . '"' : '', ' maxlength="', $context['search_string_limit'], '" size="40">';

	if (empty($modSettings['search_simple_fulltext']))
		echo '
					<br><em class="smalltext">', $txt['search_example'], '</em>';

	echo '
				</dd>

				<dt class="righttext">
					<label for="searchtype">', $txt['search_match'], ':</label>
				</dt>
				<dd>
					<select name="searchtype" id="searchtype">
						<option value="1"', empty($context['search_params']['searchtype']) ? ' selected' : '', '>', $txt['all_words'], '</option>
						<option value="2"', !empty($context['search_params']['searchtype']) ? ' selected' : '', '>', $txt['any_words'], '</option>
					</select>
				</dd>
				<dt class="righttext">
					<label for="userspec">', $txt['by_user'], ':</label>
				</dt>
				<dd>
					<input id="userspec" type="text" name="userspec" value="', empty($context['search_params']['userspec']) ? '*' : $context['search_params']['userspec'], '" size="40">
				</dd>
				<dt class="righttext">
					<label for="sort">', $txt['search_order'], ':</label>
				</dt>
				<dd>
					<select id="sort" name="sort">
						<option value="relevance|desc">', $txt['search_orderby_relevant_first'], '</option>
						<option value="num_replies|desc">', $txt['search_orderby_large_first'], '</option>
						<option value="num_replies|asc">', $txt['search_orderby_small_first'], '</option>
						<option value="id_msg|desc">', $txt['search_orderby_recent_first'], '</option>
						<option value="id_msg|asc">', $txt['search_orderby_old_first'], '</option>
					</select>
				</dd>
				<dt class="righttext options">',
					$txt['search_options'], ':
				</dt>
				<dd class="options">
					<ul>
						<li>
							<input type="checkbox" name="show_complete" id="show_complete" value="1"', !empty($context['search_params']['show_complete']) ? ' checked' : '', '>
							<label for="show_complete">', $txt['search_show_complete_messages'], '</label>
						</li>
						<li>
							<input type="checkbox" name="subject_only" id="subject_only" value="1"', !empty($context['search_params']['subject_only']) ? ' checked' : '', '>
							<label for="subject_only">', $txt['search_subject_only'], '</label>
						</li>
					</ul>
				</dd>
				<dt class="righttext between">',
					$txt['search_post_age'], ':
				</dt>
				<dd>
					<label for="minage">',$txt['search_between'], ' </label>
					<input type="number" name="minage" id="minage" value="', empty($context['search_params']['minage']) ? '0' : $context['search_params']['minage'], '" size="5" maxlength="4">
					<label for="maxage"> ', $txt['search_and'], ' </label>
					<input type="number" name="maxage" id="maxage" value="', empty($context['search_params']['maxage']) ? '9999' : $context['search_params']['maxage'], '" size="5" maxlength="4"> ', $txt['days_word'], '
				</dd>
			</dl>
			<script>
				createEventListener(window);
				window.addEventListener("load", initSearch, false);
			</script>
			<input type="hidden" name="advanced" value="1">';

	// Require an image to be typed to save spamming?
	if ($context['require_verification'])
		echo '
			<p>
				<strong>', $txt['verification'], ':</strong>
				', template_control_verification($context['visual_verification_id'], 'all'), '
			</p>';

	// If $context['search_params']['topic'] is set, that means we're searching just one topic.
	if (!empty($context['search_params']['topic']))
		echo '
			<p>
				', $txt['search_specific_topic'], ' &quot;', $context['search_topic']['link'], '&quot;.
			</p>
			<input type="hidden" name="topic" value="', $context['search_topic']['id'], '">
			<input type="submit" name="b_search" value="', $txt['search'], '" class="button">';

	echo '
		</div>';

	if (empty($context['search_params']['topic']))
	{
		echo '
		<fieldset class="flow_hidden">
			<div class="roundframe alt">
				<div class="title_bar">
					<h4 class="titlebg">
						<span id="advanced_panel_toggle" class="toggle_down floatright" style="display: none;"></span>
						<a href="#" id="advanced_panel_link">', $txt['choose_board'], '</a>
					</h4>
				</div>
				<div class="flow_auto" id="advanced_panel_div"', $context['boards_check_all'] ? ' style="display: none;"' : '', '>
					<ul class="boardslist">';

		foreach ($context['categories'] as $category)
		{
			echo '
						<li>
							<a href="javascript:void(0);" onclick="selectBoards([', implode(', ', $category['child_ids']), '], \'searchform\'); return false;">', $category['name'], '</a>';

			foreach ($category['boards'] as $board)
			{
				echo '
                            <li>
                                <label for="brd', $board['id'], '" style="margin-', $context['right_to_left'] ? 'right' : 'left', ': ', $board['child_level'], 'em;">
                                    <input type="checkbox" id="brd', $board['id'], '" name="brd[', $board['id'], ']" value="', $board['id'], '"', $board['selected'] ? ' checked' : '', '> ', $board['name'], '
                                </label>
                            </li>';
			}

			echo '
						</li>';
		}

		echo '
					</ul>
				</div><!-- #advanced_panel_div -->
				<br class="clear">
				<div class="padding">
					<input type="checkbox" name="all" id="check_all" value=""', $context['boards_check_all'] ? ' checked' : '', ' onclick="invertAll(this, this.form, \'brd\');">
					<label for="check_all"><em>', $txt['check_all'], '</em></label>
					<input type="submit" name="b_search" value="', $txt['search'], '" class="button floatright">
				</div>
			</div><!-- .roundframe -->
		</fieldset>';

		echo '
		<script>
			var oAdvancedPanelToggle = new smc_Toggle({
				bToggleEnabled: true,
				bCurrentlyCollapsed: ', $context['boards_check_all'] ? 'true' : 'false', ',
				aSwappableContainers: [
					\'advanced_panel_div\'
				],
{'fraction_non_alphanumeric': 0.23512998502790255, 'fraction_numerical': 0.00449162923642303, 'mean_word_length': 4.129144851657941, 'pattern_counts': {'":': 0, '<': 291, '<?xml version=': 0, '>': 289, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5088703', 'n_tokens_mistral': 5850, 'n_tokens_neox': 4828, 'n_words': 923}