10 defined(
'JPATH_PLATFORM') or die;
32 protected $_mime =
"application/atom+xml";
46 public function render($name =
'', $params = null, $content = null)
51 $tz =
new DateTimeZone($app->getCfg(
'offset'));
53 $now->setTimeZone($tz);
58 $url = $uri->toString(array(
'scheme',
'user',
'pass',
'host',
'port'));
59 $syndicationURL =
JRoute::_(
'&format=feed&type=atom');
61 if ($app->getCfg(
'sitename_pagetitles', 0) == 1)
63 $title =
JText::sprintf(
'JPAGETITLE', $app->getCfg(
'sitename'), $data->title);
65 elseif ($app->getCfg(
'sitename_pagetitles', 0) == 2)
67 $title =
JText::sprintf(
'JPAGETITLE', $data->title, $app->getCfg(
'sitename'));
71 $title = $data->title;
74 $feed_title = htmlspecialchars($title, ENT_COMPAT,
'UTF-8');
76 $feed =
"<feed xmlns=\"http://www.w3.org/2005/Atom\" ";
77 if ($data->language !=
"")
79 $feed .=
" xml:lang=\"" . $data->language .
"\"";
82 $feed .=
" <title type=\"text\">" . $feed_title .
"</title>\n";
83 $feed .=
" <subtitle type=\"text\">" . htmlspecialchars($data->description, ENT_COMPAT,
'UTF-8') .
"</subtitle>\n";
84 if (empty($data->category) ===
false)
86 if (is_array($data->category))
88 foreach ($data->category as $cat)
90 $feed .=
" <category term=\"" . htmlspecialchars($cat, ENT_COMPAT,
'UTF-8') .
"\" />\n";
95 $feed .=
" <category term=\"" . htmlspecialchars($data->category, ENT_COMPAT,
'UTF-8') .
"\" />\n";
98 $feed .=
" <link rel=\"alternate\" type=\"text/html\" href=\"" . $url .
"\"/>\n";
99 $feed .=
" <id>" . str_replace(
' ',
'%20', $data->getBase()) .
"</id>\n";
100 $feed .=
" <updated>" . htmlspecialchars($now->toISO8601(
true), ENT_COMPAT,
'UTF-8') .
"</updated>\n";
101 if ($data->editor !=
"")
103 $feed .=
" <author>\n";
104 $feed .=
" <name>" . $data->editor .
"</name>\n";
105 if ($data->editorEmail !=
"")
107 $feed .=
" <email>" . htmlspecialchars($data->editorEmail, ENT_COMPAT,
'UTF-8') .
"</email>\n";
109 $feed .=
" </author>\n";
111 $feed .=
" <generator uri=\"http://joomla.org\" version=\"1.6\">" . $data->getGenerator() .
"</generator>\n";
112 $feed .=
' <link rel="self" type="application/atom+xml" href="' . str_replace(
' ',
'%20', $url . $syndicationURL) .
"\"/>\n";
114 for ($i = 0, $count = count($data->items); $i < $count; $i++)
116 $feed .=
" <entry>\n";
117 $feed .=
" <title>" . htmlspecialchars(strip_tags($data->items[$i]->title), ENT_COMPAT,
'UTF-8') .
"</title>\n";
118 $feed .=
' <link rel="alternate" type="text/html" href="' . $url . $data->items[$i]->link .
"\"/>\n";
120 if ($data->items[$i]->date ==
"")
122 $data->items[$i]->date = $now->toUnix();
125 $itemDate->setTimeZone($tz);
126 $feed .=
" <published>" . htmlspecialchars($itemDate->toISO8601(
true), ENT_COMPAT,
'UTF-8') .
"</published>\n";
127 $feed .=
" <updated>" . htmlspecialchars($itemDate->toISO8601(
true), ENT_COMPAT,
'UTF-8') .
"</updated>\n";
128 if (empty($data->items[$i]->guid) ===
true)
130 $feed .=
" <id>" . str_replace(
' ',
'%20', $url . $data->items[$i]->link) .
"</id>\n";
134 $feed .=
" <id>" . htmlspecialchars($data->items[$i]->guid, ENT_COMPAT,
'UTF-8') .
"</id>\n";
137 if ($data->items[$i]->author !=
"")
139 $feed .=
" <author>\n";
140 $feed .=
" <name>" . htmlspecialchars($data->items[$i]->author, ENT_COMPAT,
'UTF-8') .
"</name>\n";
141 if ($data->items[$i]->authorEmail !=
"")
143 $feed .=
" <email>" . htmlspecialchars($data->items[$i]->authorEmail, ENT_COMPAT,
'UTF-8') .
"</email>\n";
145 $feed .=
" </author>\n";
147 if ($data->items[$i]->description !=
"")
149 $feed .=
" <summary type=\"html\">" . htmlspecialchars($data->items[$i]->description, ENT_COMPAT,
'UTF-8') .
"</summary>\n";
150 $feed .=
" <content type=\"html\">" . htmlspecialchars($data->items[$i]->description, ENT_COMPAT,
'UTF-8') .
"</content>\n";
152 if (empty($data->items[$i]->category) ===
false)
154 if (is_array($data->items[$i]->category))
156 foreach ($data->items[$i]->category as $cat)
158 $feed .=
" <category term=\"" . htmlspecialchars($cat, ENT_COMPAT,
'UTF-8') .
"\" />\n";
163 $feed .=
" <category term=\"" . htmlspecialchars($data->items[$i]->category, ENT_COMPAT,
'UTF-8') .
"\" />\n";
166 if ($data->items[$i]->enclosure != null)
168 $feed .=
" <link rel=\"enclosure\" href=\"" . $data->items[$i]->enclosure->url .
"\" type=\""
169 . $data->items[$i]->enclosure->type .
"\" length=\"" . $data->items[$i]->enclosure->length .
"\" />\n";
171 $feed .=
" </entry>\n";
173 $feed .=
"</feed>\n";