Location: PHPKode > projects > Enigma > Enigma2/Enigma2_Install/Themes/Enigma/portal/modules/ShoutBox.template.php
<?php
// Shoutbox template file

function template_shout_reader()
{
	global $context, $modSettings, $txt, $scripturl, $settings, $sc;

	// Let's make sure there are shouts to display first, if not, see the else statement at the end of this function
	if (is_array($context['shouts']))
	{
  
  
  		// if shout box scrolling is enabled, start a marquee box
  		// Note some special formatting needed to prevent weird displays caused by a marquee in some browsers
		if (!empty($modSettings['enablescrollshout']))
			echo '
			<center><marquee style="display: block; text-align: left; width: ', $modSettings['shoutscrollwidth'], 'px; height: ', $modSettings['shoutscrollheight'], 'px" behavior="scroll" direction="', $modSettings['shoutscrolldir'], '" scrollamount="', $modSettings['shoutscrollspeed'], '" scrolldelay="', $modSettings['shoutscrolldelay'], '" onmouseover="this.stop()" onmouseout="this.start()">';

		// we need to loop through all loaded shouts
		foreach ($context['shouts'] as $shout)
		{
			// if thise user has shout deleting privedges, display a delete link for each shout
			if ($context['delete_allowed'])
				echo '
				<a href="', $scripturl, '?module=ShoutBox;sa=delete_shout;id=', $shout['id'], ';sesc=', $sc, '"><img src="', $settings['images_url'], '/icons/delete.gif" border="0" alt="X"></a> ';

			// now display the current shout
			// time - time of shout, posterlink - profile link or email link, message - the actual shout, shoutsep - the separator between shouts
			echo '<span class="smalltext">', $shout['time'], '</span> ';
	
			//create a link to the users profile or email address depending on member or guest
			 // if email wasn't stored with this shout, they must be a member and have a profile
			if (empty($shout['email']))
				echo '<a href="', $scripturl, '?action=profile;user=' . $shout['name'], '">', $shout['displayname'], '</a>';
			// otherwise they are a guest and we should have an email link
			else
				echo	'<a href="mailto:', $shout['email'], '">', $shout['name'], '</a>';
	
			// now display the message, followed by a separator
			echo ' - ', $shout['message'], ' <hr />';
		}

		// if shout box scrolling is enabled, close the marquee box
		if (!empty($modSettings['enablescrollshout']) && $modSettings['enablescrollshout']==1)
			echo '
			</marquee></center>';

		// display a link to the shout archive
		echo '
			<center><p><a href="', $scripturl, '?module=ShoutBox;sa=shout_archive">', $txt['shoutbox_43'], '</a></p></center>';
	}
	// There aren't any shouts in the database if we get here, so we need to display a message saying that.
	else
	{
		echo $txt['shoutbox_44'];
	}
	
	// if this user is allowed to submit shouts, call the form template below.  Normal methods won't work here.
	if ($context['submit_shout'] == true)
	{
		echo '
			<center>', template_shout_form(), '</center>';
	}
}

