Location: PHPKode > projects > Enigma > Enigma2/Enigma2_Install/Themes/Enigma/portal/modules/Guestbook.template.php
<?php
// Version: 1.0 RC1; Guestbook

function template_guestbook_main()
{
	global $context, $scripturl, $txt;

	echo theme_linktree(), '<br /><br />';

	if ($context['index_count']>0)
	{
		foreach ($context['guestbook'] AS $guestbook)
		{
			$guestbook['guestName'] = !empty($guestbook['emailaddress']) ? '<a href="mailto:'.$guestbook['emailaddress'].'">'.$guestbook['guestName'].'</a>' : (($guestbook['userid'] > 0) ? '<a href="?action=profile;u='.$guestbook['userid'].'">'.$guestbook['guestName'].'</a>' : $guestbook['guestName']);

			echo ($context['user']['is_admin']) ? '
     <script language="JavaScript1.2" type="text/javascript"><!--
          function DoConfirm(message, url)
          {
               if (confirm(message))
                    location.href = url;
          }
     //--></script>' : '', '
	<div class="tborder">
		<table class="bordercolor" width="100%" cellSpacing="1" cellPadding="0" align="center" border="0">
			<tr>
				<td class="windowbg" width="50%" style="padding: 2px;">', $context['start_count'], ') ', $txt['guestbook_1'], ': ', $guestbook['guestName'], '</td>
				<td class="windowbg" align="right" width="50%" style="padding: 2px;">', $guestbook['signtime'], '</td>
			</tr><tr>
				<td class="windowbg2" colspan="2" style="padding: 10px;">',
		$guestbook['body'],
		($context['user']['is_admin']) ? '<br /><div style="text-align: right"><small><a href="'.$scripturl.'?module=Guestbook;sa=edit;id='.$guestbook['id'].'">' . $txt['guestbook_2'] . '</a> | <a href="javascript:DoConfirm(\'' . $txt['guestbook_4'] . '\',\''.$scripturl.'?module=Guestbook;sa=delete;id='.$guestbook['id'].'\');">' . $txt['guestbook_5'] . '</a> | <a href="'.$scripturl.'?module=Guestbook;sa=SignGuestBook;id='.$guestbook['id'].'">Respond</a></small></div>':'', '</td>';

			if (!empty($context['response'][$guestbook['id']]))
			{
				$count = @count($context['response'][$guestbook['id']]);

					echo '
			</tr><tr>
				<td class="windowbg2" colspan="2" style="padding: 5px;">', $txt['guestbook_3'], ':';

				$c=1;
				$x=0;
				foreach ($context['response'][$guestbook['id']] AS $response)
				{
					echo '
				<div class="tborder">
					<table class="bordercolor" width="100%" cellSpacing="1" cellPadding="0" align="center" border="0">
						<tr>
							<td class="titlebg" width="50%" style="padding: 2px;">',$c++,') ', $txt['guestbook_1'], ': <a href="?action=profile;u=', $guestbook['userid'], '">', $response['guestName'], '</a></td>
							<td class="titlebg" align="right" width="50%" style="padding: 2px;">', $response['signtime'], '</td>
						</tr><tr>
							<td class="windowbg2" colspan="2" style="padding: 10px;">',
					$response['body'],
					($context['user']['is_admin']) ? '<br /><div style="text-align: right"><small><a href="'.$scripturl.'?module=Guestbook;sa=edit;id='.$response['id'].'">' . $txt['guestbook_2'] . '</a> | <a href="javascript:DoConfirm(\'' . $txt['guestbook_4'] . '\',\''.$scripturl.'?module=Guestbook;sa=delete;id='.$response['id'].'\');">' . $txt['guestbook_5'] . '</a></small></div>':'', '</td>
						</tr>
					</table>
				</div>';

					echo ($x < $count) ? '<br />' : '';
					$x++;
				}
				echo '</td>';
				unset($c, $count);
			}

		echo '
			</tr>
		</table>
	</div>
<br />
';
		$context['start_count']--;
		}

		echo '
	<div class="tborder">
		<table class="bordercolor" width="100%" cellSpacing="1" cellPadding="0" align="center" border="0">
			<tr>
				<td class="windowbg" width="100%" style="padding: 2px; text-align: center;">', $context['page_index'], '</td>
			</tr>
		</table>
	</div>';
	}
	else
	{
		echo '<br /><br />
	<div class="tborder">
		<table class="bordercolor" width="100%" cellSpacing="1" cellPadding="0" align="center" border="0">
			<tr>
				<td class="windowbg" width="100%" style="padding: 3px;">', $txt['guestbook_6'], '</td>
			</tr>
		</table>
	</div>
	<br />';
	}
}

