Ejemplo n.º 1
0
 protected function _check_local_urls()
 {
     $this->page->prefer_relative_urls = false;
     $local_url = $this->context->get_icon_url('{icons}/buttons/blank', Sixteen_px);
     $local_url_with_domain = $this->env->resolve_file($local_url, Force_root_on);
     $local_path = url_to_file_name($local_url_with_domain);
     $img = new IMAGE();
     $this->_set_image($img, $local_url_with_domain);
     $this->_check_equal($local_url_with_domain, $img->properties->url);
     $this->_check_equal($local_path, $img->properties->file_name);
     $this->_set_image($img, $local_url_with_domain, true);
     $this->_check_equal($local_url_with_domain, $img->properties->url);
     $this->_check_equal($local_path, $img->properties->file_name);
     $this->_set_image($img, $local_path);
     $relative_image_url = path_between($img->properties->url, $local_url, global_url_options());
     $this->_check_equal($local_url, $relative_image_url);
     $this->_check_equal($local_path, $img->properties->file_name);
     $relative_image_url = path_between($img->properties->url, $local_url, global_url_options());
     $this->_set_image($img, $local_path, true);
     $this->_check_equal($local_url, $relative_image_url);
     $this->_check_equal($local_path, $img->properties->file_name);
     /* Check non-existent local file. */
     $this->_set_image($img, $local_url_with_domain . '.does.not_exist');
     $this->_check_equal($local_url_with_domain . '.does.not_exist', $img->properties->url);
     $this->_check_equal('', $img->properties->file_name);
 }
Ejemplo n.º 2
0
 private function _test_path_between()
 {
     $this->_check_equal('./', path_between('/a/b/c/', '/a/b/c/'));
     $this->_check_equal('.', path_between('/a/b/c/', '/a/b/c'));
     $this->_check_equal('./', path_between('/a/b/c', '/a/b/c/'));
     $this->_check_equal('../', path_between('/a/b/c/', '/a/b/'));
     $this->_check_equal('..', path_between('/a/b/c/', '/a/b'));
     $this->_check_equal('../', path_between('/a/b/c', '/a/b/'));
     $this->_check_equal('../../', path_between('/a/b/c/', '/a/'));
     $this->_check_equal('../..', path_between('/a/b/c/', '/a'));
     $this->_check_equal('../../', path_between('/a/b/c', '/a/'));
     $this->_check_equal('c/', path_between('/a/b/', '/a/b/c/'));
     $this->_check_equal('c', path_between('/a/b/', '/a/b/c'));
     $this->_check_equal('c/', path_between('/a/b', '/a/b/c/'));
     $this->_check_equal('b/c/', path_between('/a/', '/a/b/c/'));
     $this->_check_equal('b/c', path_between('/a/', '/a/b/c'));
     $this->_check_equal('b/c/', path_between('/a', '/a/b/c/'));
     $this->_check_equal('../../b/c/', path_between('/a/d/c/', '/a/b/c/'));
     $this->_check_equal('../../b/c', path_between('/a/d/c/', '/a/b/c'));
     $this->_check_equal('../../b/c/', path_between('/a/d/c', '/a/b/c/'));
     $this->_check_equal('../b/c/', path_between('/a/d/', '/a/b/c/'));
     $this->_check_equal('../b/c', path_between('/a/d/', '/a/b/c'));
     $this->_check_equal('../b/c/', path_between('/a/d', '/a/b/c/'));
     $this->_check_equal('../c/d/', path_between('/a/b/e/', '/a/b/c/d/'));
     $this->_check_equal('../c/d', path_between('/a/b/e/', '/a/b/c/d'));
     $this->_check_equal('../c/d/', path_between('/a/b/e', '/a/b/c/d/'));
     $this->_check_equal('/e/b/c/', path_between('/a/d/c/', '/e/b/c/'));
     $this->_check_equal('/e/b/c', path_between('/a/d/c/', '/e/b/c'));
     $this->_check_equal('/e/b/c/', path_between('/a/d/c', '/e/b/c/'));
     $this->_check_equal('./', path_between('/a/b/c/', '/a/b/c/'));
     $this->_check_equal('.', path_between('/a/b/c/', '/a/./b/c'));
     $this->_check_equal('./', path_between('/a/b/c/', '/a/././b/c/'));
     $this->_check_equal('a/b/c/', path_between('/a/b/c/', 'a/b/c/'));
     $this->_check_equal('a/b/c', path_between('/a/b/c/', 'a/./b/c'));
     $this->_check_equal('a/b/c/', path_between('/a/b/c/', 'a/././b/c/'));
 }
Ejemplo n.º 3
0
 public function make_relative_to($url)
 {
     list($text, $args) = $this->_extract_resource_and_args();
     $this->_text = $this->_text_for_resource_and_args(path_between($url, $text), $args);
 }
Ejemplo n.º 4
0
 /**
  * Called on a fully-resolved URL before returning it.
  * If {@link $prefer_relative_urls} is True, the URL is made relative to the
  * current page.
  * @param string $url
  * @param boolean $root_override Overrides {@link $resolve_to_root} if set to {@link Force_root_on}.
  * @return string
  * @access private
  */
 protected function _finalize_url($url, $root_override)
 {
     $Result = parent::_finalize_url($url, $root_override);
     if ($this->prefer_relative_urls && $this->root_url && !$this->_needs_root($Result, $root_override)) {
         $Result = path_between($this->root_url, $Result, global_url_options());
         if ($Result == '') {
             $Result = '.';
         }
     }
     return $Result;
 }
Ejemplo n.º 5
0
 /**
  * Called from {@link restore_root_behavior()}.
  * @return boolean
  * @access private
  */
 protected function _default_resolve_to_root()
 {
     if ($this->env->running_on_declared_host()) {
         $app_url = $this->path_to(Folder_name_application);
         $curr_url = $this->env->url(Url_part_path);
         $opts = global_url_options();
         /* Remove the domain to prevent prepending a root that is
          * already defined in the environment.
          */
         $this->root_url = strip_domain(path_between($curr_url, $app_url, $opts), $opts);
     } else {
         $this->root_url = $this->path_to(Folder_name_application, Force_root_off);
     }
     return !empty($this->root_url);
 }