Location: PHPKode > projects > Enigma > Enigma2/Enigma2_Install/Themes/Enigma/portal/News.template.php
<?php

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

	echo '
<div class="enigmanews" style="width: 100%; margin-bottom: 10px;  z-index: -1;">';
}

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

		echo '
</div>';
}

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

	echo '
<!-- div class="featured" style="float: right; width: 120px; margin-left: 5px;"><strong>', isset($context['articleSum']), '</strong></div -->';

	echo '
	<script language="JavaScript1.2" type="text/javascript"><!--
		function DoConfirm(message, url)
		{
			if (confirm(message))
				location.href = url;
		}
	//--></script>
<div class="sitenews" style="float: left; width: 100%;">';


	if (!is_array($context['sitenews'])) // if there isn't any news or something went wrong, display msg or nothing
		echo $context['sitenews'];
	else
		foreach ($context['sitenews'] AS $post)
		{
			// if news reviewer, setup the status display
			if (isset($post['status']) &&  $post['status'] != '') // for some reason when setting variables, a comma causes parse errors
				$status = '<strong>** ' . $txt['news_520'] . ':</strong> ' . $post['status'] . '<br />';
			else
				$status = '';
			
			if (!empty($post['sticky']) && !empty($post['stickylink']))
				$sticky = '<a href="' . $post['stickylink'] . '" title="Unglue this topic"><img src="' . $settings['images_url'] . '/icons/sticky.gif" alt="" border="0" /></a>';
			elseif (!empty($post['sticky']))
				$sticky = '<img src="' . $settings['images_url'] . '/icons/sticky.gif" alt="" border="0" />';
			else
				$sticky = '';

// Note: if you would like to limit the length of the News Subject, change $post['subject'] to $post['short_subject'] below.
// Note 2: if you would like to only show the News Category name, instead of linking to it, change $post['CatLink'] to $post['CatName'] below.
			echo '
	<div class="tborder" style="margin-bottom: 5px;">
		<table border="0" cellpadding="0" cellspacing="1" width="100%">
			<tr class="titlebg">
				<th style="text-align: left; padding: 3px;"><small>' , $status, $sticky, '
					[', $post['CatLink'], '] <a href="', $post['href'], '">', $post['subject'], '</a>
					', $txt[525], ' ', $post['poster']['link'], '
					', $post['new'] ? '' : '<a href="' . $scripturl . '?topic=' . $post['topic'] . '.from' . $post['newtime'] . ';topicseen#new"><img src="' . $settings['images_url'] . '/' . $context['user']['language'] . '/new.gif" alt="' . $txt[302] . '" border="0" /></a>', '</small></th>
				<th style="text-align: right; padding: 3px;" nowrap="nowrap"><small>', $post['time'], '</small></th>
			</tr><tr>
				<td style="float: left;" colspan="2">
					<a href="', $post['href'], '">', $post['CatImage'], '</a> ', $post['body'], '
				</td>
			</tr><tr>
				<td align="center" colspan="2">' . $post['footer'] . $post['admin'] . '</td>
			</tr>
		</table>
	</div>
';
			unset($status);  // *** Note, this has to be here, or all messages will have the same status
		}


	echo '
	<br />
	<p>';
	
	if (!empty($context['news_pages']))
		echo '
		<b>' . $txt[139] . ':</b> ' . $context['news_pages'] . '<br />';
	
	if (empty($context['home_page']))
	{
		echo '
		<br />
		<a href="' . $scripturl . '?op=News;sa=newsarchive">' . $txt['news_501'] . '</a>';
	}
	
	echo '
	<br />
	</p>
	</div>';
}

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

	echo '
