Deleted.php 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  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_Feed_Writer
  17. * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
  18. * @license http://framework.zend.com/license/new-bsd New BSD License
  19. * @version $Id$
  20. */
  21. /**
  22. * @see Zend_Feed_Writer_Renderer_RendererAbstract
  23. */
  24. require_once 'Zend/Feed/Writer/Renderer/RendererAbstract.php';
  25. /**
  26. * @category Zend
  27. * @package Zend_Feed_Writer
  28. * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
  29. * @license http://framework.zend.com/license/new-bsd New BSD License
  30. */
  31. class Zend_Feed_Writer_Renderer_Entry_Atom_Deleted
  32. extends Zend_Feed_Writer_Renderer_RendererAbstract
  33. implements Zend_Feed_Writer_Renderer_RendererInterface
  34. {
  35. /**
  36. * Constructor
  37. *
  38. * @param Zend_Feed_Writer_Deleted $container
  39. * @return void
  40. */
  41. public function __construct (Zend_Feed_Writer_Deleted $container)
  42. {
  43. parent::__construct($container);
  44. }
  45. /**
  46. * Render atom entry
  47. *
  48. * @return Zend_Feed_Writer_Renderer_Entry_Atom
  49. */
  50. public function render()
  51. {
  52. $this->_dom = new DOMDocument('1.0', $this->_container->getEncoding());
  53. $this->_dom->formatOutput = true;
  54. $entry = $this->_dom->createElement('at:deleted-entry');
  55. $this->_dom->appendChild($entry);
  56. $entry->setAttribute('ref', $this->_container->getReference());
  57. $entry->setAttribute('when', $this->_container->getWhen()->get(Zend_Date::ISO_8601));
  58. $this->_setBy($this->_dom, $entry);
  59. $this->_setComment($this->_dom, $entry);
  60. return $this;
  61. }
  62. /**
  63. * Set tombstone comment
  64. *
  65. * @param DOMDocument $dom
  66. * @param DOMElement $root
  67. * @return void
  68. */
  69. protected function _setComment(DOMDocument $dom, DOMElement $root)
  70. {
  71. if(!$this->getDataContainer()->getComment()) {
  72. return;
  73. }
  74. $c = $dom->createElement('at:comment');
  75. $root->appendChild($c);
  76. $c->setAttribute('type', 'html');
  77. $cdata = $dom->createCDATASection($this->getDataContainer()->getComment());
  78. $c->appendChild($cdata);
  79. }
  80. /**
  81. * Set entry authors
  82. *
  83. * @param DOMDocument $dom
  84. * @param DOMElement $root
  85. * @return void
  86. */
  87. protected function _setBy(DOMDocument $dom, DOMElement $root)
  88. {
  89. $data = $this->_container->getBy();
  90. if ((!$data || empty($data))) {
  91. return;
  92. }
  93. $author = $this->_dom->createElement('at:by');
  94. $name = $this->_dom->createElement('name');
  95. $author->appendChild($name);
  96. $root->appendChild($author);
  97. $text = $dom->createTextNode($data['name']);
  98. $name->appendChild($text);
  99. if (array_key_exists('email', $data)) {
  100. $email = $this->_dom->createElement('email');
  101. $author->appendChild($email);
  102. $text = $dom->createTextNode($data['email']);
  103. $email->appendChild($text);
  104. }
  105. if (array_key_exists('uri', $data)) {
  106. $uri = $this->_dom->createElement('uri');
  107. $author->appendChild($uri);
  108. $text = $dom->createTextNode($data['uri']);
  109. $uri->appendChild($text);
  110. }
  111. }
  112. }