Improve module listing and implement help doc draft for tests

This commit is contained in:
Dennis Eichhorn 2018-07-06 20:45:15 +02:00
parent b9298cc624
commit 97c4484c0b
4 changed files with 92 additions and 1 deletions

View File

@ -23,6 +23,7 @@ use phpOMS\Utils\Parser\Markdown\Markdown;
use phpOMS\Module\ModuleAbstract;
use phpOMS\Module\WebInterface;
use phpOMS\Views\View;
use phpOMS\Message\Http\RequestStatusCode;
/**
* Help class.
@ -152,8 +153,30 @@ final class Controller extends ModuleAbstract implements WebInterface
*/
public function viewHelpModule(RequestAbstract $request, ResponseAbstract $response, $data = null) : \Serializable
{
$active = $this->app->moduleManager->getActiveModules();
if ($request->getData('id') === null || !isset($active[$request->getData('id')])) {
return $this->viewHelpModuleList();
}
$view = new View($this->app, $request, $response);
if ($request->getData('page') === 'table-of-contencts' || $request->getData('page') === null) {
$path = \realpath(__DIR__ . '/../' . $request->getData('id') . '/Docs/Help/en/table_of_contents.md');
} else {
$path = \realpath(__DIR__ . '/../' . $request->getData('id') . '/Docs/Help/en/' . $request->getData('page') . '.md');
}
if ($path === false) {
$view->setTemplate('/Web/Backend/Error/403_inline');
$response->getHeader()->setStatusCode(RequestStatusCode::R_403);
return $view;
}
$markdown = Markdown::parse(\file_get_contents($path));
$view->setTemplate('/Modules/Help/Theme/Backend/help-module');
$view->setData('content', $markdown);
return $view;
}

View File

@ -0,0 +1,16 @@
<?php
/**
* Orange Management
*
* PHP Version 7.2
*
* @package TBD
* @copyright Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link http://website.orange-management.de
*/
return ['Help' => [
'Modules' => 'Modules',
'Name' => 'Name',
]];

View File

@ -0,0 +1,52 @@
<?php
/**
* Orange Management
*
* PHP Version 7.2
*
* @package Modules\Admin\Template\Backend
* @copyright Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link http://website.orange-management.de
*/
/**
* @var \phpOMS\Views\View $this
*/
$modules = $this->app->moduleManager->getInstalledModules();
?>
<div class="row">
<div class="col-xs-12">
<div class="box wf-100">
<table class="table red">
<caption><?= $this->getHtml('Modules') ?></caption>
<thead>
<tr>
<td class="wf-100"><?= $this->getHtml('Name') ?>
<tfoot>
<tr>
<td>
<tbody>
<?php $count = 0; foreach ($modules as $key => $module) :
if ((\realpath(__DIR__ . '/../../../' . $module['directory'] . '/Docs/Help/en/table_of_contents.md')) === false) {
continue;
}
$count++;
$url = \phpOMS\Uri\UriFactory::build(
'/{/lang}/backend/help/module/single?id={$module}',
['$module' => $module['name']['internal']]
); ?>
<tr data-href="<?= $url; ?>">
<td data-label="<?= $this->getHtml('Name') ?>"><a href="<?= $url; ?>"><?= $this->printHtml($module['name']['external']); ?></a>
<?php endforeach; ?>
<?php if ($count === 0) : ?>
<tr><td class="empty"><?= $this->getHtml('Empty', 0, 0); ?>
<?php endif; ?>
</table>
</div>
</div>
</div>

View File

@ -3,7 +3,7 @@
<section class="box wf-100">
<div class="inner">
<article>
<?= $this->getData('markdown'); ?>
<?= $this->getData('content'); ?>
</article>
</div>
</section>