?
avatar wartur
wartur
9 Jul 2015

Hello.

RSS and ATOM generate problem

"pubDate" is same as "update"

I fixed some files. It's code. My fix mark as ARTUR FIX

Sorry I cant any time for pull.

libraries/legacy/view/categoryfeed.php

<?php
/**
 * @package     Joomla.Legacy
 * @subpackage  View
 *
 * @copyright   Copyright (C) 2005 - 2015 Open Source Matters, Inc. All rights reserved.
 * @license     GNU General Public License version 2 or later; see LICENSE.txt
 */

defined('JPATH_PLATFORM') or die;

/**
 * Base feed View class for a category
 *
 * @since  3.2
 */
class JViewCategoryfeed extends JViewLegacy
{
    /**
     * Execute and display a template script.
     *
     * @param   string  $tpl  The name of the template file to parse; automatically searches through the template paths.
     *
     * @return  mixed  A string if successful, otherwise a Error object.
     *
     * @since   3.2
     */
    public function display($tpl = null)
    {
        $app      = JFactory::getApplication();
        $document = JFactory::getDocument();

        $extension      = $app->input->getString('option');
        $contentType = $extension . '.' . $this->viewName;

        $ucmType = new JUcmType;
        $ucmRow = $ucmType->getTypeByAlias($contentType);
        $ucmMapCommon = json_decode($ucmRow->field_mappings)->common;
        $createdField = null;
        $titleField = null;

        if (is_object($ucmMapCommon))
        {
            $createdField = $ucmMapCommon->core_created_time;
            $titleField = $ucmMapCommon->core_title;
                        $publishField = $ucmMapCommon->core_publish_up; // ARTUR FIX
        }
        elseif (is_array($ucmMapCommon))
        {
            $createdField = $ucmMapCommon[0]->core_created_time;
            $titleField = $ucmMapCommon[0]->core_title;
                        $publishField = $ucmMapCommon[0]->core_publish_up; // ARTUR FIX
        }

        $document->link = JRoute::_(JHelperRoute::getCategoryRoute($app->input->getInt('id'), $language = 0, $extension));

        $app->input->set('limit', $app->get('feed_limit'));
        $siteEmail        = $app->get('mailfrom');
        $fromName         = $app->get('fromname');
        $feedEmail        = $app->get('feed_email', 'author');
        $document->editor = $fromName;

        if ($feedEmail != 'none')
        {
            $document->editorEmail = $siteEmail;
        }

        // Get some data from the model
        $items    = $this->get('Items');
        $category = $this->get('Category');

        foreach ($items as $item)
        {
            $this->reconcileNames($item);

            // Strip html from feed item title
            if ($titleField)
            {
                $title = $this->escape($item->$titleField);
                $title = html_entity_decode($title, ENT_COMPAT, 'UTF-8');
            }
            else
            {
                $title = '';
            }

            // URL link to article
            $router = new JHelperRoute;
            $link   = JRoute::_($router->getRoute($item->id, $contentType, null, null, $item->catid));

            // Strip HTML from feed item description text.
            $description = $item->description;
            $author      = $item->created_by_alias ? $item->created_by_alias : $item->author;

            if ($createdField)
            {
                $date = isset($item->$createdField) ? date('r', strtotime($item->$createdField)) : '';
            }
            else
            {
                $date = '';
            }

                        // ARTUR FIX
                        if($publishField) {
                            $pubDate = isset($item->$publishField) ? date('r', strtotime($item->$publishField)) : '';
                        } else {
                            $pubDate = '';
                        }

            // Load individual item creator class.
            $feeditem              = new JFeedItem;
            $feeditem->title       = $title;
            $feeditem->link        = $link;
            $feeditem->description = $description;
            $feeditem->date        = $date;
                        $feeditem->pubDate     = $pubDate; // ARTUR FIX
            $feeditem->category    = $category->title;
            $feeditem->author      = $author;

            // We don't have the author email so we have to use site in both cases.
            if ($feedEmail == 'site')
            {
                $feeditem->authorEmail = $siteEmail;
            }
            elseif ($feedEmail === 'author')
            {
                $feeditem->authorEmail = $item->author_email;
            }

            // Loads item information into RSS array
            $document->addItem($feeditem);
        }
    }

