Cell.php 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  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-2015 Zend Technologies USA Inc. (http://www.zend.com)
  19. * @license http://framework.zend.com/license/new-bsd New BSD License
  20. * @version $Id$
  21. */
  22. /**
  23. * @see Zend_Gdata_Entry
  24. */
  25. require_once 'Zend/Gdata/Entry.php';
  26. /**
  27. * @see Zend_Gdata_Extension
  28. */
  29. require_once 'Zend/Gdata/Extension.php';
  30. /**
  31. * Concrete class for working with cell elements.
  32. *
  33. * @category Zend
  34. * @package Zend_Gdata
  35. * @subpackage Spreadsheets
  36. * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
  37. * @license http://framework.zend.com/license/new-bsd New BSD License
  38. */
  39. class Zend_Gdata_Spreadsheets_Extension_Cell extends Zend_Gdata_Extension
  40. {
  41. protected $_rootElement = 'cell';
  42. protected $_rootNamespace = 'gs';
  43. /**
  44. * The row attribute of this cell
  45. *
  46. * @var string
  47. */
  48. protected $_row = null;
  49. /**
  50. * The column attribute of this cell
  51. *
  52. * @var string
  53. */
  54. protected $_col = null;
  55. /**
  56. * The inputValue attribute of this cell
  57. *
  58. * @var string
  59. */
  60. protected $_inputValue = null;
  61. /**
  62. * The numericValue attribute of this cell
  63. *
  64. * @var string
  65. */
  66. protected $_numericValue = null;
  67. /**
  68. * Constructs a new Zend_Gdata_Spreadsheets_Extension_Cell element.
  69. *
  70. * @param string $text (optional) Text contents of the element.
  71. * @param string $row (optional) Row attribute of the element.
  72. * @param string $col (optional) Column attribute of the element.
  73. * @param string $inputValue (optional) Input value attribute of the element.
  74. * @param string $numericValue (optional) Numeric value attribute of the element.
  75. */
  76. public function __construct($text = null, $row = null, $col = null, $inputValue = null, $numericValue = null)
  77. {
  78. $this->registerAllNamespaces(Zend_Gdata_Spreadsheets::$namespaces);
  79. parent::__construct();
  80. $this->_text = $text;
  81. $this->_row = $row;
  82. $this->_col = $col;
  83. $this->_inputValue = $inputValue;
  84. $this->_numericValue = $numericValue;
  85. }
  86. public function getDOM($doc = null, $majorVersion = 1, $minorVersion = null)
  87. {
  88. $element = parent::getDOM($doc, $majorVersion, $minorVersion);
  89. $element->setAttribute('row', $this->_row);
  90. $element->setAttribute('col', $this->_col);
  91. if ($this->_inputValue) $element->setAttribute('inputValue', $this->_inputValue);
  92. if ($this->_numericValue) $element->setAttribute('numericValue', $this->_numericValue);
  93. return $element;
  94. }
  95. protected function takeAttributeFromDOM($attribute)
  96. {
  97. switch ($attribute->localName) {
  98. case 'row':
  99. $this->_row = $attribute->nodeValue;
  100. break;
  101. case 'col':
  102. $this->_col = $attribute->nodeValue;
  103. break;
  104. case 'inputValue':
  105. $this->_inputValue = $attribute->nodeValue;
  106. break;
  107. case 'numericValue':
  108. $this->_numericValue = $attribute->nodeValue;
  109. break;
  110. default:
  111. parent::takeAttributeFromDOM($attribute);
  112. }
  113. }
  114. /**
  115. * Gets the row attribute of the Cell element.
  116. * @return string Row of the Cell.
  117. */
  118. public function getRow()
  119. {
  120. return $this->_row;
  121. }
  122. /**
  123. * Gets the column attribute of the Cell element.
  124. * @return string Column of the Cell.
  125. */
  126. public function getColumn()
  127. {
  128. return $this->_col;
  129. }
  130. /**
  131. * Gets the input value attribute of the Cell element.
  132. * @return string Input value of the Cell.
  133. */
  134. public function getInputValue()
  135. {
  136. return $this->_inputValue;
  137. }
  138. /**
  139. * Gets the numeric value attribute of the Cell element.
  140. * @return string Numeric value of the Cell.
  141. */
  142. public function getNumericValue()
  143. {
  144. return $this->_numericValue;
  145. }
  146. /**
  147. * Sets the row attribute of the Cell element.
  148. * @param string $row New row of the Cell.
  149. */
  150. public function setRow($row)
  151. {
  152. $this->_row = $row;
  153. return $this;
  154. }
  155. /**
  156. * Sets the column attribute of the Cell element.
  157. * @param string $col New column of the Cell.
  158. */
  159. public function setColumn($col)
  160. {
  161. $this->_col = $col;
  162. return $this;
  163. }
  164. /**
  165. * Sets the input value attribute of the Cell element.
  166. * @param string $inputValue New input value of the Cell.
  167. */
  168. public function setInputValue($inputValue)
  169. {
  170. $this->_inputValue = $inputValue;
  171. return $this;
  172. }
  173. /**
  174. * Sets the numeric value attribute of the Cell element.
  175. * @param string $numericValue New numeric value of the Cell.
  176. */
  177. public function setNumericValue($numericValue)
  178. {
  179. $this->_numericValue = $numericValue;
  180. }
  181. }