File indexing completed on 2024-06-16 05:30:08

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 cells
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_CellQuery extends Zend_Gdata_Query
0046 {
0047 
0048     const SPREADSHEETS_CELL_FEED_URI = 'https://spreadsheets.google.com/feeds/cells';
0049 
0050     protected $_defaultFeedUri = self::SPREADSHEETS_CELL_FEED_URI;
0051     protected $_visibility = 'private';
0052     protected $_projection = 'full';
0053     protected $_spreadsheetKey = null;
0054     protected $_worksheetId = 'default';
0055     protected $_cellId = null;
0056 
0057     /**
0058      * Constructs a new Zend_Gdata_Spreadsheets_CellQuery object.
0059      *
0060      * @param string $url Base URL to use for queries
0061      */
0062     public function __construct($url = null)
0063     {
0064         parent::__construct($url);
0065     }
0066 
0067     /**
0068      * Sets the spreadsheet key for this query.
0069      *
0070      * @param string $value
0071      * @return Zend_Gdata_Spreadsheets_CellQuery Provides a fluent interface
0072      */
0073     public function setSpreadsheetKey($value)
0074     {
0075         $this->_spreadsheetKey = $value;
0076         return $this;
0077     }
0078 
0079     /**
0080      * Gets the spreadsheet key for this query.
0081      *
0082      * @return string spreadsheet key
0083      */
0084     public function getSpreadsheetKey()
0085     {
0086         return $this->_spreadsheetKey;
0087     }
0088 
0089     /**
0090      * Sets the worksheet id for this query.
0091      *
0092      * @param string $value
0093      * @return Zend_Gdata_Spreadsheets_CellQuery Provides a fluent interface
0094      */
0095     public function setWorksheetId($value)
0096     {
0097         $this->_worksheetId = $value;
0098         return $this;
0099     }
0100 
0101     /**
0102      * Gets the worksheet id for this query.
0103      *
0104      * @return string worksheet id
0105      */
0106     public function getWorksheetId()
0107     {
0108         return $this->_worksheetId;
0109     }
0110 
0111     /**
0112      * Sets the cell id for this query.
0113      *
0114      * @param string $value
0115      * @return Zend_Gdata_Spreadsheets_CellQuery Provides a fluent interface
0116      */
0117     public function setCellId($value)
0118     {
0119         $this->_cellId = $value;
0120         return $this;
0121     }
0122 
0123     /**
0124      * Gets the cell id for this query.
0125      *
0126      * @return string cell id
0127      */
0128     public function getCellId()
0129     {
0130         return $this->_cellId;
0131     }
0132 
0133     /**
0134      * Sets the projection for this query.
0135      *
0136      * @param string $value
0137      * @return Zend_Gdata_Spreadsheets_CellQuery Provides a fluent interface
0138      */
0139     public function setProjection($value)
0140     {
0141         $this->_projection = $value;
0142         return $this;
0143     }
0144 
0145     /**
0146      * Sets the visibility for this query.
0147      *
0148      * @return Zend_Gdata_Spreadsheets_CellQuery Provides a fluent interface
0149      */
0150     public function setVisibility($value)
0151     {
0152         $this->_visibility = $value;
0153         return $this;
0154     }
0155 
0156     /**
0157      * Gets the projection for this query.
0158      *
0159      * @return string projection
0160      */
0161     public function getProjection()
0162     {
0163         return $this->_projection;
0164     }
0165 
0166     /**
0167      * Gets the visibility for this query.
0168      *
0169      * @return string visibility
0170      */
0171     public function getVisibility()
0172     {
0173         return $this->_visibility;
0174     }
0175 
0176     /**
0177      * Sets the min-row attribute for this query.
0178      *
0179      * @param string $value
0180      * @return Zend_Gdata_Spreadsheets_CellQuery Provides a fluent interface
0181      */
0182     public function setMinRow($value)
0183     {
0184         if ($value != null) {
0185             $this->_params['min-row'] = $value;
0186         } else {
0187             unset($this->_params['min-row']);
0188         }
0189         return $this;
0190     }
0191 
0192     /**
0193      * Gets the min-row attribute for this query.
0194      *
0195      * @return string min-row
0196      */
0197     public function getMinRow()
0198     {
0199         if (array_key_exists('min-row', $this->_params)) {
0200             return $this->_params['min-row'];
0201         } else {
0202             return null;
0203         }
0204     }
0205 
0206     /**
0207      * Sets the max-row attribute for this query.
0208      *
0209      * @param string $value
0210      * @return Zend_Gdata_Spreadsheets_CellQuery Provides a fluent interface
0211      */
0212     public function setMaxRow($value)
0213     {
0214         if ($value != null) {
0215             $this->_params['max-row'] = $value;
0216         } else {
0217             unset($this->_params['max-row']);
0218         }
0219         return $this;
0220     }
0221 
0222     /**
0223      * Gets the max-row attribute for this query.
0224      *
0225      * @return string max-row
0226      */
0227     public function getMaxRow()
0228     {
0229         if (array_key_exists('max-row', $this->_params)) {
0230             return $this->_params['max-row'];
0231         } else {
0232             return null;
0233         }
0234     }
0235 
0236     /**
0237      * Sets the min-col attribute for this query.
0238      *
0239      * @param string $value
0240      * @return Zend_Gdata_Spreadsheets_CellQuery Provides a fluent interface
0241      */
0242     public function setMinCol($value)
0243     {
0244         if ($value != null) {
0245             $this->_params['min-col'] = $value;
0246         } else {
0247             unset($this->_params['min-col']);
0248         }
0249         return $this;
0250     }
0251 
0252     /**
0253      * Gets the min-col attribute for this query.
0254      *
0255      * @return string min-col
0256      */
0257     public function getMinCol()
0258     {
0259         if (array_key_exists('min-col', $this->_params)) {
0260             return $this->_params['min-col'];
0261         } else {
0262             return null;
0263         }
0264     }
0265 
0266     /**
0267      * Sets the max-col attribute for this query.
0268      *
0269      * @param string $value
0270      * @return Zend_Gdata_Spreadsheets_CellQuery Provides a fluent interface
0271      */
0272     public function setMaxCol($value)
0273     {
0274         if ($value != null) {
0275             $this->_params['max-col'] = $value;
0276         } else {
0277             unset($this->_params['max-col']);
0278         }
0279         return $this;
0280     }
0281 
0282     /**
0283      * Gets the max-col attribute for this query.
0284      *
0285      * @return string max-col
0286      */
0287     public function getMaxCol()
0288     {
0289         if (array_key_exists('max-col', $this->_params)) {
0290             return $this->_params['max-col'];
0291         } else {
0292             return null;
0293         }
0294     }
0295 
0296     /**
0297      * Sets the range attribute for this query.
0298      *
0299      * @param string $value
0300      * @return Zend_Gdata_Spreadsheets_CellQuery Provides a fluent interface
0301      */
0302     public function setRange($value)
0303     {
0304         if ($value != null) {
0305             $this->_params['range'] = $value;
0306         } else {
0307             unset($this->_params['range']);
0308         }
0309         return $this;
0310     }
0311 
0312     /**
0313      * Gets the range attribute for this query.
0314      *
0315      * @return string range
0316      */
0317     public function getRange()
0318     {
0319         if (array_key_exists('range', $this->_params)) {
0320             return $this->_params['range'];
0321         } else {
0322             return null;
0323         }
0324     }
0325 
0326     /**
0327      * Sets the return-empty attribute for this query.
0328      *
0329      * @param mixed $value String or bool value for whether to return empty cells
0330      * @return Zend_Gdata_Spreadsheets_CellQuery Provides a fluent interface
0331      */
0332     public function setReturnEmpty($value)
0333     {
0334         if (is_bool($value)) {
0335             $this->_params['return-empty'] = ($value?'true':'false');
0336         } else if ($value != null) {
0337             $this->_params['return-empty'] = $value;
0338         } else {
0339             unset($this->_params['return-empty']);
0340         }
0341         return $this;
0342     }
0343 
0344     /**
0345      * Gets the return-empty attribute for this query.
0346      *
0347      * @return string return-empty
0348      */
0349     public function getReturnEmpty()
0350     {
0351         if (array_key_exists('return-empty', $this->_params)) {
0352             return $this->_params['return-empty'];
0353         } else {
0354             return null;
0355         }
0356     }
0357 
0358     /**
0359      * Gets the full query URL for this query.
0360      *
0361      * @return string url
0362      */
0363     public function getQueryUrl()
0364     {
0365         if ($this->_url == null) {
0366             $uri = $this->_defaultFeedUri;
0367 
0368             if ($this->_spreadsheetKey != null) {
0369                 $uri .= '/'.$this->_spreadsheetKey;
0370             } else {
0371                 // require_once 'Zend/Gdata/App/Exception.php';
0372                 throw new Zend_Gdata_App_Exception('A spreadsheet key must be provided for cell queries.');
0373             }
0374 
0375             if ($this->_worksheetId != null) {
0376                 $uri .= '/'.$this->_worksheetId;
0377             } else {
0378                 // require_once 'Zend/Gdata/App/Exception.php';
0379                 throw new Zend_Gdata_App_Exception('A worksheet id must be provided for cell queries.');
0380             }
0381 
0382             if ($this->_visibility != null) {
0383                 $uri .= '/'.$this->_visibility;
0384             } else {
0385                 // require_once 'Zend/Gdata/App/Exception.php';
0386                 throw new Zend_Gdata_App_Exception('A visibility must be provided for cell queries.');
0387             }
0388 
0389             if ($this->_projection != null) {
0390                 $uri .= '/'.$this->_projection;
0391             } else {
0392                 // require_once 'Zend/Gdata/App/Exception.php';
0393                 throw new Zend_Gdata_App_Exception('A projection must be provided for cell queries.');
0394             }
0395 
0396             if ($this->_cellId != null) {
0397                 $uri .= '/'.$this->_cellId;
0398             }
0399         } else {
0400             $uri = $this->_url;
0401         }
0402 
0403         $uri .= $this->getQueryString();
0404         return $uri;
0405     }
0406 
0407     /**
0408      * Gets the attribute query string for this query.
0409      *
0410      * @return string query string
0411      */
0412     public function getQueryString()
0413     {
0414         return parent::getQueryString();
0415     }
0416 
0417 }