File indexing completed on 2024-12-22 05:36:46

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  * @see Zend_Gdata_Entry
0026  */
0027 // require_once 'Zend/Gdata/Entry.php';
0028 
0029 /**
0030  * @see Zend_Gdata_Spreadsheets_Extension_RowCount
0031  */
0032 // require_once 'Zend/Gdata/Spreadsheets/Extension/RowCount.php';
0033 
0034 /**
0035  * @see Zend_Gdata_Spreadsheets_Extension_ColCount
0036  */
0037 // require_once 'Zend/Gdata/Spreadsheets/Extension/ColCount.php';
0038 
0039 /**
0040  * Concrete class for working with Worksheet entries.
0041  *
0042  * @category   Zend
0043  * @package    Zend_Gdata
0044  * @subpackage Spreadsheets
0045  * @copyright  Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
0046  * @license    http://framework.zend.com/license/new-bsd     New BSD License
0047  */
0048 class Zend_Gdata_Spreadsheets_WorksheetEntry extends Zend_Gdata_Entry
0049 {
0050 
0051     protected $_entryClassName = 'Zend_Gdata_Spreadsheets_WorksheetEntry';
0052 
0053     protected $_rowCount = null;
0054     protected $_colCount = null;
0055 
0056     /**
0057      * Constructs a new Zend_Gdata_Spreadsheets_WorksheetEntry object.
0058      *
0059      * @param DOMElement $element (optional) The DOMElement on which to base this object.
0060      */
0061     public function __construct($element = null)
0062     {
0063         $this->registerAllNamespaces(Zend_Gdata_Spreadsheets::$namespaces);
0064         parent::__construct($element);
0065     }
0066 
0067     /**
0068      * Retrieves a DOMElement which corresponds to this element and all
0069      * child properties.  This is used to build an entry back into a DOM
0070      * and eventually XML text for sending to the server upon updates, or
0071      * for application storage/persistence.
0072      *
0073      * @param DOMDocument $doc The DOMDocument used to construct DOMElements
0074      * @return DOMElement The DOMElement representing this element and all
0075      * child properties.
0076      */
0077     public function getDOM($doc = null, $majorVersion = 1, $minorVersion = null)
0078     {
0079         $element = parent::getDOM($doc, $majorVersion, $minorVersion);
0080         if ($this->_rowCount != null) {
0081             $element->appendChild($this->_rowCount->getDOM($element->ownerDocument));
0082         }
0083         if ($this->_colCount != null) {
0084             $element->appendChild($this->_colCount->getDOM($element->ownerDocument));
0085         }
0086         return $element;
0087     }
0088 
0089     /**
0090      * Creates individual Entry objects of the appropriate type and
0091      * stores them in the $_entry array based upon DOM data.
0092      *
0093      * @param DOMNode $child The DOMNode to process
0094      */
0095     protected function takeChildFromDOM($child)
0096     {
0097         $absoluteNodeName = $child->namespaceURI . ':' . $child->localName;
0098         switch ($absoluteNodeName) {
0099             case $this->lookupNamespace('gs') . ':' . 'rowCount';
0100                 $rowCount = new Zend_Gdata_Spreadsheets_Extension_RowCount();
0101                 $rowCount->transferFromDOM($child);
0102                 $this->_rowCount = $rowCount;
0103                 break;
0104             case $this->lookupNamespace('gs') . ':' . 'colCount';
0105                 $colCount = new Zend_Gdata_Spreadsheets_Extension_ColCount();
0106                 $colCount->transferFromDOM($child);
0107                 $this->_colCount = $colCount;
0108                 break;
0109             default:
0110                 parent::takeChildFromDOM($child);
0111                 break;
0112         }
0113     }
0114 
0115 
0116     /**
0117      * Gets the row count for this entry.
0118      *
0119      * @return string The row count for the entry.
0120      */
0121     public function getRowCount()
0122     {
0123         return $this->_rowCount;
0124     }
0125 
0126     /**
0127      * Gets the column count for this entry.
0128      *
0129      * @return string The column count for the entry.
0130      */
0131     public function getColumnCount()
0132     {
0133         return $this->_colCount;
0134     }
0135 
0136     /**
0137      * Sets the row count for this entry.
0138      *
0139      * @param string $rowCount The new row count for the entry.
0140      */
0141     public function setRowCount($rowCount)
0142     {
0143         $this->_rowCount = $rowCount;
0144         return $this;
0145     }
0146 
0147     /**
0148      * Sets the column count for this entry.
0149      *
0150      * @param string $colCount The new column count for the entry.
0151      */
0152     public function setColumnCount($colCount)
0153     {
0154         $this->_colCount = $colCount;
0155         return $this;
0156     }
0157 
0158     /**
0159      * Returns the content of all rows as an associative array
0160      *
0161      * @return array An array of rows.  Each element of the array is an associative array of data
0162      */
0163     public function getContentsAsRows()
0164     {
0165         $service = new Zend_Gdata_Spreadsheets($this->getHttpClient());
0166         return $service->getSpreadsheetListFeedContents($this);
0167     }
0168 
0169     /**
0170      * Returns the content of all cells as an associative array, indexed
0171      * off the cell location  (ie 'A1', 'D4', etc).  Each element of
0172      * the array is an associative array with a 'value' and a 'function'.
0173      * Only non-empty cells are returned by default.  'range' is the
0174      * value of the 'range' query parameter specified at:
0175      * http://code.google.com/apis/spreadsheets/reference.html#cells_Parameters
0176      *
0177      * @param string $range The range of cells to retrieve
0178      * @param boolean $empty Whether to retrieve empty cells
0179      * @return array An associative array of cells
0180      */
0181     public function getContentsAsCells($range = null, $empty = false)
0182     {
0183         $service = new Zend_Gdata_Spreadsheets($this->getHttpClient());
0184         return $service->getSpreadsheetCellFeedContents($this, $range, $empty);
0185     }
0186 
0187 }