ListQuery.php 7.6 KB

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