File indexing completed on 2025-01-12 05:21:59

0001 <?php
0002 /**
0003  * Zend Framework
0004  *
0005  * LICENSE
0006  *
0007  * This source file is subject to the new BSD license that is bundled
0008  * with this package in the file LICENSE.txt.
0009  * It is also available through the world-wide-web at this URL:
0010  * http://framework.zend.com/license/new-bsd
0011  * If you did not receive a copy of the license and are unable to
0012  * obtain it through the world-wide-web, please send an email
0013  * to license@zend.com so we can send you a copy immediately.
0014  *
0015  * @category   Zend
0016  * @package    Zend_Feed_Writer
0017  * @copyright  Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
0018  * @license    http://framework.zend.com/license/new-bsd     New BSD License
0019  * @version    $Id$
0020  */
0021 
0022 /**
0023  * @see Zend_Feed_Writer_Renderer_RendererAbstract
0024  */
0025 // require_once 'Zend/Feed/Writer/Renderer/RendererAbstract.php';
0026 
0027 /**
0028  * @category   Zend
0029  * @package    Zend_Feed_Writer
0030  * @copyright  Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
0031  * @license    http://framework.zend.com/license/new-bsd     New BSD License
0032  */
0033 class Zend_Feed_Writer_Renderer_Entry_Atom_Deleted
0034     extends Zend_Feed_Writer_Renderer_RendererAbstract
0035     implements Zend_Feed_Writer_Renderer_RendererInterface
0036 {
0037     /**
0038      * Constructor
0039      *
0040      * @param  Zend_Feed_Writer_Deleted $container
0041      * @return void
0042      */
0043     public function __construct (Zend_Feed_Writer_Deleted $container)
0044     {
0045         parent::__construct($container);
0046     }
0047 
0048     /**
0049      * Render atom entry
0050      *
0051      * @return Zend_Feed_Writer_Renderer_Entry_Atom
0052      */
0053     public function render()
0054     {
0055         $this->_dom = new DOMDocument('1.0', $this->_container->getEncoding());
0056         $this->_dom->formatOutput = true;
0057         $entry = $this->_dom->createElement('at:deleted-entry');
0058         $this->_dom->appendChild($entry);
0059 
0060         $entry->setAttribute('ref', $this->_container->getReference());
0061         $entry->setAttribute('when', $this->_container->getWhen()->get(Zend_Date::ISO_8601));
0062 
0063         $this->_setBy($this->_dom, $entry);
0064         $this->_setComment($this->_dom, $entry);
0065 
0066         return $this;
0067     }
0068 
0069     /**
0070      * Set tombstone comment
0071      *
0072      * @param  DOMDocument $dom
0073      * @param  DOMElement $root
0074      * @return void
0075      */
0076     protected function _setComment(DOMDocument $dom, DOMElement $root)
0077     {
0078         if(!$this->getDataContainer()->getComment()) {
0079             return;
0080         }
0081         $c = $dom->createElement('at:comment');
0082         $root->appendChild($c);
0083         $c->setAttribute('type', 'html');
0084         $cdata = $dom->createCDATASection($this->getDataContainer()->getComment());
0085         $c->appendChild($cdata);
0086     }
0087 
0088     /**
0089      * Set entry authors
0090      *
0091      * @param  DOMDocument $dom
0092      * @param  DOMElement $root
0093      * @return void
0094      */
0095     protected function _setBy(DOMDocument $dom, DOMElement $root)
0096     {
0097         $data = $this->_container->getBy();
0098         if ((!$data || empty($data))) {
0099             return;
0100         }
0101         $author = $this->_dom->createElement('at:by');
0102         $name = $this->_dom->createElement('name');
0103         $author->appendChild($name);
0104         $root->appendChild($author);
0105         $text = $dom->createTextNode($data['name']);
0106         $name->appendChild($text);
0107         if (array_key_exists('email', $data)) {
0108             $email = $this->_dom->createElement('email');
0109             $author->appendChild($email);
0110             $text = $dom->createTextNode($data['email']);
0111             $email->appendChild($text);
0112         }
0113         if (array_key_exists('uri', $data)) {
0114             $uri = $this->_dom->createElement('uri');
0115             $author->appendChild($uri);
0116             $text = $dom->createTextNode($data['uri']);
0117             $uri->appendChild($text);
0118         }
0119     }
0120 
0121 }