| 1 common.inc | format_rss_channel($title, $link, $description, $items, $langcode = NULL, array $args = array()) |
Formats an RSS channel.
Arbitrary elements may be added using the $args associative array.
Parameters
string $title: RSS title.
string $link: RSS URL.
string $description: RSS description.
string $items: RSS items.
string|null $langcode: Language code.
array $args: Array of arbitrary elements.
Return value
string: RSS channel
Related topics
File
- core/
includes/ common.inc, line 2314 - Common functions that many Backdrop modules will need to reference.
Code
function format_rss_channel($title, $link, $description, $items, $langcode = NULL, array $args = array()) {
global $language_content;
$langcode = $langcode ? $langcode : $language_content->langcode;
$output = "<channel>\n";
$output .= ' <title>' . check_plain($title) . "</title>\n";
$output .= ' <link>' . check_url($link) . "</link>\n";
// The RSS 2.0 "spec" doesn't indicate HTML can be used in the description.
// We strip all HTML tags, but need to prevent double encoding from properly
// escaped source data (such as & becoming &amp;).
$output .= ' <description>' . check_plain(decode_entities(strip_tags($description))) . "</description>\n";
$output .= ' <language>' . check_plain($langcode) . "</language>\n";
$output .= format_xml_elements($args);
$output .= $items;
$output .= "</channel>\n";
return $output;
}