1 | <?php
|
---|
2 |
|
---|
3 | /**
|
---|
4 | * Zend Framework
|
---|
5 | *
|
---|
6 | * LICENSE
|
---|
7 | *
|
---|
8 | * This source file is subject to the new BSD license that is bundled
|
---|
9 | * with this package in the file LICENSE.txt.
|
---|
10 | * It is also available through the world-wide-web at this URL:
|
---|
11 | * http://framework.zend.com/license/new-bsd
|
---|
12 | * If you did not receive a copy of the license and are unable to
|
---|
13 | * obtain it through the world-wide-web, please send an email
|
---|
14 | * to license@zend.com so we can send you a copy immediately.
|
---|
15 | *
|
---|
16 | * @category Zend
|
---|
17 | * @package Zend_Gdata
|
---|
18 | * @subpackage Spreadsheets
|
---|
19 | * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
---|
20 | * @license http://framework.zend.com/license/new-bsd New BSD License
|
---|
21 | */
|
---|
22 |
|
---|
23 | /**
|
---|
24 | * @see Zend_Gdata_Entry
|
---|
25 | */
|
---|
26 | require_once 'Zend/Gdata/Entry.php';
|
---|
27 |
|
---|
28 | /**
|
---|
29 | * @see Zend_Gdata_Spreadsheets_Extension_RowCount
|
---|
30 | */
|
---|
31 | require_once 'Zend/Gdata/Spreadsheets/Extension/RowCount.php';
|
---|
32 |
|
---|
33 | /**
|
---|
34 | * @see Zend_Gdata_Spreadsheets_Extension_ColCount
|
---|
35 | */
|
---|
36 | require_once 'Zend/Gdata/Spreadsheets/Extension/ColCount.php';
|
---|
37 |
|
---|
38 | /**
|
---|
39 | * Concrete class for working with Worksheet entries.
|
---|
40 | *
|
---|
41 | * @category Zend
|
---|
42 | * @package Zend_Gdata
|
---|
43 | * @subpackage Spreadsheets
|
---|
44 | * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
---|
45 | * @license http://framework.zend.com/license/new-bsd New BSD License
|
---|
46 | */
|
---|
47 | class Zend_Gdata_Spreadsheets_WorksheetEntry extends Zend_Gdata_Entry
|
---|
48 | {
|
---|
49 |
|
---|
50 | protected $_entryClassName = 'Zend_Gdata_Spreadsheets_WorksheetEntry';
|
---|
51 |
|
---|
52 | protected $_rowCount = null;
|
---|
53 | protected $_colCount = null;
|
---|
54 |
|
---|
55 | /**
|
---|
56 | * Constructs a new Zend_Gdata_Spreadsheets_WorksheetEntry object.
|
---|
57 | *
|
---|
58 | * @param DOMElement $element (optional) The DOMElement on which to base this object.
|
---|
59 | */
|
---|
60 | public function __construct($element = null)
|
---|
61 | {
|
---|
62 | $this->registerAllNamespaces(Zend_Gdata_Spreadsheets::$namespaces);
|
---|
63 | parent::__construct($element);
|
---|
64 | }
|
---|
65 |
|
---|
66 | /**
|
---|
67 | * Retrieves a DOMElement which corresponds to this element and all
|
---|
68 | * child properties. This is used to build an entry back into a DOM
|
---|
69 | * and eventually XML text for sending to the server upon updates, or
|
---|
70 | * for application storage/persistence.
|
---|
71 | *
|
---|
72 | * @param DOMDocument $doc The DOMDocument used to construct DOMElements
|
---|
73 | * @return DOMElement The DOMElement representing this element and all
|
---|
74 | * child properties.
|
---|
75 | */
|
---|
76 | public function getDOM($doc = null, $majorVersion = 1, $minorVersion = null)
|
---|
77 | {
|
---|
78 | $element = parent::getDOM($doc, $majorVersion, $minorVersion);
|
---|
79 | if ($this->_rowCount != null) {
|
---|
80 | $element->appendChild($this->_rowCount->getDOM($element->ownerDocument));
|
---|
81 | }
|
---|
82 | if ($this->_colCount != null) {
|
---|
83 | $element->appendChild($this->_colCount->getDOM($element->ownerDocument));
|
---|
84 | }
|
---|
85 | return $element;
|
---|
86 | }
|
---|
87 |
|
---|
88 | /**
|
---|
89 | * Creates individual Entry objects of the appropriate type and
|
---|
90 | * stores them in the $_entry array based upon DOM data.
|
---|
91 | *
|
---|
92 | * @param DOMNode $child The DOMNode to process
|
---|
93 | */
|
---|
94 | protected function takeChildFromDOM($child)
|
---|
95 | {
|
---|
96 | $absoluteNodeName = $child->namespaceURI . ':' . $child->localName;
|
---|
97 | switch ($absoluteNodeName) {
|
---|
98 | case $this->lookupNamespace('gs') . ':' . 'rowCount';
|
---|
99 | $rowCount = new Zend_Gdata_Spreadsheets_Extension_RowCount();
|
---|
100 | $rowCount->transferFromDOM($child);
|
---|
101 | $this->_rowCount = $rowCount;
|
---|
102 | break;
|
---|
103 | case $this->lookupNamespace('gs') . ':' . 'colCount';
|
---|
104 | $colCount = new Zend_Gdata_Spreadsheets_Extension_ColCount();
|
---|
105 | $colCount->transferFromDOM($child);
|
---|
106 | $this->_colCount = $colCount;
|
---|
107 | break;
|
---|
108 | default:
|
---|
109 | parent::takeChildFromDOM($child);
|
---|
110 | break;
|
---|
111 | }
|
---|
112 | }
|
---|
113 |
|
---|
114 |
|
---|
115 | /**
|
---|
116 | * Gets the row count for this entry.
|
---|
117 | *
|
---|
118 | * @return string The row count for the entry.
|
---|
119 | */
|
---|
120 | public function getRowCount()
|
---|
121 | {
|
---|
122 | return $this->_rowCount;
|
---|
123 | }
|
---|
124 |
|
---|
125 | /**
|
---|
126 | * Gets the column count for this entry.
|
---|
127 | *
|
---|
128 | * @return string The column count for the entry.
|
---|
129 | */
|
---|
130 | public function getColumnCount()
|
---|
131 | {
|
---|
132 | return $this->_colCount;
|
---|
133 | }
|
---|
134 |
|
---|
135 | /**
|
---|
136 | * Sets the row count for this entry.
|
---|
137 | *
|
---|
138 | * @param string $rowCount The new row count for the entry.
|
---|
139 | */
|
---|
140 | public function setRowCount($rowCount)
|
---|
141 | {
|
---|
142 | $this->_rowCount = $rowCount;
|
---|
143 | return $this;
|
---|
144 | }
|
---|
145 |
|
---|
146 | /**
|
---|
147 | * Sets the column count for this entry.
|
---|
148 | *
|
---|
149 | * @param string $colCount The new column count for the entry.
|
---|
150 | */
|
---|
151 | public function setColumnCount($colCount)
|
---|
152 | {
|
---|
153 | $this->_colCount = $colCount;
|
---|
154 | return $this;
|
---|
155 | }
|
---|
156 |
|
---|
157 | /**
|
---|
158 | * Returns the content of all rows as an associative array
|
---|
159 | *
|
---|
160 | * @return array An array of rows. Each element of the array is an associative array of data
|
---|
161 | */
|
---|
162 | public function getContentsAsRows()
|
---|
163 | {
|
---|
164 | $service = new Zend_Gdata_Spreadsheets($this->getHttpClient());
|
---|
165 | return $service->getSpreadsheetListFeedContents($this);
|
---|
166 | }
|
---|
167 |
|
---|
168 | /**
|
---|
169 | * Returns the content of all cells as an associative array, indexed
|
---|
170 | * off the cell location (ie 'A1', 'D4', etc). Each element of
|
---|
171 | * the array is an associative array with a 'value' and a 'function'.
|
---|
172 | * Only non-empty cells are returned by default. 'range' is the
|
---|
173 | * value of the 'range' query parameter specified at:
|
---|
174 | * http://code.google.com/apis/spreadsheets/reference.html#cells_Parameters
|
---|
175 | *
|
---|
176 | * @param string $range The range of cells to retrieve
|
---|
177 | * @param boolean $empty Whether to retrieve empty cells
|
---|
178 | * @return array An associative array of cells
|
---|
179 | */
|
---|
180 | public function getContentsAsCells($range = null, $empty = false)
|
---|
181 | {
|
---|
182 | $service = new Zend_Gdata_Spreadsheets($this->getHttpClient());
|
---|
183 | return $service->getSpreadsheetCellFeedContents($this, $range, $empty);
|
---|
184 | }
|
---|
185 |
|
---|
186 | }
|
---|