~chroot64bit/zivios/gentoo-experimental

« back to all changes in this revision

Viewing changes to application/library/Zend/Gdata/Spreadsheets/WorksheetEntry.php

  • Committer: Mustafa A. Hashmi
  • Date: 2008-12-04 13:32:21 UTC
  • Revision ID: mhashmi@zivios.org-20081204133221-0nd1trunwevijj38
Inclusion of new installation framework with ties to zend layout and dojo layout

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
 * @copyright    Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
 
44
 * @license    http://framework.zend.com/license/new-bsd     New BSD License
 
45
 */
 
46
class Zend_Gdata_Spreadsheets_WorksheetEntry extends Zend_Gdata_Entry
 
47
{
 
48
 
 
49
    protected $_entryClassName = 'Zend_Gdata_Spreadsheets_WorksheetEntry';
 
50
 
 
51
    protected $_rowCount = null;
 
52
    protected $_colCount = null;
 
53
 
 
54
    /**
 
55
     * Constructs a new Zend_Gdata_Spreadsheets_WorksheetEntry object.
 
56
     *
 
57
     * @param DOMElement $element (optional) The DOMElement on which to base this object.
 
58
     */
 
59
    public function __construct($element = null)
 
60
    {
 
61
        foreach (Zend_Gdata_Spreadsheets::$namespaces as $nsPrefix => $nsUri) {
 
62
            $this->registerNamespace($nsPrefix, $nsUri);
 
63
        }
 
64
        parent::__construct($element);
 
65
    }
 
66
 
 
67
    /**
 
68
     * Retrieves a DOMElement which corresponds to this element and all
 
69
     * child properties.  This is used to build an entry back into a DOM
 
70
     * and eventually XML text for sending to the server upon updates, or
 
71
     * for application storage/persistence.
 
72
     *
 
73
     * @param DOMDocument $doc The DOMDocument used to construct DOMElements
 
74
     * @return DOMElement The DOMElement representing this element and all
 
75
     * child properties.
 
76
     */
 
77
    public function getDOM($doc = null, $majorVersion = 1, $minorVersion = null)
 
78
    {
 
79
        $element = parent::getDOM($doc, $majorVersion, $minorVersion);
 
80
        if ($this->_rowCount != null) {
 
81
            $element->appendChild($this->_rowCount->getDOM($element->ownerDocument));
 
82
        }
 
83
        if ($this->_colCount != null) {
 
84
            $element->appendChild($this->_colCount->getDOM($element->ownerDocument));
 
85
        }
 
86
        return $element;
 
87
    }
 
88
 
 
89
    /**
 
90
     * Creates individual Entry objects of the appropriate type and
 
91
     * stores them in the $_entry array based upon DOM data.
 
92
     *
 
93
     * @param DOMNode $child The DOMNode to process
 
94
     */
 
95
    protected function takeChildFromDOM($child)
 
96
    {
 
97
        $absoluteNodeName = $child->namespaceURI . ':' . $child->localName;
 
98
        switch ($absoluteNodeName) {
 
99
            case $this->lookupNamespace('gs') . ':' . 'rowCount';
 
100
                $rowCount = new Zend_Gdata_Spreadsheets_Extension_RowCount();
 
101
                $rowCount->transferFromDOM($child);
 
102
                $this->_rowCount = $rowCount;
 
103
                break;
 
104
            case $this->lookupNamespace('gs') . ':' . 'colCount';
 
105
                $colCount = new Zend_Gdata_Spreadsheets_Extension_ColCount();
 
106
                $colCount->transferFromDOM($child);
 
107
                $this->_colCount = $colCount;
 
108
                break;
 
109
            default:
 
110
                parent::takeChildFromDOM($child);
 
111
                break;
 
112
        }
 
113
    }
 
114
 
 
115
 
 
116
    /**
 
117
     * Gets the row count for this entry.
 
118
     *
 
119
     * @return string The row count for the entry.
 
120
     */
 
121
    public function getRowCount()
 
122
    {
 
123
        return $this->_rowCount;
 
124
    }
 
125
 
 
126
    /**
 
127
     * Gets the column count for this entry.
 
128
     *
 
129
     * @return string The column count for the entry.
 
130
     */
 
131
    public function getColumnCount()
 
132
    {
 
133
        return $this->_colCount;
 
134
    }
 
135
 
 
136
    /**
 
137
     * Sets the row count for this entry.
 
138
     *
 
139
     * @param string $rowCount The new row count for the entry.
 
140
     */
 
141
    public function setRowCount($rowCount)
 
142
    {
 
143
        $this->_rowCount = $rowCount;
 
144
        return $this;
 
145
    }
 
146
 
 
147
    /**
 
148
     * Sets the column count for this entry.
 
149
     *
 
150
     * @param string $colCount The new column count for the entry.
 
151
     */
 
152
    public function setColumnCount($colCount)
 
153
    {
 
154
        $this->_colCount = $colCount;
 
155
        return $this;
 
156
    }
 
157
 
 
158
    /**
 
159
     * Returns the content of all rows as an associative array
 
160
     *
 
161
     * @return array An array of rows.  Each element of the array is an associative array of data
 
162
     */
 
163
    public function getContentsAsRows()
 
164
    {
 
165
        $service = new Zend_Gdata_Spreadsheets($this->getHttpClient());
 
166
        return $service->getSpreadsheetListFeedContents($this);
 
167
    }
 
168
 
 
169
    /**
 
170
     * Returns the content of all cells as an associative array, indexed 
 
171
     * off the cell location  (ie 'A1', 'D4', etc).  Each element of 
 
172
     * the array is an associative array with a 'value' and a 'function'.  
 
173
     * Only non-empty cells are returned by default.  'range' is the 
 
174
     * value of the 'range' query parameter specified at:
 
175
     * http://code.google.com/apis/spreadsheets/reference.html#cells_Parameters
 
176
     *
 
177
     * @param string $range The range of cells to retrieve
 
178
     * @param boolean $empty Whether to retrieve empty cells
 
179
     * @return array An associative array of cells
 
180
     */    
 
181
    public function getContentsAsCells($range = null, $empty = false)
 
182
    {
 
183
        $service = new Zend_Gdata_Spreadsheets($this->getHttpClient());
 
184
        return $service->getSpreadsheetCellFeedContents($this, $range, $empty);
 
185
    }
 
186
 
 
187
}