PageRenderTime 39ms CodeModel.GetById 14ms RepoModel.GetById 0ms app.codeStats 0ms

/src/application/libraries/Zend/Gdata/Spreadsheets/WorksheetEntry.php

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