function template_guest_sign()
{
	global $context, $scripturl, $txt, $sc;

	echo theme_linktree(), '<br />';

	if (isset($_REQUEST['code']))
	{ 
		$codeError = '<div style="color: #FF0000;">**<b>' . $txt['guestbook_7'] . '</b>**</div>';
	}
	else
	{
		$codeError = '';
	}
	
	if ($context['is_response'] != '')
	{
		echo '
	<div class="tborder">
		<table class="bordercolor" width="100%" cellSpacing="1" cellPadding="0" align="center" border="0">
			<tr>
				<td class="titlebg" width="50%" style="padding: 2px;">', $txt['guestbook_8'], ': ', $context['response']['guestName'], '</td>
				<td class="titlebg" align="right" width="50%" style="padding: 2px;">', timeformat($context['response']['signtime']), '</td>
			</tr><tr>
				<td class="windowbg2" colspan="2" style="padding: 10px;">', censorText(DoUBBC($context['response']['body'])), '</td>
			</tr>
		</table>
	</div>';
	}

	echo '
	<form enctype="multipart/form-data" action="' . $scripturl . '?module=Guestbook;sa=sign2" method="post" name="form1">
	<div class="tborder" align="center">
               <table class="bordercolor" cellspacing="1" callpadding="2" align="center" style="text-align: left;">';

	if ($context['is_response'] != '')
		echo '
			<input type="hidden" name="response" value="', $context['is_response'], '" />';

	// if user is a guest, display name and email form fields
	if ($context['user']['is_guest'])
	{
		echo '
			<tr>
				<td class="windowbg2">', $txt['guestbook_9'], ':</td>
				<td class="windowbg2"><input type="text" name="signname">
				<input type="hidden" name="id" value="-1" /></td>
			</tr><tr>
				<td class="windowbg2">', $txt['guestbook_10'], ':</td>
				<td class="windowbg2"><input type="text" name="emailaddress" /></td>
			</tr>';
	}
	// not a guest, then use their account info
	else
	{
		echo '
			<tr>
				<td class="windowbg2">', $txt['guestbook_9'], ':</td><td class="windowbg2">', $context['user']['name'], '
				<input type="hidden" name="signname" value="', $context['user']['name'], '" />
				<input type="hidden" name="id" value="', $context['user']['id'], '" /></td>
			</tr>';
	}

	echo '
			<tr>
				<td class="windowbg2">', $txt['guestbook_11'], ':</td>
				<td class="windowbg2"><textarea name="body" rows=10 cols=70></textarea></td>
			</tr>';

	// if image verification is turned on, display it
	if ($context['gb_image_verify'])
	{

		echo '<tr>
				<td class="windowbg2">', $txt['guestbook_12'], ':</td>
				<td class="windowbg2">
					' . $codeError . '
					<input type="text" name="password" /> <img src="modules/ModuleCaptcha/image.php?img=' . $context['gbimg'] . '" alt="" align="absmiddle" /><br />
					' . $txt['guestbook_characters'] . '
					<input type="hidden" name="go" value="verify" />
					<input type="hidden" name="gbv" value="' . $context['gbsesc'] . '" />
				</td>
			</tr>';
	}
	// otherwise, just put the session info in the form
	else
	{
		echo '
				<INPUT TYPE="hidden" value="', $sc, '" NAME="sc" />';
	}

	echo '<tr>
				<td class="windowbg2" align="center" colspan="2">
				<input type="submit" value="', $txt['guestbook_sign'], '" /></td>
			</tr>
		</table>
	</form>
	</div>';
}

