Location: PHPKode > projects > Enigma > Enigma2/Enigma2_Install/Themes/Enigma/portal/modules/Links.template.php
<?php
// Version: 1.03; Links

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

	// linktree
	echo
	theme_linktree(), '<br />
	<br />
	<div align="center">
		<strong><a href="', $scripturl, '?module=Links;sa=linkcats">', $txt['links_73'], '</a>';
		
	// allowed to submit links
	if ($context['subLinks'])
		echo '
		| <a href="', $scripturl, '?module=Links;sa=addlink">', $txt['links_1'], '</a> | <a href="', $scripturl, '?module=Links;sa=linkIndex">', $txt['links_60'], '</a>';

	echo '</strong>
	</div><br />';

	// if a reviewer and there are new link submissions, setup a message
	if ($context['revLinks'] && $context['newItems'] > 0)
		echo
	 '<strong>**<a href="' . $scripturl . '?module=Links;sa=linkIndex">' . $txt['links_61'] . ' ' . $context['newItems'] . ' ' . $txt['links_62'] . '</a></strong><br />';

	// start the main display
	echo '
	<div class="tborder">';

	// make sure there's something to display
	if (!empty($context['linkcat']))
	{
		foreach ($context['linkcat'] as $cat)
		{
			// display the title bar for each category with the options column (if they get it) and correct column span
			echo '
		<table width="100%" cellspacing="1" cellpadding="4" border="0" align="center">
			<tr>
				<td ', $cat['colspan'], ' width="100%" class="titlebg"><strong><a href="', $scripturl, '?module=Links;id=', $cat['index'], '">', $cat['name'], '</a></strong> <small>(',$cat['total'], ' ', $txt['links_40'], ') ', $cat['description'], '</small></td>';
	
			// if user can submit OR review links, we need a "Submit Link" link
			// and an "Options" column heading for links that they submitted
			if (($context['subLinks'] && !empty($cat['showOptions'])) || $context['revLinks'])
				echo '
				<td class="titlebg" align="center">'.$txt['links_2'].'</td>';
	
			echo '
			</tr>';
			// now do the items in the category
			foreach ($cat['links'] AS $item)
			{
	
				echo '
				<tr>
					<td class="windowbg2" width="25%"><strong><a href="', $scripturl, '?module=Links;sa=gotolink;id=', $item['linkID'], '" target="blank">', $item['name'], '</a></strong><br />
						<small>', $item['description'], '</small></td>
					<td class="windowbg2" width="25%" align="center"><small>', $item['clicks'], ' Clicks</small></td>
					<td class="windowbg2" width="25%"><small>', $txt['links_6'], ' <a href="', $item['submitterLink'], '">', $item['submittedBy'], '</a></small>';
	
				// if user has any items pending submission, setup a status display
				if (!empty($item['status']))
					echo '<br />
						<em><strong>' . $txt['links_63'] . ':</strong> ' . $item['status'] . '</em>';
	
				echo '
					</td>';
	
				//include edit | delete options for reviewers and the user who submitted the current link
				if (($context['revLinks'] || $item['IsSubmitter']) && !$context['user']['is_guest'])
					echo '
					<td class="windowbg2" width="25%" align="center"><a href="' . $scripturl . '?module=Links;sa=editlink;linkID=' . $item['linkID'] . '">'.$txt['links_3'].'</a> | <a href="' . $scripturl . '?module=Links;sa=deletelink;linkID=' . $item['linkID'] . '">'.$txt['links_4'].'</a></td>';
				//if user has submission rights, but did not submit the current link, don't show the edit & delete options
				elseif (($context['subLinks'] && !empty($cat['showOptions'])) && !$context['user']['is_guest'] && !$item['IsSubmitter'])
					echo '
					<td class="windowbg2" width="25%"> </td>';
				// if neither of the above, they don't have rights, so don't echo in this column
	
				echo '
				</tr>';
				unset($status);
			}
			echo '
		</table>';
		}
	}
	else
	{
		echo $txt['links_none'];
	}

	// close the main display
	echo '
	</div>
	<br />';

	// is there a page index to display (only if there are more links than the max per page
	if (!empty($context['page_index']))
		echo
	$context['page_index'];

	echo '
	<div align="center">
		<strong><a href="', $scripturl, '?module=Links;sa=linkcats">', $txt['links_73'], '</a>';
		
	// allowed to submit links
	if ($context['subLinks'])
		echo '
		| <a href="', $scripturl, '?module=Links;sa=addlink">', $txt['links_1'], '</a> | <a href="', $scripturl, '?module=Links;sa=linkIndex">', $txt['links_60'], '</a>';

	echo '</strong>
	</div>';

}

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

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

	// allowed to submit links
	if ($context['subLinks'])
		echo '
	<br />
	<div align="center">
		<strong><a href="', $scripturl, '?module=Links;sa=addlink">', $txt['links_1'], '</a> | <a href="', $scripturl, '?module=Links;sa=linkIndex">', $txt['links_60'], '</a></strong>
	</div><br />';

	// if a reviewer and there are new link submissions, setup a message
	if ($context['revLinks'] && $context['newItems'] > 0)
		echo
	 '<strong>**<a href="' . $scripturl . '?module=Links;sa=linkIndex">' . $txt['links_61'] . ' ' . $context['newItems'] . ' ' . $txt['links_62'] . '</a></strong><br />';

	// start the main display, if you change the column display below, be sure to change the colspan to match
	echo '
	<div class="tborder">';

	// make sure there's something to display
	if (!empty($context['linkcat']))
	{
		echo '
		<table width="100%" cellspacing="1" cellpadding="4" border="0" align="center">
			<tr>
				<td colspan="2" class="titlebg"><strong>', $txt['links_50'], '</strong></td>
			</tr>
			<tr>';

		$i = 0; // set a counter for column display
		foreach ($context['linkcat'] as $cat)
		{
			// display the title bar for each category with the options column (if they get it) and correct column span
			echo '
				<td style="text-align: left; width: 50%;"><strong><a href="', $scripturl, '?module=Links;id=', $cat['index'], '">', $cat['name'], '</a></strong> <small>(',$cat['total'], ' ', $txt['links_40'], ')</small><br />
					<img src="', $settings['images_url'], '/blank.gif" border="0" alt="" style="width: 15px; height:1px;" />- ', $cat['description'], '</td>';

			$i++; // increase the counter

			// check our counter values for table column display
			// if we're on the last category, but only displayed one column
			// echo another column and close the row
			if (!empty($cat['lastcat']) && $i == 1)
			{
				echo '
				<td>&nbsp;</td>
			</tr>';
			}
			// are we on the last category and finished the columns?  just close the row
			elseif (!empty($cat['lastcat']) && $i == 2)
			{
				echo '
			</tr>';
			}
			// if we've reached our last column, just
			// close the row, start a new row and reset the counter
			elseif ($i == 2)
			{
				echo '
			</tr>
			<tr>';
				$i=0;
			}
		}
		
		echo '
		</table>';
	}
	else
	{
		echo $txt['links_none'];
	}

	// close the main display
	echo '
	</div>
	<br />';

	// allowed to submit links
	if ($context['subLinks'])
		echo '
	<div align="center">
		<strong><a href="', $scripturl, '?module=Links;sa=addlink">', $txt['links_1'], '</a> | <a href="', $scripturl, '?module=Links;sa=linkIndex">', $txt['links_60'], '</a></strong>
	</div><br />';

}

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

	echo theme_linktree(), '<br />';
	
	echo '
	<form name="addlink" action="' . $scripturl . '?module=Links;sa=addlink2" method="post">
		<div class="tborder">
		<table class="windowbg" width="100%" border="0" cellspacing="1" cellpadding="4">
			<tr>
				<td class="titlebg" colspan="2"><strong>', $txt['links_1'], '</strong></td>
			</tr><tr>
				<td align="right" nowrap>', $txt['links_8'], '</td>
				<td>
					<select size="1" name="cat" tabindex="0">';
	// setup the cat selection list
	foreach ($context['linkcats'] AS $cats)
		echo '
						<option value="', $cats['catID'], '">', $cats['name'], '</option>';

		echo '
					</select></td>
			</tr><tr>
				<td align="right" nowrap>', $txt['links_10'], '</td>
				<td><input type="text" name="name" size="40" tabindex="1"></td>
			</tr><tr>
				<td align="right" nowrap>', $txt['links_11'], '</td>
				<td><input type="text" name="linkurl" size="40" value="http://" tabindex="2"></td>
			</tr><tr>
				<td align="right" nowrap>', $txt['links_12'], '</td>
				<td><textarea rows="3" name="description" cols="80" tabindex="3"></textarea></td>
			</tr>';

		// if user is a guest, we need a name and email field
		if ($context['user']['is_guest'])
		{
			echo'<tr>
				<td align="right" nowrap>', $txt['links_13'], '</td>
				<td><input type="text" name="submitted" size="40" tabindex="4"></td>
			</tr><tr>
				<td align="right" nowrap>', $txt['links_14'], '</td>
				<td><input type="text" name="email" size="40" tabindex="5"></td>
			</tr>';
		}

		// if user is a guest and verification is not disabled, display the verification stuff
		if ($context['user']['is_guest'] && $context['link_image_verify'])
		{
			echo '<tr>
				<td align="right" nowrap="nowrap" valign="middle">', $txt['links_65'], '</td>
				<td>';

			// if a bad verification code was already entered, display a message
			if (!empty($_REQUEST['code']))
				echo '
					<div style="color: #FF0000;">**<b>' . $txt['links_66'] . '</b>**</div>';

			echo '
					<input type="text" name="password"> <img src="modules/ModuleCaptcha/image.php?img=' . $context['lkimg'] . '"  align="absmiddle" />
					<input type="hidden" name="go" value="verify" />
					<input type="hidden" name="lkv" value="' . $context['lksesc'] . '" />
				</td>
			</tr>';
		}
		// otherwise, just put the session info in the form
		else
		{
			echo '
			<INPUT TYPE="hidden" value="', $sc, '" NAME="sc" />';
		}

		echo '<tr>
				<td width="100%" align="center" colspan="2" class="smtxt">', $txt['links_15'], '<br />
				<input type="submit" value="', $txt['links_1'], '" name="B1" accesskey="a" tabindex="6">
				<input type="reset" value="', $txt['links_16'], '" name="B2" accesskey="r" tabindex="7"></td>
			</tr>
		</table>
		</div>
	</form>';
}

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

	echo theme_linktree(), '<br />
	<form name="editlink" action="' . $scripturl . '?module=Links;sa=editlink2" method="post">
		<input type="hidden" name="linkID" value="' . $context['curlink']['linkID'] . '">
		<div class="tborder">
		<table class="windowbg" width="100%" border="0" cellspacing="1" cellpadding="4">
			<tr>
				<td class="titlebg" colspan="2"><strong>', $txt['links_17'], '</strong></td>
			</tr><tr>
				<td align="right" nowrap>', $txt['links_8'], '</td>
				<td>
					<select size="1" name="cat" tabindex="0">
						<option value="0">', $txt['links_9'], '</option>';

		foreach ($context['linkcats'] AS $cats)
		{
			echo '
						<option value="', $cats['catID'], '"', (($cats['catID'] == $context['curlink']['catID']) ? ' selected="selected"' : ''),'>', $cats['name'], '</option>';
		}

		echo '
					</select></td>
			</tr><tr>
				<td align="right" nowrap>', $txt['links_10'], '</td>
				<td><input type="text" name="name" size="40" value="', $context['curlink']['name'], '" tabindex="1"></td>
			</tr><tr>
				<td align="right" nowrap>', $txt['links_11'], '</td>
				<td><input type="text" name="linkurl" size="40"  value="', $context['curlink']['linkURL'], '"  tabindex="2"></td>
			</tr><tr>
				<td align="right" nowrap>', $txt['links_12'], '</td>
				<td><textarea rows="5" name="description" cols="40" tabindex="3">', $context['curlink']['description'], '</textarea></td>
			</tr><tr>
				<td width="100%" align="center" colspan="2" class="smtxt">', $txt['links_18'], '<br />
				<input type="submit" value="', $txt['links_17'], '" name="B1" accesskey="e" tabindex="6">
				<input type="reset" value="', $txt['links_16'], '" name="B2" accesskey="r" tabindex="7"></td>
			</tr>
		</table>
		</div>
	</form>';
}

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

	echo theme_linktree(), '<br />
	<table width="100%" border="0" class="bordercolor" cellspacing="1" align="center">
		<tr>
			<td class="catbg" colspan="7">
				<div style="font-weight: normal">
				<form action="' . $scripturl . '?module=Links;sa=linkIndex" method="post"><strong>', $txt['links_19'], '</strong>
					<select name="stagef">';
	// display the stage drop down selection list
	foreach ($context['linkstage'] AS $opstage)
		echo '
						<option ', $opstage['selected'], 'value="', $opstage['stage'], '">', $opstage['option'], '</option>';

	echo '
					</select><b>Category: </b>
					<select name="catfilter">';
	// display the category drop down selection list
	foreach ($context['filtercat'] AS $cat)
		echo '
						<option ', $cat['selected'], ' value="', $cat['value'], '">', $cat['name'], '</option>';
	// finish the selection list, then display the column headings
	echo '
					</select>
					<input type="Submit" name="filter" value="Filter"></form></div></td>
		</tr><tr>
			<td class="titlebg" align="center">', $txt['links_20'], '</td>
			<td class="titlebg" align="center">', $txt['links_21'], '</td>
			<td class="titlebg" align="center">', $txt['links_22'], '</td>
			<td class="titlebg" align="center">', $txt['links_23'], '</td>
			<td class="titlebg" align="center">', $txt['links_24'], '</td>
			<td class="titlebg" align="center">', $txt['links_25'], '</td>
			<td class="titlebg" align="center">', $txt['links_26'], '</td>
		</tr>';

	if (!empty($context['linkindex']) && is_array($context['linkindex'])) // if there ARE any links, show them
	{
		foreach ($context['linkindex'] AS $row)
		{	// loop through and display all the links
			 echo '
			<tr>
				<td class="windowbg2"><font size="1">' . $row['cname'] . '</td>
				<td class="windowbg2"><font size="1"><a href="' . $scripturl . '?module=Links;sa=reviewlink;id=' . $row['linkID'] . '">' . $row['name'] . '</td>
				<td class="windowbg"><font size="1"><a href="', $row['submitterLink'], '">', $row['submitter'], '</a></font></td>
				<td class="windowbg2"><font size="1">' . $row['subdate'] . '</font></td>
				<td class="windowbg"><font size="1"><a href="', $row['reviewerLink'], '">', $row['reviewer'], '</a></font></td>
				<td class="windowbg2"><font size="1">' . $row['status'] . '</font></td>
				<td class="windowbg2"><font size="1">' . $row['moddate'] . '</font></td>
			</tr>';
		}
	}
	else // otherwise, display the error message
	{
			echo '
		<tr>
			<td colspan="7" class="windowbg2"><center><strong>', $txt['links_5'], '</strong></center></td>
		</tr>';
	}
	// re-display the selection lists for stages and categories
	echo '
		<tr>
			<td class="catbg" colspan="7">
				<div style="font-weight: normal">
				<form action="' . $scripturl . '?module=Links;sa=linkIndex" method="post"><strong>', $txt['links_19'], '</strong>
					<select name="stagef">';
	// display the stage drop down selection list
	foreach ($context['linkstage'] AS $opstage)
		echo '
						<option ', $opstage['selected'], 'value="', $opstage['stage'], '">', $opstage['option'], '</option>';

	echo '
					</select><b>Category: </b>
					<select name="catfilter">';
	// display the category drop down selection list
	foreach ($context['filtercat'] AS $cat)
		echo '
						<option ', $cat['selected'], ' value="', $cat['value'], '">', $cat['name'], '</option>';
	echo '
					</select>
					<input type="Submit" name="filter" value="Filter"></form></div></td>
		</tr>
		</table>';
}

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

	echo theme_linktree(), '<br />
	<table class="bordercolor" width="100%" cellspacing="1" cellpadding="4" border="0" align="center">
		<tr>
			<td class="catbg">', $txt['links_28'], '</td>
			<td class="catbg">', $txt['links_29'], '</td>
			<td class="catbg" align="center">', $txt['links_30'], '</td>
			<td class="catbg">', $txt['links_31'], '</td>';

	if ($context['revLinks'] == 1 || $context['subLinks'] == 1)
		echo '
			<td class="catbg" align="center">' . $txt['links_2'] . '</td>';

	echo '
		</tr>';

	foreach ($context['linkreview'] AS $link)
	{
		echo '
			<tr>
				<td class="windowbg2"><a href="' . $scripturl . '?module=Links;sa=gotolink;id=' . $link['linkID'] . '" target="blank">' . $link['name'] . '</a></td>
				<td class="windowbg2">'.$link['description'].'</td>
				<td class="windowbg2" align="center">'.$link['clicks'].'</td>
				<td class="windowbg2"><a href="', $link['submitterLink'], '">', $link['submittedBy'], '</a></td>';

		if ($context['revLinks'] == 1 || $context['subLinks'] == 1)
			echo '
				<td class="windowbg2" align="center"><a href="' . $scripturl . '?module=Links;sa=editlink;linkID=' . $link['linkID'] . '">'.$txt['links_3'].'</a>
				| <a href="' . $scripturl . '?module=Links;sa=deleteLink;linkID=' . $link['linkID'] . '">'.$txt['links_4'].'</a></td>';

		echo '
			</tr>';
	}
	echo '	</table><br />';

	if ($context['load_link_Console'])
		echo template_linkConsole();
}

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

	//We need to do some operation on that result set upfront
	$statustext	= statusText($context['submissions']['stage']);
	$subdate	= timeformat($context['submissions']['dateEntered']);
	$moddate	= (!$context['submissions']['dateModified']) ? $subdate : timeformat($context['submissions']['dateModified']);
	$achecked	= ($context['submissions']['stage'] == 1) ? 'checked="checked"' : '';
	$rchecked	= ($context['submissions']['stage'] == 2) ? 'checked="checked"' : '';

	//set up the category filter
	$sel_cat = $txt['links_72'] . ': <select name="category"><option value="0">'.$txt['links_9'].'</option>';

	if (!empty($context['listcats']))
	{
		foreach ($context['listcats'] AS $cats)
			$sel_cat .= '<option ' . $cats['selected'] . ' value="' . $cats['catID'] . '">' . $cats['name'] . '</option>';
	}

	$sel_cat .= '</select>';

	//the person viewing the link has reviewer rights
	if ($context['revLinks'] == 1)
	{
			$subconsole = '
				<td valign="top" align="left" class="windowbg" width="50%">' . $txt['links_32'] . $statustext . '<br />' . $txt['links_33']  . $context['submissions']['reviewer'] . '<br />' . $txt['links_34'] . $moddate . '</td>
				<td valign="top" align="left" class="windowbg">
					<form action="' . $scripturl . '?module=Links;sa=links2" method="post">
					<input type="hidden" value="' . $context['submissions']['linkID'] . '" name="linkID" />
					' . $txt['links_35'] . '<br /><textarea cols="50" rows="3" name="comment">' . $context['submissions']['comment'] . '</textarea><br />' . $sel_cat . '<br />
					' . $txt['links_36'] . '<input type="radio" name="lsource" value="4" ' . $achecked . ' />' . $txt['links_37'] . '
					<input type="radio" name="lsource" value="5" ' . $rchecked . ' />' . $txt['links_38'] . '<br /><br />
					<input type="submit" name="submit" value="' . $txt['links_39'] . '" />
					<input type="reset" value="' . $txt['links_16'] . '" />
					</form>
				</td>
			</tr>
			<tr>
				<td colspan="2" valign="top" align="left" class="windowbg">' . $txt['links_43'] . '</td>';
	}
	//the person viewing the link has submission rights, and they submitted this link
	else if (($context['subLinks'] == 1) && ($ID_MEMBER == $context['submissions']['ID_SUBMITTER']) && ($username != 'Guest')){
		$subconsole = '
			<td valign="top" align="left" class="windowbg" width="50%">' . $txt['links_32'] . $statustext . '<br />' . $txt['links_33'] . $context['submissions']['reviewer'] . '<br />' . $txt['links_34'] . $moddate . '</td>
			<td valign="top" align="left" class="windowbg">' . $txt['links_35'] . $context['submissions']['comment'] . '</td>
		</tr>
		<tr>
			<td colspan="2" valign="top" align="center" class="windowbg">' . $txt['links_42'] . '</td>';
	}
	//these guys don't have rights - zero out the values
	else {
		return false;
	}

//now we can output everthing

	$controlpanel = '
			<table cellpadding="0" cellspacing="0" border="0" width="100%" class="bordercolor" align="center">
			<tr>
				<td>
					<table cellpadding="3" cellspacing="1" width="100%">
					<tr>
						<td colspan="2" valign="middle" align="left" class="titlebg">' . $txt['links_41'] . '</td>
					</tr>
					<tr>
						' . $subconsole . '
					</tr>
					</table>
				</td>
			</tr>
			</table>';

	return $controlpanel;
}
?>
Return current item: Enigma