forked from kohler/hotcrp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhelp.php
73 lines (62 loc) · 2.23 KB
/
help.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<?php
// help.php -- HotCRP help page
// Copyright (c) 2006-2020 Eddie Kohler; see LICENSE.
require_once("src/initweb.php");
$help_topics = new GroupedExtensions($Me, [
'{"name":"topics","title":"Help topics","position":-1000000,"priority":1000000,"render_callback":"show_help_topics"}',
"etc/helptopics.json"
], $Conf->opt("helpTopics"));
if (!$Qreq->t && preg_match('/\A\/\w+\/*\z/i', $Qreq->path())) {
$Qreq->t = $Qreq->path_component(0);
}
$topic = $Qreq->t ? : "topics";
$want_topic = $help_topics->canonical_group($topic);
if (!$want_topic) {
$want_topic = "topics";
}
if ($want_topic !== $topic) {
$Conf->redirect_self($Qreq, ["t" => $want_topic]);
}
$topicj = $help_topics->get($topic);
$Conf->header("Help", "help", ["title_div" => '<hr class="c">', "body_class" => "leftmenu"]);
$hth = new HelpRenderer($help_topics, $Me);
function show_help_topics($hth) {
echo "<dl>\n";
foreach ($hth->groups() as $ht) {
if ($ht->name !== "topics" && isset($ht->title)) {
echo '<dt><strong><a href="', $hth->conf->hoturl("help", "t=$ht->name"), '">', $ht->title, '</a></strong></dt>';
if (isset($ht->description))
echo '<dd>', get($ht, "description", ""), '</dd>';
echo "\n";
}
}
echo "</dl>\n";
}
echo '<div class="leftmenu-left"><nav class="leftmenu-menu"><h1 class="leftmenu">';
if ($topic !== "topics") {
echo '<a href="', $Conf->hoturl("help"), '" class="qq uic js-leftmenu">Help</a>';
} else {
echo "Help";
}
echo '</h1><ul class="leftmenu-list">';
$gap = false;
foreach ($help_topics->groups() as $gj) {
if (isset($gj->title)) {
echo '<li class="leftmenu-item',
($gap ? " leftmenu-item-gap3" : ""),
($gj->name === $topic ? ' active">' : ' ui js-click-child">');
if ($gj->name === $topic) {
echo $gj->title;
} else {
echo Ht::link($gj->title, $Conf->hoturl("help", "t=$gj->name"));
}
echo '</li>';
$gap = $gj->name === "topics";
}
}
echo "</ul></nav></div>\n",
'<main id="helpcontent" class="leftmenu-content main-column">',
'<h2 class="leftmenu">', $topicj->title, '</h2>';
$hth->render_group($topic, true);
echo "</main>\n";
$Conf->footer();