PageRenderTime 48ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 0ms

/Zend/Gdata/Spreadsheets/CellQuery.php

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