<?php
// $Id: admin.help.html.php,v 1.4 2004/02/21 18:53:50 rcastley Exp $
/**
* Administrator help 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.4 $
**/

// 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_help
{
	// Args:
	//		$title, Title for the page
	//		$currentpage, Page to edit
	function mosHelp_ShowHelpForm($title, $catlist, $orderlist, $parlist, $currentpage = null)
	{
		global $option,$task;
		//
		if(!is_null($currentpage))
		{
			$helpname		= $currentpage->name;
			$helptext		= $currentpage->helptext;
			$helptitle		= $currentpage->title;
			$helpordering	= $currentpage->ordering;
			$helpid			= $currentpage->id;
		}
		else
		{
			$helpname		= "";
			$helptext		= "";
			$helptitle		= "";
			$helpordering	= 999;
			$helpid			= 0;
		}
?>
		<form action="index2.php" method="POST" name="adminForm">
		<table cellpadding="4" cellspacing="0" border="0" width="100%">
    <tr> 
      <td width="100%"><span class="sectionname">Help</span></td>
    </tr>
  </table>
		<table cellpadding="4" cellspacing="1" width="100%" class="adminform">
			<tr>
				<th colspan="3" class="title">Add/Edit Help</th>
			</tr>
			<tr>
				<td width="15%">Help Title:</td>
				<td width=70><input class="inputbox" type="text" name="title" size="40" maxlength="40" value="<?php echo $helptitle; ?>" title="A short title to appear in menus, etc"></td>
			</tr>
			<tr>
				<td width="15%">Help Name:</td>
				<td width=70><input class="inputbox" type="text" name="name" size="70" maxlength="100" value="<?php echo $helpname; ?>" title="A long name to be displayed in headings"></td>
			</tr>
			<tr>
				<td>Category:</td>
				<td><?php echo $catlist; ?></td>
			</tr>
			<tr>
				<td>Parent node:</td>
				<td><?php echo $parlist; ?></td>
			</tr>
			<tr>
				<td width="15%">Ordering:</td>
				<td><?php echo $orderlist; ?></td>
			</tr>
			<tr>
				<td valign="top">Help text:</td>
				<td colspan="2">
					<?php 
					// parameters : areaname, content, hidden field, width, height, rows, cols
					editorArea( 'editor1',  str_replace('&','&amp;',$helptext) , 'helptext', '500', '400', '70', '15' ) ; ?>
				</td>
			</tr>
			
			
			<input type="hidden" name="option" value="<?php echo $option; ?>">
			<input type="hidden" name="id" value="<?php echo $helpid; ?>">
			<input type="hidden" name="task" value="">
		</form>
		</table>

<?php
	}


	// Args: Title to display
	//		array of files to display in the table
	function mosHelp_ShowHelpIndex( $catid, $helpTitle,$arrayContent)
	{
		global $option,$task,$helpid,$PHP_SELF;
?>
		<form action="index2.php" method="POST" name="adminForm">
		<table cellpadding="4" cellspacing="0" border="0" width="100%">
		<tr>
			 <td width="100%"><span class="sectionname">Help</span></td>
			<td>
			</td>
		<td nowrap="nowrap">Search:&nbsp;<input class="inputbox" type="text" name="helpsearchvalue">&nbsp;<input class="button" type="submit" value="Search"><br /></td>
		</tr>
		</table>

		<input type="hidden" name="task" value="helpsearch">
		<input type="hidden" name="option" value="<?php echo $option; ?>">
		<input type="hidden" name="catid" value="<?php echo $catid;?>" />
		</form>

		<table cellpadding="4" cellspacing="0" border="0" width="100%" class="adminform">
			<tr>
				<th class="title"><?php echo $helpTitle;?></th>
			</tr>
	<?php
if(count($arrayContent))
{
	$k = 0;
	foreach ($arrayContent as $parent)
	{
	?>
			<tr class=row<?php echo $k;?>>
				<td>
					<a href="<?php echo $PHP_SELF;?>?option=<?php echo $option; ?>&task=showhelp&helpid=<?php echo $parent->id;?>"><?php echo $parent->title;?></a><br>
	<?php
		HTML_help::mosHelp_DisplayHelpLevel( $catid, $parent);
	?>
				</td>
			</tr>
	<?php
	}
}
	?>
			<tr>
				<td colspan="2" align="center">

				</td>
			</tr>
		</table>
	<?php
	}

	function mosHelp_DisplayHelpLevel( $catid, $startpoint, $indent = 1)
	{
		global $option, $database,$PHP_SELF;
		$sublevels = mosHelp_GetHelpIndexDB( $catid, $startpoint->id );
		if(is_array($sublevels) && count($sublevels) > 0)
		{
			foreach($sublevels as $level)
			{
				?>
				<li style='padding-left: <?php echo $indent *15;?>px;'><a href="<?php echo $PHP_SELF;?>?option=<?php echo $option; ?>&task=showhelp&helpid=<?php echo $level->id;?>"><?php echo $level->title; ?></a></li>
				<?php
				HTML_help::mosHelp_DisplayHelpLevel( $catid, $level, $indent + 1);
			}
		}
	}

	function mosHelp_ShowHelp( $helpTitle, $helpfile, $seealso )
	{
		global $option,$helpid,$PHP_SELF;
	?>
		<form action="index2.php" method="POST" name="adminForm">
		<input type="hidden" name="task" value="">
		<input type="hidden" name="option" value="<?php echo $option; ?>">
		<input type="hidden" name="boxchecked" value="<?php echo $helpid;?>">
		<input type="hidden" name="helpid" value="<?php echo $helpid;?>">
		<input type="hidden" name="catid" value="<?php echo $helpfile->catid;?>">
		<table cellpadding="4" cellspacing="0" border="0" width="100%">
    <tr> 
      <td width="100%"><span class="sectionname">Help</span></td>
    </tr>
  </table>
		<table cellpadding="4" cellspacing="0" border="0" width="100%" class="adminform">
			<tr>
				<th align="left"><a href="index2.php?option=<?php echo $option; ?>&catid=<?php echo $helpfile->catid;?>"><?php echo "".$helpTitle."</a> :: Topic -> ".$helpfile->title;?></th>
			</tr>
			<tr>
				<td><b><?php echo $helpfile->name; ?></b></td>
			</tr>
			<tr>
				<td><?php echo $helpfile->helptext;?></td>
			</tr>
	<?php
	if(count($seealso))
	{
	?>
			<tr>
				<td colspan="2"><b>See also</b><br />
	<?php
	foreach($seealso as $child)
	{
	?>
					<a href="<?php echo $PHP_SELF;?>?option=<?php echo $option; ?>&task=showhelp&helpid=<?php echo $child->id;?>"><?php echo $child->title; ?></a>&nbsp;|&nbsp;
	<?php
	}
	}
	?>
				</td>
			</tr>
			<tr>
				<td colspan="2" align="center"><a href="<?php echo $PHP_SELF?>?option=<?php echo $option; ?>&catid=<?php echo $helpfile->catid;?>">[Back to index]</a></td>
			</tr>
		</table>
		</form>
	<?php
	}

	function mosHelp_ShowHelpSearchResult($title,$searchvalue,$result)
	{
		global $option, $PHP_SELF;
	?>
		<table cellpadding="4" cellspacing="0" border="0" width="100%" class="adminform">
			<tr>
				<th><?php echo $title;?></th>
			</tr>
			<tr>
				<td>Seach for '<?php echo $searchvalue;?>' result(s) <?php echo count($result); ?> </td>
			</tr>
			<?php
	if(count($result))
	{
		foreach($result as $child)
		{
			?>
					<tr><td colspan=2><a href="<?php echo $PHP_SELF;?>?option=<?php echo $option; ?>&task=showhelp&helpid=<?php echo $child->id;?>"><?php echo $child->title; ?></a></td></tr>
			<?php
		}
	}
			?>
			<tr>
				<td colspan="2" align="center"><a href="<?php echo $PHP_SELF?>?option=<?php echo $option; ?>">Back to index</a></td>
			</tr>

		</table>

	<?php
	}
}
?>
