<?php
/*
 * Copyright (c) 2013, webvariants GbR, http://www.webvariants.de
 *
 * This file is released under the terms of the MIT license. You can find the
 * complete text in the attached LICENSE file or online at:
 *
 * http://www.opensource.org/licenses/mit-license.php
 */

extract($this->getServices());

$helpfile     = $pservice->baseDirectory($addon).DIRECTORY_SEPARATOR.'help.php';
$version      = $pservice->getVersion($addon);
$author       = $pservice->getAuthor($addon);
$requirements = $pservice->getRequirements($addon);
$dependencies = $pservice->getDependencies($addon);
$supportPage  = sly_Helper_Package::getSupportPage($addon);
$name         = str_replace('/', ' / ', $addon);

?>
<div class="sly-area sly-addon-help">
	<h2><?php echo t('addon_help', $name) ?></h2>

	<div class="sly-area-content">
		<?php if (!is_file($helpfile)): ?>
		<p><?php echo t('addon_help_file_not_found') ?></p>
		<?php else: ?>
		<?php include $helpfile ?>
		<?php endif ?>
		<dl>
			<dt><?php echo t('name') ?></dt>
			<dd><?php echo sly_html($name) ?></dd>

			<?php if ($version): ?>
			<dt><?php echo t('version') ?></dt>
			<dd><?php echo sly_html($version) ?></dd>
			<?php endif ?>

			<?php if ($supportPage): ?>
			<dt><?php echo t('author') ?></dt>
			<dd><?php echo $supportPage ?></dd>
			<?php elseif ($author): ?>
			<dt><?php echo t('author') ?></dt>
			<dd><?php echo sly_html($author) ?></dd>
			<?php endif ?>

			<?php if ($requirements): ?>
			<dt><?php echo t('requires') ?></dt>
			<dd><code class="sly-literal"><?php echo implode('</code>, <code class="sly-literal">', $requirements) ?></code></dd>
			<?php endif ?>

			<?php if ($dependencies): ?>
			<dt><?php echo t('required_by') ?></dt>
			<dd><code class="sly-literal"><?php echo implode('</code>, <code class="sly-literal">', $dependencies) ?></code></dd>
			<?php endif ?>
		</dl>
	</div>

	<div class="sly-area-footer">
		<p><a href="<?php print $_router->getUrl('credits') ?>"><?php echo t('back') ?></a></p>
	</div>
</div>