    /**
     * Method to reconcile non standard names from components to usage in this class.
     * Typically overriden in the component feed view class.
     *
     * @param   object  $item  The item for a feed, an element of the $items array.
     *
     * @return  void
     *
     * @since   3.2
     */
    protected function reconcileNames($item)
    {
        if (!property_exists($item, 'title') && property_exists($item, 'name'))
        {
            $item->title = $item->name;
        }
    }
}

libraries/joomla/document/feed/feed.php

<?php
/**
 * @package     Joomla.Platform
 * @subpackage  Document
 *
 * @copyright   Copyright (C) 2005 - 2015 Open Source Matters, Inc. All rights reserved.
 * @license     GNU General Public License version 2 or later; see LICENSE
 */

defined('JPATH_PLATFORM') or die;

/**
 * DocumentFeed class, provides an easy interface to parse and display any feed document
 *
 * @since  11.1
 */
class JDocumentFeed extends JDocument
{
    /**
     * Syndication URL feed element
     *
     * optional
     *
     * @var    string
     * @since  11.1
     */
    public $syndicationURL = "";

    /**
     * Image feed element
     *
     * optional
     *
     * @var    object
     * @since  11.1
     */
    public $image = null;

    /**
     * Copyright feed element
     *
     * optional
     *
     * @var    string
     * @since  11.1
     */
    public $copyright = "";

    /**
     * Published date feed element
     *
     * optional
     *
     * @var    string
     * @since  11.1
     */
    public $pubDate = "";

    /**
     * Lastbuild date feed element
     *
     * optional
     *
     * @var    string
     * @since  11.1
     */
    public $lastBuildDate = "";

    /**
     * Editor feed element
     *
     * optional
     *
     * @var    string
     * @since  11.1
     */
    public $editor = "";

    /**
     * Docs feed element
     *
     * @var    string
     * @since  11.1
     */
    public $docs = "";

    /**
     * Editor email feed element
     *
     * optional
     *
     * @var    string
     * @since  11.1
     */
    public $editorEmail = "";

    /**
     * Webmaster email feed element
     *
     * optional
     *
     * @var    string
     * @since  11.1
     */
    public $webmaster = "";

    /**
     * Category feed element
     *
     * optional
     *
     * @var    string
     * @since  11.1
     */
    public $category = "";

    /**
     * TTL feed attribute
     *
     * optional
     *
     * @var    string
     * @since  11.1
     */
    public $ttl = "";

    /**
     * Rating feed element
     *
     * optional
     *
     * @var    string
     * @since  11.1
     */
    public $rating = "";

    /**
     * Skiphours feed element
     *
     * optional
     *
     * @var    string
     * @since  11.1
     */
    public $skipHours = "";

    /**
     * Skipdays feed element
     *
     * optional
     *
     * @var    string
     * @since  11.1
     */
    public $skipDays = "";

    /**
     * The feed items collection
     *
     * @var    array
     * @since  11.1
     */
    public $items = array();

    /**
     * Class constructor
     *
     * @param   array  $options  Associative array of options
     *
     * @since  11.1
     */
    public function __construct($options = array())
    {
        parent::__construct($options);

        // Set document type
        $this->_type = 'feed';
    }

    /**
     * Render the document
     *
     * @param   boolean  $cache   If true, cache the output
     * @param   array    $params  Associative array of attributes
     *
     * @return  The rendered data
     *
     * @since  11.1
     * @throws Exception
     * @todo   Make this cacheable
     */
    public function render($cache = false, $params = array())
    {
        // Get the feed type
        $type = JFactory::getApplication()->input->get('type', 'rss');

        // Instantiate feed renderer and set the mime encoding
        $renderer = $this->loadRenderer(($type) ? $type : 'rss');

        if (!is_a($renderer, 'JDocumentRenderer'))
        {
            throw new Exception(JText::_('JGLOBAL_RESOURCE_NOT_FOUND'), 404);
        }

        $this->setMimeEncoding($renderer->getContentType());

        // Output
        // Generate prolog
        $data = "<?xml version=\"1.0\" encoding=\"" . $this->_charset . "\"?>\n";
        $data .= "<!-- generator=\"" . $this->getGenerator() . "\" -->\n";

        // Generate stylesheet links
        foreach ($this->_styleSheets as $src => $attr)
        {
            $data .= "<?xml-stylesheet href=\"$src\" type=\"" . $attr['mime'] . "\"?>\n";
        }

        // Render the feed
        $data .= $renderer->render();

        parent::render();

        return $data;
    }

