[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 cells
|
---|
| 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_CellQuery extends Zend_Gdata_Query
|
---|
| 45 | {
|
---|
| 46 |
|
---|
| 47 | const SPREADSHEETS_CELL_FEED_URI = 'http://spreadsheets.google.com/feeds/cells';
|
---|
| 48 |
|
---|
| 49 | protected $_defaultFeedUri = self::SPREADSHEETS_CELL_FEED_URI;
|
---|
| 50 | protected $_visibility = 'private';
|
---|
| 51 | protected $_projection = 'full';
|
---|
| 52 | protected $_spreadsheetKey = null;
|
---|
| 53 | protected $_worksheetId = 'default';
|
---|
| 54 | protected $_cellId = null;
|
---|
| 55 |
|
---|
| 56 | /**
|
---|
| 57 | * Constructs a new Zend_Gdata_Spreadsheets_CellQuery object.
|
---|
| 58 | *
|
---|
| 59 | * @param string $url Base URL to use for queries
|
---|
| 60 | */
|
---|
| 61 | public function __construct($url = null)
|
---|
| 62 | {
|
---|
| 63 | parent::__construct($url);
|
---|
| 64 | }
|
---|
| 65 |
|
---|
| 66 | /**
|
---|
| 67 | * Sets the spreadsheet key for this query.
|
---|
| 68 | *
|
---|
| 69 | * @param string $value
|
---|
| 70 | * @return Zend_Gdata_Spreadsheets_CellQuery Provides a fluent interface
|
---|
| 71 | */
|
---|
| 72 | public function setSpreadsheetKey($value)
|
---|
| 73 | {
|
---|
| 74 | $this->_spreadsheetKey = $value;
|
---|
| 75 | return $this;
|
---|
| 76 | }
|
---|
| 77 |
|
---|
| 78 | /**
|
---|
| 79 | * Gets the spreadsheet key for this query.
|
---|
| 80 | *
|
---|
| 81 | * @return string spreadsheet key
|
---|
| 82 | */
|
---|
| 83 | public function getSpreadsheetKey()
|
---|
| 84 | {
|
---|
| 85 | return $this->_spreadsheetKey;
|
---|
| 86 | }
|
---|
| 87 |
|
---|
| 88 | /**
|
---|
| 89 | * Sets the worksheet id for this query.
|
---|
| 90 | *
|
---|
| 91 | * @param string $value
|
---|
| 92 | * @return Zend_Gdata_Spreadsheets_CellQuery Provides a fluent interface
|
---|
| 93 | */
|
---|
| 94 | public function setWorksheetId($value)
|
---|
| 95 | {
|
---|
| 96 | $this->_worksheetId = $value;
|
---|
| 97 | return $this;
|
---|
| 98 | }
|
---|
| 99 |
|
---|
| 100 | /**
|
---|
| 101 | * Gets the worksheet id for this query.
|
---|
| 102 | *
|
---|
| 103 | * @return string worksheet id
|
---|
| 104 | */
|
---|
| 105 | public function getWorksheetId()
|
---|
| 106 | {
|
---|
| 107 | return $this->_worksheetId;
|
---|
| 108 | }
|
---|
| 109 |
|
---|
| 110 | /**
|
---|
| 111 | * Sets the cell id for this query.
|
---|
| 112 | *
|
---|
| 113 | * @param string $value
|
---|
| 114 | * @return Zend_Gdata_Spreadsheets_CellQuery Provides a fluent interface
|
---|
| 115 | */
|
---|
| 116 | public function setCellId($value)
|
---|
| 117 | {
|
---|
| 118 | $this->_cellId = $value;
|
---|
| 119 | return $this;
|
---|
| 120 | }
|
---|
| 121 |
|
---|
| 122 | /**
|
---|
| 123 | * Gets the cell id for this query.
|
---|
| 124 | *
|
---|
| 125 | * @return string cell id
|
---|
| 126 | */
|
---|
| 127 | public function getCellId()
|
---|
| 128 | {
|
---|
| 129 | return $this->_cellId;
|
---|
| 130 | }
|
---|
| 131 |
|
---|
| 132 | /**
|
---|
| 133 | * Sets the projection for this query.
|
---|
| 134 | *
|
---|
| 135 | * @param string $value
|
---|
| 136 | * @return Zend_Gdata_Spreadsheets_CellQuery Provides a fluent interface
|
---|
| 137 | */
|
---|
| 138 | public function setProjection($value)
|
---|
| 139 | {
|
---|
| 140 | $this->_projection = $value;
|
---|
| 141 | return $this;
|
---|
| 142 | }
|
---|
| 143 |
|
---|
| 144 | /**
|
---|
| 145 | * Sets the visibility for this query.
|
---|
| 146 | *
|
---|
| 147 | * @return Zend_Gdata_Spreadsheets_CellQuery Provides a fluent interface
|
---|
| 148 | */
|
---|
| 149 | public function setVisibility($value)
|
---|
| 150 | {
|
---|
| 151 | $this->_visibility = $value;
|
---|
| 152 | return $this;
|
---|
| 153 | }
|
---|
| 154 |
|
---|
| 155 | /**
|
---|
| 156 | * Gets the projection for this query.
|
---|
| 157 | *
|
---|
| 158 | * @return string projection
|
---|
| 159 | */
|
---|
| 160 | public function getProjection()
|
---|
| 161 | {
|
---|
| 162 | return $this->_projection;
|
---|
| 163 | }
|
---|
| 164 |
|
---|
| 165 | /**
|
---|
| 166 | * Gets the visibility for this query.
|
---|
| 167 | *
|
---|
| 168 | * @return string visibility
|
---|
| 169 | */
|
---|
| 170 | public function getVisibility()
|
---|
| 171 | {
|
---|
| 172 | return $this->_visibility;
|
---|
| 173 | }
|
---|
| 174 |
|
---|
| 175 | /**
|
---|
| 176 | * Sets the min-row attribute for this query.
|
---|
| 177 | *
|
---|
| 178 | * @param string $value
|
---|
| 179 | * @return Zend_Gdata_Spreadsheets_CellQuery Provides a fluent interface
|
---|
| 180 | */
|
---|
| 181 | public function setMinRow($value)
|
---|
| 182 | {
|
---|
| 183 | if ($value != null) {
|
---|
| 184 | $this->_params['min-row'] = $value;
|
---|
| 185 | } else {
|
---|
| 186 | unset($this->_params['min-row']);
|
---|
| 187 | }
|
---|
| 188 | return $this;
|
---|
| 189 | }
|
---|
| 190 |
|
---|
| 191 | /**
|
---|
| 192 | * Gets the min-row attribute for this query.
|
---|
| 193 | *
|
---|
| 194 | * @return string min-row
|
---|
| 195 | */
|
---|
| 196 | public function getMinRow()
|
---|
| 197 | {
|
---|
| 198 | if (array_key_exists('min-row', $this->_params)) {
|
---|
| 199 | return $this->_params['min-row'];
|
---|
| 200 | } else {
|
---|
| 201 | return null;
|
---|
| 202 | }
|
---|
| 203 | }
|
---|
| 204 |
|
---|
| 205 | /**
|
---|
| 206 | * Sets the max-row attribute for this query.
|
---|
| 207 | *
|
---|
| 208 | * @param string $value
|
---|
| 209 | * @return Zend_Gdata_Spreadsheets_CellQuery Provides a fluent interface
|
---|
| 210 | */
|
---|
| 211 | public function setMaxRow($value)
|
---|
| 212 | {
|
---|
| 213 | if ($value != null) {
|
---|
| 214 | $this->_params['max-row'] = $value;
|
---|
| 215 | } else {
|
---|
| 216 | unset($this->_params['max-row']);
|
---|
| 217 | }
|
---|
| 218 | return $this;
|
---|
| 219 | }
|
---|
| 220 |
|
---|
| 221 | /**
|
---|
| 222 | * Gets the max-row attribute for this query.
|
---|
| 223 | *
|
---|
| 224 | * @return string max-row
|
---|
| 225 | */
|
---|
| 226 | public function getMaxRow()
|
---|
| 227 | {
|
---|
| 228 | if (array_key_exists('max-row', $this->_params)) {
|
---|
| 229 | return $this->_params['max-row'];
|
---|
| 230 | } else {
|
---|
| 231 | return null;
|
---|
| 232 | }
|
---|
| 233 | }
|
---|
| 234 |
|
---|
| 235 | /**
|
---|
| 236 | * Sets the min-col attribute for this query.
|
---|
| 237 | *
|
---|
| 238 | * @param string $value
|
---|
| 239 | * @return Zend_Gdata_Spreadsheets_CellQuery Provides a fluent interface
|
---|
| 240 | */
|
---|
| 241 | public function setMinCol($value)
|
---|
| 242 | {
|
---|
| 243 | if ($value != null) {
|
---|
| 244 | $this->_params['min-col'] = $value;
|
---|
| 245 | } else {
|
---|
| 246 | unset($this->_params['min-col']);
|
---|
| 247 | }
|
---|
| 248 | return $this;
|
---|
| 249 | }
|
---|
| 250 |
|
---|
| 251 | /**
|
---|
| 252 | * Gets the min-col attribute for this query.
|
---|
| 253 | *
|
---|
| 254 | * @return string min-col
|
---|
| 255 | */
|
---|
| 256 | public function getMinCol()
|
---|
| 257 | {
|
---|
| 258 | if (array_key_exists('min-col', $this->_params)) {
|
---|
| 259 | return $this->_params['min-col'];
|
---|
| 260 | } else {
|
---|
| 261 | return null;
|
---|
| 262 | }
|
---|
| 263 | }
|
---|
| 264 |
|
---|
| 265 | /**
|
---|
| 266 | * Sets the max-col attribute for this query.
|
---|
| 267 | *
|
---|
| 268 | * @param string $value
|
---|
| 269 | * @return Zend_Gdata_Spreadsheets_CellQuery Provides a fluent interface
|
---|
| 270 | */
|
---|
| 271 | public function setMaxCol($value)
|
---|
| 272 | {
|
---|
| 273 | if ($value != null) {
|
---|
| 274 | $this->_params['max-col'] = $value;
|
---|
| 275 | } else {
|
---|
| 276 | unset($this->_params['max-col']);
|
---|
| 277 | }
|
---|
| 278 | return $this;
|
---|
| 279 | }
|
---|
| 280 |
|
---|
| 281 | /**
|
---|
| 282 | * Gets the max-col attribute for this query.
|
---|
| 283 | *
|
---|
| 284 | * @return string max-col
|
---|
| 285 | */
|
---|
| 286 | public function getMaxCol()
|
---|
| 287 | {
|
---|
| 288 | if (array_key_exists('max-col', $this->_params)) {
|
---|
| 289 | return $this->_params['max-col'];
|
---|
| 290 | } else {
|
---|
| 291 | return null;
|
---|
| 292 | }
|
---|
| 293 | }
|
---|
| 294 |
|
---|
| 295 | /**
|
---|
| 296 | * Sets the range attribute for this query.
|
---|
| 297 | *
|
---|
| 298 | * @param string $value
|
---|
| 299 | * @return Zend_Gdata_Spreadsheets_CellQuery Provides a fluent interface
|
---|
| 300 | */
|
---|
| 301 | public function setRange($value)
|
---|
| 302 | {
|
---|
| 303 | if ($value != null) {
|
---|
| 304 | $this->_params['range'] = $value;
|
---|
| 305 | } else {
|
---|
| 306 | unset($this->_params['range']);
|
---|
| 307 | }
|
---|
| 308 | return $this;
|
---|
| 309 | }
|
---|
| 310 |
|
---|
| 311 | /**
|
---|
| 312 | * Gets the range attribute for this query.
|
---|
| 313 | *
|
---|
| 314 | * @return string range
|
---|
| 315 | */
|
---|
| 316 | public function getRange()
|
---|
| 317 | {
|
---|
| 318 | if (array_key_exists('range', $this->_params)) {
|
---|
| 319 | return $this->_params['range'];
|
---|
| 320 | } else {
|
---|
| 321 | return null;
|
---|
| 322 | }
|
---|
| 323 | }
|
---|
| 324 |
|
---|
| 325 | /**
|
---|
| 326 | * Sets the return-empty attribute for this query.
|
---|
| 327 | *
|
---|
| 328 | * @param mixed $value String or bool value for whether to return empty cells
|
---|
| 329 | * @return Zend_Gdata_Spreadsheets_CellQuery Provides a fluent interface
|
---|
| 330 | */
|
---|
| 331 | public function setReturnEmpty($value)
|
---|
| 332 | {
|
---|
| 333 | if (is_bool($value)) {
|
---|
| 334 | $this->_params['return-empty'] = ($value?'true':'false');
|
---|
| 335 | } else if ($value != null) {
|
---|
| 336 | $this->_params['return-empty'] = $value;
|
---|
| 337 | } else {
|
---|
| 338 | unset($this->_params['return-empty']);
|
---|
| 339 | }
|
---|
| 340 | return $this;
|
---|
| 341 | }
|
---|
| 342 |
|
---|
| 343 | /**
|
---|
| 344 | * Gets the return-empty attribute for this query.
|
---|
| 345 | *
|
---|
| 346 | * @return string return-empty
|
---|
| 347 | */
|
---|
| 348 | public function getReturnEmpty()
|
---|
| 349 | {
|
---|
| 350 | if (array_key_exists('return-empty', $this->_params)) {
|
---|
| 351 | return $this->_params['return-empty'];
|
---|
| 352 | } else {
|
---|
| 353 | return null;
|
---|
| 354 | }
|
---|
| 355 | }
|
---|
| 356 |
|
---|
| 357 | /**
|
---|
| 358 | * Gets the full query URL for this query.
|
---|
| 359 | *
|
---|
| 360 | * @return string url
|
---|
| 361 | */
|
---|
| 362 | public function getQueryUrl()
|
---|
| 363 | {
|
---|
| 364 | if ($this->_url == null) {
|
---|
| 365 | $uri = $this->_defaultFeedUri;
|
---|
| 366 |
|
---|
| 367 | if ($this->_spreadsheetKey != null) {
|
---|
| 368 | $uri .= '/'.$this->_spreadsheetKey;
|
---|
| 369 | } else {
|
---|
| 370 | require_once 'Zend/Gdata/App/Exception.php';
|
---|
| 371 | throw new Zend_Gdata_App_Exception('A spreadsheet key must be provided for cell queries.');
|
---|
| 372 | }
|
---|
| 373 |
|
---|
| 374 | if ($this->_worksheetId != null) {
|
---|
| 375 | $uri .= '/'.$this->_worksheetId;
|
---|
| 376 | } else {
|
---|
| 377 | require_once 'Zend/Gdata/App/Exception.php';
|
---|
| 378 | throw new Zend_Gdata_App_Exception('A worksheet id must be provided for cell queries.');
|
---|
| 379 | }
|
---|
| 380 |
|
---|
| 381 | if ($this->_visibility != null) {
|
---|
| 382 | $uri .= '/'.$this->_visibility;
|
---|
| 383 | } else {
|
---|
| 384 | require_once 'Zend/Gdata/App/Exception.php';
|
---|
| 385 | throw new Zend_Gdata_App_Exception('A visibility must be provided for cell queries.');
|
---|
| 386 | }
|
---|
| 387 |
|
---|
| 388 | if ($this->_projection != null) {
|
---|
| 389 | $uri .= '/'.$this->_projection;
|
---|
| 390 | } else {
|
---|
| 391 | require_once 'Zend/Gdata/App/Exception.php';
|
---|
| 392 | throw new Zend_Gdata_App_Exception('A projection must be provided for cell queries.');
|
---|
| 393 | }
|
---|
| 394 |
|
---|
| 395 | if ($this->_cellId != null) {
|
---|
| 396 | $uri .= '/'.$this->_cellId;
|
---|
| 397 | }
|
---|
| 398 | } else {
|
---|
| 399 | $uri = $this->_url;
|
---|
| 400 | }
|
---|
| 401 |
|
---|
| 402 | $uri .= $this->getQueryString();
|
---|
| 403 | return $uri;
|
---|
| 404 | }
|
---|
| 405 |
|
---|
| 406 | /**
|
---|
| 407 | * Gets the attribute query string for this query.
|
---|
| 408 | *
|
---|
| 409 | * @return string query string
|
---|
| 410 | */
|
---|
| 411 | public function getQueryString()
|
---|
| 412 | {
|
---|
| 413 | return parent::getQueryString();
|
---|
| 414 | }
|
---|
| 415 |
|
---|
| 416 | }
|
---|