<?php
// $Id: admin.sections.html.php,v 1.11 2004/02/21 18:53:52 rcastley Exp $
/**
* Section admin 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 $
**/

/**
* Utility class for the display of section functions
*/
class sections_html {
/**
* Writes a list of the categories for a section
* @param array An array of category objects
* @param string The name of the category section
*/
	function show( &$rows, $scope, $myid, &$pageNav, $option ) {
?>
<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">Sections</span></td>
		<td nowrap>Display #</td>
		<td> <?php echo $pageNav->writeLimitBox(); ?> </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">Section Name</th>
		<th width="15%"># of&nbsp;Records</th>
		<th width="15%"># Checked&nbsp;Out</th>
		<th width="10%">Published</th>
		<th width="10%">Checked Out</th>
		<th width="10%">Access</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 width="20" align="right"><?php echo $i+$pageNav->limitstart+1;?></td>
		<td width="20">
<?php		if ($row->checked_out && $row->checked_out != $myid) { ?>
						&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="35%">
			<a href="#edit" onClick="return listItemTask('cb<?php echo $i;?>','edit')">
				<?php echo "$row->name ($row->title)"; ?>
			</a>
		</td>
		<td width="15%" align="center"><?php echo $row->num; ?></td>
		<td width="15%" align="center"><?php echo $row->checked_out; ?></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;?>" width="12" height="12" border="0" alt="" /></a></td>
		<td width="15%" align="center"><?php echo $row->editor; ?>&nbsp;</td>
		<td width="10%" 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>
<?php		$k = 1 - $k; ?>
	</tr>
<?php	} // for loop ?>

    <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="scope" value="<?php echo $scope;?>" />
<input type="hidden" name="task" value="" />
<input type="hidden" name="chosen" value="" />
<input type="hidden" name="act" value="" />
<input type="hidden" name="boxchecked" value="0" />
</form>
<?php
	}
/**
* Writes the edit form for new and existing categories
*
* A new record is defined when <var>$row</var> is passed witht the <var>id</var>
* property set to 0.  Note that the <var>section</var> property <b>must</b> be defined
* even for a new record.
* @param mosCategory The category object
* @param string The html for the image list select list
* @param string The html for the image position select list
* @param string The html for the ordering list
* @param string The html for the groups select list
*/
	function edit( &$row, $imagelist, $iposlist, $orderlist, $glist, $option ) {
		global $mosConfig_live_site, $mosConfig_editor;
		if ($row->name!='') {
			$name = $row->name;
		} else {
			$name = "New Section";
		}
		if ($row->image == "") {
			$row->image = 'blank.png';
		}
?>
		<script language="javascript" type="text/javascript">
		function submitbutton(pressbutton) {
			var form = document.adminForm;
			if (pressbutton == 'cancel') {
				submitform( pressbutton );
				return;
			}

			if (form.name.value == ""){
				alert("Section must have a name");
			} else if (form.title.value ==""){
				alert("Section must have a title");
			} else {
				<?php getEditorContents( 'editor1', 'description' ) ; ?>
				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->id ? 'Edit' : 'Add';?> Section <?php echo " :: ".$name ; ?></td>
			</tr>
		</table>
		<table cellpadding="4" cellspacing="1" border="0" width="100%" class="adminform">
		<tr>
			<td width="150">Scope:</td>
			<td width="85%" colspan="2">
				<strong><?php echo $row->scope; ?></strong>
			</td>
		</tr>
		<tr>
			<td>Title:</td>
			<td colspan="2">
				<input class="inputbox" type="text" name="title" value="<?php echo $row->title; ?>" size="50" maxlength="50" title="A short name to appear in menus" />
			</td>
		</tr>
		<tr>
			<td><?php echo (isset($row->section) ? "Category" : "Section");?> Name:</td>
			<td colspan="2">
				<input class="inputbox" type="text" name="name" value="<?php echo $row->name; ?>" size="50" maxlength="255" title="A long name to be displayed in headings" />
			</td>
		</tr>
		<tr>
			<td>Image:</td>
			<td>
				<?php echo $imagelist; ?>
			</td>
			<td rowspan="4" width="50%">
				<img src="<?php echo $mosConfig_live_site;?>/images/stories/<?php echo $row->image;?>" name="imagelib" width="80" height="80" border="2" alt="Preview" />
			</td>
		</tr>
		<tr>
			<td>Image Position:</td>
			<td>
				<?php echo $iposlist; ?>
			</td>
		</tr>
		<tr>
			<td>Ordering:</td>
			<td>
				<?php echo $orderlist; ?>
			</td>
		</tr>
		<tr>
			<td>Access Level:</td>
			<td>
				<?php echo $glist; ?>
			</td>
		</tr>
		<tr>
			<td valign="top">Description:</td>
			<td colspan="2">
				<?php 
				// parameters : areaname, content, hidden field, width, height, rows, cols
				editorArea( 'editor1',  $row->description , 'description', '500', '200', '50', '5' ) ; ?>
			</td>
		</tr>

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

		</table>
		</form>
	<?php }

}
?>
