RendererAbstract.php 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  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 padraic dot brady at yahoo dot com so we can send you a copy immediately.
  14. *
  15. * @category Zend
  16. * @package Zend_Feed_Writer_Entry_Rss
  17. * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
  18. * @license http://framework.zend.com/license/new-bsd New BSD License
  19. */
  20. /**
  21. * @see Zend_Feed_Writer_Extension_RendererInterface
  22. */
  23. require_once 'Zend/Feed/Writer/Extension/RendererInterface.php';
  24. /**
  25. * @category Zend
  26. * @package Zend_Feed_Writer_Entry_Rss
  27. * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
  28. * @license http://framework.zend.com/license/new-bsd New BSD License
  29. */
  30. abstract class Zend_Feed_Writer_Extension_RendererAbstract
  31. implements Zend_Feed_Writer_Extension_RendererInterface
  32. {
  33. /**
  34. * @var DOMDocument
  35. */
  36. protected $_dom = null;
  37. /**
  38. * @var mixed
  39. */
  40. protected $_entry = null;
  41. /**
  42. * @var DOMElement
  43. */
  44. protected $_base = null;
  45. /**
  46. * @var mixed
  47. */
  48. protected $_container = null;
  49. /**
  50. * @var string
  51. */
  52. protected $_type = null;
  53. /**
  54. * @var DOMElement
  55. */
  56. protected $_rootElement = null;
  57. /**
  58. * Encoding of all text values
  59. *
  60. * @var string
  61. */
  62. protected $_encoding = 'UTF-8';
  63. /**
  64. * Constructor
  65. *
  66. * @param mixed $container
  67. * @return void
  68. */
  69. public function __construct($container)
  70. {
  71. $this->_container = $container;
  72. }
  73. /**
  74. * Set feed encoding
  75. *
  76. * @param string $enc
  77. * @return Zend_Feed_Writer_Extension_RendererAbstract
  78. */
  79. public function setEncoding($enc)
  80. {
  81. $this->_encoding = $enc;
  82. return $this;
  83. }
  84. /**
  85. * Get feed encoding
  86. *
  87. * @return void
  88. */
  89. public function getEncoding()
  90. {
  91. return $this->_encoding;
  92. }
  93. /**
  94. * Set DOMDocument and DOMElement on which to operate
  95. *
  96. * @param DOMDocument $dom
  97. * @param DOMElement $base
  98. * @return Zend_Feed_Writer_Extension_RendererAbstract
  99. */
  100. public function setDomDocument(DOMDocument $dom, DOMElement $base)
  101. {
  102. $this->_dom = $dom;
  103. $this->_base = $base;
  104. return $this;
  105. }
  106. /**
  107. * Get data container being rendered
  108. *
  109. * @return mixed
  110. */
  111. public function getDataContainer()
  112. {
  113. return $this->_container;
  114. }
  115. /**
  116. * Set feed type
  117. *
  118. * @param string $type
  119. * @return Zend_Feed_Writer_Extension_RendererAbstract
  120. */
  121. public function setType($type)
  122. {
  123. $this->_type = $type;
  124. return $this;
  125. }
  126. /**
  127. * Get feedtype
  128. *
  129. * @return string
  130. */
  131. public function getType()
  132. {
  133. return $this->_type;
  134. }
  135. /**
  136. * Set root element of document
  137. *
  138. * @param DOMElement $root
  139. * @return Zend_Feed_Writer_Extension_RendererAbstract
  140. */
  141. public function setRootElement(DOMElement $root)
  142. {
  143. $this->_rootElement = $root;
  144. return $this;
  145. }
  146. /**
  147. * Get root element
  148. *
  149. * @return DOMElement
  150. */
  151. public function getRootElement()
  152. {
  153. return $this->_rootElement;
  154. }
  155. /**
  156. * Append namespaces to feed
  157. *
  158. * @return void
  159. */
  160. abstract protected function _appendNamespaces();
  161. }