/zf/library/Zend/Feed/Writer/Extension/WellFormedWeb/Renderer/Entry.php
PHP | 96 lines | 38 code | 6 blank | 52 comment | 7 complexity | eb1b32feef7eef505f3a3e330b775d34 MD5 | raw file
Possible License(s): MIT, BSD-3-Clause, Apache-2.0, LGPL-2.1, LGPL-3.0, BSD-2-Clause
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-2011 Zend Technologies USA Inc. (http://www.zend.com) 18 * @license http://framework.zend.com/license/new-bsd New BSD License 19 * @version $Id: Entry.php 23775 2011-03-01 17:25:24Z ralph $ 20 */ 21 22/** 23 * @see Zend_Feed_Writer_Extension_RendererAbstract 24 */ 25require_once 'Zend/Feed/Writer/Extension/RendererAbstract.php'; 26 27/** 28 * @category Zend 29 * @package Zend_Feed_Writer 30 * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) 31 * @license http://framework.zend.com/license/new-bsd New BSD License 32 */ 33class Zend_Feed_Writer_Extension_WellFormedWeb_Renderer_Entry 34 extends Zend_Feed_Writer_Extension_RendererAbstract 35{ 36 37 /** 38 * Set to TRUE if a rendering method actually renders something. This 39 * is used to prevent premature appending of a XML namespace declaration 40 * until an element which requires it is actually appended. 41 * 42 * @var bool 43 */ 44 protected $_called = false; 45 46 /** 47 * Render entry 48 * 49 * @return void 50 */ 51 public function render() 52 { 53 if (strtolower($this->getType()) == 'atom') { 54 return; // RSS 2.0 only 55 } 56 $this->_setCommentFeedLinks($this->_dom, $this->_base); 57 if ($this->_called) { 58 $this->_appendNamespaces(); 59 } 60 } 61 62 /** 63 * Append entry namespaces 64 * 65 * @return void 66 */ 67 protected function _appendNamespaces() 68 { 69 $this->getRootElement()->setAttribute('xmlns:wfw', 70 'http://wellformedweb.org/CommentAPI/'); 71 } 72 73 /** 74 * Set entry comment feed links 75 * 76 * @param DOMDocument $dom 77 * @param DOMElement $root 78 * @return void 79 */ 80 protected function _setCommentFeedLinks(DOMDocument $dom, DOMElement $root) 81 { 82 $links = $this->getDataContainer()->getCommentFeedLinks(); 83 if (!$links || empty($links)) { 84 return; 85 } 86 foreach ($links as $link) { 87 if ($link['type'] == 'rss') { 88 $flink = $this->_dom->createElement('wfw:commentRss'); 89 $text = $dom->createTextNode($link['uri']); 90 $flink->appendChild($text); 91 $root->appendChild($flink); 92 } 93 } 94 $this->_called = true; 95 } 96}