<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
 */

/**
 * A form for creating and/or editing a poll.
 */
function template_main()
{
	global $context, $txt, $scripturl;

	// Some javascript for adding more options.
	echo '
	<script>
		var pollOptionNum = 0;
		var pollOptionId = ', $context['last_choice_id'], ';

		function addPollOption()
		{
			if (pollOptionNum == 0)
			{
				for (var i = 0; i < document.forms.postmodify.elements.length; i++)
					if (document.forms.postmodify.elements[i].id.substr(0, 8) == "options-")
						pollOptionNum++;
			}
			pollOptionNum++
			pollOptionId++

			setOuterHTML(document.getElementById("pollMoreOptions"), \'<dt><label for="options-\' + pollOptionId + \'" ', (isset($context['poll_error']['no_question']) ? ' class="error"' : ''), '>', $txt['option'], ' \' + pollOptionNum + \'</label>:</dt><dd><input type="text" name="options[\' + (pollOptionId) + \']" id="options-\' + (pollOptionId) + \'" value="" size="80" maxlength="255"></dd><p id="pollMoreOptions"></p\');
		}
	</script>';

	// Start the main poll form.
	echo '
	<div id="edit_poll">
		<form action="' . $scripturl . '?action=editpoll2', $context['is_edit'] ? '' : ';add', ';topic=' . $context['current_topic'] . '.' . $context['start'] . '" method="post" accept-charset="', $context['character_set'], '" onsubmit="submitonce(this);" name="postmodify" id="postmodify">
			<div class="cat_bar">
				<h3 class="catbg">', $context['page_title'], '</h3>
			</div>';

	if (!empty($context['poll_error']['messages']))
		echo '
			<div class="errorbox">
				<dl class="poll_error">
					<dt>
						', $context['is_edit'] ? $txt['error_while_editing_poll'] : $txt['error_while_adding_poll'], ':
					</dt>
					<dt>
						', empty($context['poll_error']['messages']) ? '' : implode('<br>', $context['poll_error']['messages']), '
					</dt>
				</dl>
			</div>';

	echo '
			<div>
				<div class="roundframe">
					<input type="hidden" name="poll" value="', $context['poll']['id'], '">
					<fieldset id="poll_main">
						<legend><span ', (isset($context['poll_error']['no_question']) ? ' class="error"' : ''), '>', $txt['poll_question'], ':</span></legend>
						<dl class="settings poll_options">
							<dt>', $txt['poll_question'], ':</dt>
							<dd><input type="text" name="question" size="80" value="', $context['poll']['question'], '"></dd>';

	foreach ($context['choices'] as $choice)
	{
		echo '
							<dt>
								<label for="options-', $choice['id'], '" ', (isset($context['poll_error']['poll_few']) ? ' class="error"' : ''), '>', $txt['option'], ' ', $choice['number'], '</label>:
							</dt>
							<dd>
								<input type="text" name="options[', $choice['id'], ']" id="options-', $choice['id'], '" value="', $choice['label'], '" size="80" maxlength="255">';

		// Does this option have a vote count yet, or is it new?
		if ($choice['votes'] != -1)
			echo ' (', $choice['votes'], ' ', $txt['votes'], ')';

		echo '
							</dd>';
	}

	echo '
							<p id="pollMoreOptions"></p>
						</dl>
						<strong><a href="javascript:addPollOption(); void(0);">(', $txt['poll_add_option'], ')</a></strong>
					</fieldset>
					<fieldset id="poll_options">
						<legend>', $txt['poll_options'], ':</legend><commit_msg>Fix the layout of the Edit Poll screen<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
 */

/**
 * A form for creating and/or editing a poll.
 */
function template_main()
{
	global $context, $txt, $scripturl;

	// Some javascript for adding more options.
	echo '
	<script>
		var pollOptionNum = 0;
		var pollOptionId = ', $context['last_choice_id'], ';

		function addPollOption()
		{
			if (pollOptionNum == 0)
			{
				for (var i = 0; i < document.forms.postmodify.elements.length; i++)
					if (document.forms.postmodify.elements[i].id.substr(0, 8) == "options-")
						pollOptionNum++;
			}
			pollOptionNum++
			pollOptionId++

			setOuterHTML(document.getElementById("pollMoreOptions"), \'<dt><label for="options-\' + pollOptionId + \'" ', (isset($context['poll_error']['no_question']) ? ' class="error"' : ''), '>', $txt['option'], ' \' + pollOptionNum + \'</label>:</dt><dd><input type="text" name="options[\' + (pollOptionId) + \']" id="options-\' + (pollOptionId) + \'" value="" size="80" maxlength="255"></dd><p id="pollMoreOptions"></p\');
		}
	</script>';

	if (!empty($context['poll_error']['messages']))
		echo '
			<div class="errorbox">
				<dl class="poll_error">
					<dt>
						', $context['is_edit'] ? $txt['error_while_editing_poll'] : $txt['error_while_adding_poll'], ':
					</dt>
					<dt>
						', empty($context['poll_error']['messages']) ? '' : implode('<br>', $context['poll_error']['messages']), '
					</dt>
				</dl>
			</div>';

	// Start the main poll form.
	echo '
	<div id="edit_poll">
		<form action="' . $scripturl . '?action=editpoll2', $context['is_edit'] ? '' : ';add', ';topic=' . $context['current_topic'] . '.' . $context['start'] . '" method="post" accept-charset="', $context['character_set'], '" onsubmit="submitonce(this);" name="postmodify" id="postmodify">
			<div class="cat_bar">
				<h3 class="catbg">', $context['page_title'], '</h3>
			</div>';

	echo '
			<div>
				<div class="roundframe noup">
					<input type="hidden" name="poll" value="', $context['poll']['id'], '">
					<fieldset id="poll_main">
						<legend><span ', (isset($context['poll_error']['no_question']) ? ' class="error"' : ''), '>', $txt['poll_question'], ':</span></legend>
						<dl class="settings poll_options">
							<dt>', $txt['poll_question'], ':</dt>
							<dd><input type="text" name="question" size="80" value="', $context['poll']['question'], '"></dd>';

	foreach ($context['choices'] as $choice)
	{
		echo '
							<dt>
								<label for="options-', $choice['id'], '" ', (isset($context['poll_error']['poll_few']) ? ' class="error"' : ''), '>', $txt['option'], ' ', $choice['number'], '</label>:
							</dt>
							<dd>
								<input type="text" name="options[', $choice['id'], ']" id="options-', $choice['id'], '" value="', $choice['label'], '" size="80" maxlength="255">';

		// Does this option have a vote count yet, or is it new?
		if ($choice['votes'] != -1)
			echo ' (', $choice['votes'], ' ', $txt['votes'], ')';

		echo '
							</dd>';
	}

	echo '
							<p id="pollMoreOptions"></p>
						</dl>
						<strong><a href="javascript:addPollOption(); void(0);">(', $txt['poll_add_option'], ')</a></strong>
					</fieldset>
					<fieldset id="poll_options">
						<legend>', $txt['poll_options'], ':</legend>
{'fraction_non_alphanumeric': 0.24267662263067202, 'fraction_numerical': 0.00832854681217691, 'mean_word_length': 4.0216294160057675, 'pattern_counts': {'":': 0, '<': 123, '<?xml version=': 0, '>': 117, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2208304', 'n_tokens_mistral': 2787, 'n_tokens_neox': 2342, 'n_words': 467}