3 namespace app\Controller
;
8 class Wikipage
implements Controller
10 const WIKI_PATH
= "../vendor/m6w6/pharext.wiki/";
13 function __construct(Web
$app) {
15 $app->getView()->addData([
16 "pages" => $this->wikiPages()
20 function __invoke(array $args = null) {
21 $title = $args["page"];
22 $page = $this->wikiPath($args["page"]);
23 $this->app
->display("pages/wiki", compact("title", "page"));
26 function wikiPages() {
27 return array_filter(array_map(function($s) {
28 return strtr(basename($s, ".md"), "-", " ");
29 }, scandir(self
::WIKI_PATH
)), function($s) {
33 function wikiPath($page) {
34 $file = basename(strtr($page, " ", "-"), ".md") . ".md";
35 return self
::WIKI_PATH
. $file;