10 defined(
'JPATH_PLATFORM') or die;
37 protected $properties = array(
42 'categories' => array(),
43 'contributors' => array(),
56 public function __get($name)
58 return (isset($this->properties[$name])) ? $this->properties[$name] : null;
71 public function __set($name, $value)
74 if ((($name ==
'updatedDate') || ($name ==
'publishedDate')) && !($value instanceof
JDate))
76 $value =
new JDate($value);
80 if (($name ==
'author') && (!($value instanceof
JFeedPerson) || ($value === null)))
82 throw new InvalidArgumentException(
'JFeedEntry "author" must be of type JFeedPerson. ' . gettype($value) .
'given.');
86 if (($name ==
'source') && (!($value instanceof
JFeed) || ($value === null)))
88 throw new InvalidArgumentException(
'JFeedEntry "source" must be of type JFeed. ' . gettype($value) .
'given.');
92 if (($name ==
'categories') || ($name ==
'contributors') || ($name ==
'links'))
94 throw new InvalidArgumentException(
'Cannot directly set JFeedEntry property "' . $name .
'".');
97 $this->properties[$name] = $value;
110 public function addCategory($name, $uri =
'')
112 $this->properties[
'categories'][$name] = $uri;
129 public function addContributor($name, $email, $uri = null, $type = null)
131 $contributor =
new JFeedPerson($name, $email, $uri, $type);
134 foreach ($this->properties[
'contributors'] as $c)
136 if ($c == $contributor)
143 $this->properties[
'contributors'][] = $contributor;
160 foreach ($this->properties[
'links'] as $l)
169 $this->properties[
'links'][] = $link;
183 public function removeCategory($name)
185 unset($this->properties[
'categories'][$name]);
202 foreach ($this->properties[
'contributors'] as $k => $c)
204 if ($c == $contributor)
206 unset($this->properties[
'contributors'][$k]);
207 $this->properties[
'contributors'] = array_values($this->properties[
'contributors']);
228 foreach ($this->properties[
'links'] as $k => $l)
232 unset($this->properties[
'links'][$k]);
233 $this->properties[
'links'] = array_values($this->properties[
'links']);
254 public function setAuthor($name, $email, $uri = null, $type = null)
256 $author =
new JFeedPerson($name, $email, $uri, $type);
258 $this->properties[
'author'] = $author;