File indexing completed on 2024-12-22 05:36:46
0001 <?php 0002 0003 /** 0004 * Zend Framework 0005 * 0006 * LICENSE 0007 * 0008 * This source file is subject to the new BSD license that is bundled 0009 * with this package in the file LICENSE.txt. 0010 * It is also available through the world-wide-web at this URL: 0011 * http://framework.zend.com/license/new-bsd 0012 * If you did not receive a copy of the license and are unable to 0013 * obtain it through the world-wide-web, please send an email 0014 * to license@zend.com so we can send you a copy immediately. 0015 * 0016 * @category Zend 0017 * @package Zend_Gdata 0018 * @subpackage Spreadsheets 0019 * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) 0020 * @license http://framework.zend.com/license/new-bsd New BSD License 0021 * @version $Id$ 0022 */ 0023 0024 /** 0025 * Zend_Gdata_App_util 0026 */ 0027 // require_once('Zend/Gdata/App/Util.php'); 0028 0029 /** 0030 * Zend_Gdata_Query 0031 */ 0032 // require_once('Zend/Gdata/Query.php'); 0033 0034 /** 0035 * Assists in constructing queries for Google Spreadsheets documents 0036 * 0037 * @link http://code.google.com/apis/gdata/spreadsheets/ 0038 * 0039 * @category Zend 0040 * @package Zend_Gdata 0041 * @subpackage Spreadsheets 0042 * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) 0043 * @license http://framework.zend.com/license/new-bsd New BSD License 0044 */ 0045 class Zend_Gdata_Spreadsheets_DocumentQuery extends Zend_Gdata_Query 0046 { 0047 0048 const SPREADSHEETS_FEED_URI = 'https://spreadsheets.google.com/feeds'; 0049 0050 protected $_defaultFeedUri = self::SPREADSHEETS_FEED_URI; 0051 protected $_documentType; 0052 protected $_visibility = 'private'; 0053 protected $_projection = 'full'; 0054 protected $_spreadsheetKey = null; 0055 protected $_worksheetId = null; 0056 0057 /** 0058 * Constructs a new Zend_Gdata_Spreadsheets_DocumentQuery object. 0059 */ 0060 public function __construct() 0061 { 0062 parent::__construct(); 0063 } 0064 0065 /** 0066 * Sets the spreadsheet key for this query. 0067 * @param string $value 0068 * @return Zend_Gdata_Spreadsheets_CellQuery Provides a fluent interface 0069 */ 0070 public function setSpreadsheetKey($value) 0071 { 0072 $this->_spreadsheetKey = $value; 0073 return $this; 0074 } 0075 0076 /** 0077 * Gets the spreadsheet key for this query. 0078 * @return string spreadsheet key 0079 */ 0080 public function getSpreadsheetKey() 0081 { 0082 return $this->_spreadsheetKey; 0083 } 0084 0085 /** 0086 * Sets the worksheet id for this query. 0087 * @param string $value 0088 * @return Zend_Gdata_Spreadsheets_CellQuery Provides a fluent interface 0089 */ 0090 public function setWorksheetId($value) 0091 { 0092 $this->_worksheetId = $value; 0093 return $this; 0094 } 0095 0096 /** 0097 * Gets the worksheet id for this query. 0098 * @return string worksheet id 0099 */ 0100 public function getWorksheetId() 0101 { 0102 return $this->_worksheetId; 0103 } 0104 0105 /** 0106 * Sets the document type for this query. 0107 * @param string $value spreadsheets or worksheets 0108 * @return Zend_Gdata_Spreadsheets_DocumentQuery Provides a fluent interface 0109 */ 0110 public function setDocumentType($value) 0111 { 0112 $this->_documentType = $value; 0113 return $this; 0114 } 0115 0116 /** 0117 * Gets the document type for this query. 0118 * @return string document type 0119 */ 0120 public function getDocumentType() 0121 { 0122 return $this->_documentType; 0123 } 0124 0125 /** 0126 * Sets the projection for this query. 0127 * @param string $value 0128 * @return Zend_Gdata_Spreadsheets_DocumentQuery Provides a fluent interface 0129 */ 0130 public function setProjection($value) 0131 { 0132 $this->_projection = $value; 0133 return $this; 0134 } 0135 0136 /** 0137 * Sets the visibility for this query. 0138 * @return Zend_Gdata_Spreadsheets_DocumentQuery Provides a fluent interface 0139 */ 0140 public function setVisibility($value) 0141 { 0142 $this->_visibility = $value; 0143 return $this; 0144 } 0145 0146 /** 0147 * Gets the projection for this query. 0148 * @return string projection 0149 */ 0150 public function getProjection() 0151 { 0152 return $this->_projection; 0153 } 0154 0155 /** 0156 * Gets the visibility for this query. 0157 * @return string visibility 0158 */ 0159 public function getVisibility() 0160 { 0161 return $this->_visibility; 0162 } 0163 0164 /** 0165 * Sets the title attribute for this query. 0166 * @param string $value 0167 * @return Zend_Gdata_Spreadsheets_DocumentQuery Provides a fluent interface 0168 */ 0169 public function setTitle($value) 0170 { 0171 if ($value != null) { 0172 $this->_params['title'] = $value; 0173 } else { 0174 unset($this->_params['title']); 0175 } 0176 return $this; 0177 } 0178 0179 /** 0180 * Sets the title-exact attribute for this query. 0181 * @param string $value 0182 * @return Zend_Gdata_Spreadsheets_DocumentQuery Provides a fluent interface 0183 */ 0184 public function setTitleExact($value) 0185 { 0186 if ($value != null) { 0187 $this->_params['title-exact'] = $value; 0188 } else { 0189 unset($this->_params['title-exact']); 0190 } 0191 return $this; 0192 } 0193 0194 /** 0195 * Gets the title attribute for this query. 0196 * @return string title 0197 */ 0198 public function getTitle() 0199 { 0200 if (array_key_exists('title', $this->_params)) { 0201 return $this->_params['title']; 0202 } else { 0203 return null; 0204 } 0205 } 0206 0207 /** 0208 * Gets the title-exact attribute for this query. 0209 * @return string title-exact 0210 */ 0211 public function getTitleExact() 0212 { 0213 if (array_key_exists('title-exact', $this->_params)) { 0214 return $this->_params['title-exact']; 0215 } else { 0216 return null; 0217 } 0218 } 0219 0220 private function appendVisibilityProjection() 0221 { 0222 $uri = ''; 0223 0224 if ($this->_visibility != null) { 0225 $uri .= '/'.$this->_visibility; 0226 } else { 0227 // require_once 'Zend/Gdata/App/Exception.php'; 0228 throw new Zend_Gdata_App_Exception('A visibility must be provided for document queries.'); 0229 } 0230 0231 if ($this->_projection != null) { 0232 $uri .= '/'.$this->_projection; 0233 } else { 0234 // require_once 'Zend/Gdata/App/Exception.php'; 0235 throw new Zend_Gdata_App_Exception('A projection must be provided for document queries.'); 0236 } 0237 0238 return $uri; 0239 } 0240 0241 0242 /** 0243 * Gets the full query URL for this query. 0244 * @return string url 0245 */ 0246 public function getQueryUrl() 0247 { 0248 $uri = $this->_defaultFeedUri; 0249 0250 if ($this->_documentType != null) { 0251 $uri .= '/'.$this->_documentType; 0252 } else { 0253 // require_once 'Zend/Gdata/App/Exception.php'; 0254 throw new Zend_Gdata_App_Exception('A document type must be provided for document queries.'); 0255 } 0256 0257 if ($this->_documentType == 'spreadsheets') { 0258 $uri .= $this->appendVisibilityProjection(); 0259 if ($this->_spreadsheetKey != null) { 0260 $uri .= '/'.$this->_spreadsheetKey; 0261 } 0262 } else if ($this->_documentType == 'worksheets') { 0263 if ($this->_spreadsheetKey != null) { 0264 $uri .= '/'.$this->_spreadsheetKey; 0265 } else { 0266 // require_once 'Zend/Gdata/App/Exception.php'; 0267 throw new Zend_Gdata_App_Exception('A spreadsheet key must be provided for worksheet document queries.'); 0268 } 0269 $uri .= $this->appendVisibilityProjection(); 0270 if ($this->_worksheetId != null) { 0271 $uri .= '/'.$this->_worksheetId; 0272 } 0273 } 0274 0275 $uri .= $this->getQueryString(); 0276 return $uri; 0277 } 0278 0279 /** 0280 * Gets the attribute query string for this query. 0281 * @return string query string 0282 */ 0283 public function getQueryString() 0284 { 0285 return parent::getQueryString(); 0286 } 0287 0288 }