[ Index ] |
PHP Cross Reference of moodle-2.8 |
[Summary view] [Print] [Text view]
1 <?php 2 3 /** 4 * Zend Framework 5 * 6 * LICENSE 7 * 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 [email protected] so we can send you a copy immediately. 15 * 16 * @category Zend 17 * @package Zend_Gdata 18 * @subpackage Gbase 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 21 * @version $Id$ 22 */ 23 24 /** 25 * @see Zend_Gdata_Gbase_Entry 26 */ 27 require_once 'Zend/Gdata/Gbase/Entry.php'; 28 29 /** 30 * Concrete class for working with Item entries. 31 * 32 * @link http://code.google.com/apis/base/ 33 * 34 * @category Zend 35 * @package Zend_Gdata 36 * @subpackage Gbase 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 39 */ 40 class Zend_Gdata_Gbase_ItemEntry extends Zend_Gdata_Gbase_Entry 41 { 42 /** 43 * The classname for individual item entry elements. 44 * 45 * @var string 46 */ 47 protected $_entryClassName = 'Zend_Gdata_Gbase_ItemEntry'; 48 49 /** 50 * Set the value of the itme_type 51 * 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 54 */ 55 public function setItemType($value) 56 { 57 $this->addGbaseAttribute('item_type', $value, 'text'); 58 return $this; 59 } 60 61 /** 62 * Adds a custom attribute to the entry in the following format: 63 * <g:[$name] type='[$type]'>[$value]</g:[$name]> 64 * 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 70 */ 71 public function addGbaseAttribute($name, $text, $type = null) { 72 $newBaseAttribute = new Zend_Gdata_Gbase_Extension_BaseAttribute($name, $text, $type); 73 $this->_baseAttributes[] = $newBaseAttribute; 74 return $this; 75 } 76 77 /** 78 * Removes a Base attribute from the current list of Base attributes 79 * 80 * @param Zend_Gdata_Gbase_Extension_BaseAttribute $baseAttribute The attribute to be removed 81 * @return Zend_Gdata_Gbase_ItemEntry Provides a fluent interface 82 */ 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); 88 break; 89 } 90 } 91 $this->_baseAttributes = $baseAttributes; 92 return $this; 93 } 94 95 /** 96 * Uploads changes in this entry to the server using Zend_Gdata_App 97 * 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 100 * contains the URI. 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 108 */ 109 public function save($dryRun = false, 110 $uri = null, 111 $className = null, 112 $extraHeaders = array()) 113 { 114 if ($dryRun == true) { 115 $editLink = $this->getEditLink(); 116 if ($uri == null && $editLink !== null) { 117 $uri = $editLink->getHref() . '?dry-run=true'; 118 } 119 if ($uri === null) { 120 require_once 'Zend/Gdata/App/InvalidArgumentException.php'; 121 throw new Zend_Gdata_App_InvalidArgumentException('You must specify an URI which needs deleted.'); 122 } 123 $service = new Zend_Gdata_App($this->getHttpClient()); 124 return $service->updateEntry($this, 125 $uri, 126 $className, 127 $extraHeaders); 128 } else { 129 parent::save($uri, $className, $extraHeaders); 130 } 131 } 132 133 /** 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. 137 * 138 * @param boolean $dyrRun Whether the transaction is dry run or not 139 * @return void 140 * @throws Zend_Gdata_App_Exception 141 */ 142 public function delete($dryRun = false) 143 { 144 $uri = null; 145 146 if ($dryRun == true) { 147 $editLink = $this->getEditLink(); 148 if ($editLink !== null) { 149 $uri = $editLink->getHref() . '?dry-run=true'; 150 } 151 if ($uri === null) { 152 require_once 'Zend/Gdata/App/InvalidArgumentException.php'; 153 throw new Zend_Gdata_App_InvalidArgumentException('You must specify an URI which needs deleted.'); 154 } 155 parent::delete($uri); 156 } else { 157 parent::delete(); 158 } 159 } 160 161 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Fri Nov 28 20:29:05 2014 | Cross-referenced by PHPXref 0.7.1 |