/** * Walk a JSON tree to import a hierarchy of menus */ private static function importRecurse($entry, $depth) { if (isset($entry->menu)) { $entry = $entry->menu; } // Skip right past these if (!is_array($entry)) { $link = $entry->link; $href = $entry->href; if (is_string($href)) { return new \Tsugi\UI\MenuEntry($link, $href); } $submenu = self::importRecurse($href, $depth + 1); return new \Tsugi\UI\MenuEntry($link, $submenu); } $submenu = new \Tsugi\UI\Menu(); foreach ($entry as $child) { $submenu->add(self::importRecurse($child, $depth + 1)); } return $submenu; }
function defaultMenuSet() { global $CFG; $R = $CFG->wwwroot . '/'; $set = new \Tsugi\UI\MenuSet(); $set->setHome($CFG->servicename, $CFG->apphome); if ($CFG->DEVELOPER) { $set->addLeft('Developer', $R . 'dev.php'); } if (isset($_SESSION['id']) || $CFG->DEVELOPER) { $set->addLeft('Admin', $R . 'admin/index.php'); } $submenu = new \Tsugi\UI\Menu(); $submenu->addLink('IMS LTI Documentation', 'http://developers.imsglobal.org/')->addLink('IMS LTI 1.1 Spec', 'http://www.imsglobal.org/LTI/v1p1p1/ltiIMGv1p1p1.html')->addLink('IMS LTI 2.0 Spec', 'http://www.imsglobal.org/lti/ltiv2p0/ltiIMGv2p0.html')->addLink('Tsugi Developer Site', 'https://github.com/csev/tsugi/blob/master/docs/DEVELOP.md')->addlink('Tsugi YouTube Channel', 'https://www.youtube.com/playlist?list=PLlRFEj9H3Oj5WZUjVjTJVBN18ozYSWMhw'); $set->addLeft('Links', $submenu); if (isset($_SESSION['id'])) { $submenu = new \Tsugi\UI\Menu(); $submenu->addLink('Profile', $R . 'profile.php')->addLink('Use this Service', $R . 'admin/key/index.php')->addLink('Logout', $R . 'logout.php'); $set->addRight(htmlentities($_SESSION['displayname']), $submenu); } else { $set->addRight('Login', $R . 'login.php'); } $set->addRight('<img style="width:4em;" src="' . $CFG->staticroot . '/img/logos/tsugi-logo.png' . '">', $R . 'about.php'); return $set; }