Custom.php 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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 custom gsx 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_Custom extends Zend_Gdata_Extension
  40. {
  41. // custom elements have custom names.
  42. protected $_rootElement = null; // The name of the column
  43. protected $_rootNamespace = 'gsx';
  44. /**
  45. * Constructs a new Zend_Gdata_Spreadsheets_Extension_Custom object.
  46. * @param string $column (optional) The column/tag name of the element.
  47. * @param string $value (optional) The text content of the element.
  48. */
  49. public function __construct($column = null, $value = null)
  50. {
  51. $this->registerAllNamespaces(Zend_Gdata_Spreadsheets::$namespaces);
  52. parent::__construct();
  53. $this->_text = $value;
  54. $this->_rootElement = $column;
  55. }
  56. public function getDOM($doc = null, $majorVersion = 1, $minorVersion = null)
  57. {
  58. $element = parent::getDOM($doc, $majorVersion, $minorVersion);
  59. return $element;
  60. }
  61. /**
  62. * Transfers each child and attribute into member variables.
  63. * This is called when XML is received over the wire and the data
  64. * model needs to be built to represent this XML.
  65. *
  66. * @param DOMNode $node The DOMNode that represents this object's data
  67. */
  68. public function transferFromDOM($node)
  69. {
  70. parent::transferFromDOM($node);
  71. $this->_rootElement = $node->localName;
  72. }
  73. /**
  74. * Sets the column/tag name of the element.
  75. * @param string $column The new column name.
  76. */
  77. public function setColumnName($column)
  78. {
  79. $this->_rootElement = $column;
  80. return $this;
  81. }
  82. /**
  83. * Gets the column name of the element
  84. * @return string The column name.
  85. */
  86. public function getColumnName()
  87. {
  88. return $this->_rootElement;
  89. }
  90. }