1: <?php
2: /**
3: * Copyright 2008-2012 Horde LLC (http://www.horde.org/)
4: *
5: * @author Chuck Hagenbuch <chuck@horde.org>
6: * @license http://www.horde.org/licenses/bsd BSD
7: * @category Horde
8: * @package Feed
9: */
10:
11: /**
12: * Concrete class for working with Blogroll elements.
13: *
14: * @author Chuck Hagenbuch <chuck@horde.org>
15: * @license http://www.horde.org/licenses/bsd BSD
16: * @category Horde
17: * @package Feed
18: */
19: class Horde_Feed_Entry_Blogroll extends Horde_Feed_Entry_Base
20: {
21: /**
22: * The XML string for an "empty" outline element.
23: *
24: * @var string
25: */
26: protected $_emptyXml = '<outline xmlUrl=""/>';
27:
28: /**
29: * Get a Horde_Feed object for the feed described by this outline element.
30: *
31: * @return Horde_Feed_Base
32: */
33: public function getFeed()
34: {
35: if (!$this['xmlUrl']) {
36: throw new Horde_Feed_Exception('No XML URL in <outline/> element');
37: }
38: return Horde_Feed::readUri($this['xmlUrl']);
39: }
40:
41: /**
42: * Add child elements and attributes to this element from a simple key =>
43: * value hash. Because feed list outline elements only use attributes, this
44: * overrides Horde_Xml_Element#fromArray to set attributes whether the
45: * #Attribute syntax is used or not.
46: *
47: * @see Horde_Xml_Element#fromArray
48: *
49: * @param $array Hash to import into this element.
50: */
51: public function fromArray($array)
52: {
53: foreach ($array as $key => $value) {
54: $attribute = $key;
55: if (substr($attribute, 0, 1) == '#') {
56: $attribute = substr($attribute, 1);
57: }
58: $this[$attribute] = $value;
59: }
60: }
61:
62: /**
63: * Always use attributes instead of child nodes.
64: *
65: * @param string $var The property to access.
66: * @return mixed
67: */
68: public function __get($var)
69: {
70: return $this->offsetGet($var);
71: }
72:
73: /**
74: * Always use attributes instead of child nodes.
75: *
76: * @param string $var The property to change.
77: * @param string $val The property's new value.
78: */
79: public function __set($var, $val)
80: {
81: return $this->offsetSet($var, $val);
82: }
83:
84: }
85: