mirror of
https://github.com/Chouchen/ShikiryuRSS.git
synced 2024-10-31 14:38:51 +01:00
added addItemBefore()
changed _loadAttributes function which was buggy
This commit is contained in:
parent
67732ad6d3
commit
a4865b1eb8
22
srss.php
22
srss.php
@ -47,6 +47,7 @@ class SRSS extends DomDocument implements Iterator
|
||||
$this->items = array();
|
||||
$this->position = 0;
|
||||
$this->formatOutput = true;
|
||||
$this->preserveWhiteSpace = false;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -270,6 +271,25 @@ class SRSS extends DomDocument implements Iterator
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* add a SRSS Item as an item into current RSS as first item
|
||||
* @param SRSSItem $item
|
||||
*/
|
||||
public function addItemBefore(SRSSItem $item)
|
||||
{
|
||||
$node = $this->importNode($item->getItem(), true);
|
||||
$items = $this->getElementsByTagName('item');
|
||||
if($items->length != 0){
|
||||
$firstNode = $items->item(0);
|
||||
if($firstNode != null)
|
||||
$firstNode->parentNode->insertBefore($node, $firstNode);
|
||||
else
|
||||
$this->addItem($item);
|
||||
}
|
||||
else
|
||||
$this->addItem($item);
|
||||
}
|
||||
|
||||
/**
|
||||
* add a SRSS Item as an item into current RSS
|
||||
* @param SRSSItem $item
|
||||
@ -385,7 +405,7 @@ class SRSS extends DomDocument implements Iterator
|
||||
{
|
||||
if($child->nodeType == XML_ELEMENT_NODE && $child->nodeName != 'item')
|
||||
{
|
||||
$this->{$child->nodeName} = $child->nodeValue;
|
||||
$this->attr[$child->nodeName] = $child->nodeValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user