<?php
// $Id: admin.poll.html.php,v 1.10 2003/12/21 21:59:58 eddieajau Exp $
/**
* Poll 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.10 $
**/
class HTML_poll
{
	function showPolls( &$rows, &$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%"><span class="sectionname"><img src="images/mos_gel.png" width="70" height="67" align="middle" />Poll Manager</span></td>
		<td nowrap>Display #</td>
		<td><?php echo $pageNav->writeLimitBox(); ?></td>
	</tr>
</table>
<table cellpadding="5" cellspacing="0" border="0" width="100%" class="adminlist">
    <tr>
		<th colspan="2" align="left">Poll Title</th>
		<th width="15%" align="center">Options</th>
		<th width="15%" align="center">Published</th>
		<th width="20%" align="center">Checked Out</th>
    </tr>
<?php
		$k = 0;
		for ($i=0, $n=count( $rows ); $i < $n; $i++) {
			$row = &$rows[$i];
?>
	<tr class="<?php echo "row$k"; ?>">
		<td width="20">
<?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 width="50%"><a href="#edit" onclick="return listItemTask('cb<?php echo $i;?>','edit')"><?php echo $row->title; ?></a></td>
			<td width="" align="center"><?php echo $row->numoptions; ?>&nbsp;</td>
<?php
			$task = $row->published ? 'unpublish' : 'publish';
			$img = $row->published ? 'publish_g.png' : 'publish_x.png';
?>
			<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;?>" width="12" height="12" border="0" alt="" /></a></td>
			<td width="10%" align="center"><?php echo $row->editor; ?>&nbsp;</td>
<?php		$k = 1 - $k; ?>
	</tr>
<?php	} ?>
	<tr>
		<th align="center" colspan="6">
			<?php echo $pageNav->writePagesLinks(); ?></th>
	</tr>
	<tr>
		<td align="center" colspan="6">
			<?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 editPoll( &$row, &$options, &$menulist ) {
		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.title.value == "") {
			alert( "Poll must have a title" );
		} else if( isNaN( parseInt( form.lag.value ) ) ) {
			alert( "Poll must have a non-zero lag time" );
		//} else if (form.menu.options.value == ""){
		//	alert( "Poll must have pages." );
		//} else if (form.adminForm.textfieldcheck.value == 0){
		//	alert( "Poll must have options." );
		} else {
			submitform( pressbutton );
		}
	}
	</script>
	<table cellpadding="4" cellspacing="0" border="0" width="100%">
    <tr> 
      <td width="100%"><span class="sectionname"><?php echo $row->id ? 'Edit' : 'Add';?> Poll</span></td>
    </tr>
  </table>
	<form action="index2.php" method="POST" name="adminForm">
		<table cellpadding="5" cellspacing="0" border="0" width="100%" class="adminform">
			<tr>
				<td valign="top">Show on menu items:</td>
				<td width="100%"><?php echo $menulist; ?></td></tr>
			<tr>
				<td>Title:</td>
				<td><input class="inputbox" type="text" name="title" size="75" value="<?php echo $row->title; ?>" /></td>
			</tr>
			<tr>
				<td>Lag:</td>
				<td><input class="inputbox" type="text" name="lag" size="10" value="<?php echo $row->lag; ?>" /> (seconds between votes)</td>
			</tr>
			<tr>
				<td>Options:</td>
			</tr>
<?php
		for ($i=0, $n=count( $options ); $i < $n; $i++ ) { ?>
			<tr>
				<td><?php echo ($i+1); ?></td>
				<td><input class="inputbox" type="text" name="polloption[<?php echo $options[$i]->id; ?>]" value="<?php echo htmlspecialchars( $options[$i]->text, ENT_QUOTES ); ?>" size="75" /></td>
			</tr>
<?php	}
		for (; $i < 12; $i++) { ?>
			<tr>
				<td><?php echo ($i+1); ?></td>
				<td><input class="inputbox" type="text" name="polloption[]" value="" size="75" /></td>
			</tr>
<?php	}
?>
		</table>
		<input type="hidden" name="task" value="">
		<input type="hidden" name="option" value="com_poll" />
		<input type="hidden" name="id" value="<?php echo $row->id; ?>" />
		<input type="hidden" name="textfieldcheck" value="<?php echo $n; ?>" />
	</form>
<?php
	}
}
?>
