Added the zend framework 2 library, the path is specified in line no.26 in zend_modul...
[openemr.git] / interface / modules / zend_modules / library / Zend / Feed / Writer / Renderer / Entry / AtomDeleted.php
blobf7cbd9ac9b9999a03f89fe708f403058b1f49b52
1 <?php
2 /**
3 * Zend Framework (http://framework.zend.com/)
5 * @link http://github.com/zendframework/zf2 for the canonical source repository
6 * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
7 * @license http://framework.zend.com/license/new-bsd New BSD License
8 */
10 namespace Zend\Feed\Writer\Renderer\Entry;
12 use DateTime;
13 use DOMDocument;
14 use DOMElement;
15 use Zend\Feed\Writer;
16 use Zend\Feed\Writer\Renderer;
18 /**
20 class AtomDeleted extends Renderer\AbstractRenderer implements Renderer\RendererInterface
22 /**
23 * Constructor
25 * @param Writer\Deleted $container
27 public function __construct(Writer\Deleted $container)
29 parent::__construct($container);
32 /**
33 * Render atom entry
35 * @return \Zend\Feed\Writer\Renderer\Entry\Atom
37 public function render()
39 $this->dom = new DOMDocument('1.0', $this->container->getEncoding());
40 $this->dom->formatOutput = true;
41 $entry = $this->dom->createElement('at:deleted-entry');
42 $this->dom->appendChild($entry);
44 $entry->setAttribute('ref', $this->container->getReference());
45 $entry->setAttribute('when', $this->container->getWhen()->format(DateTime::ISO8601));
47 $this->_setBy($this->dom, $entry);
48 $this->_setComment($this->dom, $entry);
50 return $this;
53 /**
54 * Set tombstone comment
56 * @param DOMDocument $dom
57 * @param DOMElement $root
58 * @return void
60 protected function _setComment(DOMDocument $dom, DOMElement $root)
62 if (!$this->getDataContainer()->getComment()) {
63 return;
65 $c = $dom->createElement('at:comment');
66 $root->appendChild($c);
67 $c->setAttribute('type', 'html');
68 $cdata = $dom->createCDATASection($this->getDataContainer()->getComment());
69 $c->appendChild($cdata);
72 /**
73 * Set entry authors
75 * @param DOMDocument $dom
76 * @param DOMElement $root
77 * @return void
79 protected function _setBy(DOMDocument $dom, DOMElement $root)
81 $data = $this->container->getBy();
82 if ((!$data || empty($data))) {
83 return;
85 $author = $this->dom->createElement('at:by');
86 $name = $this->dom->createElement('name');
87 $author->appendChild($name);
88 $root->appendChild($author);
89 $text = $dom->createTextNode($data['name']);
90 $name->appendChild($text);
91 if (array_key_exists('email', $data)) {
92 $email = $this->dom->createElement('email');
93 $author->appendChild($email);
94 $text = $dom->createTextNode($data['email']);
95 $email->appendChild($text);
97 if (array_key_exists('uri', $data)) {
98 $uri = $this->dom->createElement('uri');
99 $author->appendChild($uri);
100 $text = $dom->createTextNode($data['uri']);
101 $uri->appendChild($text);