/** * Retrieve the redirection hostname. * * @return string */ public function getLinkHost() { if ($this->RedirectType === 'Page') { // Determine the home page URL when appropriate. if (($page = $this->getRedirectPage()) && ($link = $page->Link() === Director::baseURL() ? Controller::join_links(Director::baseURL(), 'home/') : $page->Link())) { // Determine whether a redirection hostname exists. return MisdirectionService::is_external_URL($link) ? parse_url($link, PHP_URL_HOST) : null; } } else { // Apply the regular expression pattern replacement. if ($link = $this->LinkType === 'Regular Expression' && $this->matchedURL ? preg_replace("%{$this->MappedLink}%i", $this->RedirectLink, $this->matchedURL) : $this->RedirectLink) { // Determine whether a redirection hostname exists. return MisdirectionService::is_external_URL($link) ? parse_url($link, PHP_URL_HOST) : null; } } // No redirection hostname has been found. return null; }
/** * Retrieve the redirection URL. * * @return string */ public function getLink() { if ($this->RedirectType === 'Page') { // Determine the home page URL when appropriate. if (($page = $this->getRedirectPage()) && ($link = $page->Link() === Director::baseURL() ? Controller::join_links(Director::baseURL(), 'home/') : $page->Link())) { return $link; } } else { // Apply the regular expression pattern replacement. if ($link = $this->LinkType === 'Regular Expression' && $this->matchedURL ? preg_replace("|{$this->MappedLink}|i", $this->RedirectLink, $this->matchedURL) : $this->RedirectLink) { // When appropriate, prepend the base URL to match a page redirection. return MisdirectionService::is_external_URL($link) ? $link : Controller::join_links(Director::baseURL(), $link); } } // No redirection URL has been found. return null; }