Actions

API16

JDocumentRendererAtom/render

From Joomla! Documentation

< API16:JDocumentRendererAtom
Revision as of 17:44, 22 March 2010 by Doxiki (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Replacement filing cabinet.png
This Namespace has been archived - Please Do Not Edit or Create Pages in this namespace. Pages contain information for a Joomla! version which is no longer supported. It exists only as a historical reference, will not be improved and its content may be incomplete.

Contents

Description

Render the feed

[Edit Descripton]

Description:JDocumentRendererAtom/render

Syntax

render()


Returns

string

Defined in

libraries/joomla/document/feed/renderer/atom.php

Importing

jimport( 'joomla.document.feed.renderer.atom' );

Source Body

function render()
{
        $now    = &JFactory::getDate();
        $data   = &$this->_doc;
 
        $uri = &JFactory::getURI();
        $url = $uri->toString(array('scheme', 'user', 'pass', 'host', 'port'));
        $syndicationURL = &JRoute::_('&format=feed&type=atom');
 
        $feed = "<feed xmlns=\"http://www.w3.org/2005/Atom\" ";
        if ($data->language!="") {
                $feed.= " xml:lang=\"".$data->language."\"";
        }
        $feed.= ">\n";
        $feed.= "       <title type=\"text\">".htmlspecialchars($data->title, ENT_COMPAT, 'UTF-8')."</title>\n";
        $feed.= "       <subtitle type=\"text\">".htmlspecialchars($data->description, ENT_COMPAT, 'UTF-8')."</subtitle>\n";
        $feed.= "       <link rel=\"alternate\" type=\"text/html\" href=\"".$url."\"/>\n";
        $feed.= "       <id>".str_replace(' ','%20',$data->getBase())."</id>\n";
        $feed.= "       <updated>".htmlspecialchars($now->toISO8601(), ENT_COMPAT, 'UTF-8')."</updated>\n";
        if ($data->editor!="") {
                $feed.= "       <author>\n";
                $feed.= "               <name>".$data->editor."</name>\n";
                if ($data->editorEmail!="") {
                        $feed.= "               <email>".htmlspecialchars($data->editorEmail, ENT_COMPAT, 'UTF-8')."</email>\n";
                }
                $feed.= "       </author>\n";
        }
        $feed.= "       <generator uri=\"http://joomla.org\" version=\"1.5\">".$data->getGenerator()."</generator>\n";
        $feed.= '<link rel="self" type="application/atom+xml" href="'.str_replace(' ','%20',$url.$syndicationURL). "\" />\n";
 
        for ($i=0;$i<count($data->items);$i++)
        {
                $feed.= "       <entry>\n";
                $feed.= "               <title>".htmlspecialchars(strip_tags($data->items[$i]->title), ENT_COMPAT, 'UTF-8')."</title>\n";
                $feed.= '               <link rel="alternate" type="text/html" href="'.$url.$data->items[$i]->link."\"/>\n";
 
                if ($data->items[$i]->date=="") {
                        $data->items[$i]->date = $now->toUnix();
                }
                $itemDate = &JFactory::getDate($data->items[$i]->date);
                $feed.= "               <published>".htmlspecialchars($itemDate->toISO8601(), ENT_COMPAT, 'UTF-8')."</published>\n";
                $feed.= "               <updated>".htmlspecialchars($itemDate->toISO8601(),ENT_COMPAT, 'UTF-8')."</updated>\n";
                $feed.= "               <id>".str_replace(' ', '%20', $url.$data->items[$i]->link)."</id>\n";
 
                if ($data->items[$i]->author!="")
                {
                        $feed.= "               <author>\n";
                        $feed.= "                       <name>".htmlspecialchars($data->items[$i]->author, ENT_COMPAT, 'UTF-8')."</name>\n";
                        if ($data->items[$i]->authorEmail!="") {
                                $feed.= "               <email>".htmlspecialchars($data->items[$i]->authorEmail, ENT_COMPAT, 'UTF-8')."</email>\n";
                        }
                        $feed.= "               </author>\n";
                }
                if ($data->items[$i]->description!="") {
                        $feed.= "               <summary type=\"html\">".htmlspecialchars($data->items[$i]->description, ENT_COMPAT, 'UTF-8')."</summary>\n";
                        $feed.= "               <content type=\"html\">".htmlspecialchars($data->items[$i]->description, ENT_COMPAT, 'UTF-8')."</content>\n";
                }
                if ($data->items[$i]->enclosure != NULL) {
                $feed.="                <link rel=\"enclosure\" href=\"". $data->items[$i]->enclosure->url ."\" type=\"". $data->items[$i]->enclosure->type."\"  length=\"". $data->items[$i]->enclosure->length . "\" />\n";
                }
                $feed.= "       </entry>\n";
        }
        $feed.= "</feed>\n";
        return $feed;
}

[Edit See Also] SeeAlso:JDocumentRendererAtom/render

Examples

<CodeExamplesForm />