<?php
// $Id: admin.frontpage.html.php,v 1.21 2003/12/20 09:09:15 saka_car Exp $
/**
* Frontpage Admin code
* @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.21 $
**/

class HTML_content {
	/**
	* Writes a list of the content items
	* @param array An array of content objects
	*/
	function showList( &$rows, $search, $pageNav, $option ) {
		global $my;
?>
<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%"><span class="sectionname"><img src="images/mos_gel.png" width="70" height="67" align="middle" />Front Page Items</span></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" width="50%">Title</th>
      <th width="15%" align="left">Category</th>
      <th width="10%" nowrap="nowrap">Published</th>
      <th width="10%" nowrap="nowrap">Checked Out</th>
      <th width="10%" nowrap="nowrap">Access</th>
      <th colspan="2" nowrap="nowrap">Reorder</th>
      <th>Order</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>
        <?php echo $row->title; ?> </a> </td>
      <td><?php echo $row->name; ?></td>
        <?php
			$now = date( "Y-m-d h:i:s" );
			if ($now <= $row->publish_up && $row->state == "1") {
				$img = 'publish_y.png';
			} else if (($now <= $row->publish_down || $row->publish_down == "0000-00-00 00:00:00") && $row->state == "1") {
				$img = 'publish_g.png';
			} else if ($now > $row->publish_down && $row->state == "1") {
				$img = 'publish_r.png';
			} elseif ($row->state == "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>";
                                }
                        }
			if ($times) {
?>
        <td 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 $row->state ? "unpublish" : "publish";?>')"><img src="images/<?php echo $img;?>" width="12" height="12" border=0 alt="" /></a>
        <?php
			}
	  ?>
      </td>
      <?php
			if ($row->checked_out) { ?>
      <td align="center"><?php echo $row->editor; ?></td>
      <?php		} else { ?>
      <td align="center">&nbsp;</td>
      <?php		} ?>
      <td align="center"><?php echo $row->groupname;?></td>
      <td>
        <?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>
        <?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>
	  <td><?php echo $row->fpordering;?></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="sectionid" value="<?php echo $section->id;?>" />
  <input type="hidden" name="task" value="" />
  <input type="hidden" name="boxchecked" value="0" />
</form>
<br />
<table cellspacing="0" cellpadding="4" border="0" align="center">
  <tr align="center">
    <td> <img src="images/publish_y.png" width="12" height="12" border=0 alt="Pending" />
    </td>
    <td> Published, but is <u>Pending</u> |</td>
    <td> <img src="images/publish_g.png" width="12" height="12" border=0 alt="Visible" />
    </td>
    <td> Published and is <u>Current</u> |</td>
    <td> <img src="images/publish_r.png" width="12" height="12" border=0 alt="Finished" />
    </td>
    <td> Published, but has <u>Expired</u> |</td>
    <td> <img src="images/publish_x.png" width="12" height="12" border=0 alt="Finished" />
    </td>
    <td> Not Published </td>
  </tr>
</table>
<?php
	}

	function showSettings( $col, $option, $params, $act ) {
?>
<table cellpadding="4" cellspacing="0" border="0" width="100%">
		<tr>
			<td class="sectionname"><img src="images/mos_gel.png" width="70" height="67" align="middle" />Front Page Settings</td>
		</tr>
		</table>
<script language="javascript" src="js/dhtml.js"></script>
<table cellpadding="3" cellspacing="0" border="0" width="100%">
  <tr>
    <td width="" class="tabpadding">&nbsp;</td>
    <td id="tab1" class="offtab" onclick="dhtml.cycleTab(this.id)">Item structure</td>
    <td id="tab2" class="offtab" onClick="dhtml.cycleTab(this.id)">Parameters</td>
    <td width="90%" class="tabpadding">&nbsp;</td>
  </tr>
</table>
<script language="javascript" type="text/javascript">
		function submitbutton(pressbutton) {
			var form = document.adminForm;
			submitform( pressbutton );
		}
</script>
<form action="index2.php" method="POST" name="adminForm">
  <div id="page1" class="pagetext">
    <table cellpadding="2" cellspacing="4" border="0" width="100%" class="adminform">
      <tr>
        <td><input name="col_main" type="radio" value="1"<?php if ($col==1) echo " checked"; ?>></td>
        <td class="error">One column per row</td>
      </tr>
      <tr>
        <td><input name="col_main" type="radio" value="2"<?php if ($col==2) echo " checked"; ?>></td>
        <td class="error">Two columns per row</td>
      </tr>
      <tr>
        <td><input name="col_main" type="radio" value="3"<?php if ($col==3) echo " checked"; ?>></td>
        <td class="error">Two columns per row with leading story</td>
      </tr>
    </table>
  </div>
  <div id="page2" class="pagetext">
    <table cellpadding="2" cellspacing="4" border="0" width="100%" class="adminform">
      <tr>
        <td width="80">Count:</td>
        <td><input class="inputbox" type="text" name="count" size="5" value="<?php echo $params['count']; ?>"></td>
      	<td class="error">Total number of frontpage items</td>
      </tr>
      <tr>
        <td width="80">Intro:</td>
        <td><input class="inputbox" type="text" name="intro" size="5" value="<?php echo $params['intro']; ?>"></td>
      	<td class="error">Number of displayed frontpage items</td>
      </tr>
      <tr>
        <td width="80">Image:</td>
        <td><?php echo $params['image']; ?></td>
      	<td class="error">Use image in intro items</td>
      </tr>
      <tr>
        <td width="80">Header:</td>
        <td><input class="inputbox" type="text" name="header" size="50" value="<?php echo $params['header']; ?>"></td>
      	<td class="error">Header text</td>
      </tr>
      <tr>
        <td width="80">Empty:</td>
        <td><input class="inputbox" type="text" name="empty" size="50" value="<?php echo $params['empty']; ?>"></td>
      	<td class="error">Text displayed if no items published</td>
      </tr>
      <tr>
        <td width="80">Order by:</td>
        <td><?php echo $params['orderby']; ?></td>
      	<td class="error">Overrides the items ordering settings</td>
      </tr>
    </table>
  </div>
  <input type="hidden" name="option" value="<?php echo $option; ?>">
  <input type="hidden" name="act" value="<?php echo $act; ?>">
  <input type="hidden" name="task" value="">
</form>
<script language="javascript" type="text/javascript">
		dhtml.cycleTab('tab1');
		</script>
<?php
	}

}
?>
