<?PHP

#
#   FILE:  SPT--Home.html
#
#   REQUIRED FUNCTIONS:
#       PrintAnnouncementRow($Headline, $DatePosted, $PosterName, $Text, 
#                   $EditOkay, $EditLink)
#           - called to print line in News & Announcements table
#       PrintNoAnnouncementsMessage()
#           - called to print message that there were no announcements
#       PrintNewResourceRow($Title, $Description, $FullRecordLink, $Url, 
#                   $DateOfRecordCreation, $DateRecordAdded, $Contributor, 
#                   $EditOkay, $EditUrl, $DateLastVerified, $DateLastModified,
#                   $CumulativeRating)
#           - called to print line in New Resources table
#       PrintNoResourcesMessage()
#           - called to print message that there were no resources to display
#
#   OPTIONAL FUNCTIONS:
#       SupplyResourceDisplayQuery($MaxDaysToGoBack, $MaxItems)
#       SupplyAnnouncementDisplayQuery($MaxDaysToGoBack, $MaxItems)
#           - can be used to specify SQL query for selecting what items
#                   to display on front page
#

function PrintAnnouncementRow(
        $Headline, $DatePosted, $PosterName, $Text, $EditOkay, $EditLink)
{
?>

<div class="Announcement">
	<div class="AnnouncementHeadline">
		<?php  if ($EditOkay) {  ?>
			<a href="<?PHP  print($EditLink);  ?>" class="EditButton">Edit</a>
		<?php  } ?>
		<?PHP  print($Headline);  ?>
	</div>
	<div class="AnnouncementInfo">
		Posted <?php  print($DatePosted);  ?> by <?php  print($PosterName);  ?>
	</div>
	<div class="AnnouncementText"><?PHP  print($Text);  ?></div>
</div>
<?PHP
}

function PrintNoAnnouncementsMessage()
{
?>
    No new announcements.
<?PHP
}

function PrintNewResourceRow($Fields, $FullRecordLink, $EditOkay, $EditLink,
                             $CumulativeRating)
{
    PrintResource($Fields, $FullRecordLink, $EditOkay, $EditLink, 
                  $CumulativeRating);
}

function PrintNoResourcesMessage()
{

?>
    No new resources.
<?PHP
}
?>

<br>
<!-- ANNOUNCEMENTS -->
<?PHP if(AnnouncementsEnabled()) { ?>
<div class="BodyDiv">
<div class="BodyDivTop">
	<?php  
	    if ( $User->HasPriv(PRIV_NEWSADMIN) &&
	        ((NumAnnouncementRows() < $SysConfig->NumAnnounceOnHomePage())
	        || !SoftwareIsCWIS()) )
	    {
	?>
	    <a href="index.php?P=EditAnnouncement" class="EditButton">Add</a>
	<?php
	    }
	?>
	Announcements	
</div>
<?php  PrintAnnouncementsTableRows();  ?>

<?PHP 
    if( !SoftwareIsCWIS() )
    {
?>    
    <?PHP
    if(PreviousAnnouncementsAvailable())
    {
    ?>
        <a href="<?PHP PrintPrevAnnouncementLink(); ?>">Previous <?PHP PrintNumberOfAnnouncements(); ?> announcements</a>
    <?PHP
    }
    if(NextAnnouncementsAvailable())
    {
    ?>
        <a href="<?PHP PrintNextAnnouncementLink(); ?>">Next <?PHP PrintNumberOfAnnouncements(); ?> announcements</a>
    <?PHP
    }
    ?>      
<?PHP
}
?>      
    </div>

<?PHP } ?>
<!-- NEW RESOURCES -->
<div class="BodyDiv">
<div class="BodyDivTop">
	<?php  if ($User->HasPriv(PRIV_RESOURCEADMIN)) {  ?> <a href="index.php?P=DBEntry" class="EditButton">Add</a><?php  } ?> New Resources
</div>
	<?php  PrintNewResourceTableRows();  ?>
<?PHP
if(NextResourcesAvailable())
{
?>
    <a href="<?PHP PrintNextResourceLink(); ?>">Previous <?PHP PrintNumberOfResources(); ?> resources</a>
<?PHP
}
if(PreviousResourcesAvailable())
{
?>
    <a href="<?PHP PrintPrevResourceLink(); ?>">Next <?PHP PrintNumberOfResources(); ?>  resources</a>
<?PHP
}
?>
</div>

