[44] | 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 license@zend.com so we can send you a copy immediately.
|
---|
| 15 | *
|
---|
| 16 | * @category Zend
|
---|
| 17 | * @package Zend_Gdata
|
---|
| 18 | * @subpackage Spreadsheets
|
---|
| 19 | * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
---|
| 20 | * @license http://framework.zend.com/license/new-bsd New BSD License
|
---|
| 21 | */
|
---|
| 22 |
|
---|
| 23 | /**
|
---|
| 24 | * Zend_Gdata_App_util
|
---|
| 25 | */
|
---|
| 26 | require_once('Zend/Gdata/App/Util.php');
|
---|
| 27 |
|
---|
| 28 | /**
|
---|
| 29 | * Zend_Gdata_Query
|
---|
| 30 | */
|
---|
| 31 | require_once('Zend/Gdata/Query.php');
|
---|
| 32 |
|
---|
| 33 | /**
|
---|
| 34 | * Assists in constructing queries for Google Spreadsheets documents
|
---|
| 35 | *
|
---|
| 36 | * @link http://code.google.com/apis/gdata/spreadsheets/
|
---|
| 37 | *
|
---|
| 38 | * @category Zend
|
---|
| 39 | * @package Zend_Gdata
|
---|
| 40 | * @subpackage Spreadsheets
|
---|
| 41 | * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
---|
| 42 | * @license http://framework.zend.com/license/new-bsd New BSD License
|
---|
| 43 | */
|
---|
| 44 | class Zend_Gdata_Spreadsheets_DocumentQuery extends Zend_Gdata_Query
|
---|
| 45 | {
|
---|
| 46 |
|
---|
| 47 | const SPREADSHEETS_FEED_URI = 'http://spreadsheets.google.com/feeds';
|
---|
| 48 |
|
---|
| 49 | protected $_defaultFeedUri = self::SPREADSHEETS_FEED_URI;
|
---|
| 50 | protected $_documentType;
|
---|
| 51 | protected $_visibility = 'private';
|
---|
| 52 | protected $_projection = 'full';
|
---|
| 53 | protected $_spreadsheetKey = null;
|
---|
| 54 | protected $_worksheetId = null;
|
---|
| 55 |
|
---|
| 56 | /**
|
---|
| 57 | * Constructs a new Zend_Gdata_Spreadsheets_DocumentQuery object.
|
---|
| 58 | */
|
---|
| 59 | public function __construct()
|
---|
| 60 | {
|
---|
| 61 | parent::__construct();
|
---|
| 62 | }
|
---|
| 63 |
|
---|
| 64 | /**
|
---|
| 65 | * Sets the spreadsheet key for this query.
|
---|
| 66 | * @param string $value
|
---|
| 67 | * @return Zend_Gdata_Spreadsheets_CellQuery Provides a fluent interface
|
---|
| 68 | */
|
---|
| 69 | public function setSpreadsheetKey($value)
|
---|
| 70 | {
|
---|
| 71 | $this->_spreadsheetKey = $value;
|
---|
| 72 | return $this;
|
---|
| 73 | }
|
---|
| 74 |
|
---|
| 75 | /**
|
---|
| 76 | * Gets the spreadsheet key for this query.
|
---|
| 77 | * @return string spreadsheet key
|
---|
| 78 | */
|
---|
| 79 | public function getSpreadsheetKey()
|
---|
| 80 | {
|
---|
| 81 | return $this->_spreadsheetKey;
|
---|
| 82 | }
|
---|
| 83 |
|
---|
| 84 | /**
|
---|
| 85 | * Sets the worksheet id for this query.
|
---|
| 86 | * @param string $value
|
---|
| 87 | * @return Zend_Gdata_Spreadsheets_CellQuery Provides a fluent interface
|
---|
| 88 | */
|
---|
| 89 | public function setWorksheetId($value)
|
---|
| 90 | {
|
---|
| 91 | $this->_worksheetId = $value;
|
---|
| 92 | return $this;
|
---|
| 93 | }
|
---|
| 94 |
|
---|
| 95 | /**
|
---|
| 96 | * Gets the worksheet id for this query.
|
---|
| 97 | * @return string worksheet id
|
---|
| 98 | */
|
---|
| 99 | public function getWorksheetId()
|
---|
| 100 | {
|
---|
| 101 | return $this->_worksheetId;
|
---|
| 102 | }
|
---|
| 103 |
|
---|
| 104 | /**
|
---|
| 105 | * Sets the document type for this query.
|
---|
| 106 | * @param string $value spreadsheets or worksheets
|
---|
| 107 | * @return Zend_Gdata_Spreadsheets_DocumentQuery Provides a fluent interface
|
---|
| 108 | */
|
---|
| 109 | public function setDocumentType($value)
|
---|
| 110 | {
|
---|
| 111 | $this->_documentType = $value;
|
---|
| 112 | return $this;
|
---|
| 113 | }
|
---|
| 114 |
|
---|
| 115 | /**
|
---|
| 116 | * Gets the document type for this query.
|
---|
| 117 | * @return string document type
|
---|
| 118 | */
|
---|
| 119 | public function getDocumentType()
|
---|
| 120 | {
|
---|
| 121 | return $this->_documentType;
|
---|
| 122 | }
|
---|
| 123 |
|
---|
| 124 | /**
|
---|
| 125 | * Sets the projection for this query.
|
---|
| 126 | * @param string $value
|
---|
| 127 | * @return Zend_Gdata_Spreadsheets_DocumentQuery Provides a fluent interface
|
---|
| 128 | */
|
---|
| 129 | public function setProjection($value)
|
---|
| 130 | {
|
---|
| 131 | $this->_projection = $value;
|
---|
| 132 | return $this;
|
---|
| 133 | }
|
---|
| 134 |
|
---|
| 135 | /**
|
---|
| 136 | * Sets the visibility for this query.
|
---|
| 137 | * @return Zend_Gdata_Spreadsheets_DocumentQuery Provides a fluent interface
|
---|
| 138 | */
|
---|
| 139 | public function setVisibility($value)
|
---|
| 140 | {
|
---|
| 141 | $this->_visibility = $value;
|
---|
| 142 | return $this;
|
---|
| 143 | }
|
---|
| 144 |
|
---|
| 145 | /**
|
---|
| 146 | * Gets the projection for this query.
|
---|
| 147 | * @return string projection
|
---|
| 148 | */
|
---|
| 149 | public function getProjection()
|
---|
| 150 | {
|
---|
| 151 | return $this->_projection;
|
---|
| 152 | }
|
---|
| 153 |
|
---|
| 154 | /**
|
---|
| 155 | * Gets the visibility for this query.
|
---|
| 156 | * @return string visibility
|
---|
| 157 | */
|
---|
| 158 | public function getVisibility()
|
---|
| 159 | {
|
---|
| 160 | return $this->_visibility;
|
---|
| 161 | }
|
---|
| 162 |
|
---|
| 163 | /**
|
---|
| 164 | * Sets the title attribute for this query.
|
---|
| 165 | * @param string $value
|
---|
| 166 | * @return Zend_Gdata_Spreadsheets_DocumentQuery Provides a fluent interface
|
---|
| 167 | */
|
---|
| 168 | public function setTitle($value)
|
---|
| 169 | {
|
---|
| 170 | if ($value != null) {
|
---|
| 171 | $this->_params['title'] = $value;
|
---|
| 172 | } else {
|
---|
| 173 | unset($this->_params['title']);
|
---|
| 174 | }
|
---|
| 175 | return $this;
|
---|
| 176 | }
|
---|
| 177 |
|
---|
| 178 | /**
|
---|
| 179 | * Sets the title-exact attribute for this query.
|
---|
| 180 | * @param string $value
|
---|
| 181 | * @return Zend_Gdata_Spreadsheets_DocumentQuery Provides a fluent interface
|
---|
| 182 | */
|
---|
| 183 | public function setTitleExact($value)
|
---|
| 184 | {
|
---|
| 185 | if ($value != null) {
|
---|
| 186 | $this->_params['title-exact'] = $value;
|
---|
| 187 | } else {
|
---|
| 188 | unset($this->_params['title-exact']);
|
---|
| 189 | }
|
---|
| 190 | return $this;
|
---|
| 191 | }
|
---|
| 192 |
|
---|
| 193 | /**
|
---|
| 194 | * Gets the title attribute for this query.
|
---|
| 195 | * @return string title
|
---|
| 196 | */
|
---|
| 197 | public function getTitle()
|
---|
| 198 | {
|
---|
| 199 | if (array_key_exists('title', $this->_params)) {
|
---|
| 200 | return $this->_params['title'];
|
---|
| 201 | } else {
|
---|
| 202 | return null;
|
---|
| 203 | }
|
---|
| 204 | }
|
---|
| 205 |
|
---|
| 206 | /**
|
---|
| 207 | * Gets the title-exact attribute for this query.
|
---|
| 208 | * @return string title-exact
|
---|
| 209 | */
|
---|
| 210 | public function getTitleExact()
|
---|
| 211 | {
|
---|
| 212 | if (array_key_exists('title-exact', $this->_params)) {
|
---|
| 213 | return $this->_params['title-exact'];
|
---|
| 214 | } else {
|
---|
| 215 | return null;
|
---|
| 216 | }
|
---|
| 217 | }
|
---|
| 218 |
|
---|
| 219 | private function appendVisibilityProjection()
|
---|
| 220 | {
|
---|
| 221 | $uri = '';
|
---|
| 222 |
|
---|
| 223 | if ($this->_visibility != null) {
|
---|
| 224 | $uri .= '/'.$this->_visibility;
|
---|
| 225 | } else {
|
---|
| 226 | require_once 'Zend/Gdata/App/Exception.php';
|
---|
| 227 | throw new Zend_Gdata_App_Exception('A visibility must be provided for document queries.');
|
---|
| 228 | }
|
---|
| 229 |
|
---|
| 230 | if ($this->_projection != null) {
|
---|
| 231 | $uri .= '/'.$this->_projection;
|
---|
| 232 | } else {
|
---|
| 233 | require_once 'Zend/Gdata/App/Exception.php';
|
---|
| 234 | throw new Zend_Gdata_App_Exception('A projection must be provided for document queries.');
|
---|
| 235 | }
|
---|
| 236 |
|
---|
| 237 | return $uri;
|
---|
| 238 | }
|
---|
| 239 |
|
---|
| 240 |
|
---|
| 241 | /**
|
---|
| 242 | * Gets the full query URL for this query.
|
---|
| 243 | * @return string url
|
---|
| 244 | */
|
---|
| 245 | public function getQueryUrl()
|
---|
| 246 | {
|
---|
| 247 | $uri = $this->_defaultFeedUri;
|
---|
| 248 |
|
---|
| 249 | if ($this->_documentType != null) {
|
---|
| 250 | $uri .= '/'.$this->_documentType;
|
---|
| 251 | } else {
|
---|
| 252 | require_once 'Zend/Gdata/App/Exception.php';
|
---|
| 253 | throw new Zend_Gdata_App_Exception('A document type must be provided for document queries.');
|
---|
| 254 | }
|
---|
| 255 |
|
---|
| 256 | if ($this->_documentType == 'spreadsheets') {
|
---|
| 257 | $uri .= $this->appendVisibilityProjection();
|
---|
| 258 | if ($this->_spreadsheetKey != null) {
|
---|
| 259 | $uri .= '/'.$this->_spreadsheetKey;
|
---|
| 260 | }
|
---|
| 261 | } else if ($this->_documentType == 'worksheets') {
|
---|
| 262 | if ($this->_spreadsheetKey != null) {
|
---|
| 263 | $uri .= '/'.$this->_spreadsheetKey;
|
---|
| 264 | } else {
|
---|
| 265 | require_once 'Zend/Gdata/App/Exception.php';
|
---|
| 266 | throw new Zend_Gdata_App_Exception('A spreadsheet key must be provided for worksheet document queries.');
|
---|
| 267 | }
|
---|
| 268 | $uri .= $this->appendVisibilityProjection();
|
---|
| 269 | if ($this->_worksheetId != null) {
|
---|
| 270 | $uri .= '/'.$this->_worksheetId;
|
---|
| 271 | }
|
---|
| 272 | }
|
---|
| 273 |
|
---|
| 274 | $uri .= $this->getQueryString();
|
---|
| 275 | return $uri;
|
---|
| 276 | }
|
---|
| 277 |
|
---|
| 278 | /**
|
---|
| 279 | * Gets the attribute query string for this query.
|
---|
| 280 | * @return string query string
|
---|
| 281 | */
|
---|
| 282 | public function getQueryString()
|
---|
| 283 | {
|
---|
| 284 | return parent::getQueryString();
|
---|
| 285 | }
|
---|
| 286 |
|
---|
| 287 | }
|
---|