Skip to content

Commit

Permalink
Correctly select alternate links as per RFC4287
Browse files Browse the repository at this point in the history
  • Loading branch information
Melissa Draper committed Nov 29, 2011
1 parent 0f4ce99 commit b44c879
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions XML/Feed/Parser/Atom.php
Expand Up @@ -347,15 +347,18 @@ function getLink($offset = 0, $attribute = 'href', $params = false)
} else {
$links = $this->model->getElementsByTagName('link');
}
if ($links->length > $offset) {
if ($links->item($offset)->hasAttribute($attribute)) {
$value = $links->item($offset)->getAttribute($attribute);
foreach ($links as $link) {
if ($link->hasAttribute($attribute)
&& ($link->hasAttribute('rel') == false
|| $link->getAttribute('rel') == 'alternate')
) {
$value = $link->getAttribute($attribute);
if ($attribute == 'href') {
$value = $this->addBase($value, $links->item($offset));
$value = $this->addBase($value, $link);
}
return $value;
} else if ($attribute == 'rel') {
return 'alternate';
return $link->getAttribute($attribute);
}
}
return false;
Expand Down

0 comments on commit b44c879

Please sign in to comment.