<?php
// $Id: admin.menus.html.php,v 1.13 2003/12/11 02:41:33 saka_car Exp $
/**
* Administrator menu presentation layer
* @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.13 $
**/

// 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_menusections {
	function showMenusections( &$rows, &$pageNav, $search, &$levellist, $menutype, $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" />Menu Manager :: <?php echo $menutype;?></span></td>
			<td nowrap="nowrap">Max Levels</td>
			<td><?php echo $levellist;?></td>
			<td nowrap="nowrap">Display #</td>
			<td><?php $pageNav->writeLimitBox();?></td>
			<td>Search:</td>
			<td><input type="text" name="search" value="<?php echo $search;?>" class="inputbox" /></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">Menu Item</th>
			<th>Section</th>
			<th>Published</th>
			<th nowrap>Checked Out</th>
			<th>Access</th>
			<th nowrap="nowrap">Menu Id</th>
			<th colspan="2">Reorder</th>
		</tr>
    <?php
		$k = 0;
		$i = 0;
		$n = count( $rows );
		foreach ($rows as $row) {
			$task = $row->published ? 'unpublish' : 'publish';
?>
    <tr class="<?php echo "row$k"; ?>">
      <td width="20"><?php echo $i + 1 + $pageNav->limitstart;?></td>
      <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="63%"><a href="#edit" onclick="return listItemTask('cb<?php echo $i;?>','edit')">
        <?php echo $row->treename; ?></a></td>
      <td width="15%" align="center"> <?php echo $row->type;?> </td>
<?php
			$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 ($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 ($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 $task;?>')"><img src="images/<?php echo $img;?>" width="12" height="12" border="0" alt="" /></a>

<?php		} else {
				$img = $row->published ? 'tick.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>
<?php		} ?>
      <td width="15%" align="center"><?php echo $row->editor;?>&nbsp;</td>
      <td width="10%" align="center"><?php echo $row->groupname;?></td>
      <td width="15%" align="center"><?php echo $row->id;?></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 { ?>
			&nbsp;
<?php		} ?>
					</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 { ?>
			&nbsp;
<?php		} ?>
					</td>
<?php
			$k = 1 - $k;
			$i++;
?>
    </tr>
<?php
		}
?>
    <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="menutype" value="<?php echo $menutype; ?>" />
  <input type="hidden" name="task" value="" />
  <input type="hidden" name="boxchecked" value="0" />
</form>
<table cellspacing="0" cellpadding="4" border="0" align="center">
  <tr align="center">
    <td>  </td>
    <td> <img src="images/tick.png" width="12" height="12" border=0 alt="Pending" />
    </td>
    <td align="left"> Published</td>
    <td align="left"> <img src="images/publish_x.png" width="12" height="12" border=0 alt="Finished" />
    </td>
    <td align="left"> Not Published </td>
  </tr>
  <tr align="center">
    <td> Typed Content: </td>
    <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>
  </tr>
  <tr>
	<td colspan="8" align="center">Click on icon to toggle state.</td>
  </tr>
</table>
<?php
		}

/**
* Displays a selection list for menu item types
*/
	function addMenuItem( &$cid, &$glist, &$tlist, $menutype, $option ) {
		$limit		= intval( mosGetParam( $_REQUEST, 'limit', 10 ) );
		$limitstart	= intval( mosGetParam( $_REQUEST, 'limitstart', 0 ) );
		$levellimit	= intval( mosGetParam( $_REQUEST, 'levellimit', 0 ) );
?>
	<script language="javascript">
	<!--
		function checkstep1( form ) {
			if (document.adminForm.task.selectedIndex < 0) {
				alert('Please select an item type.');
			} else {
				document.adminForm.action = 'index2.php';
				document.adminForm.submit(form);
			}
		}
	//-->
	</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">Add Menu Item</span>
      </td>
    </tr>
  </table>
  <table cellpadding="5" cellspacing="0" border="0" width="100%" class="adminform">
    <tr>
      <td colspan="2">&nbsp;</td>
    </tr>
    <!-- <tr>
				<td>Item Name:</td>
				<td width="85%"><input type="text" name="ItemName" /></td>
			</tr> -->
    <tr>
      <td width="20%" align="left" valign="top">Select a Component to Add:</td>
      <td width="80%"> <?php echo $tlist;?> </td>
    </tr>
    <!--
			<tr>
				<td valign="top">Access Level:</td>
				<td>
					<?php echo $glist;?>
				</td>
			</tr>
			-->
    <tr>
      <td>&nbsp;</td>
      <td>
		<input type="hidden" name="parent" value="<?php echo $cid[0]; ?>" />
		<input type="hidden" name="option" value="<?php echo $option; ?>" />
		<input type="hidden" name="menutype" value="<?php echo $menutype; ?>" />
        <input type="hidden" name="limit" value="<?php echo $limit;?>" />
        <input type="hidden" name="limitstart" value="<?php echo $limitstart;?>" />
        <input type="hidden" name="levellimit" value="<?php echo $levellimit;?>" />
        <input type="hidden" name="task" value="edit" />
		<input type="button" value="Next" onClick="checkstep1(this.form);" class="button" />
      </td>
    </tr>
    <tr>
      <td colspan="2">&nbsp;</td>
    </tr>
  </table>
</form>
<?php }
/*******************************************************************************************
	Please keep this for the moment.  I want to re-use this elsewhere ...aje
	function addMenusection($option, $glist, &$types, $displayPerPage, $limitstart) {
?>
<script language="javascript">
		<!--
			function checkstep1( form ) {
				if (document.adminForm.task.selectedIndex < 0) {
					alert('Please select an item type.');
				} else {
					document.adminForm.action = 'index2.php';
					document.adminForm.submit(form);
				}
			}
			var mtypes = new Array();
			var mactions = new Array();
<?php
		$i = 0;
		$j = 0;
		foreach ($types as $type=>$opts) {
			echo "\n	mtypes[".$i++."] = new Array( '','$type','$type' );";
			foreach ($opts as $k=>$v) {
				echo "\n	mactions[".$j++."] = new Array( '$type','$v->value','$v->text' );";
			}
		}
?>

		//-->
		</script>
<form action="index2.php" method="POST" name="adminForm">
  <table cellpadding="5" cellspacing="0" border="0" width="100%" class="adminform">
    <tr>
      <th colspan="2" class="title">Add Menu Item - Top Level</th>
    </tr>
    <tr>
      <td colspan="2">&nbsp;</td>
    </tr>
    <tr>
      <td width="20%" align="right" valign="top">Select a Component:</td>
      <td width="80%"> <script language="javascript">
					<!--
						writeDynaList( 'name="type" size="5" onchange="changeDynaList(\'task\',mactions,document.adminForm.type.options[document.adminForm.type.selectedIndex].value, \'\', \'\')"', mtypes, '', '', '' );
					-->
					</script> </td>
    </tr>
    <tr>
      <td align="right" valign="top">Select an item to add:</td>
      <td> <script language="javascript">
					<!--
						writeDynaList( 'class="inputbox" name="task" size="5"', mactions, '', '', '' );
					-->
					</script> </td>
    </tr>
    <tr>
      <td>&nbsp;</td>
      <td><input type="hidden" name="option" value="<?php echo $option; ?>" />
        <input type="hidden" name="limit" value="<?php echo $limit;?>" />
        <input type="hidden" name="limitstart" value="<?php echo $limitstart;?>" />
        <input type="hidden" name="levellimit" value="<?php echo $levellimit;?>" />
        <input type="hidden" name="displayPerPage" value="<?php echo $displayPerPage;?>" />
        <input type="button" value="Next" onClick="checkstep1(this.form);" />
      </td>
    </tr>
    <tr>
      <td colspan="2">&nbsp;</td>
    </tr>
    <tr>
      <th colspan="2">&nbsp;</th>
    </tr>
  </table>
</form>
<?php }
*/
}
?>