function template_guest_edit()
{
	global $context, $scripturl;

	echo '
	<form enctype="multipart/form-data" action="', $scripturl, '?module=Guestbook;sa=doEdit" method="post" name="form1">
	<table class="bordercolor" cellspacing="1" align="center">
		<tr>
			<td class="windowbg2">', $txt['guestbook_9'], ':</td>
			<td class="windowbg2"><input type="text" name="signname" value="', $context['message']['guestName'], '" /></td>
		</tr><tr>
			<td class="windowbg2">', $txt['guestbook_10'], ':</td>
			<td class="windowbg2"><input type="text" name="emailaddress" value="', $context['message']['emailaddress'], '" /></td>
		</tr><tr>
			<td class="windowbg2">', $txt['guestbook_11'], ':</td>
			<td class="windowbg2"><textarea name="body" rows=10 cols=70>', $context['message']['body'], '</textarea></td>
		</tr><tr>
			<td class="windowbg2" align="center" colspan="2"><input type="submit" value="', $txt['guestbook_13'], '" /></td>
		</tr>
	</table>
	<input type="hidden" name="id" value="', $context['message']['id'], '" />
	</form>
';
}

function template_guest_admin()
{
	global $context, $scripturl, $txt;

	echo '
	<div class="tborder">
		<table class="bordercolor" width="100%" cellSpacing="1" cellPadding="0" align="center" border="0">
			<tr>
				<td class="blockhead" width="100%" style="text-align: center; font-weight: bold;">', $txt['guestbook_admin'], '</td>
			</tr>
			<tr>
				<td class="windowbg" width="100%" style="padding: 3px;">', $txt['guestbook_14'], '</td>
			</tr>
		</table>
	</div>
	<br />';
	if (is_array($context['messages']))
	{
		foreach ($context['messages'] AS $guestbook)
		{
			$guestbook['guestName'] = ($guestbook['emailaddress'] != '') ? '<a href="mailto:'.$guestbook['emailaddress'].'">'.$guestbook['guestName'].'</a>' : (($guestbook['userid'] > 0) ? '<a href="?action=profile;u='.$guestbook['userid'].'">'.$guestbook['guestName'].'</a>' : $guestbook['guestName']);
			$bgcolor	= ($guestbook['is_response'] > 0) ? 'titlebg' : 'windowbg';
			$extra		= ($guestbook['is_response'] > 0) ? $txt['guestbook_15'] .': ' . $guestbook['is_response'] : '';

			echo '
	<form action="', $scripturl, '?module=Guestbook;sa=AdminDelete" method="post">
	<div class="tborder">
		<table class="bordercolor" width="100%" cellSpacing="1" cellPadding="0" align="center" border="0">
			<tr>
				<td class="', $bgcolor, '" width="15%">', $txt['guestbook_16'], ': ',$guestbook['id'],' <input type="checkbox" name="delete[', $guestbook['id'], ']"></td>
				<td class="', $bgcolor, '" width="40%">', $guestbook['guestName'], '</td>
				<td class="', $bgcolor, '" align="right" width="45%">', $guestbook['signtime'], '</td>
			</tr><tr>
				<td class="windowbg2" colspan="3">', (($guestbook['is_response'] > 0) ? '<small>(' . $txt['guestbook_17'] . ' ' . $guestbook['is_response'] . ')</small><br />' : ''), $guestbook['body'], '</td>
			</tr>
		</table>
	</div>
	<br />';
		}

	echo '
	<div align="center">
		<input type="submit" name="array" value="', $txt['guestbook_18'], '" />&nbsp;', $txt['guestbook_19'], '&nbsp;<input type="submit" name="delete_all" value="', $txt['guestbook_delall'], '" />
	</div>
	</form>';
	}
	else
	{
		echo '
	<div class="tborder">
		<table class="bordercolor" width="100%" cellSpacing="1" cellPadding="0" align="center" border="0">
			<tr>
				<td class="windowbg" width="100%" style="padding: 3px;">', $txt['guestbook_6'], '</td>
			</tr>
		</table>
	</div>
	<br />';
	}
}
?>
Return current item: Enigma