Ejemplo n.º 1
0
 /**
  * Make a URL from Lobby Base Path.
  * Eg: /hello to http://lobby.dev/hello
  */
 public static function u($path = null, $relative = false)
 {
     if (self::$cli) {
         return null;
     }
     /**
      * The $path var is changed during the process
      * So, original path is stored separately
      */
     $origPath = $path;
     /**
      * The return URL
      */
     $url = $path;
     /**
      * Prettyify $path
      */
     if ($path !== null) {
         $path = ltrim($path, "/");
         $parts = parse_url($path);
         /**
          * Make host along with port:
          * 127.0.0.1:9000
          */
         if (isset($parts['host'])) {
             $urlHost = $parts['host'] . (isset($parts['port']) ? ":{$parts['port']}" : "");
         } else {
             $urlHost = null;
         }
     }
     /**
      * If no path, give the current page URL
      */
     if ($path == null) {
         $pageURL = 'http';
         if (isset($_SERVER["HTTPS"]) && $_SERVER["HTTPS"] == "on") {
             $pageURL .= "s";
         }
         $pageURL .= "://";
         $requestURI = $relative === false ? Request::getRequestURI() : $_SERVER["REQUEST_URI"];
         if (isset($_SERVER["SERVER_PORT"]) && $_SERVER["SERVER_PORT"] != "80") {
             $pageURL .= $_SERVER["SERVER_NAME"] . ":" . $_SERVER["SERVER_PORT"] . $requestURI;
         } else {
             $pageURL .= $_SERVER["SERVER_NAME"] . $requestURI;
         }
         $url = $pageURL;
     } else {
         if ($path === self::$url) {
             $url = self::$url;
         } else {
             if (!preg_match("/http/", $path) || $urlHost !== self::$host) {
                 /**
                  * If $origPath is a relative URI
                  */
                 if ($urlHost == null) {
                     $url = self::$url . "/{$path}";
                 } else {
                     if (Apps::isAppRunning()) {
                         $url = Apps::getRunningInstance()->u($origPath);
                     }
                 }
             }
         }
     }
     return $url;
 }
Ejemplo n.º 2
0
    ?>
  <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 
});
Ejemplo n.º 3
0
 /**
  * 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>";
 }