    /**
     * Adds an JFeedItem to the feed.
     *
     * @param   JFeedItem  $item  The feeditem to add to the feed.
     *
     * @return  JDocumentFeed  instance of $this to allow chaining
     *
     * @since   11.1
     */
    public function addItem(JFeedItem $item)
    {
        $item->source = $this->link;
        $this->items[] = $item;

        return $this;
    }
}

/**
 * JFeedItem is an internal class that stores feed item information
 *
 * @since  11.1
 */
class JFeedItem
{
    /**
     * Title item element
     *
     * required
     *
     * @var    string
     * @since  11.1
     */
    public $title;

    /**
     * Link item element
     *
     * required
     *
     * @var    string
     * @since  11.1
     */
    public $link;

    /**
     * Description item element
     *
     * required
     *
     * @var    string
     * @since  11.1
     */
    public $description;

    /**
     * Author item element
     *
     * optional
     *
     * @var    string
     * @since  11.1
     */
    public $author;

    /**
     * Author email element
     *
     * optional
     *
     * @var    string
     * @since  11.1
     */
    public $authorEmail;

    /**
     * Category element
     *
     * optional
     *
     * @var    array or string
     * @since  11.1
     */
    public $category;

    /**
     * Comments element
     *
     * optional
     *
     * @var    string
     * @since  11.1
     */
    public $comments;

    /**
     * Enclosure element
     *
     * @var    object
     * @since  11.1
     */
    public $enclosure = null;

    /**
     * Guid element
     *
     * optional
     *
     * @var    string
     * @since  11.1
     */
    public $guid;

    /**
     * Published date
     *
     * optional
     *
     * May be in one of the following formats:
     *
     * RFC 822:
     * "Mon, 20 Jan 03 18:05:41 +0400"
     * "20 Jan 03 18:05:41 +0000"
     *
     * ISO 8601:
     * "2003-01-20T18:05:41+04:00"
     *
     * Unix:
     * 1043082341
     *
     * @var    string
     * @since  11.1
     */
    public $date;

    /**
     * Source element
     *
     * optional
     *
     * @var    string
     * @since  11.1
     */
    public $source;

        /**
         * ARTUR FIX
         */
        public $pubDate;

    /**
     * Set the JFeedEnclosure for this item
     *
     * @param   JFeedEnclosure  $enclosure  The JFeedEnclosure to add to the feed.
     *
     * @return  JFeedItem instance of $this to allow chaining
     *
     * @since   11.1
     */
    public function setEnclosure(JFeedEnclosure $enclosure)
    {
        $this->enclosure = $enclosure;

        return $this;
    }
}

/**
 * JFeedEnclosure is an internal class that stores feed enclosure information
 *
 * @since  11.1
 */
class JFeedEnclosure
{
    /**
     * URL enclosure element
     *
     * required
     *
     * @var    string
     * @since  11.1
     */
    public $url = "";

    /**
     * Length enclosure element
     *
     * required
     *
     * @var    string
     * @since  11.1
     */
    public $length = "";

    /**
     * Type enclosure element
     *
     * required
     *
     * @var    string
     * @since  11.1
     */
    public $type = "";
}

/**
 * JFeedImage is an internal class that stores feed image information
 *
 * @since  11.1
 */
class JFeedImage
{
    /**
     * Title image attribute
     *
     * required
     *
     * @var    string
     * @since  11.1
     */
    public $title = "";

    /**
     * URL image attribute
     *
     * required
     *
     * @var    string
     * @since  11.1
     */
    public $url = "";

    /**
     * Link image attribute
     *
     * required
     *
     * @var    string
     * @since  11.1
     */
    public $link = "";

    /**
     * Width image attribute
     *
     * optional
     *
     * @var    string
     * @since  11.1
     */
    public $width;

    /**
     * Title feed attribute
     *
     * optional
     *
     * @var    string
     * @since  11.1
     */
    public $height;

    /**
     * Title feed attribute
     *
     * optional
     *
     * @var    string
     * @since  11.1
     */
    public $description;
}

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

<?php
/**
 * @package     Joomla.Platform
 * @subpackage  Document
 *
 * @copyright   Copyright (C) 2005 - 2015 Open Source Matters, Inc. All rights reserved.
 * @license     GNU General Public License version 2 or later; see LICENSE
 */

defined('JPATH_PLATFORM') or die;

