Example #1
0
 /**
  * Returns the URL where the link goes.
  *
  * @return String The linked URL.
  */
 public function href()
 {
     $url = $this->node->attr('href');
     if ($this->url) {
         $deriver = new AbsoluteUrlDeriver();
         $deriver->init($url, $this->url);
         $url = $deriver->getAbsoluteUrl();
     }
     return $url;
 }
Example #2
0
 /**
  * Make URLs absolute
  */
 private function makeUrlsAbsolute()
 {
     foreach ($this->images as $key => &$image) {
         // Make sure we have an absolute URL
         $absoluteUrl = new AbsoluteUrlDeriver($image->getUrl(), $this->document->getUrl());
         $image->setUrl((string) $absoluteUrl->getAbsoluteUrl());
     }
 }
 /**
  * 
  * @param WebPage $webPage
  * @return array
  */
 private function findStylesheetUrls(WebPage $webPage)
 {
     $stylesheetUrls = array();
     $hrefs = $this->findStylesheetHrefs($webPage);
     foreach ($hrefs as $href) {
         $absoluteUrlDeriver = new AbsoluteUrlDeriver($href, $webPage->getUrl());
         $stylesheetUrl = (string) $absoluteUrlDeriver->getAbsoluteUrl();
         if (!in_array($stylesheetUrl, $stylesheetUrls)) {
             $stylesheetUrls[] = $stylesheetUrl;
         }
     }
     return $stylesheetUrls;
 }
 protected function assertDerivedUrl($testData = array())
 {
     $this->deriver->init($testData['non-absolute-url'], $testData['source-url']);
     $this->assertEquals($testData['expected-derived-url'], (string) $this->deriver->getAbsoluteUrl(), 'Expected derived URL "' . $testData['expected-derived-url'] . '" not formed from non-absolute URL "' . $testData['non-absolute-url'] . '" and source URL "' . $testData['source-url'] . '"');
 }