| [ Index ] |
PHP Cross Reference of Joomla 1.5.26 DE |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * @version $Id: atom.php 15105 2010-02-27 14:59:11Z ian $ 4 * @package Joomla.Framework 5 * @subpackage Document 6 * @copyright Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved. 7 * @license GNU/GPL, see LICENSE.php 8 * Joomla! is free software. This version may have been modified pursuant 9 * to the GNU General Public License, and as distributed it includes or 10 * is derivative of works licensed under the GNU General Public License or 11 * other free or open source software licenses. 12 * See COPYRIGHT.php for copyright notices and details. 13 */ 14 15 // Check to ensure this file is within the rest of the framework 16 defined('JPATH_BASE') or die(); 17 18 19 20 /** 21 * JDocumentRenderer_Atom is a feed that implements the atom specification 22 * 23 * Please note that just by using this class you won't automatically 24 * produce valid atom files. For example, you have to specify either an editor 25 * for the feed or an author for every single feed item. 26 * 27 * @package Joomla.Framework 28 * @subpackage Document 29 * @see http://www.atomenabled.org/developers/syndication/atom-format-spec.php 30 * @since 1.5 31 */ 32 33 class JDocumentRendererAtom extends JDocumentRenderer 34 { 35 /** 36 * Document mime type 37 * 38 * @var string 39 * @access private 40 */ 41 var $_mime = "application/atom+xml"; 42 43 /** 44 * Render the feed 45 * 46 * @access public 47 * @return string 48 */ 49 function render() 50 { 51 $now =& JFactory::getDate(); 52 $data =& $this->_doc; 53 54 $uri =& JFactory::getURI(); 55 $url = $uri->toString(array('scheme', 'user', 'pass', 'host', 'port')); 56 $syndicationURL =& JRoute::_('&format=feed&type=atom'); 57 58 $feed = "<feed xmlns=\"http://www.w3.org/2005/Atom\" "; 59 if ($data->language!="") { 60 $feed.= " xml:lang=\"".$data->language."\""; 61 } 62 $feed.= ">\n"; 63 $feed.= " <title type=\"text\">".htmlspecialchars($data->title, ENT_COMPAT, 'UTF-8')."</title>\n"; 64 $feed.= " <subtitle type=\"text\">".htmlspecialchars($data->description, ENT_COMPAT, 'UTF-8')."</subtitle>\n"; 65 $feed.= " <link rel=\"alternate\" type=\"text/html\" href=\"".$url."\"/>\n"; 66 $feed.= " <id>".str_replace(' ','%20',$data->getBase())."</id>\n"; 67 $feed.= " <updated>".htmlspecialchars($now->toISO8601(), ENT_COMPAT, 'UTF-8')."</updated>\n"; 68 if ($data->editor!="") { 69 $feed.= " <author>\n"; 70 $feed.= " <name>".$data->editor."</name>\n"; 71 if ($data->editorEmail!="") { 72 $feed.= " <email>".htmlspecialchars($data->editorEmail, ENT_COMPAT, 'UTF-8')."</email>\n"; 73 } 74 $feed.= " </author>\n"; 75 } 76 $feed.= " <generator uri=\"http://joomla.org\" version=\"1.5\">".$data->getGenerator()."</generator>\n"; 77 $feed.= '<link rel="self" type="application/atom+xml" href="'.str_replace(' ','%20',$url.$syndicationURL). "\" />\n"; 78 79 for ($i=0;$i<count($data->items);$i++) 80 { 81 $feed.= " <entry>\n"; 82 $feed.= " <title>".htmlspecialchars(strip_tags($data->items[$i]->title), ENT_COMPAT, 'UTF-8')."</title>\n"; 83 $feed.= ' <link rel="alternate" type="text/html" href="'.$url.$data->items[$i]->link."\"/>\n"; 84 85 if ($data->items[$i]->date=="") { 86 $data->items[$i]->date = $now->toUnix(); 87 } 88 $itemDate =& JFactory::getDate($data->items[$i]->date); 89 $feed.= " <published>".htmlspecialchars($itemDate->toISO8601(), ENT_COMPAT, 'UTF-8')."</published>\n"; 90 $feed.= " <updated>".htmlspecialchars($itemDate->toISO8601(),ENT_COMPAT, 'UTF-8')."</updated>\n"; 91 $feed.= " <id>".str_replace(' ', '%20', $url.$data->items[$i]->link)."</id>\n"; 92 93 if ($data->items[$i]->author!="") 94 { 95 $feed.= " <author>\n"; 96 $feed.= " <name>".htmlspecialchars($data->items[$i]->author, ENT_COMPAT, 'UTF-8')."</name>\n"; 97 if ($data->items[$i]->authorEmail!="") { 98 $feed.= " <email>".htmlspecialchars($data->items[$i]->authorEmail, ENT_COMPAT, 'UTF-8')."</email>\n"; 99 } 100 $feed.= " </author>\n"; 101 } 102 if ($data->items[$i]->description!="") { 103 $feed.= " <summary type=\"html\">".htmlspecialchars($this->_relToAbs($data->items[$i]->description))."</summary>\n"; 104 $feed.= " <content type=\"html\">".htmlspecialchars($this->_relToAbs($data->items[$i]->description))."</content>\n"; 105 } 106 if ($data->items[$i]->enclosure != NULL) { 107 $feed.=" <link rel=\"enclosure\" href=\"". $data->items[$i]->enclosure->url ."\" type=\"". $data->items[$i]->enclosure->type."\" length=\"". $data->items[$i]->enclosure->length . "\" />\n"; 108 } 109 $feed.= " </entry>\n"; 110 } 111 $feed.= "</feed>\n"; 112 return $feed; 113 } 114 115 function _relToAbs($text) 116 { 117 $base = JURI::base(); 118 $text = preg_replace("/(href|src)=\"(?!http|ftp|https|mailto)([^\"]*)\"/", "$1=\"$base\$2\"", $text); 119 120 return $text; 121 } 122 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Wed Mar 28 15:54:07 2012 | Cross-referenced by PHPXref 0.7.1 |