<div class="sitenews" style="float: left; width: 100%;">';

	if (!empty($context['iscats']))
	{
		echo '
	<table width="100%" border="0" cellspacing="1" cellpadding="4">
		<tr>
			<td colspan="2">
				<h1><b>' . $txt['news_501'] . '</b></h1><br />
				' . $txt['news_522'] . '
			</td>
		</tr>';
		$cl = 0;
		foreach ($context['ncats'] as $cat) // loop through the categories
		{
			// Left column
			if ($cl == 0)
			{
				echo '
		<tr>
			<td>
				<br /><br />
					<img src="' . $cat['image'] .'" title="' . $cat['name'] . '" alt="' . $cat['name'] . '" border="0" style="padding-right: 2px; padding-bottom: 2px;" />
					<a href="' . $cat['caturl'] . '"><b>' . $cat['name'] . '<b></a>
			</td>';
			$cl++;
			}
			
			// Right column
			elseif ($cl == 1)
			{
				echo '
			<td>
				<br /><br />
					<img src="' . $cat['image'] .'" title="' . $cat['name'] . '" alt="' . $cat['name'] . '" border="0" style="padding-right: 2px; padding-bottom: 2px;" />
					<a href="' . $cat['caturl'] . '"><b>' . $cat['name'] . '<b></a>
			</td>
		</tr>';
			$cl = 0;
			}
		}
		
		// We know it's an array, we set it. But, save an index/undefined error!
		// Displays the category for News items that were munsoned.
		if (is_array($context['lastcat']))
		{
			if ($cl == 0)
			{
				echo '
		<tr>
			<td>
				<br /><br />
					<img src="' . $context['lastcat']['image'] .'" title="' . $context['lastcat']['name'] . '" alt="' . $context['lastcat']['name'] . '" border="0" style="padding-right: 2px; padding-bottom: 2px;" />
					<a href="' . $context['lastcat']['caturl'] . '"><b>' . $context['lastcat']['name'] . '<b></a>
			</td>
			<td>
				<img src="' . $settings['images_url'] . '/blank.gif" title="' . $context['lastcat']['name'] . '" alt="' . $context['lastcat']['name'] . '" border="0" style="padding-right: 2px; padding-bottom: 2px;" />
			</td>
		</tr>
	</table>';
			}

			elseif ($cl == 1)
			{
				echo '
			<td>
				<br /><br />
					<img src="' . $context['lastcat']['image'] .'" title="' . $context['lastcat']['name'] . '" alt="' . $context['lastcat']['name'] . '" border="0" style="padding-right: 2px; padding-bottom: 2px;" />
					<a href="' . $context['lastcat']['caturl'] . '"><b>' . $context['lastcat']['name'] . '<b></a>
			</td>
		</tr>
	</table>';
			}
		}
	
	unset($cl);


	}
	
	elseif (!empty($context['isarchive']))
	{
		// Show the category image and title
		foreach ($context['catinfo'] as $cat)
		{
		echo '
		<div>
		<a href="' . $scripturl . '?op=News;sa=newsarchive">
			<img src="' . $cat['image'] .'" title="' . $cat['name'] . '" alt="' . $cat['name'] . '" border="0" style="padding-right: 2px; padding-bottom: 2px;" />
		</a>
		<br /><br />
		<b>' . $txt['news_501'] . ' :: ' . $cat['name'] . '</b>
		</div>
		<br /><br />
		<div>';
		}
		
		if (!is_array($context['catarchive']))
		{
			echo $txt['news_none'];
		}
		
		else
		{
			foreach ($context['catarchive'] as $archive)
			{
				echo '
				<ul>
					<li>
						<a href="' . $scripturl . '?topic=' . $archive['topic'] . '">' . $archive['subject'] . '</a><br />
						<strong>' . $txt['news_502'] . ':</strong> <a href="' . $archive['bylineUrl'] . '">' . $archive['posterName'] . '</a>
						<strong>' . $txt['news_503'] . ':</strong> ' . $archive['postedTime'] . '
					</li>
				</ul>';
			}
		}
		
		echo '
		</div>
		<p>' . $context['newsar_pages'] . '</p>';
	}

	// Closes opening div,  that opens before if/else checks 
	echo '
</div>';

}

function template_news_index() // All the news with it's submission status
{
	global $context, $txt, $scripturl, $settings;
	// show the link tree and selection lists first
	echo theme_linktree(), '<br />
	 <script language="JavaScript1.2" type="text/javascript"><!--
		function DoConfirm(message, url)
		{
			if (confirm(message))
			location.href = url;
		}
	//--></script>
	<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 . '?op=News;sa=newsIndex" method="post"><strong>', $txt['news_508'], '</strong>
					<select name="stagef">';
	// display the stage drop down selection list
	foreach ($context['newsstage'] AS $opstage)
		echo '
						<option ', $opstage['selected'], 'value="', $opstage['stage'], '">', $opstage['option'], '</option>';

	echo '
					</select><strong>Category: </strong>
					<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>';
	// display the column headings
	echo '
					</select>
					<input type="Submit" name="filter" value="Filter"></form></div></td>
		</tr><tr>
			<td class="titlebg" align="center">', $txt['news_509'], '</td>
			<td class="titlebg" align="center">', $txt['news_510'], '</td>
			<td class="titlebg" align="center">', $txt['news_511'], '</td>
			<td class="titlebg" align="center">', $txt['news_512'], '</td>
			<td class="titlebg" align="center">', $txt['news_513'], '</td>
			<td class="titlebg" align="center">', $txt['news_514'], '</td>
			<td class="titlebg" align="center">', $txt['news_515'], '</td>
		</tr>
';
	// loop through the submission array if there's something to display based on the current selections
	if (is_array($context['newsindex']) && sizeof($context['newsindex']) > 0)
	{
		foreach ($context['newsindex'] AS $row)
		{

			 echo '
			<tr>
				<td class="windowbg2"><font size="1"><a href="' . $row['caturl'] . '"><img src="' . $row['catimage'] . '" alt="' . $row['catname'] . '" border="0" />
					' . $row['catname'] . '</a></td>
				<td class="windowbg2"><font size="1"><a href="' . $row['msgurl'] . '">' . $row['msgsubject'] . '</a> ' . $row['newurl'] . '</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>';
		}
	}
	// nothing to display for the current selection?  Then display a message saying that.
	else
	{
		echo '
			<tr><td class="windowbg2" colspan="7"><p><strong>' . $context['newsindex'] . '</strong></p><br />
				</td></tr>';
	}
	// display the selection lists again at the bottom of the page
	echo '
		<tr>
			<td class="catbg" colspan="7">
				<div style="font-weight: normal">
				<form action="' . $scripturl . '?op=News;sa=newsIndex" method="post"><strong>', $txt['news_508'], '</strong>
					<select name="stagef">';

	foreach ($context['newsstage'] AS $opstage)
		echo '
						<option ', $opstage['selected'], 'value="', $opstage['stage'], '">', $opstage['option'], '</option>';

	echo '
					</select><strong>Category: </strong>
					<select name="catfilter">';

	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>';
}

?>
Return current item: Enigma