Example #1
0
 /**
  * Does the path include a drive or domain?
  * @see has_domain()
  * @param string $domain If not empty, checks for the given domain only.
  * @return boolean
  */
 public function has_domain($domain = '')
 {
     return has_domain($this->_text, $domain, $this->options());
 }
Example #2
0
 /**
  * Determines whether the root needs to be prepended to the given url.
  * If the url already has a domain, if it starts with an {@link
  * $anchor_delimiter} (assumes the link will be resolvable in page context).
  * or if it starts with a delimiter and the root does not have a domain, no
  * root can be prepended. If the url is empty, the root can be prepended.
  *
  * @see _finalize_url()
  *
  * @param string $url The url to resolve.
  * @param bool $root_override If null, no override is applied; if true, the root is applied; otherwise, no root is applied.
  * @return boolean
  *
  * @access private
  */
 protected function _needs_root($url, $root_override)
 {
     /* Check that there is a root and that it is desired. */
     $Result = $this->root_url && ($this->resolve_to_root || !empty($root_override)) && !(isset($root_override) && !$root_override);
     /* Check that the url is empty or does not begin with an anchor. */
     if ($Result) {
         $Result = !$url || $url[0] != $this->anchor_delimiter;
     }
     /* Check that the root is not already present. */
     if ($Result) {
         $Result = strpos($url, $this->root_url) !== 0;
     }
     /* Check that the url does not already have a domain. */
     if ($Result) {
         $Result = !has_domain($url, '', $this->_url_options);
     }
     /* Check that the root has a domain or that the url does not begin
      * with a delimiter.
      */
     if ($Result) {
         $Result = has_domain($this->root_url, '', $this->_url_options) || !begins_with_delimiter($url, $this->_url_options);
     }
     return $Result;
 }