Skip to content

Commit

Permalink
add docs
Browse files Browse the repository at this point in the history
  • Loading branch information
alxndr-w committed Aug 18, 2024
1 parent e629710 commit fd77183
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
Empty file added docs/01_intro.md
Empty file.
48 changes: 48 additions & 0 deletions pages/docs.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?php

/**
* @var rex_addon $this
* @psalm-scope-this rex_addon
*/

$mdFiles = [];
foreach (glob(rex_addon::get('blaupause')->getPath('docs') . '/*.md') ?: [] as $file) {
$mdFiles[mb_substr(basename($file), 0, -3)] = $file;
}

$currenMDFile = rex_request('mdfile', 'string', '01_intro');
if (!array_key_exists($currenMDFile, $mdFiles)) {
$currenMDFile = '01_a_intro';
}

$page = rex_be_controller::getPageObject('blaupause/docs');

if (null !== $page) {
foreach ($mdFiles as $key => $mdFile) {
$keyWithoudPrio = mb_substr($key, 3);
$currenMDFileWithoudPrio = mb_substr($currenMDFile, 3);
$page->addSubpage(
(new rex_be_page($key, rex_i18n::msg('blaupause_docs_' . $keyWithoudPrio)))
->setSubPath($mdFile)
->setHref('index.php?page=blaupause/docs&mdfile=' . $key)
->setIsActive($key == $currenMDFile),
);
}
}

echo rex_view::title($this->i18n('blaupause_title'));

[$Toc, $Content] = rex_markdown::factory()->parseWithToc(rex_file::require($mdFiles[$currenMDFile]), 2, 3, [
rex_markdown::SOFT_LINE_BREAKS => false,
rex_markdown::HIGHLIGHT_PHP => true,
]);

$fragment = new rex_fragment();
$fragment->setVar('content', $Content, false);
$fragment->setVar('toc', $Toc, false);
$content = $fragment->parse('core/page/docs.php');

$fragment = new rex_fragment();
$fragment->setVar('title', rex_i18n::msg('package_help') . ' ', false);
$fragment->setVar('body', $content, false);
echo $fragment->parse('core/page/section.php');

0 comments on commit fd77183

Please sign in to comment.