1
0
mirror of https://github.com/Chouchen/ShikiryuRSS.git synced 2025-09-06 01:14:32 +02:00

Added image getter

This commit is contained in:
Chouchen
2011-06-01 14:07:17 +02:00
parent a4865b1eb8
commit eb4230d23f
2 changed files with 102 additions and 1 deletions

View File

@@ -105,6 +105,27 @@ class SRSS extends DomDocument implements Iterator
return $doc;
}
/**
* getter of "image"'s channel attributes
* @return string or array
*/
public function image()
{
$args = func_get_args();
if(func_num_args() == 0) $args[0] = 'url';
$r = array();
if(!empty($this->attr['image']))
{
foreach($this->attr['image'] as $key => $val)
{
if(in_array($key, $args))
$r[$key] = $val;
}
}
else return;
return (func_num_args() > 1) ? $r : $r[$args[0]];
}
/**
* setter of "image"'s channel attributes
* @param $url picture's url
@@ -405,7 +426,15 @@ class SRSS extends DomDocument implements Iterator
{
if($child->nodeType == XML_ELEMENT_NODE && $child->nodeName != 'item')
{
$this->attr[$child->nodeName] = $child->nodeValue;
if($child->nodeName == 'image'){
foreach($child->childNodes as $children)
{
if($children->nodeType == XML_ELEMENT_NODE)
$this->attr['image'][$children->nodeName] = $children->nodeValue;
}
}
else
$this->attr[$child->nodeName] = $child->nodeValue;
}
}
}