<?php
// $Id: admin.newsfeeds.html.php,v 1.11 2003/12/21 22:13:26 eddieajau Exp $
/**
* Newsfeed admin component HTML
* @package Mambo Open Source
* @Copyright (C) 2000 - 2003 Miro International Pty Ltd
* @ All rights reserved
* @ Mambo Open Source is Free Software
* @ Released under GNU/GPL License: http://www.gnu.org/copyleft/gpl.html
* @version $Revision: 1.11 $
**/

class HTML_newsfeeds {

	function showNewsFeeds( &$rows, &$catlist, $pageNav, $option ) {
		global $my;
?>
	<form action="index2.php" method="post" name="adminForm">
	<table cellpadding="4" cellspacing="0" border="0" width="100%">
		<tr>
			<td width="100%" class="sectionname"><img src="images/mos_gel.png" width="70" height="67" align="middle" />Newsfeed Manager</span></td>
			<td nowrap>Display #</td>
			<td> <?php echo $pageNav->writeLimitBox(); ?> </td>
			<td width="right"> <?php echo $catlist;?> </td>
		</tr>
	</table>

	<table cellpadding="4" cellspacing="0" border="0" width="100%" class="adminlist">
		<tr>
			<th width="20">#</th>
			<th width="20"><input type="checkbox" name="toggle" value="" onclick="checkAll(<?php echo count( $rows ); ?>);" /></th>
			<th class="title" width="25%">News Feed</th>
			<th class="title">Category</th>
			<th># Articles</th>
			<th>Cache time(sec)</th>
			<th>Published</th>
			<th>Checked out</th>
			<th colspan="2">Reorder</th>
		</tr>
<?php
		$k = 0;
		for ($i=0, $n=count( $rows ); $i < $n; $i++) {
			$row = &$rows[$i];
			$img = $row->published ? 'tick.png' : 'publish_x.png';
			$task = $row->published ? 'unpublish' : 'publish';
?>
		<tr class="<?php echo "row$k"; ?>">
			<td align="center"><?php echo $i+$pageNav->limitstart+1;?></td>
			<td>
<?php		if ($row->checked_out && $row->checked_out != $my->id) { ?>
				&nbsp;
<?php		} else { ?>
				<input type="checkbox" id="cb<?php echo $i;?>" name="cid[]" value="<?php echo $row->id; ?>" onclick="isChecked(this.checked);" />
<?php		} ?>
			</td>
			<td><a href="#edit" onclick="return listItemTask('cb<?php echo $i;?>','edit')"><?php echo $row->name; ?> </a></td>
			<td><?php echo $row->catname;?></td>
			<td align="center"><?php echo $row->numarticles;?></td>
			<td align="center"><?php echo $row->cache_time;?></td>
			<td width="10%" align="center"><a href="javascript: void(0);" onclick="return listItemTask('cb<?php echo $i;?>','<?php echo $task;?>')"><img src="images/<?php echo $img;?>" border="0" alt="" /></a></td>
			<td align="center"><?php echo $row->editor != "" ? $row->editor : "&nbsp;"; ?></td>
			<td align="center">
<?php		if (($i > 0 || ($i+$pageNav->limitstart > 0))) { ?>
				<a href="#reorder" onclick="return listItemTask('cb<?php echo $i;?>','orderup')">
				<img src="images/uparrow.png" width="12" height="12" border="0" alt="Move Up">
				</a>
<?php		} else { echo "&nbsp;"; } ?>
			</td>
			<td align="center">
<?php		if (($i < $n-1 || $i+$pageNav->limitstart < $pageNav->total-1)) { ?>
				<a href="#reorder" onclick="return listItemTask('cb<?php echo $i;?>','orderdown')">
				<img src="images/downarrow.png" width="12" height="12" border="0" alt="Move Down">
				</a>
<?php		} else { echo "&nbsp;"; } ?>
			</td>
		</tr>
<?php
			$k = 1 - $k;
		}
?>
		<tr>
			<th align="center" colspan="10"> <?php echo $pageNav->writePagesLinks(); ?></th>
		</tr>
		<tr>
			<td align="center" colspan="10"> <?php echo $pageNav->writePagesCounter(); ?></td>
		</tr>
	</table>

	<input type="hidden" name="option" value="<?php echo $option;?>" />
	<input type="hidden" name="task" value="" />
	<input type="hidden" name="boxchecked" value="0" />
	</form>
<?php
	}

	function editNewsFeed( &$row, &$catlist, &$orderlist, $option ) {
		mosMakeHtmlSafe( $row, ENT_QUOTES );
?>
	<script language="javascript" type="text/javascript">
		function submitbutton(pressbutton) {
			var form = document.adminForm;
			if (pressbutton == 'cancel') {
				submitform( pressbutton );
				return;
			}

			// do field validation
			if (form.name.value == '') {
				alert( "Please fill in the newsfeed name." );
			} else if (form.link.value == '') {
				alert( "Please fill in the newsfeed link." );
			} else if (getSelectedValue('adminForm','catid') < 0) {
				alert( "Please select a category." );
			} else if (form.cache_time.value == "" || form.cache_time.value == 0) {
				alert( "Please fill in the cache refresh time." );
			} else if (form.numarticles.value == "" || form.numarticles.value == 0) {
				alert( "Please fill in the number of articles to display." );
			} else {
				submitform( pressbutton );
			}
		}
	</script>

	<form action="index2.php" method="POST" name="adminForm">
	<table cellpadding="4" cellspacing="0" border="0" width="100%">
		<tr>
			<td class="sectionname"><?php echo $row->name;?> News Feed</td>
		</tr>
	</table>
	<table cellpadding="4" cellspacing="1" border="0" width="100%" class="adminform">
		<tr>
			<td>Category</td>
			<td><?php echo $catlist; ?></td>
		</tr>

		<tr>
			<td>Name</td>
			<td><input class="inputbox" type="text" size="40" name="name" value="<?php echo $row->name; ?>"></td>
		</tr>
		<tr>
			<td>Link</td>
			<td><input class="inputbox" type="text" size="60" name="link" value="<?php echo $row->link; ?>"></td>
		</tr>
		<tr>
			<td>File Name</td>
			<td><input class="inputbox" type="text" size="60" name="filename" value="<?php echo $row->filename; ?>"></td>
		</tr>
		<tr>
			<td>Number of Articles</td>
			<td><input class="inputbox" type="text" size="2" name="numarticles" value="<?php echo $row->numarticles; ?>"></td>
		</tr>
		<tr>
			<td>Cache time (in seconds)</td>
			<td><input class="inputbox" type="text" size="4" name="cache_time" value="<?php echo $row->cache_time; ?>"></td>
		</tr>

		<tr>
			<td>Ordering</td>
			<td><?php echo $orderlist; ?></td>
		</tr>
		<tr>
			<td colspan="2" align="center">&nbsp;</td>
		</tr>
	</table>

	<input type="hidden" name="id" value="<?php echo $row->id; ?>">
	<input type="hidden" name="option" value="<?php echo $option; ?>">
	<input type="hidden" name="task" value="">
	</form>
<?php
	}
}
?>