/** * Define some pages by default */ public static function defaults() { /** * Route App Pages (/app/{appname}/{page}) to according apps */ self::route("/app/[:appID]?/[**:page]?", function ($request) { $AppID = $request->appID; $page = $request->page != "" ? "/{$request->page}" : "/"; /** * Check if App exists */ $App = new \Lobby\Apps($AppID); if ($App->exists && $App->enabled) { $class = $App->run(); $AppInfo = $App->info; /** * Set the title */ Response::setTitle($AppInfo['name']); /** * Add the App item to the navbar */ \Lobby\UI\Panel::addTopItem("lobbyApp{$AppID}", array("text" => $AppInfo['name'], "href" => $AppInfo['url'], "subItems" => array("app_admin" => array("text" => "Admin", "href" => "/admin/apps.php?app={$AppID}"), "app_disable" => array("text" => "Disable", "href" => "/admin/apps.php?action=disable&app={$AppID}" . \CSRF::getParam()), "app_remove" => array("text" => "Remove", "href" => "/admin/apps.php?action=remove&app={$AppID}" . \CSRF::getParam())), "position" => "left")); $pageResponse = $class->page($page); if ($pageResponse === "auto") { if ($page === "/") { $page = "/index"; } if (is_dir($class->fs->loc("src/page{$page}"))) { $page = "{$page}/index"; } $html = $class->inc("/src/page{$page}.php"); if ($html) { Response::setPage($html); } else { ser(); } } else { if ($pageResponse === null) { ser(); } else { Response::setPage($pageResponse); } } } else { echo ser(); } }); /** * Dashboard Page * The main Page. Add CSS & JS accordingly */ self::route("/", function () { Response::setTitle("Dashboard"); \Lobby\UI\Themes::loadDashboard("head"); Response::loadPage("/includes/lib/lobby/inc/dashboard.php"); }); }
public function init() { if (\Lobby::status("lobby.assets-serve") === false) { $this->install(); $this->routes(); require_once $this->app->dir . "/src/inc/load.php"; if (LS::$loggedIn) { /** * Logged In */ Hooks::addAction("init", function () { /** * Add Change Password Item in Top Panel -> Admin before Log Out item * This is done by first removing the Log Out item, adding the Change * Password item and then adding back the Log Out item */ \Lobby\UI\Panel::addTopItem('adminModule', array("text" => "<img src='" . $this->app->srcURL . "/src/image/logo.svg' style='width: 40px;height: 40px;' />", "href" => "/", "position" => "left", "subItems" => array("changePassword" => array("text" => "Change Password", "href" => "/app/admin/change-password"), 'LogOut' => array("text" => "Log Out", "href" => "/app/admin/logout")))); }); } else { /** * If `indi` module is active, make the index page available to everyone */ if (!Modules::exists("app_indi")) { if (\Lobby::curPage() != "/admin/login" && !\Lobby::status("lobby.install")) { \Response::redirect("/admin/login"); } } else { Panel::removeTopItem("indiModule", "left"); if (\Lobby::curPage() != "/admin/login" && \Lobby::curPage() != "/admin/install.php" && substr(\Lobby::curPage(), 0, 6) == "/admin") { \Response::redirect("/admin/login"); } } Hooks::addFilter("panel.left.items", function ($left) { unset($left["lobbyAdmin"]); if (Modules::exists("app_indi")) { unset($left["indiModule"]); } return $left; }); Assets::removeJS("notify"); Assets::removeCSS("notify"); } } }
<?php use Lobby\UI\Panel; /** * Panel UI */ $panelLeftItems = Panel::getPanelItems("left"); $panelRightItems = Panel::getPanelItems("right"); ?> <nav> <ul class="left"> <?php if (isset($panelLeftItems["lobbyAdmin"])) { echo $this->makePanelTree("lobbyAdmin", $panelLeftItems["lobbyAdmin"]); unset($panelLeftItems["lobbyAdmin"]); } $html = ""; foreach ($panelLeftItems as $id => $item) { if (count($item['subItems']) !== 0) { $html .= $this->makePanelTree($id, $item); } else { if ($item['html'] != null) { $html .= $this->makePanelItem($item['html'], "htmlContent", $id, "parent"); } else { $html .= $this->makePanelItem($item['text'], $item['href'], $id, "parent"); } } } echo $html; ?> </ul>
/** * Remove a notify item */ public function removeNotifyItem($id) { return \Lobby\UI\Panel::removeNotifyItem("app_{$this->id}_{$id}"); }
/** * Define some pages by default */ public static function defaults() { /** * Route App Pages (/app/{appname}/{page}) to according apps */ self::route("/app/[:appID]?/[**:page]?", function ($request) { $AppID = $request->appID; $GLOBALS['AppID'] = $AppID; $page = $request->page != "" ? "/{$request->page}" : "/"; /** * Check if App exists */ $App = new \Lobby\Apps($AppID); if ($App->exists && $App->isEnabled() && substr($page, 0, 7) != "/Admin/") { $class = $App->run(); $AppInfo = $App->info; /** * Set the title */ \Lobby::setTitle($AppInfo['name']); /** * Add the App item to the navbar */ \Lobby\UI\Panel::addTopItem("lobbyApp{$AppID}", array("text" => $AppInfo['name'], "href" => APP_URL, "position" => "left")); $page_response = $class->page($page); if ($page_response == "auto") { if ($page == "/") { $page = "/index"; } $GLOBALS['workspaceHTML'] = $class->inc("/src/Page{$page}.php"); } else { $GLOBALS['workspaceHTML'] = $page_response; } if ($GLOBALS['workspaceHTML'] == null) { ser(); } } else { ser(); } }); /** * Dashboard Page * The main Page. Add CSS & JS accordingly */ self::route("/", function () { \Lobby::setTitle("Dashboard"); \Lobby\UI\Themes::loadDashboard("head"); $GLOBALS['workspaceHTML'] = array("/includes/lib/core/Inc/dashboard.php"); }); /** * Administration */ self::route("/admin/app/[:appID]?/[**:page]?", function ($request) { $AppID = $request->appID; $GLOBALS['AppID'] = $AppID; $page = $request->page != "" ? "/Admin/{$request->page}" : "/Admin/index"; /** * Check if App exists */ $App = new \Lobby\Apps($AppID); if ($App->exists && $App->isEnabled()) { /** * Redirect /src/ files to App's Source in /contents folder */ $class = $App->run(); $AppInfo = $App->info; /** * Set the title */ \Lobby::setTitle($AppInfo['name']); /** * Add the App item to the navbar */ \Lobby\UI\Panel::addTopItem("lobbyApp{$AppID}", array("text" => "Admin > " . $AppInfo['name'], "href" => "/admin/app/{$AppID}", "position" => "left")); $page_response = $class->page($page); if ($page_response == "auto") { if ($page == "/") { $page = "/index"; } $GLOBALS['workspaceHTML'] = $class->inc("/src/Page{$page}.php"); } else { $GLOBALS['workspaceHTML'] = $page_response; } if ($GLOBALS['workspaceHTML'] === false || $GLOBALS['workspaceHTML'] == null) { ob_start(); ser("Error", "The app '<strong>{$AppID}</strong>' does not have an Admin Page"); $error = ob_get_contents(); ob_end_clean(); $GLOBALS['workspaceHTML'] = "<div class='contents'>" . $error . "</div>"; } } }); }
<?php /** * Add the <head> files if it's not the install page */ if (!\Lobby::status("lobby.install")) { /** * Left Menu */ \Lobby\UI\Panel::addTopItem("lobbyHome", array("text" => "Home", "href" => L_URL, "position" => "left")); $adminArray = array("text" => "Admin", "href" => "/admin", "position" => "left"); $adminArray["subItems"] = array("app_manager" => array("text" => "Apps", "href" => "/admin/apps.php"), "lobby_store" => array("text" => "Lobby Store", "href" => "/admin/lobby-store.php"), "about" => array("text" => "Settings", "href" => "/admin/settings.php")); \Lobby\UI\Panel::addTopItem("lobbyAdmin", $adminArray); if (\Lobby\FS::exists("/upgrade.lobby")) { require_once L_DIR . "/includes/src/Update.php"; $l_info = json_decode(\Lobby\FS::get("/lobby.json")); if ($lobby_version != $l_info->version) { Lobby\DB::saveOption("lobby_latest_version", $l_info->version); Lobby\DB::saveOption("lobby_latest_version_release", $l_info->released); } \Lobby\Update::finish_software_update(); } } if (\Lobby::status("lobby.admin")) { /** * Add Admin Pages' stylesheet, script */ \Assets::js("admin", "/admin/js/admin.js"); /** * Add sidebar */
public function menu_items() { $this->addStyle("style.css"); \Lobby\UI\Panel::addTopItem("lobbyDownload", array("position" => "left", "text" => "<span class='btn red' style='margin:0;padding: 0 10px;'>Download</span>", "href" => "/download")); \Lobby\UI\Panel::addTopItem("lobbyWeb", array("position" => "left", "text" => "<span class='btn purple' style='margin:0;padding: 0 10px;'>Demo</span>", "href" => "/web-readme")); \Lobby\UI\Panel::addTopItem("lobbyApps", array("position" => "left", "text" => "<span class='btn green' style='margin:0;padding: 0 10px;'>Apps</span>", "href" => "/apps")); \Lobby\UI\Panel::addTopItem("lobbyDocs", array("position" => "left", "text" => "<span class='btn' style='margin:0;padding: 0 10px;'>Docs</span>", "href" => "/docs", "subItems" => array("mods" => array("text" => "Modules", "href" => "/mods"), "install_apps" => array("text" => "Install Apps", "href" => "/docs/install-app"), "dev_docs" => array("text" => "Developer", "href" => "/docs/dev")))); require_once $this->dir . "/src/inc/logsys.php"; $meSubItems = array(); if (\Fr\LS2::$loggedIn) { $meSubItems["Profile"] = array("text" => "My Profile", "href" => "/u/" . \Fr\LS2::$user); $meSubItems["EditProfile"] = array("text" => "Edit Profile", "href" => "/me/profile"); $meSubItems["SubmitApp"] = array("text" => "Submit App", "href" => "/me/app"); $meSubItems["LogOut"] = array("text" => "Log Out", "href" => "/me/login?logout"); } else { $meSubItems["LogIn"] = array("text" => "Log In", "href" => "/me/login"); } \Lobby\UI\Panel::addTopItem("lobbyUser", array("position" => "right", "text" => \Fr\LS2::$loggedIn ? \Fr\LS2::getUser("display_name") : "Me", "href" => "/me", "subItems" => $meSubItems)); }
* "Update Available" icon on the right side of panel */ $AppUpdates = json_decode(getOption("app_updates"), true); $lobby_version = getOption("lobby_version"); $latestVersion = getOption("lobby_latest_version"); if (\Lobby\FS::exists("/upgrade.lobby")) { require_once L_DIR . "/includes/src/Update.php"; $l_info = json_decode(\Lobby\FS::get("/lobby.json")); if ($lobby_version != $l_info->version) { saveOption("lobby_latest_version", $l_info->version); saveOption("lobby_latest_version_release", $l_info->released); } \Lobby\Update::finish_software_update(); } if (count($AppUpdates) != 0 || $latestVersion && $lobby_version != $latestVersion) { \Lobby\UI\Panel::addTopItem("updateNotify", array("html" => \Lobby::l("/admin/update.php", "<span id='update' title='An Update Is Available'></span>"), "position" => "right")); } } if (\Lobby::status("lobby.install")) { \Lobby::addStyle("admin", "/includes/lib/core/CSS/admin.css"); } if (\Lobby::status("lobby.admin")) { /** * Add Admin Pages' stylesheet */ \Lobby::addStyle("admin", "/includes/lib/core/CSS/admin.css"); /** * Check For New Versions (Apps & Core) */ if (\Lobby::$config['server_check'] === true && !isset($_SESSION['checkedForLatestVersion'])) { \Lobby\Server::check();
public function init() { $appID = $this->app->getData("appID"); $this->appAdminSetup(); if ($appID === null) { return null; } $App = new Apps($appID); $App->run(); Hooks::addAction("router.finish", function () { /** * Route App Pages (/app/{appname}/{page}) to according apps */ Router::route("/?[*:page]?", function ($request) { $appID = Apps::getInfo("id"); $page = $request->page === null ? "/" : "/{$request->page}"; if (substr($page, 0, 6) == "/admin") { return false; } else { $App = new \Lobby\Apps($appID); $class = $App->getInstance(); /** * Set the title */ Response::setTitle($App->info["name"]); $pageResponse = $class->page($page); if ($pageResponse === "auto") { if ($page === "/") { $page = "/index"; } $html = $class->inc("/src/page{$page}.php"); if ($html) { Response::setPage($html); } else { ser(); } } else { if ($pageResponse === null) { ser(); } else { Response::setPage($pageResponse); } } } }); }); Router::route("/app/[:appID]?/[**:page]?", function ($request) { if ($request->appID === "admin") { Response::redirect("admin/app/admin/{$page}" . $request->page); } ser(); }); /** * Disable FilePicker Module */ if (\Lobby\Modules::exists("filepicker")) { \Lobby\Modules::disableModule("filepicker"); } Router::route("/includes/lib/modules?/[**:page]?", function ($request) { ser(); }); \Lobby\UI\Panel::addTopItem('indiModule', array("text" => "<img src='" . $this->app->srcURL . "/src/image/logo.svg' />", "href" => "/admin/app/indi", "position" => "left", "subItems" => array("appAdmin" => array("text" => "App Admin", "href" => "/admin/app/{$appID}"), "configIndi" => array("text" => "Configure Indi", "href" => "/admin/app/indi")))); }
$panelLeftItems = \Lobby\UI\Panel::getPanelItems("left"); ?> <div class="panel top"> <ul class="left"> <?php echo $this->makePanelTree("lobbyAdmin", $panelLeftItems["lobbyAdmin"]); unset($panelLeftItems["lobbyAdmin"]); ?> <?php $html = ""; foreach ($panelLeftItems as $id => $item) { if (!isset($item['subItems'])) { if (!isset($item['text']) && isset($item['html'])) { $html .= $this->makePanelItem($item['html'], "htmlContent", $id, "prnt"); } else { $html .= $this->makePanelItem($item['text'], $item['href'], $id, "prnt"); } } else { $html .= $this->makePanelTree($id, $item); } } echo $html; ?> </ul> <ul class="right"> <?php \Lobby\UI\Panel::getPanelItems("right"); ?> </ul> </div>
/** * Get updates */ public static function check() { $url = self::$apiURL . "/lobby/updates"; $apps = Apps::getApps(); try { $response = \Requests::post($url, array(), self::makeData(array("apps" => implode(",", $apps))))->body; } catch (\Requests_Exception $error) { \Lobby::log("Checkup with server failed ({$url}) : {$error}"); $response = false; } if ($response) { $response = json_decode($response, true); if (is_array($response)) { DB::saveOption("lobby_latest_version", $response['version']); DB::saveOption("lobby_latest_version_release", $response['released']); DB::saveOption("lobby_latest_version_release_notes", $response['release_notes']); if (isset($response['apps']) && count($response['apps']) != 0) { $AppUpdates = array(); foreach ($response['apps'] as $appID => $version) { $App = new \Lobby\Apps($appID); if ($App->hasUpdate($version)) { $AppUpdates[$appID] = $version; } } DB::saveOption("app_updates", json_encode($AppUpdates)); } if (isset($response["notify"])) { foreach ($response["notify"]["items"] as $itemID => $item) { if (isset($item["href"])) { $item["href"] = \Lobby::u($item["href"]); } Panel::addNotifyItem("lobby_server_msg_" . $itemID, $item); } foreach ($response["notify"]["remove_items"] as $itemID) { Panel::removeNotifyItem("lobby_server_msg_" . $itemID); } } } } }