/**
 * JDocumentRenderer_Atom is a feed that implements the atom specification
 *
 * Please note that just by using this class you won't automatically
 * produce valid atom files. For example, you have to specify either an editor
 * for the feed or an author for every single feed item.
 *
 * @see    http://www.atomenabled.org/developers/syndication/atom-format-spec.php
 * @since  11.1
 */
class JDocumentRendererAtom extends JDocumentRenderer
{
    /**
     * Document mime type
     *
     * @var    string
     * @since  11.1
     */
    protected $_mime = "application/atom+xml";

    /**
     * Render the feed.
     *
     * @param   string  $name     The name of the element to render
     * @param   array   $params   Array of values
     * @param   string  $content  Override the output of the renderer
     *
     * @return  string  The output of the script
     *
     * @see JDocumentRenderer::render()
     * @since   11.1
     */
    public function render($name = '', $params = null, $content = null)
    {
        $app = JFactory::getApplication();

        // Gets and sets timezone offset from site configuration
        $tz = new DateTimeZone($app->getCfg('offset'));
        $now = JFactory::getDate();
        $now->setTimeZone($tz);

        $data = $this->_doc;

        $uri = JUri::getInstance();
        $url = $uri->toString(array('scheme', 'user', 'pass', 'host', 'port'));
        $syndicationURL = JRoute::_('&format=feed&type=atom');

        if ($app->getCfg('sitename_pagetitles', 0) == 1)
        {
            $title = JText::sprintf('JPAGETITLE', $app->getCfg('sitename'), $data->title);
        }
        elseif ($app->getCfg('sitename_pagetitles', 0) == 2)
        {
            $title = JText::sprintf('JPAGETITLE', $data->title, $app->getCfg('sitename'));
        }
        else
        {
            $title = $data->title;
        }

        $feed_title = htmlspecialchars($title, ENT_COMPAT, 'UTF-8');

        $feed = "<feed xmlns=\"http://www.w3.org/2005/Atom\" ";

        if ($data->language != "")
        {
            $feed .= " xml:lang=\"" . $data->language . "\"";
        }

        $feed .= ">\n";
        $feed .= "  <title type=\"text\">" . $feed_title . "</title>\n";
        $feed .= "  <subtitle type=\"text\">" . htmlspecialchars($data->description, ENT_COMPAT, 'UTF-8') . "</subtitle>\n";

        if (empty($data->category) === false)
        {
            if (is_array($data->category))
            {
                foreach ($data->category as $cat)
                {
                    $feed .= "  <category term=\"" . htmlspecialchars($cat, ENT_COMPAT, 'UTF-8') . "\" />\n";
                }
            }
            else
            {
                $feed .= "  <category term=\"" . htmlspecialchars($data->category, ENT_COMPAT, 'UTF-8') . "\" />\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(true), 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";
        }

        if ($app->get('MetaVersion', 0))
        {
            $version = new JVersion;

            $versionHtmlEscaped = ' version="' . htmlspecialchars($version->RELEASE, ENT_COMPAT, 'UTF-8') . '"';
        }
        else
        {
            $versionHtmlEscaped = '';
        }

        $feed .= "  <generator uri=\"http://joomla.org\"" . $versionHtmlEscaped . ">" . $data->getGenerator() . "</generator>\n";
        $feed .= '  <link rel="self" type="application/atom+xml" href="' . str_replace(' ', '%20', $url . $syndicationURL) . "\"/>\n";

        for ($i = 0, $count = count($data->items); $i < $count; $i++)
        {
            if (!preg_match('/[\x80-\xFF]/', $data->items[$i]->link))
            {
                $itemlink = $data->items[$i]->link;
            }
            else
            {
                $itemlink = implode("/", array_map("rawurlencode", explode("/", $data->items[$i]->link)));
            }

            $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 . $itemlink . "\"/>\n";

            if ($data->items[$i]->date == "")
            {
                $data->items[$i]->date = $now->toUnix();
            }

                        $lolo = $data->items[$i];

            $itemDate = JFactory::getDate($data->items[$i]->date);
            $itemDate->setTimeZone($tz);
            $feed .= "      <updated>" . htmlspecialchars($itemDate->toISO8601(true), ENT_COMPAT, 'UTF-8') . "</updated>\n";

                        // ARTUR FIX
                        if(empty($data->items[$i]->pubDate)) {
                            $feed .= "      <published>" . htmlspecialchars($itemDate->toISO8601(true), ENT_COMPAT, 'UTF-8') . "</published>\n";
                        } else {
                            $pubDate = JFactory::getDate($data->items[$i]->pubDate);
                            $pubDate->setTimezone($tz);
                            $feed .= "      <published>" . htmlspecialchars($pubDate->toISO8601(true), ENT_COMPAT, 'UTF-8') . "</published>\n";
                        }

            if (empty($data->items[$i]->guid) === true)
            {
                $feed .= "      <id>" . str_replace(' ', '%20', $url . $itemlink) . "</id>\n";
            }
            else
            {
                $feed .= "      <id>" . htmlspecialchars($data->items[$i]->guid, ENT_COMPAT, 'UTF-8') . "</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($this->_relToAbs($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 (empty($data->items[$i]->category) === false)
            {
                if (is_array($data->items[$i]->category))
                {
                    foreach ($data->items[$i]->category as $cat)
                    {
                        $feed .= "      <category term=\"" . htmlspecialchars($cat, ENT_COMPAT, 'UTF-8') . "\" />\n";
                    }
                }
                else
                {
                    $feed .= "      <category term=\"" . htmlspecialchars($data->items[$i]->category, ENT_COMPAT, 'UTF-8') . "\" />\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;
    }
}

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

<?php
/**
 * @package     Joomla.Platform
 * @subpackage  Document
 *
 * @copyright   Copyright (C) 2005 - 2015 Open Source Matters, Inc. All rights reserved.
 * @license     GNU General Public License version 2 or later; see LICENSE
 */

defined('JPATH_PLATFORM') or die;

/**
 * JDocumentRenderer_RSS is a feed that implements RSS 2.0 Specification
 *
 * @see    http://www.rssboard.org/rss-specification
 * @since  11.1
 */
class JDocumentRendererRSS extends JDocumentRenderer
{
    /**
     * Renderer mime type
     *
     * @var    string
     * @since  11.1
     */
    protected $_mime = "application/rss+xml";

    /**
     * Render the feed.
     *
     * @param   string  $name     The name of the element to render
     * @param   array   $params   Array of values
     * @param   string  $content  Override the output of the renderer
     *
     * @return  string  The output of the script
     *
     * @see JDocumentRenderer::render()
     * @since   11.1
     */
    public function render($name = '', $params = null, $content = null)
    {
        $app = JFactory::getApplication();

        // Gets and sets timezone offset from site configuration
        $tz = new DateTimeZone($app->get('offset'));
        $now = JFactory::getDate();
        $now->setTimeZone($tz);

        $data = $this->_doc;

        $uri = JUri::getInstance();
        $url = $uri->toString(array('scheme', 'user', 'pass', 'host', 'port'));
        $syndicationURL = JRoute::_('&format=feed&type=rss');

        if ($app->get('sitename_pagetitles', 0) == 1)
        {
            $title = JText::sprintf('JPAGETITLE', $app->get('sitename'), $data->title);
        }
        elseif ($app->get('sitename_pagetitles', 0) == 2)
        {
            $title = JText::sprintf('JPAGETITLE', $data->title, $app->get('sitename'));
        }
        else
        {
            $title = $data->title;
        }

        $feed_title = htmlspecialchars($title, ENT_COMPAT, 'UTF-8');

        if (!preg_match('/[\x80-\xFF]/', $data->link))
        {
            $datalink = $data->link;
        }
        else
        {
            $datalink = implode("/", array_map("rawurlencode", explode("/", $data->link)));
        }

        $feed = "<rss version=\"2.0\" xmlns:atom=\"http://www.w3.org/2005/Atom\">\n";
        $feed .= "  <channel>\n";
        $feed .= "      <title>" . $feed_title . "</title>\n";
        $feed .= "      <description><![CDATA[" . $data->description . "]]></description>\n";
        $feed .= "      <link>" . str_replace(' ', '%20', $url . $datalink) . "</link>\n";
        $feed .= "      <lastBuildDate>" . htmlspecialchars($now->toRFC822(true), ENT_COMPAT, 'UTF-8') . "</lastBuildDate>\n";
        $feed .= "      <generator>" . $data->getGenerator() . "</generator>\n";
        $feed .= '      <atom:link rel="self" type="application/rss+xml" href="' . str_replace(' ', '%20', $url . $syndicationURL) . "\"/>\n";

        if ($data->image != null)
        {
            $feed .= "      <image>\n";
            $feed .= "          <url>" . $data->image->url . "</url>\n";
            $feed .= "          <title>" . htmlspecialchars($data->image->title, ENT_COMPAT, 'UTF-8') . "</title>\n";
            $feed .= "          <link>" . str_replace(' ', '%20', $data->image->link) . "</link>\n";

            if ($data->image->width != "")
            {
                $feed .= "          <width>" . $data->image->width . "</width>\n";
            }

            if ($data->image->height != "")
            {
                $feed .= "          <height>" . $data->image->height . "</height>\n";
            }

            if ($data->image->description != "")
            {
                $feed .= "          <description><![CDATA[" . $data->image->description . "]]></description>\n";
            }

            $feed .= "      </image>\n";
        }

        if ($data->language != "")
        {
            $feed .= "      <language>" . $data->language . "</language>\n";
        }

        if ($data->copyright != "")
        {
            $feed .= "      <copyright>" . htmlspecialchars($data->copyright, ENT_COMPAT, 'UTF-8') . "</copyright>\n";
        }

        if ($data->editorEmail != "")
        {
            $feed .= "      <managingEditor>" . htmlspecialchars($data->editorEmail, ENT_COMPAT, 'UTF-8') . ' ('
                . htmlspecialchars($data->editor, ENT_COMPAT, 'UTF-8') . ")</managingEditor>\n";
        }

        if ($data->webmaster != "")
        {
            $feed .= "      <webMaster>" . htmlspecialchars($data->webmaster, ENT_COMPAT, 'UTF-8') . "</webMaster>\n";
        }

        if ($data->pubDate != "")
        {
            $pubDate = JFactory::getDate($data->pubDate);
            $pubDate->setTimeZone($tz);
            $feed .= "      <pubDate>" . htmlspecialchars($pubDate->toRFC822(true), ENT_COMPAT, 'UTF-8') . "</pubDate>\n";
        }

        if (empty($data->category) === false)
        {
            if (is_array($data->category))
            {
                foreach ($data->category as $cat)
                {
                    $feed .= "      <category>" . htmlspecialchars($cat, ENT_COMPAT, 'UTF-8') . "</category>\n";
                }
            }
            else
            {
                $feed .= "      <category>" . htmlspecialchars($data->category, ENT_COMPAT, 'UTF-8') . "</category>\n";
            }
        }

        if ($data->docs != "")
        {
            $feed .= "      <docs>" . htmlspecialchars($data->docs, ENT_COMPAT, 'UTF-8') . "</docs>\n";
        }

        if ($data->ttl != "")
        {
            $feed .= "      <ttl>" . htmlspecialchars($data->ttl, ENT_COMPAT, 'UTF-8') . "</ttl>\n";
        }

        if ($data->rating != "")
        {
            $feed .= "      <rating>" . htmlspecialchars($data->rating, ENT_COMPAT, 'UTF-8') . "</rating>\n";
        }

        if ($data->skipHours != "")
        {
            $feed .= "      <skipHours>" . htmlspecialchars($data->skipHours, ENT_COMPAT, 'UTF-8') . "</skipHours>\n";
        }

        if ($data->skipDays != "")
        {
            $feed .= "      <skipDays>" . htmlspecialchars($data->skipDays, ENT_COMPAT, 'UTF-8') . "</skipDays>\n";
        }

        for ($i = 0, $count = count($data->items); $i < $count; $i++)
        {
            if (!preg_match('/[\x80-\xFF]/', $data->items[$i]->link))
            {
                $itemlink = $data->items[$i]->link;
            }
            else
            {
                $itemlink = implode("/", array_map("rawurlencode", explode("/", $data->items[$i]->link)));
            }

            if ((strpos($itemlink, 'http://') === false) && (strpos($itemlink, 'https://') === false))
            {
                $itemlink = str_replace(' ', '%20', $url . $itemlink);
            }

            $feed .= "      <item>\n";
            $feed .= "          <title>" . htmlspecialchars(strip_tags($data->items[$i]->title), ENT_COMPAT, 'UTF-8') . "</title>\n";
            $feed .= "          <link>" . str_replace(' ', '%20', $itemlink) . "</link>\n";

            if (empty($data->items[$i]->guid) === true)
            {
                $feed .= "          <guid isPermaLink=\"true\">" . str_replace(' ', '%20', $itemlink) . "</guid>\n";
            }
            else
            {
                $feed .= "          <guid isPermaLink=\"false\">" . htmlspecialchars($data->items[$i]->guid, ENT_COMPAT, 'UTF-8') . "</guid>\n";
            }

            $feed .= "          <description><![CDATA[" . $this->_relToAbs($data->items[$i]->description) . "]]></description>\n";

            if ($data->items[$i]->authorEmail != "")
            {
                $feed .= "          <author>"
                    . htmlspecialchars($data->items[$i]->authorEmail . ' (' . $data->items[$i]->author . ')', ENT_COMPAT, 'UTF-8') . "</author>\n";
            }

            /*
             * @todo: On hold
             * if ($data->items[$i]->source!="") {
             *   $data.= "          <source>".htmlspecialchars($data->items[$i]->source, ENT_COMPAT, 'UTF-8')."</source>\n";
             * }
             */

            if (empty($data->items[$i]->category) === false)
            {
                if (is_array($data->items[$i]->category))
                {
                    foreach ($data->items[$i]->category as $cat)
                    {
                        $feed .= "          <category>" . htmlspecialchars($cat, ENT_COMPAT, 'UTF-8') . "</category>\n";
                    }
                }
                else
                {
                    $feed .= "          <category>" . htmlspecialchars($data->items[$i]->category, ENT_COMPAT, 'UTF-8') . "</category>\n";
                }
            }

            if ($data->items[$i]->comments != "")
            {
                $feed .= "          <comments>" . htmlspecialchars($data->items[$i]->comments, ENT_COMPAT, 'UTF-8') . "</comments>\n";
            }

            if ($data->items[$i]->date != "")
            {
                                // ARTUR FIX
                                if(empty($data->items[$i]->pubDate)) {
                                    $itemDate = JFactory::getDate($data->items[$i]->date);
                                } else {
                                    $itemDate = JFactory::getDate($data->items[$i]->pubDate);
                                }

                $itemDate->setTimeZone($tz);
                $feed .= "          <pubDate>" . htmlspecialchars($itemDate->toRFC822(true), ENT_COMPAT, 'UTF-8') . "</pubDate>\n";
            }

            if ($data->items[$i]->enclosure != null)
            {
                $feed .= "          <enclosure url=\"";
                $feed .= $data->items[$i]->enclosure->url;
                $feed .= "\" length=\"";
                $feed .= $data->items[$i]->enclosure->length;
                $feed .= "\" type=\"";
                $feed .= $data->items[$i]->enclosure->type;
                $feed .= "\"/>\n";
            }

            $feed .= "      </item>\n";
        }

        $feed .= "  </channel>\n";
        $feed .= "</rss>\n";

        return $feed;
    }
}
avatar wartur wartur - open - 9 Jul 2015
avatar Bakual
Bakual - comment - 9 Jul 2015

Sorry I cant any time for pull.

@wartur Please try to get some time to do a Pull Request since you already seem to know the fix.
It doesn't take that much time. For a how to documentation: https://docs.joomla.org/Using_the_Github_UI_to_Make_Pull_Requests

avatar wartur
wartur - comment - 9 Jul 2015

@Bakual Ok. Around 11 or 12 Jul I try.
Thanks for link. I know how to do this.

avatar zero-24 zero-24 - change - 9 Jul 2015
Labels Added: ?
avatar Bakual
Bakual - comment - 9 Jul 2015

Thanks! :+1:

avatar zero-24 zero-24 - change - 10 Jul 2015
Category Libraries
avatar wartur
wartur - comment - 10 Jul 2015

@Bakual hello. I has created pull.

avatar zero-24
zero-24 - comment - 10 Jul 2015

Thanks @wartur I'm closing here since we have that PR :smile:

avatar zero-24 zero-24 - change - 10 Jul 2015
Status New Closed
Closed_Date 0000-00-00 00:00:00 2015-07-10 18:01:50
Closed_By zero-24
avatar zero-24 zero-24 - close - 10 Jul 2015
avatar zero-24 zero-24 - close - 10 Jul 2015
avatar wartur
wartur - comment - 10 Jul 2015

It's fix need for right publish date.
I'm using hootsuite.com for RSS feed for all social accounts from http://goingrus.com/info/en/russia-photo to https://www.facebook.com/goingrus https://plus.google.com/+GoingrusService/posts https://www.facebook.com/palytratravel and other accounts.
Sevice work not correct because update date NOT publish date. I'm using system publish date and if publish date not set i'm using update date.

Add a Comment

Login with GitHub to post a comment