/** * Make links which include the current HTTP host relative, even if the scheme doens't match. * * Internal links within text are stored as relative links so that if a site moves host * or the database is copied to another site (e.g. development or staging versions) * the links will still work correctly. * * @param string $text * * @return string */ public static function makeInternalLinksRelative($text) { if ($base = Request::getHttpHost()) { return preg_replace("|<(.*?)href=(['\"])(https?://)" . $base . "/(.*?)(['\"])(.*?)>|", '<$1href=$2/$4$5$6>', $text); } return $text; }
public static function factory($link) { $link = preg_replace('|^https?://' . Request::getHttpHost() . '|', '', $link); if (is_int($link) || ctype_digit($link) || substr($link, 0, 1) == '/') { $internal = new Internal($link); // If it's not a valid CMS URL then it's a relative URL which isn't CMS managed so treat it as an external URL. return $internal->isValidPage() ? $internal : new External($link); } else { return new External($link); } }
/** * Bind data to the view. * * @param View $view * @return void */ public function compose(View $view) { // Are we connecting from a known URL? if ($airline = Airline::where('url', '=', Request::getHttpHost())->first()) { Session::put('airlineId', $airline->id); } if (Session::has('airlineId')) { $view->with('airline', Airline::find(Session::get('airlineId'))); } if (Request::user()) { $view->with('user', Request::user()); $view->with('pilot', PilotRepository::getCurrentPilot()); $airline = Airline::find(Session::get('airlineId')); $view->with('airlineStaff', UserRepository::hasRole($airline->prefix . '-staff', Request::user())); } }
public static function makeRelative($url) { return ($base = Request::getHttpHost()) ? str_replace(Request::getScheme() . $base, '/', $url) : $url; }
public static function makeRelative($url) { return preg_replace('|^https?://' . Request::getHttpHost() . '|', '', $url); }