format_rss_channel

Definition

format_rss_channel($title, $link, $description, $items, $langcode = NULL, $args = array())
includes/common.inc, line 901

Description

Formats an RSS channel.

Arbitrary elements may be added using the $args associative array.

Related topics

Namesort iconDescription
FormattingFunctions to format numbers, strings, dates, etc.

Code

<?php
function format_rss_channel($title, $link, $description, $items, $langcode = NULL, $args = array()) {
  global $language;
  $langcode = $langcode ? $langcode : $language->language;

  $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 &amp becoming &amp;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;
}
?>
 
 

Drupal is a registered trademark of Dries Buytaert.