예제 #1
0
파일: Router.php 프로젝트: saviobosco/lobby
 /**
  * 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>";
             }
         }
     });
 }
예제 #2
0
파일: Router.php 프로젝트: LobbyOS/server
 /**
  * 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");
     });
 }
예제 #3
0
<?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);
}