8 * This source file is subject to the new BSD license that is bundled
9 * with this package in the file LICENSE.txt.
10 * It is also available through the world-wide-web at this URL:
11 * http://framework.zend.com/license/new-bsd
12 * If you did not receive a copy of the license and are unable to
13 * obtain it through the world-wide-web, please send an email
14 * to license@zend.com so we can send you a copy immediately.
19 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
20 * @license http://framework.zend.com/license/new-bsd New BSD License
25 * @see Zend_Gdata_Entry
27 require_once 'Zend/Gdata/Entry.php';
30 * @see Zend_Gdata_Gbase_Extension_BaseAttribute
32 require_once 'Zend/Gdata/Gbase/Extension/BaseAttribute.php';
35 * Base class for working with Google Base entries.
37 * @link http://code.google.com/apis/base/
42 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
43 * @license http://framework.zend.com/license/new-bsd New BSD License
45 class Zend_Gdata_Gbase_Entry extends Zend_Gdata_Entry
49 * Name of the base class for Google Base entries
53 protected $_entryClassName = 'Zend_Gdata_Gbase_Entry';
56 * Google Base attribute elements in the 'g' namespace
60 protected $_baseAttributes = array();
63 * Constructs a new Zend_Gdata_Gbase_ItemEntry object.
64 * @param DOMElement $element (optional) The DOMElement on which to base this object.
66 public function __construct($element = null)
68 $this->registerAllNamespaces(Zend_Gdata_Gbase::$namespaces);
69 parent::__construct($element);
73 * Retrieves a DOMElement which corresponds to this element and all
74 * child properties. This is used to build an entry back into a DOM
75 * and eventually XML text for application storage/persistence.
77 * @param DOMDocument $doc The DOMDocument used to construct DOMElements
78 * @return DOMElement The DOMElement representing this element and all
81 public function getDOM($doc = null, $majorVersion = 1, $minorVersion = null)
83 $element = parent::getDOM($doc, $majorVersion, $minorVersion);
84 foreach ($this->_baseAttributes as $baseAttribute) {
85 $element->appendChild($baseAttribute->getDOM($element->ownerDocument));
91 * Creates individual Entry objects of the appropriate type and
92 * stores them as members of this entry based upon DOM data.
94 * @param DOMNode $child The DOMNode to process
96 protected function takeChildFromDOM($child)
98 $absoluteNodeName = $child->namespaceURI . ':' . $child->localName;
100 if (strstr($absoluteNodeName, $this->lookupNamespace('g') . ':')) {
101 $baseAttribute = new Zend_Gdata_Gbase_Extension_BaseAttribute();
102 $baseAttribute->transferFromDOM($child);
103 $this->_baseAttributes[] = $baseAttribute;
105 parent::takeChildFromDOM($child);
110 * Get the value of the itme_type
112 * @return Zend_Gdata_Gbase_Extension_ItemType The requested object.
114 public function getItemType()
116 $itemType = $this->getGbaseAttribute('item_type');
117 if (is_object($itemType[0])) {
125 * Return all the Base attributes
126 * @return Zend_Gdata_Gbase_Extension_BaseAttribute
128 public function getGbaseAttributes() {
129 return $this->_baseAttributes;
133 * Return an array of Base attributes that match the given attribute name
135 * @param string $name The name of the Base attribute to look for
136 * @return array $matches Array that contains the matching list of Base attributes
138 public function getGbaseAttribute($name)
141 for ($i = 0; $i < count($this->_baseAttributes); $i++) {
142 $baseAttribute = $this->_baseAttributes[$i];
143 if ($baseAttribute->rootElement == $name &&
144 $baseAttribute->rootNamespaceURI == $this->lookupNamespace('g')) {
145 $matches[] = &$this->_baseAttributes[$i];