function template_shout_form()
{
	global $scripturl, $modSettings, $user_info, $txt, $context, $sc, $settings;

	// check for a bad verification code message and set a variable to display an error message
	if (isset($_REQUEST['code']))
		$codeError = '<div style="color: #FF0000;">**<b>Bad Code!</b>**</div>';
	// no error this time
	else
		$codeError = '';

	// start the shout form. Important:  hidden fields HAVE to be there
	echo '
		<form name="shoutform" enctype="multipart/form-data"  action="', $scripturl, '?module=ShoutBox;sa=shout" method="post">
			<INPUT TYPE="hidden" value="', $context['shoutform']['returnlink'], '" NAME="qstr" />';

	// if this user is a guest, display form fields for name, email address
	if ($context['user']['is_guest'])
	{
		echo '
			<INPUT TYPE="text" value="', $txt['shoutbox_6'], '" NAME="name" maxlength="100" onfocus="this.value=\'\'" /><br />
			<INPUT TYPE="text" value="', $txt['shoutbox_7'], '" NAME="email" maxlength="100" onfocus="this.value=\'\'" /><br />';
	}
	// then this user isn't a guest and has profile info to use
	else
	{
		echo '
			<INPUT TYPE="hidden" value="', $user_info['username'], '" NAME="name" />
			<INPUT TYPE="hidden" value="', $user_info['name'], '" NAME="displayname" />';
	}


	// if image verification is not disabled and the user is a guest, do the verification
	if ($context['user']['is_guest'] && $context['shout_image_verify'])
	{
			// set verification image width less than the form fields
			$width = 120;
			// calculate proportional height based on verification image sizes and the set width
			$height = $width*70/180;
			// set a variable to use when displaying the image below
			$size = 'width="' . $width . 'px" height="' . $height . 'px"';


		// display the form fields and verification image.  Important:  the hidden fields HAVE to be there.
		echo '
			', $txt['shoutbox_13'], '<br />
			', $codeError, '
			<img src="modules/ModuleCaptcha/image.php?img=', $context['shoutimg'], '" ', $size, ' /><br />
			<input type="text" value="', $txt['shoutbox_14'], '" name="password" maxlength="100" onfocus="this.value=\'\'" /><br />
			<input type="hidden" name="go" value="verify" />
			<input type="hidden" name="shoutv" value="' . $context['shoutsesc'] . '" />';
	}
	// not a guest or verification is off, use the session
	else
	{
		echo'
			<INPUT TYPE="hidden" value="', $sc, '" NAME="sc" />';
	}

	// Now start printing all of the smileys.
	if (!empty($context['shoutsmileys']['shoutform']))
	{
		echo '<br />';

		// Show each row of smileys ;).
		foreach ($context['shoutsmileys']['shoutform'] as $smiley_row)
		{
			foreach ($smiley_row['smileys'] as $smiley)
				echo '
					<a href="javascript:void(0);" onclick="replaceText(\' ', $smiley['code'], '\', document.shoutform.message); return false;"><img src="', $settings['smileys_url'], '/', $smiley['filename'], '" align="bottom" alt="', $smiley['description'], '" title="', $smiley['description'], '" border="0" /></a>';
		}

		// If the smileys popup is to be shown... show it!
		if (!empty($context['shoutsmileys']['shoutpopup']))
			echo '
					<a href="javascript:moreshoutSmileys();">[', $txt['more_smileys'], ']</a><br /><br />';
	}

	// If there are additional smileys then ensure we provide the javascript for them.
	if (!empty($context['shoutsmileys']['shoutpopup']))
	{
		echo '
			<script language="JavaScript" type="text/javascript"><!--
				var smileys = [';

		foreach ($context['shoutsmileys']['shoutpopup'] as $smiley_row)
		{
			echo '
					[';
			foreach ($smiley_row['smileys'] as $smiley)
			{
				echo '
						["', $smiley['code'], '","', $smiley['filename'], '","', $smiley['js_description'], '"]';
				if (empty($smiley['last']))
					echo ',';
			}

			echo ']';
			if (empty($smiley_row['last']))
				echo ',';
		}

		echo '];
				var smileyshoutpopupWindow;

				function moreshoutSmileys()
				{
					var row, i;

					if (smileyshoutpopupWindow)
						smileyshoutpopupWindow.close();

					smileyshoutpopupWindow = window.open("", "add_smileys", "toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,width=480,height=220,resizable=yes");
					smileyshoutpopupWindow.document.write(\'<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">\n<html>\');
					smileyshoutpopupWindow.document.write(\'\n\t<head>\n\t\t<title>', $txt['more_shout_smileys_title'], '</title>\n\t\t<link rel="stylesheet" type="text/css" href="', $settings['theme_url'], '/style.css" />\n\t</head>\');
					smileyshoutpopupWindow.document.write(\'\n\t<body style="margin: 1ex;">\n\t\t<table width="100%" cellpadding="5" cellspacing="0" border="0" class="tborder">\n\t\t\t<tr class="titlebg"><td align="left">', $txt['more_smileys_pick'], '</td></tr>\n\t\t\t<tr class="windowbg"><td align="left">\');

					for (row = 0; row < smileys.length; row++)
					{
						for (i = 0; i < smileys[row].length; i++)
						{
							smileys[row][i][2] = smileys[row][i][2].replace(/"/g, \'&quot;\');
							smileyshoutpopupWindow.document.write(\'<a href="javascript:void(0);" onclick="window.opener.replaceText(&quot; \' + smileys[row][i][0] + \'&quot;, window.opener.document.shoutform.message); window.focus(); return false;"><img src="', $settings['smileys_url'], '/\' + smileys[row][i][1] + \'" alt="\' + smileys[row][i][2] + \'" title="\' + smileys[row][i][2] + \'" style="padding: 4px;" border="0" /></a>\');
						}
						smileyshoutpopupWindow.document.write("<br />");
					}

					smileyshoutpopupWindow.document.write(\'</td></tr>\n\t\t\t<tr><td align="center" class="windowbg"><a href="javascript:window.close();\\">', $txt['more_smileys_close_window'], '</a></td></tr>\n\t\t</table>\n\t</body>\n</html>\');
					smileyshoutpopupWindow.document.close();
				}
			// --></script>';
	}

	// message field and shout button
	echo '
			<br /><INPUT TYPE="text" value="" NAME="message" maxlength="100" onselect="storeCaret(this);" onclick="storeCaret(this);" onkeyup="storeCaret(this);" onchange="storeCaret(this);" /><br \>
			<INPUT TYPE="submit" NAME="submit" VALUE="', $txt['shoutbox_9'], '" />
		</form>';

}

function template_shout_archive()
{
	global $context, $txt, $settings, $modSettings, $sc, $scripturl;

	echo '
	<div class="tborder">
		<table width="100%" cellspacing="1" cellpadding="4" border="0" align="center">
			<tr>
				<td class="catbg" align="center">', $txt['shoutbox_1'], '</td>
			</tr><tr>
				<td class="windowbg">';

	// Let's make sure there are shouts to display first, if not, see the else statement at the end of this function
	if (is_array($context['shouts_archive']))
	{
		// we need to loop through all loaded shouts
		foreach ($context['shouts_archive'] as $shout)
		{
			// if thise user has shout deleting privedges, display a delete link for each shout
			if ($context['delete_allowed'])
				echo '
					<a href="', $scripturl, '?module=ShoutBox;sa=delete_shout;id=', $shout['id'], ';sesc=', $sc, '"><img src="', $settings['images_url'], '/icons/delete.gif" border="0" alt="X"></a> ';

			// now display the current shout
			// time - time of shout, posterlink - profile link or email link, message - the actual shout, shoutsep - the separator between shouts
			echo '<span class="smalltext">', $shout['time'], '</span> ';

			//create a link to the users profile or email address depending on member or guest
			 // if email wasn't stored with this shout, they must be a member and have a profile
			if (empty($shout['email']))
				echo '<a href="', $scripturl, '?action=profile;user=' . $shout['name'], '">', $shout['displayname'], '</a>';
			// otherwise they are a guest and we should have an email link
			else
				echo	'<a href="mailto:', $shout['email'], '">', $shout['name'], '</a>';
	
			// now display the message, followed by a separator
			echo ' - ', $shout['message'], ' <hr />';
		}
	}
	// There aren't any shouts in the database if we get here, so we need to display a message saying that.
	else
	{
		echo $txt['shoutbox_44'];
	}

	// if this user is allowed to submit shouts, call the form template above.  Normal methods won't work here.
	if ($context['submit_shout'] == true)
	{
		echo '
					<center>', template_shout_form(), '</center>';
	}

	echo '
				</td>
			</tr>
		</table>
	</div';

	//pull the delete options for the administrator
	if ($context['delete_allowed'])
	{
		echo '
	<br />
	<div class="tborder">
		<table width="100%" cellspacing="1" cellpadding="4" border="0" align="center">
			<tr>
				<td class="catbg" align="center">', $txt['shoutbox_42'], '</td>
			</tr><tr>
				<td class="windowbg2">
					<form enctype="multipart/form-data"  action="', $scripturl, '?module=ShoutBox;sa=delete_shout_age" method="post">
						', $txt['shoutbox_2'], ' <input type="text" name="age" id="age" value="25" size="4" /> ', $txt['shoutbox_3'], ' -
						<input type="hidden" name="sc" value="', $sc, '" />
						<input type="submit" name="submit" value="', $txt['shoutbox_5'], '" />
					</form>
					<form enctype="multipart/form-data"  action="', $scripturl, '?module=ShoutBox;sa=delete_all_shouts" method="post">
						', $txt['shoutbox_4'],' ', $modSettings['shoutlimit'], ' -
						<input type="hidden" name="sc" value="', $sc, '" />
						<input type="submit" name="submit" value="', $txt['shoutbox_5'], '" />
					</form>
				</td>
			</tr>
		</table>
	</div>';
	}

}
?>
Return current item: Enigma