<?php
// $Id: content_typed.menu.html.php,v 1.16 2004/02/21 18:53:51 rcastley Exp $
/**
* Administrator menu typed content 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.16 $
**/

// ensure this file is being included by a parent file
defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );

/**
* Writes the edit form for new and existing content item
*
* A new record is defined when <var>$row</var> is passed witht the <var>id</var>
* property set to 0.
* @param mosContent The category object
*/

class content_menu_html {
	function edit( &$menu, &$row, &$images, &$lists, $myid, $option ) {
		global $mosConfig_live_site, $mosConfig_editor;

		//mosMakeHtmlSafe( $row );
?>
<table cellpadding="4" cellspacing="0" border="0" width="100%">
    <tr>
      <td width="100%"><span class="sectionname"><?php echo $row->id ? 'Edit' : 'Add';?> Menu Item - Typed Content</span></td>
    </tr>
  </table>
<link rel="stylesheet" type="text/css" media="all" href="<?php echo $mosConfig_live_site; ?>/includes/js/calendar/calendar-mos.css" title="green" />
<!-- import the calendar script -->
<script type="text/javascript" src="<?php echo $mosConfig_live_site; ?>/includes/js/calendar/calendar.js"></script>
<!-- import the language module -->
<script type="text/javascript" src="<?php echo $mosConfig_live_site; ?>/includes/js/calendar/lang/calendar-en.js"></script>
		<script language="javascript" src="js/dhtml.js"></script>
		<table cellspacing="0" cellpadding="4" border="0" width="100%">
		<tr>
		    <td width="" class="tabpad">&nbsp;</td>
			<td id="tab1" class="offtab" onclick="dhtml.cycleTab(this.id)">Content</td>
			<td id="tab2" class="offtab" onclick="dhtml.cycleTab(this.id)">Images</td>
			<td id="tab3" class="offtab" onclick="dhtml.cycleTab(this.id)">Publishing</td>
			<td id="tab4" class="offtab" onclick="dhtml.cycleTab(this.id)">Metadata</td>
			<td width="90%" class="tabpadding">&nbsp;</td>
		</tr>
		</table>

		<script language="javascript" type="text/javascript">
	var folderimages = new Array;
<?php	$i = 0;
foreach ($images as $k=>$items) {
	foreach ($items as $v) {
		echo "\n	folderimages[".$i++."] = new Array( '$k','$v->value','$v->text' );";
	}
}
?>
		function submitbutton(pressbutton) {
			if (pressbutton == 'cancel') {
				submitform( pressbutton );
				return;
			}
			var form = document.adminForm;
			var temp = new Array;
			for (var i=0, n=form.imagelist.options.length; i < n; i++) {
				temp[i] = form.imagelist.options[i].value;
			}
			form.images.value = temp.join( '\n' );

			try {
				document.adminForm.onsubmit();
			}
			catch(e){}
			if (trim(form.title.value) == ""){
				alert( "Content item must have a title" );
			} else if (trim(form.name.value) == ""){
				alert( "Content item must have a name" );
			} else {
				<?php getEditorContents( 'editor1', 'introtext' ) ; ?>
				submitform( pressbutton );
			}
		}

		</script>

		<form action="index2.php" method="POST" name="adminForm">
		<input type="hidden" name="images" value="" />

		<div id="page1" class="pagetext">
		<table cellpadding="5" cellspacing="0" border="0" width="100%" class="adminform">
			<tr>
				<td width="20%" align="right">Parent Item:</td>
				<td width="80%">
					<?php echo $lists['parent'];?>
				</td>
				<td width="30%" rowspan="5" align="middle" valign="top">
		  <table cellpadding="3" cellspacing="0" border="0" width="180" class="adminform">
            <tr>
              <th colspan="2">Item Status</th>
            </tr>
            <tr>
              <td width="34%"><strong>State</strong></td>
              <td width="50%"><?php echo $row->state > 0 ? 'Published' : ($row->state < 0 ? 'Archived' : 'Draft Unpublished');?></td>
            </tr>
            <tr>
              <td><strong>Hits</strong></td>
              <td><?php echo "$row->hits";?></td>
            </tr>
            <tr>
              <th colspan="2">Item Info</th>
            </tr>
            <tr>
              <td><strong>Version</strong></td>
              <td><?php echo "$row->version";?></td>
            </tr>
            <tr>
              <td><strong>Created</strong></td>
              <td> <?php echo $row->created ? "$row->created</td></tr><tr><td><strong>By</strong></td><td>$row->creator" : "New document";?></td>
            </tr>
            <tr>
              <td><strong>Last Modified</strong></td>
              <td><?php echo $row->modified ? "$row->modified</td></tr><tr><td><strong>By</strong></td><td>$row->modifier" : "Not modified";?></td>
            </tr>
             <tr>
              <td><strong>Expires</strong></td>
              <td><?php echo "$row->publish_down";?><td>
            </tr>
          </table>
		</td>
			</tr>

			<tr>
				<td align="right">Name:</td>
				<td>
					<input class="inputbox" type="text" name="name" size="50" maxlength="100" value="<?php echo $menu->name; ?>" />
				</td>
			</tr>

			<tr>
				<td align="right">Title:</td>
				<td>
					<input class="inputbox" type="text" name="title" size="50" maxlength="100" value="<?php echo $row->title; ?>" />
				</td>
			</tr>

			<tr>
				<td valign="top" align="right">
					Text:<br />(required)
				</td>
				<td>
					<?php 
					// parameters : areaname, content, hidden field, width, height, rows, cols
					editorArea( 'editor1',  str_replace('&','&amp;',$row->introtext), 'introtext', '500', '500', '70', '15' ) ; ?>
				</td>
			</tr>
			<tr>
		</table>
		</div>

		<div id="page2" class="pagetext">
		<table cellpadding="5" cellspacing="0" border="0" width="100%" class="adminform">
			<tr>
				<td colspan="6">Sub-folder :: <?php echo $lists['folders'];?></td>
			</tr>
			<tr>
				<td>
					Gallery Images
					<br />
					<?php echo $lists['imagefiles'];?>
					<br />
					<input type="button" value="insert &gt;" onclick="addSelectedToList('adminForm','imagefiles','imagelist')" />
				</td>
				<td>
					Content Images:
					<br />
					<?php echo $lists['imagelist'];?>
					<br />
					<input type="button" value="up" onClick="moveInList('adminForm','imagelist',adminForm.imagelist.selectedIndex,-1)"/>
					<input type="button" value="down" onClick="moveInList('adminForm','imagelist',adminForm.imagelist.selectedIndex,+1)"/>
					<input type="button" value="remove" onclick="delSelectedFromList('adminForm','imagelist')" />

				</td>
				<td>
					Edit the image selected:
					<table>
					<tr>
						<td align="right">Source</td>
						<td>
							<input type="text" name= "_source" value="" />
						</td>
					</tr>
					<tr>
						<td align="right">Align</td>
						<td>
							<?php echo $lists['_align']; ?>
						</td>
					</tr>
					<tr>
						<td align="right">Alt Text</td>
						<td>
							<input type="text" name="_alt" value="" />
						</td>
					</tr>
					<tr>
						<td align="right">Border</td>
						<td>
							<input type="text" name="_border" value="" size="3" maxlength="1" />
						</td>
					</tr>
					<tr>
						<td align="right"></td>
						<td>
							<input type="button" value="Apply" onclick="applyImageProps()" />
						</td>
					</tr>
					</table>
				</td>
			</tr>
			<tr>
				<td>
					<img name="view_imagefiles" src="<?php echo $mosConfig_live_site;?>/images/stories/blank.png" width="100">
				</td>
				<td>
					<img name="view_imagelist" src="<?php echo $mosConfig_live_site;?>/images/stories/blank.png" width="100">
				</td>
			</tr>
		</table>
		</div>

		<div id="page3" class="pagetext">
		<table cellpadding="5" cellspacing="0" border="0" width="100%" class="adminform">
			<tr>
				<td valign="top" align="right">State:</td>
					<td><?php echo $row->state > 0 ? 'Published' : ($row->state < 0 ? 'Archived' : 'Draft Unpublished');?> </td>
			</tr>
			<tr>
				<td valign="top" align="right">Access Level:</td>
				<td>
					<?php echo $lists['access']; ?>
				</td>
			</tr>
			<tr>
				<td valign="top" align="right">Ordering:</td>
				<td>
					<?php echo $lists['ordering']; ?>
				</td>
			</tr>
			<tr>
				<td width="20%" align="right">Start Publishing:</td>
				<td width="80%">
					<input class="inputbox" type="text" name="publish_up" id="publish_up" size="25" maxlength="19" value="<?php echo $row->publish_up; ?>" />
					<input type="reset" class="button" value="..." onclick="return showCalendar('publish_up', 'y-mm-dd');">
				</td>
			</tr>
			<tr>
				<td width="20%" align="right">Finish Publishing:</td>
				<td width="80%">
					<input class="inputbox" type="text" name="publish_down" id="publish_down" size="25" maxlength="19" value="<?php echo $row->publish_down; ?>" />
					<input type="reset" class="button" value="..." onclick="return showCalendar('publish_down', 'y-mm-dd');">
				</td>
			</tr>
		</table>
		</div>

		<div id="page4" class="pagetext">
		<table cellpadding="5" cellspacing="0" border="0" width="100%" class="adminform">
			<tr>
				<td width="20%" align="right">Description:</td>
				<td width="80%">
					<textarea class="inputbox" cols="70" rows="5" name="metadesc" style="width:500px" width="500"><?php echo str_replace('&','&amp;',$row->metadesc); ?></textarea></td>
				</td>
			</tr>
			<tr>
				<td align="right">Keywords:</td>
				<td >
					<textarea class="inputbox" cols="70" rows="5" name="metakey" style="width:500px" width="500"><?php echo str_replace('&','&amp;',$row->metakey); ?></textarea></td>
				</td>
			</tr>
		</table>
		</div>
		<input type="hidden" name="option" value="<?php echo $option; ?>" />
		<input type="hidden" name="type" value="<?php echo $menu->type; ?>" />
		<input type="hidden" name="id" value="<?php echo $row->id; ?>" />
		<input type="hidden" name="menuid" value="<?php echo $menu->id; ?>" />
		<input type="hidden" name="menutype" value="<?php echo $menu->menutype; ?>" />
		<input type="hidden" name="utaccess" value="3" />
		<input type="hidden" name="task" value="" />
		</form>

		<script language="javascript" type="text/javascript">
		dhtml.cycleTab('tab1');
		</script>
<?php
	}
}
?>
