ListQuery.php 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305
  1. <?php
  2. /**
  3. * Zend Framework
  4. *
  5. * LICENSE
  6. *
  7. * This source file is subject to the new BSD license that is bundled
  8. * with this package in the file LICENSE.txt.
  9. * It is also available through the world-wide-web at this URL:
  10. * http://framework.zend.com/license/new-bsd
  11. * If you did not receive a copy of the license and are unable to
  12. * obtain it through the world-wide-web, please send an email
  13. * to license@zend.com so we can send you a copy immediately.
  14. *
  15. * @category Zend
  16. * @package Zend_Gdata
  17. * @subpackage Spreadsheets
  18. * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
  19. * @license http://framework.zend.com/license/new-bsd New BSD License
  20. * @version $Id$
  21. */
  22. /**
  23. * Zend_Gdata_App_util
  24. */
  25. require_once('Zend/Gdata/App/Util.php');
  26. /**
  27. * Zend_Gdata_Query
  28. */
  29. require_once('Zend/Gdata/Query.php');
  30. /**
  31. * Assists in constructing queries for Google Spreadsheets lists
  32. *
  33. * @link http://code.google.com/apis/gdata/calendar/
  34. *
  35. * @category Zend
  36. * @package Zend_Gdata
  37. * @subpackage Spreadsheets
  38. * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
  39. * @license http://framework.zend.com/license/new-bsd New BSD License
  40. */
  41. class Zend_Gdata_Spreadsheets_ListQuery extends Zend_Gdata_Query
  42. {
  43. const SPREADSHEETS_LIST_FEED_URI = 'https://spreadsheets.google.com/feeds/list';
  44. protected $_defaultFeedUri = self::SPREADSHEETS_LIST_FEED_URI;
  45. protected $_visibility = 'private';
  46. protected $_projection = 'full';
  47. protected $_spreadsheetKey = null;
  48. protected $_worksheetId = 'default';
  49. protected $_rowId = null;
  50. /**
  51. * Constructs a new Zend_Gdata_Spreadsheets_ListQuery object.
  52. */
  53. public function __construct()
  54. {
  55. parent::__construct();
  56. }
  57. /**
  58. * Sets the spreadsheet key for the query.
  59. * @param string $value
  60. * @return Zend_Gdata_Spreadsheets_CellQuery Provides a fluent interface
  61. */
  62. public function setSpreadsheetKey($value)
  63. {
  64. $this->_spreadsheetKey = $value;
  65. return $this;
  66. }
  67. /**
  68. * Gets the spreadsheet key for the query.
  69. * @return string spreadsheet key
  70. */
  71. public function getSpreadsheetKey()
  72. {
  73. return $this->_spreadsheetKey;
  74. }
  75. /**
  76. * Sets the worksheet id for the query.
  77. * @param string $value
  78. * @return Zend_Gdata_Spreadsheets_CellQuery Provides a fluent interface
  79. */
  80. public function setWorksheetId($value)
  81. {
  82. $this->_worksheetId = $value;
  83. return $this;
  84. }
  85. /**
  86. * Gets the worksheet id for the query.
  87. * @return string worksheet id
  88. */
  89. public function getWorksheetId()
  90. {
  91. return $this->_worksheetId;
  92. }
  93. /**
  94. * Sets the row id for the query.
  95. * @param string $value row id
  96. * @return Zend_Gdata_Spreadsheets_CellQuery Provides a fluent interface
  97. */
  98. public function setRowId($value)
  99. {
  100. $this->_rowId = $value;
  101. return $this;
  102. }
  103. /**
  104. * Gets the row id for the query.
  105. * @return string row id
  106. */
  107. public function getRowId()
  108. {
  109. return $this->_rowId;
  110. }
  111. /**
  112. * Sets the projection for the query.
  113. * @param string $value Projection
  114. * @return Zend_Gdata_Spreadsheets_ListQuery Provides a fluent interface
  115. */
  116. public function setProjection($value)
  117. {
  118. $this->_projection = $value;
  119. return $this;
  120. }
  121. /**
  122. * Sets the visibility for this query.
  123. * @param string $value visibility
  124. * @return Zend_Gdata_Spreadsheets_ListQuery Provides a fluent interface
  125. */
  126. public function setVisibility($value)
  127. {
  128. $this->_visibility = $value;
  129. return $this;
  130. }
  131. /**
  132. * Gets the projection for this query.
  133. * @return string projection
  134. */
  135. public function getProjection()
  136. {
  137. return $this->_projection;
  138. }
  139. /**
  140. * Gets the visibility for this query.
  141. * @return string visibility
  142. */
  143. public function getVisibility()
  144. {
  145. return $this->_visibility;
  146. }
  147. /**
  148. * Sets the spreadsheet key for this query.
  149. * @param string $value
  150. * @return Zend_Gdata_Spreadsheets_DocumentQuery Provides a fluent interface
  151. */
  152. public function setSpreadsheetQuery($value)
  153. {
  154. if ($value != null) {
  155. $this->_params['sq'] = $value;
  156. } else {
  157. unset($this->_params['sq']);
  158. }
  159. return $this;
  160. }
  161. /**
  162. * Gets the spreadsheet key for this query.
  163. * @return string spreadsheet query
  164. */
  165. public function getSpreadsheetQuery()
  166. {
  167. if (array_key_exists('sq', $this->_params)) {
  168. return $this->_params['sq'];
  169. } else {
  170. return null;
  171. }
  172. }
  173. /**
  174. * Sets the orderby attribute for this query.
  175. * @param string $value
  176. * @return Zend_Gdata_Spreadsheets_DocumentQuery Provides a fluent interface
  177. */
  178. public function setOrderBy($value)
  179. {
  180. if ($value != null) {
  181. $this->_params['orderby'] = $value;
  182. } else {
  183. unset($this->_params['orderby']);
  184. }
  185. return $this;
  186. }
  187. /**
  188. * Gets the orderby attribute for this query.
  189. * @return string orderby
  190. */
  191. public function getOrderBy()
  192. {
  193. if (array_key_exists('orderby', $this->_params)) {
  194. return $this->_params['orderby'];
  195. } else {
  196. return null;
  197. }
  198. }
  199. /**
  200. * Sets the reverse attribute for this query.
  201. * @param string $value
  202. * @return Zend_Gdata_Spreadsheets_DocumentQuery Provides a fluent interface
  203. */
  204. public function setReverse($value)
  205. {
  206. if ($value != null) {
  207. $this->_params['reverse'] = $value;
  208. } else {
  209. unset($this->_params['reverse']);
  210. }
  211. return $this;
  212. }
  213. /**
  214. * Gets the reverse attribute for this query.
  215. * @return string reverse
  216. */
  217. public function getReverse()
  218. {
  219. if (array_key_exists('reverse', $this->_params)) {
  220. return $this->_params['reverse'];
  221. } else {
  222. return null;
  223. }
  224. }
  225. /**
  226. * Gets the full query URL for this query.
  227. * @return string url
  228. */
  229. public function getQueryUrl()
  230. {
  231. $uri = $this->_defaultFeedUri;
  232. if ($this->_spreadsheetKey != null) {
  233. $uri .= '/'.$this->_spreadsheetKey;
  234. } else {
  235. require_once 'Zend/Gdata/App/Exception.php';
  236. throw new Zend_Gdata_App_Exception('A spreadsheet key must be provided for list queries.');
  237. }
  238. if ($this->_worksheetId != null) {
  239. $uri .= '/'.$this->_worksheetId;
  240. } else {
  241. require_once 'Zend/Gdata/App/Exception.php';
  242. throw new Zend_Gdata_App_Exception('A worksheet id must be provided for list queries.');
  243. }
  244. if ($this->_visibility != null) {
  245. $uri .= '/'.$this->_visibility;
  246. } else {
  247. require_once 'Zend/Gdata/App/Exception.php';
  248. throw new Zend_Gdata_App_Exception('A visibility must be provided for list queries.');
  249. }
  250. if ($this->_projection != null) {
  251. $uri .= '/'.$this->_projection;
  252. } else {
  253. require_once 'Zend/Gdata/App/Exception.php';
  254. throw new Zend_Gdata_App_Exception('A projection must be provided for list queries.');
  255. }
  256. if ($this->_rowId != null) {
  257. $uri .= '/'.$this->_rowId;
  258. }
  259. $uri .= $this->getQueryString();
  260. return $uri;
  261. }
  262. /**
  263. * Gets the attribute query string for this query.
  264. * @return string query string
  265. */
  266. public function getQueryString()
  267. {
  268. return parent::getQueryString();
  269. }
  270. }