Control.php 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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. * @see Zend_Gdata_App_Extension_Draft
  27. */
  28. require_once 'Zend/Gdata/App/Extension/Draft.php';
  29. /**
  30. * Represents the app:control element
  31. *
  32. * @category Zend
  33. * @package Zend_Gdata
  34. * @subpackage App
  35. * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
  36. * @license http://framework.zend.com/license/new-bsd New BSD License
  37. */
  38. class Zend_Gdata_App_Extension_Control extends Zend_Gdata_App_Extension
  39. {
  40. protected $_rootNamespace = 'app';
  41. protected $_rootElement = 'control';
  42. protected $_draft = null;
  43. public function __construct($draft = null)
  44. {
  45. parent::__construct();
  46. $this->_draft = $draft;
  47. }
  48. public function getDOM($doc = null, $majorVersion = 1, $minorVersion = null)
  49. {
  50. $element = parent::getDOM($doc, $majorVersion, $minorVersion);
  51. if ($this->_draft != null) {
  52. $element->appendChild($this->_draft->getDOM($element->ownerDocument));
  53. }
  54. return $element;
  55. }
  56. protected function takeChildFromDOM($child)
  57. {
  58. $absoluteNodeName = $child->namespaceURI . ':' . $child->localName;
  59. switch ($absoluteNodeName) {
  60. case $this->lookupNamespace('app') . ':' . 'draft':
  61. $draft = new Zend_Gdata_App_Extension_Draft();
  62. $draft->transferFromDOM($child);
  63. $this->_draft = $draft;
  64. break;
  65. default:
  66. parent::takeChildFromDOM($child);
  67. break;
  68. }
  69. }
  70. /**
  71. * @return Zend_Gdata_App_Extension_Draft
  72. */
  73. public function getDraft()
  74. {
  75. return $this->_draft;
  76. }
  77. /**
  78. * @param Zend_Gdata_App_Extension_Draft $value
  79. * @return Zend_Gdata_App_Entry Provides a fluent interface
  80. */
  81. public function setDraft($value)
  82. {
  83. $this->_draft = $value;
  84. return $this;
  85. }
  86. }