~quam-plures-gatekeepers/quam-plures/trunk

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
<?php
/**
 * Blog Items feed, RSS 0.92 format
 *
 * @copyright (c) 2009 by {@link http://quamplures.net/ the Quam Plures project}
 * @license http://www.gnu.org/licenses/gpl.txt GNU General Public License v3
 * @package xml
 * @subpackage rss
 */
if(!defined('QP_MAIN_INIT')) die('fail');

// Note: even if we request the same post as $Item earlier, the following will do more restrictions (dates, etc.)
// Init the MainList object:
init_MainList( $Blog->get_setting('posts_per_feed') );

// What level of detail do we want?
$feed_content = $Blog->get_setting('feed_content');
if( $feed_content == 'none' )
{
	// We don't want to provide this feed! This will normaly have been detected earlier but just for security:
	debug_die( 'Feeds are disabled.');
}

header_content_type( 'application/xml' ); // sets charset

echo '<?xml version="1.0" encoding="'.$io_charset.'"?'.'>';
?>
<rss version="0.92">
<channel>
<title><?php
$Blog->disp( 'name', 'xml' );
// title for the current request
request_title( array(
	'title_before' => ' - ',
	'format' => 'xml',
) ); ?></title>
<link><?php $Blog->disp( 'url', 'xml' ) ?></link>
<description><?php $Blog->disp( 'shortdesc' ,'xml' ) ?></description>
<language><?php $Blog->disp( 'locale', 'xml' ) ?></language>
<docs>http://blogs.law.harvard.edu/tech/rss</docs>
<?php
// loop through as long as we have an Item...
while( $Item = & mainlist_get_item() )
{
	?>
	<item>
	<title><?php $Item->title( array(
		'format' => 'xml',
		'link_type' => 'none',
	) ); ?></title>
	<?php
	if( $feed_content == 'excerpt' )
	{
		// EXCERPTS
		?>
		<description><?php
		$content = $Item->get_excerpt( 'entityencoded' );
		echo make_rel_links_abs( $content );
		// Display Item footer text (text can be edited in Blog Settings):
		$Item->footer( array(
			'mode' => 'xml',
			'format' => 'entityencoded',
		) );
		?></description>
		<?php
	}
	elseif( $feed_content == 'normal' || $feed_content == 'full' )
	{
		// POST CONTENTS
		?>
		<description><?php
		// URL link, if the post has one
		$Item->url_link( array(
			'before' => '<p>',
			'after' => '</p>',
			'format' => 'entityencoded',
		) );
		// Display images that are linked to this post
		$content = $Item->get_images( array(
			'before_image_legend' => '<div><i>',
			'after_image_legend' => '</i></div>',
			'image_size' => 'fit-320'
		), 'entityencoded' );
		$content .= $Item->get_content_teaser( 1, false, 'entityencoded' );
		if( $feed_content == 'normal' )
		{
			// Teasers only
			$content .= $Item->get_more_link( array(
				'before' => '',
				'after' => '',
				'disppage' => 1,
				'format' => 'entityencoded',
			) );
		}
		else
		{
			// Full contents
			$content .= $Item->get_content_extension( 1, true, 'entityencoded' );
		}
		echo make_rel_links_abs( $content );
		// display item's footer
		$Item->footer( array( 'mode' => 'xml', 'format' => 'entityencoded' ) );
		?></description>
		<link><?php $Item->permanent_url( 'single' ) ?></link>
		<?php
	}
	?>
	</item>
	<?php
}
?>
</channel>
</rss>
<?php $Hit->log(); // log the hit on this page ?>