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 / Atom / Deleted.php
blobcde7067ef78717d5258fbf6d4f482b27880b5aa1
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\Atom;
12 use DateTime;
13 use DOMDocument;
14 use DOMElement;
15 use Zend\Feed\Writer;
16 use Zend\Feed\Writer\Renderer;
18 class Deleted extends Renderer\AbstractRenderer implements Renderer\RendererInterface
20 /**
21 * Constructor
23 * @param Writer\Deleted $container
25 public function __construct(Writer\Deleted $container)
27 parent::__construct($container);
30 /**
31 * Render atom entry
33 * @return Writer\Renderer\Entry\Atom
35 public function render()
37 $this->dom = new DOMDocument('1.0', $this->container->getEncoding());
38 $this->dom->formatOutput = true;
39 $entry = $this->dom->createElement('at:deleted-entry');
40 $this->dom->appendChild($entry);
42 $entry->setAttribute('ref', $this->container->getReference());
43 $entry->setAttribute('when', $this->container->getWhen()->format(DateTime::ISO8601));
45 $this->_setBy($this->dom, $entry);
46 $this->_setComment($this->dom, $entry);
48 return $this;
51 /**
52 * Set tombstone comment
54 * @param DOMDocument $dom
55 * @param DOMElement $root
56 * @return void
58 protected function _setComment(DOMDocument $dom, DOMElement $root)
60 if (!$this->getDataContainer()->getComment()) {
61 return;
63 $c = $dom->createElement('at:comment');
64 $root->appendChild($c);
65 $c->setAttribute('type', 'html');
66 $cdata = $dom->createCDATASection($this->getDataContainer()->getComment());
67 $c->appendChild($cdata);
70 /**
71 * Set entry authors
73 * @param DOMDocument $dom
74 * @param DOMElement $root
75 * @return void
77 protected function _setBy(DOMDocument $dom, DOMElement $root)
79 $data = $this->container->getBy();
80 if ((!$data || empty($data))) {
81 return;
83 $author = $this->dom->createElement('at:by');
84 $name = $this->dom->createElement('name');
85 $author->appendChild($name);
86 $root->appendChild($author);
87 $text = $dom->createTextNode($data['name']);
88 $name->appendChild($text);
89 if (array_key_exists('email', $data)) {
90 $email = $this->dom->createElement('email');
91 $author->appendChild($email);
92 $text = $dom->createTextNode($data['email']);
93 $email->appendChild($text);
95 if (array_key_exists('uri', $data)) {
96 $uri = $this->dom->createElement('uri');
97 $author->appendChild($uri);
98 $text = $dom->createTextNode($data['uri']);
99 $uri->appendChild($text);