예제 #1
0
파일: url.php 프로젝트: simudream/caffeine
 /**
  * Returns the relative url to the base of the application, including any sub-directories.
  * If a base url exists, it will start with a slash "/", otherwise the base will be an empty string.
  */
 public static function base($includeLang = true)
 {
     if (is_null(self::$_base)) {
         $bits = explode('index.php', $_SERVER['SCRIPT_NAME']);
         self::$_base = isset($bits[0]) ? rtrim($bits[0], '/') : '';
         if ($lang = Multilanguage::getCurrentLang()) {
             self::$_lang = $lang->code;
         }
     }
     if ($includeLang && !is_null(self::$_lang)) {
         return self::$_base . '/' . self::$_lang;
     }
     return self::$_base;
 }