*prechod na novsiu verziu ZF
[sport-group.git] / library / Zend / Gdata / Spreadsheets / DocumentQuery.php
blob7912e9864201656981adf2da5aa48be23fca094c
1 <?php
3 /**
4 * Zend Framework
6 * LICENSE
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.
16 * @category Zend
17 * @package Zend_Gdata
18 * @subpackage Spreadsheets
19 * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
20 * @license http://framework.zend.com/license/new-bsd New BSD License
21 * @version $Id: DocumentQuery.php 16971 2009-07-22 18:05:45Z mikaelkael $
24 /**
25 * Zend_Gdata_App_util
27 require_once('Zend/Gdata/App/Util.php');
29 /**
30 * Zend_Gdata_Query
32 require_once('Zend/Gdata/Query.php');
34 /**
35 * Assists in constructing queries for Google Spreadsheets documents
37 * @link http://code.google.com/apis/gdata/spreadsheets/
39 * @category Zend
40 * @package Zend_Gdata
41 * @subpackage Spreadsheets
42 * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
43 * @license http://framework.zend.com/license/new-bsd New BSD License
45 class Zend_Gdata_Spreadsheets_DocumentQuery extends Zend_Gdata_Query
48 const SPREADSHEETS_FEED_URI = 'http://spreadsheets.google.com/feeds';
50 protected $_defaultFeedUri = self::SPREADSHEETS_FEED_URI;
51 protected $_documentType;
52 protected $_visibility = 'private';
53 protected $_projection = 'full';
54 protected $_spreadsheetKey = null;
55 protected $_worksheetId = null;
57 /**
58 * Constructs a new Zend_Gdata_Spreadsheets_DocumentQuery object.
60 public function __construct()
62 parent::__construct();
65 /**
66 * Sets the spreadsheet key for this query.
67 * @param string $value
68 * @return Zend_Gdata_Spreadsheets_CellQuery Provides a fluent interface
70 public function setSpreadsheetKey($value)
72 $this->_spreadsheetKey = $value;
73 return $this;
76 /**
77 * Gets the spreadsheet key for this query.
78 * @return string spreadsheet key
80 public function getSpreadsheetKey()
82 return $this->_spreadsheetKey;
85 /**
86 * Sets the worksheet id for this query.
87 * @param string $value
88 * @return Zend_Gdata_Spreadsheets_CellQuery Provides a fluent interface
90 public function setWorksheetId($value)
92 $this->_worksheetId = $value;
93 return $this;
96 /**
97 * Gets the worksheet id for this query.
98 * @return string worksheet id
100 public function getWorksheetId()
102 return $this->_worksheetId;
106 * Sets the document type for this query.
107 * @param string $value spreadsheets or worksheets
108 * @return Zend_Gdata_Spreadsheets_DocumentQuery Provides a fluent interface
110 public function setDocumentType($value)
112 $this->_documentType = $value;
113 return $this;
117 * Gets the document type for this query.
118 * @return string document type
120 public function getDocumentType()
122 return $this->_documentType;
126 * Sets the projection for this query.
127 * @param string $value
128 * @return Zend_Gdata_Spreadsheets_DocumentQuery Provides a fluent interface
130 public function setProjection($value)
132 $this->_projection = $value;
133 return $this;
137 * Sets the visibility for this query.
138 * @return Zend_Gdata_Spreadsheets_DocumentQuery Provides a fluent interface
140 public function setVisibility($value)
142 $this->_visibility = $value;
143 return $this;
147 * Gets the projection for this query.
148 * @return string projection
150 public function getProjection()
152 return $this->_projection;
156 * Gets the visibility for this query.
157 * @return string visibility
159 public function getVisibility()
161 return $this->_visibility;
165 * Sets the title attribute for this query.
166 * @param string $value
167 * @return Zend_Gdata_Spreadsheets_DocumentQuery Provides a fluent interface
169 public function setTitle($value)
171 if ($value != null) {
172 $this->_params['title'] = $value;
173 } else {
174 unset($this->_params['title']);
176 return $this;
180 * Sets the title-exact attribute for this query.
181 * @param string $value
182 * @return Zend_Gdata_Spreadsheets_DocumentQuery Provides a fluent interface
184 public function setTitleExact($value)
186 if ($value != null) {
187 $this->_params['title-exact'] = $value;
188 } else {
189 unset($this->_params['title-exact']);
191 return $this;
195 * Gets the title attribute for this query.
196 * @return string title
198 public function getTitle()
200 if (array_key_exists('title', $this->_params)) {
201 return $this->_params['title'];
202 } else {
203 return null;
208 * Gets the title-exact attribute for this query.
209 * @return string title-exact
211 public function getTitleExact()
213 if (array_key_exists('title-exact', $this->_params)) {
214 return $this->_params['title-exact'];
215 } else {
216 return null;
220 private function appendVisibilityProjection()
222 $uri = '';
224 if ($this->_visibility != null) {
225 $uri .= '/'.$this->_visibility;
226 } else {
227 require_once 'Zend/Gdata/App/Exception.php';
228 throw new Zend_Gdata_App_Exception('A visibility must be provided for document queries.');
231 if ($this->_projection != null) {
232 $uri .= '/'.$this->_projection;
233 } else {
234 require_once 'Zend/Gdata/App/Exception.php';
235 throw new Zend_Gdata_App_Exception('A projection must be provided for document queries.');
238 return $uri;
243 * Gets the full query URL for this query.
244 * @return string url
246 public function getQueryUrl()
248 $uri = $this->_defaultFeedUri;
250 if ($this->_documentType != null) {
251 $uri .= '/'.$this->_documentType;
252 } else {
253 require_once 'Zend/Gdata/App/Exception.php';
254 throw new Zend_Gdata_App_Exception('A document type must be provided for document queries.');
257 if ($this->_documentType == 'spreadsheets') {
258 $uri .= $this->appendVisibilityProjection();
259 if ($this->_spreadsheetKey != null) {
260 $uri .= '/'.$this->_spreadsheetKey;
262 } else if ($this->_documentType == 'worksheets') {
263 if ($this->_spreadsheetKey != null) {
264 $uri .= '/'.$this->_spreadsheetKey;
265 } else {
266 require_once 'Zend/Gdata/App/Exception.php';
267 throw new Zend_Gdata_App_Exception('A spreadsheet key must be provided for worksheet document queries.');
269 $uri .= $this->appendVisibilityProjection();
270 if ($this->_worksheetId != null) {
271 $uri .= '/'.$this->_worksheetId;
275 $uri .= $this->getQueryString();
276 return $uri;
280 * Gets the attribute query string for this query.
281 * @return string query string
283 public function getQueryString()
285 return parent::getQueryString();