/[drupal]/contributions/modules/feed/feed.theme
ViewVC logotype

Contents of /contributions/modules/feed/feed.theme

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.6 - (show annotations) (download) (as text)
Tue Oct 31 22:51:39 2006 UTC (3 years ago) by thegreenman
Branch: MAIN
CVS Tags: HEAD
Branch point for: DRUPAL-4-7
Changes since 1.5: +0 -1 lines
File MIME type: text/x-php
Fixed output buffering bug.
1 <?
2 /**
3 * Themeable functions for the feed module
4 *
5 * IMPORTANT NOTE:
6 * Style functions output XSLT, not HTML. XSLT is a different language and can be quite tricky, so it may be
7 * good to do a bit of research into how it works before you change too many things.
8 *
9 *
10 */
11
12
13 /**
14 * Render a RSS feed.
15 * @param array $items An array of items formatted using format_rss_item
16 * @param array $extra_namespaces An array of namespaces beyond the default that will apply to this feed
17 */
18 function theme_rss($items,$channel=array(),$extra_namespaces=array(),$xsl_stylesheet=NULL) {
19 global $base_url,$base_path, $locale;
20
21 $namespaces = array('xmlns:dc="http://purl.org/dc/elements/1.1/"') + $extra_namespaces;
22 $title=variable_get('site_name', 'Drupal');
23 if ($slogan= variable_get('site_slogan', '')) {
24 $title.= ' - '.$slogan;
25 }
26
27 $channel_defaults = array(
28 'version' => '2.0',
29 'title' => $title ,
30 'link' => $base_url,
31 'description' => variable_get('site_mission', ''),
32 'language' => $locale
33 );
34 $channel = array_merge($channel_defaults, $channel);
35
36 // By default, we use the processed xsl template available at /feed.xsl
37 // we pass through the path to the current feed so that we can modify the template based on the feed that was requested
38 $xsl_stylesheet or $xsl_stylesheet=url("feed.xsl","feedpath=".urlencode($_GET[q]));
39
40 $output = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n";
41 $output.= "<?xml-stylesheet title=\"XSL_formatting\" type=\"text/xsl\" href=\"$xsl_stylesheet\"?>";
42 $output .= "<rss version=\"". $channel["version"] . "\" xml:base=\"". $base_url ."\" ". implode(' ', $namespaces) .">\n";
43 $output .= format_rss_channel($channel['title'], $channel['link'], $channel['description'], $items, $channel['language']);
44 $output .= "</rss>\n";
45
46 return $output;
47 }
48
49 /**
50 * Create an XSLT stylesheet for an rss feed
51 * Overrride this and replace it with a template callback to use your own XSL
52 */
53 function theme_xslt_rss($variables=array()){
54 extract($variables, EXTR_SKIP); // Extract the variables to a local namespace
55 ob_start(); // Start output buffering
56 include "feed_rss.xsl"; // Include the file
57 $contents = ob_get_contents(); // Get the contents of the buffer
58 ob_end_clean(); // End buffering and discard
59 return $contents; // Return the contents
60 }
61
62
63 ?>

  ViewVC Help
Powered by ViewVC 1.1.2