Location: PHPKode > projects > Enigma > Enigma2/Enigma2_Install/Themes/Enigma/portal/blocks/Block_polls.template.php
<?php
// Polls Block template file

if (!defined('ENIGMA'))
	die('<b>Access Violation</b><br />Direct Access to this location is not allowed.');


function template_Block_polls()
{
	global $context, $scripturl, $settings, $txt, $bpollinfo;

	if (!empty($context['no_poll']))
	{
		echo $txt['polls_none'];
		return;
	}
	
	echo '
					<img src="', $settings['images_url'], $context['bpoll']['is_locked'] ? '/topic/normal_poll_locked' : '/topic/normal_poll', '.gif" alt="" align="top" />
					<b>', $txt['smf21'], ':</b><br />
					', $context['bpoll']['question'], '<br />
					<br />';

	if (!empty($context['bpoll']['expire_time']))
		echo '
					&nbsp;(', ($context['bpoll']['is_expired'] ? $txt['poll_expired_on'] : $txt['poll_expires_on']), ': ', $context['bpoll']['expire_time'], ')<br />';

	// Have they already voted and are allowed to change their vote?
	if ($context['bpoll']['has_voted'] && $context['allow_change_vote'])
	{
		echo '
					<form name="changepollvote" action="', $scripturl, '?module=Polls;code=true;sa=vote;poll=', $context['bpoll']['id'], '" method="post" style="margin: 0px;">
						<input type="hidden" value="', $context['bpoll']['qstr'], '" name="qstr" />
						<input type="hidden" value="', (!empty($bpollinfo['ID_TOPIC']) ? $bpollinfo['ID_TOPIC'] : ''), '" name="topic" />
						<input type="hidden" value="1" name="changevote" />
						<p><span style="font-size: x-small; font-weight: bold;">', $txt['bpoll_change_message'], '</span><br />';

		// Show each option with its corresponding percentage bar and it's corresponding vote button/checkbox.
		foreach ($context['bpoll']['options'] as $option)
			echo
					$option['vote_button'], ' ', $option['option'], '<br />
					&nbsp;', $context['allow_poll_view'] ? $option['bar'] . ' ' . $option['votes'] . ' (' . $option['percent'] . '%)<br />
					<img src="' . $settings['images_url'] . '/blank.gif" width="1" height="6" alt="" /><br />' : '<br />';

		// Show a warning if they are allowed more than one option.
		if ($context['bpoll']['allowed_warning'])
			echo '
						<span style="font-size: x-small; font-weight: bold;">', $context['bpoll']['allowed_warning'], '</span><br />';

		// display the Submit/Vote button
		echo '
						<p style="text-align: center"><input type="submit" value="', $txt['bpoll_change_vote'], '" /></p>
						<input type="hidden" name="sc" value="', $context['session_id'], '" />
					</form>
					', $context['allow_poll_view'] ? '<b>' . $txt['smf24'] . ': ' . $context['bpoll']['total_votes'] . '</b>' : '', '<br />';

	}
	// Are they not allowed to vote but allowed to view the options?
	elseif (!$context['allow_vote'] || $context['bpoll']['has_voted'])
	{
		// Show each option with its corresponding percentage bar.
		foreach ($context['bpoll']['options'] as $option)
			echo
					$option['option'], '<br />
					&nbsp;', $context['allow_poll_view'] ? $option['bar'] . ' ' . $option['votes'] . ' (' . $option['percent'] . '%)<br />
					<img src="' . $settings['images_url'] . '/blank.gif" width="1" height="6" alt="" /><br />' : '<br />';
		echo
					$context['allow_poll_view'] ? '<b>' . $txt['smf24'] . ': ' . $context['bpoll']['total_votes'] . '</b>' : '', '<br />';

	}
	// They are allowed to vote!  Go to it!
	else
	{

		echo '
					<form name="pollvote" action="', $scripturl, '?module=Polls;code=true;sa=vote;poll=', $context['bpoll']['id'], '" method="post" style="margin: 0px;">
						<input type="hidden" value="', $context['bpoll']['qstr'], '" name="qstr" />
						<input type="hidden" value="', (!empty($bpollinfo['ID_TOPIC']) ? $bpollinfo['ID_TOPIC'] : ''), '" name="topic" />
						<p>';

		// Show a warning if they are allowed more than one option.
		if ($context['bpoll']['allowed_warning'])
			echo '
						<span style="font-size: x-small; font-weight: bold;">', $context['bpoll']['allowed_warning'], '</span><br />';

		// Show each option with its button - a radio likely.
		foreach ($context['bpoll']['options'] as $option)
			echo
						$option['vote_button'], ' ', $option['option'], '<br />
						<img src="' . $settings['images_url'] . '/blank.gif" width="1" height="6" alt="" /><br />';

		// display the Submit/Vote button
		echo '
						<p style="text-align: center"><input type="submit" value="', $txt['smf23'], '" /></p>
						<input type="hidden" name="sc" value="', $context['session_id'], '" />
					</form>';

	}

	// If they're allowed to lock the poll, show a link!
	if ($context['bpoll']['lock'])
		echo '
					<form name="lockpoll" action="', $scripturl, '?module=Polls;code=true;sa=lockVoting;poll=', $context['bpoll']['id'], '" method="post" style="margin: 0px;">
						<INPUT TYPE="hidden" value="', $context['bpoll']['qstr'], '" NAME="qstr" />
						<INPUT TYPE="hidden" value="', (!$context['bpoll']['is_locked'] ? 1 : 0), '" NAME="status" />
						<p style="text-align: center"><input type="submit" value="', (!$context['bpoll']['is_locked'] ? $txt['smf30'] : $txt['smf30b']), '" /></p>
					</form>';

	// If the poll is attached to a message topic, provide a link to the topic
	if (!empty($bpollinfo['ID_TOPIC']) && empty($_REQUEST['topic']))
		echo '
					<p><span style="font-size: x-small;"><a href="', $scripturl, '?topic=', $bpollinfo['ID_TOPIC'], '">', $txt['bpoll_view_topic'], '</a></span></p>';

	// If they're allowed to edit the poll... guess what... show a link!
	if ($context['bpoll']['edit'])
		echo '
					<p><span style="font-size: x-small;"><a href="', $scripturl, '?module=PollsManagement;sa=EditPoll;ID_POLL=', $context['bpoll']['id'], '">', $txt['smf39'], '</a></span></p>';
					
}
?>
Return current item: Enigma