<?php
// $Id: admin.newsflash.html.php,v 1.26 2004/03/03 17:04:21 rcastley Exp $
/**
* Newsflash 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.26 $
**/
// ensure this file is being included by a parent file
defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );

class HTML_newsflash {
	function shownewsflash( &$rows, $search, $pageNav, $option ) {
		  ?>
  <div id="overDiv" style="position:absolute; visibility:hidden; z-index:1000;"></div>		  
	<script language="Javascript" src="../includes/js/overlib_mini.js"></script>
	<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" />Newsflash Manager</td>
		<td nowrap>Display #</td>
		<td>
			<?php echo $pageNav->writeLimitBox(); ?>
		</td>
		<td>Search:</td>
		<td>
			<input type="text" name="search" value="<?php echo $search;?>" class="inputbox" onChange="document.adminForm.submit();" />
		</td>
	</tr>
	</table>

	<table cellpadding="4" cellspacing="0" border="0" width="100%" class="adminlist">
		<tr>
			<th width="20">
				<input type="checkbox" name="toggle" value="" onclick="checkAll(<?php echo count( $rows ); ?>);" />
			</th>
			<th class="title">Title</td>
			<th>Access            
			<th>Published</td>
			<th width="154">Checked Out</td>
		</tr>
		<?php
		$k = 0;
		$i = 0;
		for ($i=0, $n=count( $rows ); $i < $n; $i++) {
			$row = &$rows[$i];
			?>
			<tr class="row<?php echo $k; ?>">
				<td width="20"><input type="checkbox" id="cb<?php echo $i;?>" name="cid[]" value="<?php echo $row->id; ?>" onClick="isChecked(this.checked);"></td>
				<td width="637"><a href="#edit" onclick="return listItemTask('cb<?php echo $i; ?>','edit')"><?php echo $row->title; ?></a></td>
                <td width="79" align="center"><?php echo $row->groupname; ?></td>
              <?php
			$task = $row->published ? 'unpublish' : 'publish';
			$now = date( "Y-m-d h:i:s" );
			if ($now <= $row->publish_up && $row->published == "1") {
				$img = 'publish_y.png';
			} else if (($now <= $row->publish_down || $row->publish_down == "0000-00-00 00:00:00") && $row->published == "1") {
				$img = 'publish_g.png';
			} else if ($now > $row->publish_down && $row->published == "1") {
				$img = 'publish_r.png';
			} elseif ($row->published == "0") {
				$img = "publish_x.png";
			}
			$times = '';
			if (isset($row->publish_up)) {
				if ($row->publish_up == '0000-00-00 00:00:00') {
					$times .= "<tr><td>Start: Always</td></tr>";
				} else {
					$times .= "<tr><td>Start: $row->publish_up</td></tr>";
				}
			}
			if (isset($row->publish_down)) {
				if ($row->publish_down == '0000-00-00 00:00:00') {
					$times .= "<tr><td>Finish: No Expiry</td></tr>";
				} else {
					$times .= "<tr><td>Finish: $row->publish_down</td></tr>";
				}
			}
?>
				<td width="65" align="center"><a href="javascript: void(0);" onMouseOver="return overlib('<table border=0 width=100% height=100%><?php echo $times; ?></table>', CAPTION, 'Publish Information', BELOW, RIGHT);" onMouseOut="return nd();"  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 align="center"><?php echo $row->editor != "" ? $row->editor : "&nbsp;";?></td>
				<?php
					$k = 1 - $k;

			}?>
		</tr>
		<tr>
			<th align="center" colspan="5">
				<?php echo $pageNav->writePagesLinks(); ?></th>
		</tr>
		<tr>
			<td align="center" colspan="5">
				<?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 editNewsflash( &$row, &$publist, $option , $glist ) {
	mosMakeHtmlSafe( $row, ENT_QUOTES, 'content' );
?>
  	<link rel="stylesheet" type="text/css" media="all" href="../includes/js/calendar/calendar-mos.css" title="green" /> 
	<script type="text/javascript" src="../includes/js/calendar/calendar.js"></script> 
	<script type="text/javascript" src="../includes/js/calendar/lang/calendar-en.js"></script> 
	<script language="javascript" src="js/dhtml.js"></script>
		
		<script language="javascript" type="text/javascript">
		function submitbutton(pressbutton) {
			var form = document.adminForm;
			if (pressbutton == 'cancel') {
				submitform( pressbutton );
				return;
			}

			// do field validation
			try {
			document.adminForm.onsubmit();
			}
			catch(e){}
			if (form.title.value == ""){
				alert( "Newsflash must have a title" );
			} else {
				<?php getEditorContents( 'editor1', 'content' ) ; ?>
				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';?> Newsflash Item</span></td>
    </tr>
  </table>
  <table cellspacing="0" cellpadding="4" border="0" width="100%">
  <tr>
    <td class="tabpadding">&nbsp;</td>
    <td id="tab1" class="offtab" onclick="dhtml.cycleTab(this.id)">Newsflash</td>
    <td id="tab2" class="offtab" onclick="dhtml.cycleTab(this.id)">Publishing</td>	
    <td width="90%" class="tabpadding">&nbsp;</td>
  </tr>
</table><form action="index2.php" method="POST" name="adminForm">
<div id="page1" class="pagetext">
		
		<table cellpadding="4" cellspacing="0" border="0" width="100%" class="adminform">
			<tr>
				<td width="200">Title:</td>
				<td><input class="inputbox" type="text" name="title" size="25" value="<?php echo $row->title; ?>"></td>
			</tr>

			<tr>
				<td valign="top">Content (Max 600 chars):</td>
				<td>
					<?php 
					// parameters : areaname, content, hidden field, width, height, rows, cols
					editorArea( 'editor1', str_replace('&','&amp;',$row->content) , 'content', '500', '200', '70', '10' ) ; ?>
				</td>
			</tr>

			<tr>
				<td valign="top" align="right">Published:</td>
				<td>
					<?php echo $publist; ?>
				</td>
			</tr>
		</table>
	</div>
	<div id="page2" class="pagetext">
		    <table cellpadding="5" cellspacing="0" border="0" width="100%" class="adminform">
		<tr><td>
		<table cellpadding="5" cellspacing="0" border="0" width="100%">
    <tr>
      <td width="25%" align="right"><?php echo _E_STATE; ?></td>
      <td><?php if ($row->published == "1")
                    {
                      ?>
                       Published                            <?php
                    } else {
					?>
                            Unpublished                           <?php
                   }
                   ?> 
              </td>
    </tr>
    <tr>
      <td align="right"><?php echo _E_ACCESS_LEVEL; ?></td>
      <td> <?php echo $glist; ?> </td>
    </tr>
      <tr>
        <td align="right"><?php echo _E_START_PUB; ?></td>
        <td><input class="inputbox" type="text" name="publish_up" id="publish_up" size="25" maxlength="19" value="<?php echo $row->publish_up; ?>" />
          <input name="reset" type="reset" class="button" onClick="return showCalendar('publish_up', 'y-mm-dd');" value="..." />
</td>
      </tr>
    <tr>
      <td align="right"><?php echo _E_FINISH_PUB; ?></td>
      <td><input class="inputbox" type="text" name="publish_down" id="publish_down" size="25" maxlength="19" value="<?php echo $row->publish_down; ?>" />
        <input name="reset2" type="reset" class="button" onClick="return showCalendar('publish_down', 'y-mm-dd');" value="..." /> 
      </td>
    </tr>
    <tr>
      <td align="right">&nbsp;</td>
      <td>&nbsp;        </td>
    </tr>
    <tr>
      <td align="right">&nbsp;</td>
      <td>&nbsp;      </td>
    </tr>
    <tr>
      <td align="right">&nbsp;</td>
      <td>&nbsp;      </td>
    </tr>
    <tr>
      <td align="right">&nbsp;</td>
      <td>&nbsp;</td>
    </tr>
    <tr>
      <td align="right">&nbsp;</td>
      <td>&nbsp;</td>
    </tr>
  </table>
		</td></tr>
	   </table>
	</div>
			<input type="hidden" name="id" value="<?php echo $row->id; ?>">
			<input type="hidden" name="task" value="">
			<input type="hidden" name="option" value="<?php echo $option; ?>">
			</form>
		<script language="javascript" type="text/javascript">
		dhtml.cycleTab('tab1');
		</script>
		<?php }
}
?>
