PageRenderTime 48ms CodeModel.GetById 22ms RepoModel.GetById 1ms app.codeStats 0ms

/src/application/libraries/Zend/Gdata/Spreadsheets/CellQuery.php

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