Support Joomla!

Joomla! 1.5 Documentation

Packages

Package: Joomla-Framework

Developer Network License

The Joomla! Developer Network content is © copyright 2006 by the individual contributors and can be used in accordance with the Creative Commons License, Attribution- NonCommercial- ShareAlike 2.5
Source code for file /joomla/document/feed/renderer/atom.php

Documentation is available at atom.php

  1. <?php
  2. /**
  3.  * @version        $Id: atom.php 6472 2007-02-03 10:47:26Z pasamio $
  4.  * @package        Joomla.Framework
  5.  * @subpackage    Document
  6.  * @copyright    Copyright (C) 2005 - 2007 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. jimport'joomla.utilities.date' );
  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.  * @author    Johan Janssens <[email protected]>
  28.  *
  29.  * @package     Joomla.Framework
  30.  * @subpackage        Document
  31.  * @see http://www.atomenabled.org/developers/syndication/atom-format-spec.php
  32.  * @since    1.5
  33.  */
  34.  
  35.  {
  36.     /**
  37.      * Document mime type
  38.      *
  39.      * @var        string 
  40.      * @access    private
  41.      */
  42.      //var $_mime = "application/atom+xml";
  43.           var $_mime "text/xml";
  44.  
  45.  
  46.     /**
  47.      * Render the feed
  48.      *
  49.      * @access public
  50.      * @return string 
  51.      */
  52.     function render()
  53.     {
  54.         $now    new JDate();
  55.         $data    =$this->_doc;
  56.  
  57.         $feed "<feed xmlns=\"http://www.w3.org/2005/Atom\"";
  58.         if ($data->language!=""{
  59.             $feed.= " xml:lang=\"".$data->language."\"";
  60.         }
  61.         $feed.= ">\n";
  62.         $feed.= "    <title>".htmlspecialchars($data->title)."</title>\n";
  63.         $feed.= "    <subtitle>".htmlspecialchars($data->description)."</subtitle>\n";
  64.         $feed.= "    <link rel=\"alternate\" type=\"text/html\" href=\"".htmlspecialchars($data->link)."\"/>\n";
  65.         $feed.= "    <id>".htmlspecialchars($data->link)."</id>\n";
  66.         $feed.= "    <updated>".htmlspecialchars($now->toISO8601())."</updated>\n";
  67.         if ($data->editor!=""{
  68.             $feed.= "    <author>\n";
  69.             $feed.= "        <name>".$data->editor."</name>\n";
  70.             if ($data->editorEmail!=""{
  71.                 $feed.= "        <email>".$data->editorEmail."</email>\n";
  72.             }
  73.             $feed.= "    </author>\n";
  74.         }
  75.         $feed.= "    <generator uri=\"http://joomla.org\" version=\"1.5\">".$data->getGenerator()."</generator>\n";
  76.         $feed.= "<link rel=\"self\" type=\"application/atom+xml\" href=\""$data->syndicationURL "\" />\n";
  77.         for ($i=0;$i<count($data->items);$i++)
  78.         {
  79.             $feed.= "    <entry>\n";
  80.             $feed.= "        <title>".htmlspecialchars(strip_tags($data->items[$i]->title))."</title>\n";
  81.             $feed.= "        <link rel=\"alternate\" type=\"text/html\" href=\"".htmlspecialchars($data->items[$i]->link)."\"/>\n";
  82.  
  83.             if ($data->items[$i]->date==""{
  84.                 $data->items[$i]->date time();
  85.             }
  86.             $itemDate new JDate($data->items[$i]->date);
  87.             $feed.= "        <published>".htmlspecialchars($itemDate->toISO8601())."</published>\n";
  88.             $feed.= "        <updated>".htmlspecialchars($itemDate->toISO8601())."</updated>\n";
  89.             $feed.= "        <id>".htmlspecialchars($data->items[$i]->link)."</id>\n";
  90.  
  91.             if ($data->items[$i]->author!="")
  92.             {
  93.                 $feed.= "        <author>\n";
  94.                 $feed.= "            <name>".htmlspecialchars($data->items[$i]->author)."</name>\n";
  95.                 $feed.= "        </author>\n";
  96.             }
  97.             if ($data->items[$i]->description!=""{
  98.                 $feed.= "        <summary type=\"html\">".htmlspecialchars($data->items[$i]->description)."</summary>\n";
  99.             }
  100.             if ($data->items[$i]->enclosure != NULL{
  101.             $feed.="        <link rel=\"enclosure\" href=\""$data->items[$i]->enclosure->url ."\" type=\""$data->items[$i]->enclosure->type."\"  length=\""$data->items[$i]->enclosure->length "\" />\n";
  102.             }
  103.             $feed.= "    </entry>\n";
  104.         }
  105.         $feed.= "</feed>\n";
  106.         return $feed;
  107.     }
  108. }
  109. ?>

Documentation generated on Mon, 05 Mar 2007 20:52:38 +0000 by phpDocumentor 1.3.1