<?php
// $Header: /cvsroot/phptsmadmin/phpTSMadmin/htdocs/help.php,v 1.3 2009/04/19 03:53:40 wurley Exp $

# This page should detail on Client storage usage.

# Required Libraries
require './common.php';

# Defaults
$help = objectCache('help');
$form['command'] = get_request('command','REQUEST');

# List of Clients.
$blockTitle['help'] = sprintf(_('Select HELP on %s'),$app['server']->getValue('server','name'));

$blockBody['help'] = '<form action="cmd.php">';
$blockBody['help'] .= sprintf('<input type="hidden" name="cmd" value="%s" />',get_request('cmd','REQUEST'));
$blockBody['help'] .= '<table class="blockcitem">';

$blockBody['help'] .= '<tr><td width=0%>';
$blockBody['help'] .= sprintf('<input type="hidden" name="index" value="%s" />',$app['server']->getIndex());
$blockBody['help'] .= '<select name="command">';
foreach ($help->getCommands() as $command) {
	$blockBody['help'] .= sprintf('<option id="%s" %s>%s</option>',
		$command,
		isset($form['command']) && $command == $form['command'] ? 'selected' : '',
		$command);
}
$blockBody['help'] .= '</select>';
$blockBody['help'] .= '</td>';
$blockBody['help'] .= '<td><input type="checkbox" name="raw" title="Show RAW help page"/></td>';
$blockBody['help'] .= '<td><input align="left" type="submit" name="submit" value="Go" /></td>';
$blockBody['help'] .= '<td width=100%>&nbsp;</td>';
$blockBody['help'] .= '</tr>';
$blockBody['help'] .= '</table>';
$blockBody['help'] .= '</form>';

if (isset($form['command'])) {
	$helpCommand = $help->getCommand($form['command']);

	if (get_request('raw','REQUEST')) {
		$blockBody['help'] .= '<pre>'.implode('<br />',$helpCommand->raw).'</pre>';

	} else {
		$blockBody['help'] .= '<br />';
		$blockBody['help'] .= '<table class="blockcitem">';

		$blockBody['help'] .= sprintf('<tr><td><h3><u>%s</u></h3></td></tr>',$helpCommand->getTitle());
		$blockBody['help'] .= sprintf('<tr><td>%s</td></tr>',$helpCommand->getDescription());

		$blockBody['help'] .= sprintf('<tr><td><b>%s</b></td></tr>',_('Privileges Required'));
		$blockBody['help'] .= sprintf('<tr><td>%s</td></tr>',$helpCommand->getClass());

		$blockBody['help'] .= sprintf('<tr><td><b>%s</b></td></tr>',_('Syntax'));
		$blockBody['help'] .= sprintf('<tr><td>%s</td></tr>',$helpCommand->getSyntax());

		$blockBody['help'] .= sprintf('<tr><td><b>%s</b></td></tr>',_('Parameters'));
		$blockBody['help'] .= sprintf('<tr><td>%s</td></tr>',$helpCommand->getParameters());

		$blockBody['help'] .= '<tr><td>&nbsp;</td></tr>';
		$blockBody['help'] .= sprintf('<tr><td><b>%s</b></td></tr>',_('Related Commands'));
		$blockBody['help'] .= sprintf('<tr><td>%s</td></tr>',$helpCommand->getRelated());

		$blockBody['help'] .= '</table>';
	}
}

# End
render_page($blockTitle,$blockBody);
?>
