1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
|
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Feed_Writer
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Atom.php 20096 2010-01-06 02:05:09Z bkarwin $
*/
// require_once 'Zend/Feed/Writer/Renderer/Feed/Atom/AtomAbstract.php';
/**
* @category Zend
* @package Zend_Feed_Writer
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Feed_Writer_Renderer_Feed_Atom_Source
extends Zend_Feed_Writer_Renderer_Feed_Atom_AtomAbstract
implements Zend_Feed_Writer_Renderer_RendererInterface
{
/**
* Constructor
*
* @param Zend_Feed_Writer_Feed_Source $container
* @return void
*/
public function __construct (Zend_Feed_Writer_Source $container)
{
parent::__construct($container);
}
/**
* Render Atom Feed Metadata (Source element)
*
* @return Zend_Feed_Writer_Renderer_Feed_Atom
*/
public function render()
{
if (!$this->_container->getEncoding()) {
$this->_container->setEncoding('UTF-8');
}
$this->_dom = new DOMDocument('1.0', $this->_container->getEncoding());
$this->_dom->formatOutput = true;
$root = $this->_dom->createElement('source');
$this->setRootElement($root);
$this->_dom->appendChild($root);
$this->_setLanguage($this->_dom, $root);
$this->_setBaseUrl($this->_dom, $root);
$this->_setTitle($this->_dom, $root);
$this->_setDescription($this->_dom, $root);
$this->_setDateCreated($this->_dom, $root);
$this->_setDateModified($this->_dom, $root);
$this->_setGenerator($this->_dom, $root);
$this->_setLink($this->_dom, $root);
$this->_setFeedLinks($this->_dom, $root);
$this->_setId($this->_dom, $root);
$this->_setAuthors($this->_dom, $root);
$this->_setCopyright($this->_dom, $root);
$this->_setCategories($this->_dom, $root);
foreach ($this->_extensions as $ext) {
$ext->setType($this->getType());
$ext->setRootElement($this->getRootElement());
$ext->setDomDocument($this->getDomDocument(), $root);
$ext->render();
}
return $this;
}
/**
* Set feed generator string
*
* @param DOMDocument $dom
* @param DOMElement $root
* @return void
*/
protected function _setGenerator(DOMDocument $dom, DOMElement $root)
{
if(!$this->getDataContainer()->getGenerator()) {
return;
}
$gdata = $this->getDataContainer()->getGenerator();
$generator = $dom->createElement('generator');
$root->appendChild($generator);
$text = $dom->createTextNode($gdata['name']);
$generator->appendChild($text);
if (array_key_exists('uri', $gdata)) {
$generator->setAttribute('uri', $gdata['uri']);
}
if (array_key_exists('version', $gdata)) {
$generator->setAttribute('version', $gdata['version']);
}
}
}
|