/** * 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>"; } } }); }
/** * 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"); }); }
<?php /** * Get installed apps and make the tiles on dashboard */ $apps = \Lobby\Apps::getEnabledApps(); if (count($apps) == 0) { echo ser("No Apps", "You haven't enabled or installed any apps. <br/>Get great Apps from " . \Lobby::l("/admin/lobby-store.php", "Lobby Store")); } else { $dashboard_items = array("apps" => array()); foreach ($apps as $app => $null) { $App = new \Lobby\Apps($app); $data = $App->info; $dashboard_items["apps"][$app] = $data; } \Lobby\UI\Themes::loadDashboard($dashboard_items); }
/** * Get the manifest info of app as array */ private function setInfo() { $manifest = FS::exists($this->dir . "/manifest.json") ? FS::get($this->dir . "/manifest.json") : false; if ($manifest) { $details = json_decode($manifest, true); $details = array_replace_recursive(self::$manifestConfig, $details); /** * Add extra info with the manifest info */ $details['id'] = $this->app; $details['dir'] = $this->dir; $details['url'] = Lobby::getURL() . "/app/{$this->app}"; $details['srcURL'] = Lobby::getURL() . "/contents/apps/{$this->app}"; $details['adminURL'] = Lobby::getURL() . "/admin/app/{$this->app}"; /** * Prefer SVG over PNG */ $details['logo'] = $details['logo'] !== false ? FS::exists($this->dir . "/src/image/logo.svg") ? self::$appsURL . "/{$this->app}/src/image/logo.svg" : self::$appsURL . "/{$this->app}/src/image/logo.png" : Themes::getThemeURL() . "/src/main/image/app-logo.png"; $details["latestVersion"] = isset(self::$appUpdates[$this->app]) ? self::$appUpdates[$this->app] : null; $details = \Hooks::applyFilters("app.manifest", $details); /** * Insert the info as a property */ $this->info = $details; /** * Whether app is enabled */ $this->enabled = in_array($this->app, self::getEnabledApps(), true); return $details; } else { return false; } }
} } /** * Load Dashboard */ public static function loadDashboard($dashboard_items) { if ($dashboard_items == "head") { $GLOBALS["THEME_OBJ"]->dashboard(); } else { echo $GLOBALS["THEME_OBJ"]->inc("/Dashboard/load.php"); } } /** * Check if a theme is valid */ public static function validTheme($theme) { $valid = false; $loc = THEMES_DIR . "/{$theme}"; /** * Does the "Theme.php" file in theme directory exist ? */ if (file_exists("{$loc}/Dashboard/load.php") && file_exists("{$loc}/Panel/load.php")) { $valid = true; } return $valid; } } \Lobby\UI\Themes::init();
<?php require "../load.php"; $install_step = Request::get('step'); ?> <!DOCTYPE html> <html> <head> <?php \Lobby\UI\Themes::loadTheme(); \Hooks::doAction("head.begin"); /** * Install Head */ \Assets::css("install", "/admin/css/install.css"); \Assets::js("install", "/admin/js/install.js"); \Response::head("Install"); \Hooks::doAction("head.end"); ?> </head> <body id="workspace"> <div class="contents" id="<?php $steps = array("1", "2", "3", "4"); if (in_array($install_step, $steps)) { echo "step{$install_step}"; } ?> "> <h1 style="text-align: center;"> <?php echo \Lobby::l(L_URL, "Install Lobby");
/** * Print the <head> tag */ public static function head($title = "") { header('Content-type: text/html; charset=utf-8'); if ($title != "") { self::setTitle($title); } if (Assets::issetJS('jquery')) { /** * Load jQuery, jQuery UI, Lobby Main, App separately without async */ $url = L_URL . "/includes/serve-assets.php?type=js&assets=" . implode(",", array(Assets::getJS('jquery'), Assets::getJS('jqueryui'), Assets::getJS('main'), Assets::issetJS('app') ? Assets::getJS('app') : "")); echo "<script src='{$url}'></script>"; Assets::removeJS("jquery"); Assets::removeJS("jqueryui"); Assets::removeJS("main"); } $jsURLParams = array("THEME_URL" => Themes::getThemeURL()); if (Apps::isAppRunning()) { $jsURLParams["APP_URL"] = urlencode(Apps::getInfo("url")); $jsURLParams["APP_SRC"] = urlencode(Apps::getInfo("srcURL")); } $jsURL = Assets::getServeURL("js", $jsURLParams); echo "<script>lobby.load_script_url = '" . $jsURL . "';</script>"; $cssServeParams = array("THEME_URL" => THEME_URL); /** * CSS Files */ if (Apps::isAppRunning()) { $cssServeParams["APP_URL"] = urlencode(Apps::getInfo("url")); $cssServeParams["APP_SRC"] = urlencode(Apps::getInfo("srcURL")); } echo Assets::getServeLinkTag($cssServeParams); echo "<link href='" . L_URL . "/favicon.ico' sizes='16x16 32x32 64x64' rel='shortcut icon' />"; /* Title */ echo "<title>" . self::$title . "</title>"; }