2
0

Text.php 2.3 KB

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