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_Gbase_Entry
27 require_once 'Zend/Gdata/Gbase/Entry.php';
30 * Concrete class for working with Item entries.
32 * @link http://code.google.com/apis/base/
37 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
38 * @license http://framework.zend.com/license/new-bsd New BSD License
40 class Zend_Gdata_Gbase_ItemEntry extends Zend_Gdata_Gbase_Entry
43 * The classname for individual item entry elements.
47 protected $_entryClassName = 'Zend_Gdata_Gbase_ItemEntry';
50 * Set the value of the itme_type
52 * @param Zend_Gdata_Gbase_Extension_ItemType $value The desired value for the item_type
53 * @return Zend_Gdata_Gbase_ItemEntry Provides a fluent interface
55 public function setItemType($value)
57 $this->addGbaseAttribute('item_type', $value, 'text');
62 * Adds a custom attribute to the entry in the following format:
63 * <g:[$name] type='[$type]'>[$value]</g:[$name]>
65 * @param string $name The name of the attribute
66 * @param string $value The text value of the attribute
67 * @param string $type (optional) The type of the attribute.
68 * e.g.: 'text', 'number', 'floatUnit'
69 * @return Zend_Gdata_Gbase_ItemEntry Provides a fluent interface
71 public function addGbaseAttribute($name, $text, $type = null) {
72 $newBaseAttribute = new Zend_Gdata_Gbase_Extension_BaseAttribute($name, $text, $type);
73 $this->_baseAttributes[] = $newBaseAttribute;
78 * Removes a Base attribute from the current list of Base attributes
80 * @param Zend_Gdata_Gbase_Extension_BaseAttribute $baseAttribute The attribute to be removed
81 * @return Zend_Gdata_Gbase_ItemEntry Provides a fluent interface
83 public function removeGbaseAttribute($baseAttribute) {
84 $baseAttributes = $this->_baseAttributes;
85 for ($i = 0; $i < count($this->_baseAttributes); $i++) {
86 if ($this->_baseAttributes[$i] == $baseAttribute) {
87 array_splice($baseAttributes, $i, 1);
91 $this->_baseAttributes = $baseAttributes;
96 * Uploads changes in this entry to the server using Zend_Gdata_App
98 * @param boolean $dryRun Whether the transaction is dry run or not.
99 * @param string|null $uri The URI to send requests to, or null if $data
101 * @param string|null $className The name of the class that should we
102 * deserializing the server response. If null, then
103 * 'Zend_Gdata_App_Entry' will be used.
104 * @param array $extraHeaders Extra headers to add to the request, as an
105 * array of string-based key/value pairs.
106 * @return Zend_Gdata_App_Entry The updated entry
107 * @throws Zend_Gdata_App_Exception
109 public function save($dryRun = false,
112 $extraHeaders = array())
114 if ($dryRun == true) {
115 $editLink = $this->getEditLink();
116 if ($uri == null && $editLink !== null) {
117 $uri = $editLink->getHref() . '?dry-run=true';
120 require_once 'Zend/Gdata/App/InvalidArgumentException.php';
121 throw new Zend_Gdata_App_InvalidArgumentException('You must specify an URI which needs deleted.');
123 $service = new Zend_Gdata_App($this->getHttpClient());
124 return $service->updateEntry($this,
129 parent::save($uri, $className, $extraHeaders);
134 * Deletes this entry to the server using the referenced
135 * Zend_Http_Client to do a HTTP DELETE to the edit link stored in this
136 * entry's link collection.
138 * @param boolean $dyrRun Whether the transaction is dry run or not
140 * @throws Zend_Gdata_App_Exception
142 public function delete($dryRun = false)
146 if ($dryRun == true) {
147 $editLink = $this->getEditLink();
148 if ($editLink !== null) {
149 $uri = $editLink->getHref() . '?dry-run=true';
152 require_once 'Zend/Gdata/App/InvalidArgumentException.php';
153 throw new Zend_Gdata_App_InvalidArgumentException('You must specify an URI which needs deleted.');
155 parent::delete($uri);