function view_GET(Web &$w) { $p = $w->pathMatch("m", "a"); // first see if we need to split into sub modules $module = $p['m']; $action = $p['a']; // check if help is allowed for this topic if (!$w->Auth->allowed($p['m'] . '/' . $p['a'])) { $w->ctx("help_content", "Sorry, there is no help for this topic."); } $submodule = ""; // check for submodule if (strcontains($p['m'], array("-"))) { $ms = explode("-", $p['m']); $module = $ms[0]; $submodule = $ms[1]; } // find a module toc $tocf = getHelpFileContent($w, $module, null, $module . "_toc"); if ($tocf) { $w->ctx("module_toc", $module . '/' . $module . "_toc"); $w->ctx("module_title", HelpLib::extractTitle($tocf)); } // load help file $help_file = HelpLib::getHelpFilePath($w, $module, $submodule, $action); $content = "Sorry, this help topic is not yet written."; if (file_exists($help_file)) { $content = file_get_contents($help_file); } // set context $w->ctx("help_content", helpMarkup(pruneRestricted($w, $content), $module)); $w->ctx("module", $module); $w->ctx("submodule", $submodule); $w->ctx("action", $action); }
/** * Show a Table of Contents by searching * through all modules for the file * ./help/<module>_toc.help * * @param \Web $w */ function toc_GET(Web $w) { foreach ($w->modules() as $h) { $p = HelpLib::getHelpFilePath($w, $h, null, $h . "_toc"); if ($p) { $tocs[$h] = $p; } } foreach ($tocs as $module => $path) { if ($w->Auth->allowed($module . '/index')) { $content = file_get_contents($path); $title = HelpLib::extractTitle($content); $ul[] = Html::a(WEBROOT . '/help/view/' . $module . '/' . $module . '_toc', $title ? $title : ucfirst($module)); } } $w->ctx("ul", Html::ul($ul)); }