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=rss'); 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 = "\n"; $feed .= " \n"; $feed .= " " . $feed_title . "\n"; $feed .= " description . "]]>\n"; $feed .= " " . str_replace(' ', '%20', $url . $data->link) . "\n"; $feed .= " " . htmlspecialchars($now->toRFC822(true), ENT_COMPAT, 'UTF-8') . "\n"; $feed .= " " . $data->getGenerator() . "\n"; $feed .= ' \n"; if ($data->image != null) { $feed .= " \n"; $feed .= " " . $data->image->url . "\n"; $feed .= " " . htmlspecialchars($data->image->title, ENT_COMPAT, 'UTF-8') . "\n"; $feed .= " " . str_replace(' ', '%20', $data->image->link) . "\n"; if ($data->image->width != "") { $feed .= " " . $data->image->width . "\n"; } if ($data->image->height != "") { $feed .= " " . $data->image->height . "\n"; } if ($data->image->description != "") { $feed .= " image->description . "]]>\n"; } $feed .= " \n"; } if ($data->language != "") { $feed .= " " . $data->language . "\n"; } if ($data->copyright != "") { $feed .= " " . htmlspecialchars($data->copyright, ENT_COMPAT, 'UTF-8') . "\n"; } if ($data->editorEmail != "") { $feed .= " " . htmlspecialchars($data->editorEmail, ENT_COMPAT, 'UTF-8') . ' (' . htmlspecialchars($data->editor, ENT_COMPAT, 'UTF-8') . ")\n"; } if ($data->webmaster != "") { $feed .= " " . htmlspecialchars($data->webmaster, ENT_COMPAT, 'UTF-8') . "\n"; } if ($data->pubDate != "") { $pubDate = JFactory::getDate($data->pubDate); $pubDate->setTimeZone($tz); $feed .= " " . htmlspecialchars($pubDate->toRFC822(true), ENT_COMPAT, 'UTF-8') . "\n"; } if (empty($data->category) === false) { if (is_array($data->category)) { foreach ($data->category as $cat) { $feed .= " " . htmlspecialchars($cat, ENT_COMPAT, 'UTF-8') . "\n"; } } else { $feed .= " " . htmlspecialchars($data->category, ENT_COMPAT, 'UTF-8') . "\n"; } } if ($data->docs != "") { $feed .= " " . htmlspecialchars($data->docs, ENT_COMPAT, 'UTF-8') . "\n"; } if ($data->ttl != "") { $feed .= " " . htmlspecialchars($data->ttl, ENT_COMPAT, 'UTF-8') . "\n"; } if ($data->rating != "") { $feed .= " " . htmlspecialchars($data->rating, ENT_COMPAT, 'UTF-8') . "\n"; } if ($data->skipHours != "") { $feed .= " " . htmlspecialchars($data->skipHours, ENT_COMPAT, 'UTF-8') . "\n"; } if ($data->skipDays != "") { $feed .= " " . htmlspecialchars($data->skipDays, ENT_COMPAT, 'UTF-8') . "\n"; } for ($i = 0, $count = count($data->items); $i < $count; $i++) { if ((strpos($data->items[$i]->link, 'http://') === false) && (strpos($data->items[$i]->link, 'https://') === false)) { $data->items[$i]->link = str_replace(' ', '%20', $url . $data->items[$i]->link); } $feed .= " \n"; $feed .= " " . htmlspecialchars(strip_tags($data->items[$i]->title), ENT_COMPAT, 'UTF-8') . "\n"; $feed .= " " . str_replace(' ', '%20', $data->items[$i]->link) . "\n"; if (empty($data->items[$i]->guid) === true) { $feed .= " " . str_replace(' ', '%20', $data->items[$i]->link) . "\n"; } else { $feed .= " " . htmlspecialchars($data->items[$i]->guid, ENT_COMPAT, 'UTF-8') . "\n"; } $feed .= " _relToAbs($data->items[$i]->description) . "]]>\n"; if ($data->items[$i]->authorEmail != "") { $feed .= " " . htmlspecialchars($data->items[$i]->authorEmail . ' (' . $data->items[$i]->author . ')', ENT_COMPAT, 'UTF-8') . "\n"; } /* * @todo: On hold * if ($data->items[$i]->source!="") { * $data.= " ".htmlspecialchars($data->items[$i]->source, ENT_COMPAT, 'UTF-8')."\n"; * } */ if (empty($data->items[$i]->category) === false) { if (is_array($data->items[$i]->category)) { foreach ($data->items[$i]->category as $cat) { $feed .= " " . htmlspecialchars($cat, ENT_COMPAT, 'UTF-8') . "\n"; } } else { $feed .= " " . htmlspecialchars($data->items[$i]->category, ENT_COMPAT, 'UTF-8') . "\n"; } } if ($data->items[$i]->comments != "") { $feed .= " " . htmlspecialchars($data->items[$i]->comments, ENT_COMPAT, 'UTF-8') . "\n"; } if ($data->items[$i]->date != "") { $itemDate = JFactory::getDate($data->items[$i]->date); $itemDate->setTimeZone($tz); $feed .= " " . htmlspecialchars($itemDate->toRFC822(true), ENT_COMPAT, 'UTF-8') . "\n"; } if ($data->items[$i]->enclosure != null) { $feed .= " items[$i]->enclosure->url; $feed .= "\" length=\""; $feed .= $data->items[$i]->enclosure->length; $feed .= "\" type=\""; $feed .= $data->items[$i]->enclosure->type; $feed .= "\"/>\n"; } $feed .= " \n"; } $feed .= " \n"; $feed .= "\n"; return $feed; } /** * Convert links in a text from relative to absolute * * @param string $text The text processed * * @return string Text with converted links * * @since 11.1 */ public function _relToAbs($text) { $base = JUri::base(); $text = preg_replace("/(href|src)=\"(?!http|ftp|https|mailto|data)([^\"]*)\"/", "$1=\"$base\$2\"", $text); return $text; } }