예제 #1
0
파일: Module.php 프로젝트: LobbyOS/server
 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"))));
 }
예제 #2
0
파일: init.php 프로젝트: LobbyOS/server
    ?>
  <script>
    window.tmp = {};
    window.lobbyExtra = {
      url: "<?php 
    echo L_URL;
    ?>
",
      csrfToken: "<?php 
    echo CSRF::get();
    ?>
",
      sysInfo: {
        os: "<?php 
    echo \Lobby::getSysInfo("os");
    ?>
"
      }
    };
    <?php 
    if (\Lobby\Apps::isAppRunning()) {
        echo 'window.lobbyExtra["app"] = {
        id: "' . \Lobby\Apps::getInfo("id") . '",
        url: "' . \Lobby\Apps::getInfo("url") . '",
        src: "' . \Lobby\Apps::getInfo("srcURL") . '"
      };';
    }
    ?>
</script>
<?php 
});
예제 #3
0
파일: Response.php 프로젝트: LobbyOS/server
 /**
  * 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>";
 }