Text.php 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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 App
  18. * @copyright Copyright (c) 2005-2012 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_App_Extension
  24. */
  25. require_once 'Zend/Gdata/App/Extension.php';
  26. /**
  27. * Abstract class for data models that require only text and type-- such as:
  28. * title, summary, etc.
  29. *
  30. * @category Zend
  31. * @package Zend_Gdata
  32. * @subpackage App
  33. * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
  34. * @license http://framework.zend.com/license/new-bsd New BSD License
  35. */
  36. abstract class Zend_Gdata_App_Extension_Text extends Zend_Gdata_App_Extension
  37. {
  38. protected $_rootElement = null;
  39. protected $_type = 'text';
  40. public function __construct($text = null, $type = 'text')
  41. {
  42. parent::__construct();
  43. $this->_text = $text;
  44. $this->_type = $type;
  45. }
  46. public function getDOM($doc = null, $majorVersion = 1, $minorVersion = null)
  47. {
  48. $element = parent::getDOM($doc, $majorVersion, $minorVersion);
  49. if ($this->_type !== null) {
  50. $element->setAttribute('type', $this->_type);
  51. }
  52. return $element;
  53. }
  54. protected function takeAttributeFromDOM($attribute)
  55. {
  56. switch ($attribute->localName) {
  57. case 'type':
  58. $this->_type = $attribute->nodeValue;
  59. break;
  60. default:
  61. parent::takeAttributeFromDOM($attribute);
  62. }
  63. }
  64. /*
  65. * @return Zend_Gdata_App_Extension_Type
  66. */
  67. public function getType()
  68. {
  69. return $this->_type;
  70. }
  71. /*
  72. * @param string $value
  73. * @return Zend_Gdata_App_Extension_Text Provides a fluent interface
  74. */
  75. public function setType($value)
  76. {
  77. $this->_type = $value;
  78. return $this;
  79. }
  80. }