Support Joomla!

Joomla! 1.5 Documentation

Packages

Package: Joomla-Framework

License

Content on this site is copyright © 2005 - 2008 by the individual contributors and can be used in accordance with the Creative Commons License, Attribution- NonCommercial- ShareAlike 2.5. Some parts of this website may be subject to other licenses.
Source code for file /joomla/document/feed/renderer/atom.php

Documentation is available at atom.php

  1. <?php
  2. /**
  3.  * @version        $Id: atom.php 9794 2008-01-02 10:57:00Z tcp $
  4.  * @package        Joomla.Framework
  5.  * @subpackage    Document
  6.  * @copyright    Copyright (C) 2005 - 2008 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 <johan.janssens@joomla.org>
  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.  
  44.     /**
  45.      * Render the feed
  46.      *
  47.      * @access public
  48.      * @return string 
  49.      */
  50.     function render()
  51.     {
  52.         $now    new JDate();
  53.         $data    =$this->_doc;
  54.  
  55.         $feed "<feed xmlns=\"http://www.w3.org/2005/Atom\" xml:base=\"".$data->getBase()."\"";
  56.         if ($data->language!=""{
  57.             $feed.= " xml:lang=\"".$data->language."\"";
  58.         }
  59.         $feed.= ">\n";
  60.         $feed.= "    <title type=\"text\">".htmlspecialchars($data->titleENT_COMPAT'UTF-8')."</title>\n";
  61.         $feed.= "    <subtitle type=\"text\">".htmlspecialchars($data->descriptionENT_COMPAT'UTF-8')."</subtitle>\n";
  62.         $feed.= "    <link rel=\"alternate\" type=\"text/html\" href=\"".$data->link."\"/>\n";
  63.         $feed.= "    <id>".$data->link."</id>\n";
  64.         $feed.= "    <updated>".htmlspecialchars($now->toISO8601()ENT_COMPAT'UTF-8')."</updated>\n";
  65.         if ($data->editor!=""{
  66.             $feed.= "    <author>\n";
  67.             $feed.= "        <name>".$data->editor."</name>\n";
  68.             if ($data->editorEmail!=""{
  69.                 $feed.= "        <email>".$data->editorEmail."</email>\n";
  70.             }
  71.             $feed.= "    </author>\n";
  72.         }
  73.         $feed.= "    <generator uri=\"http://joomla.org\" version=\"1.5\">".$data->getGenerator()."</generator>\n";
  74.         $feed.= "<link rel=\"self\" type=\"application/atom+xml\" href=\""$data->syndicationURL "\" />\n";
  75.         for ($i=0;$i<count($data->items);$i++)
  76.         {
  77.             $feed.= "    <entry>\n";
  78.             $feed.= "        <title>".htmlspecialchars(strip_tags($data->items[$i]->title)ENT_COMPAT'UTF-8')."</title>\n";
  79.             $feed.= '        <link rel="alternate" type="text/html" href="'.$data->items[$i]->link."\"/>\n";
  80.  
  81.             if ($data->items[$i]->date==""{
  82.                 $data->items[$i]->date time();
  83.             }
  84.             $itemDate new JDate($data->items[$i]->date);
  85.             $feed.= "        <published>".htmlspecialchars($itemDate->toISO8601()ENT_COMPAT'UTF-8')."</published>\n";
  86.             $feed.= "        <updated>".htmlspecialchars($itemDate->toISO8601(),ENT_COMPAT'UTF-8')."</updated>\n";
  87.             $feed.= "        <id>".htmlspecialchars($data->items[$i]->linkENT_COMPAT'UTF-8')."</id>\n";
  88.  
  89.             if ($data->items[$i]->author!="")
  90.             {
  91.                 $feed.= "        <author>\n";
  92.                 $feed.= "            <name>".htmlspecialchars($data->items[$i]->authorENT_COMPAT'UTF-8')."</name>\n";
  93.                 $feed.= "        </author>\n";
  94.             }
  95.             if ($data->items[$i]->description!=""{
  96.                 $feed.= "        <summary type=\"html\">".htmlspecialchars($data->items[$i]->descriptionENT_COMPAT'UTF-8')."</summary>\n";
  97.                 $feed.= "        <content type=\"html\">".htmlspecialchars($data->items[$i]->descriptionENT_COMPAT'UTF-8')."</content>\n";
  98.             }
  99.             if ($data->items[$i]->enclosure != NULL{
  100.             $feed.="        <link rel=\"enclosure\" href=\""$data->items[$i]->enclosure->url ."\" type=\""$data->items[$i]->enclosure->type."\"  length=\""$data->items[$i]->enclosure->length "\" />\n";
  101.             }
  102.             $feed.= "    </entry>\n";
  103.         }
  104.         $feed.= "</feed>\n";
  105.         return $feed;
  106.     }
  107. }

Documentation generated on Tue, 29 Jan 2008 18:44:30 +0000 by phpDocumentor 1.3.1