Wordpress 2.5.1-scripts
[autoinstalls/wordpress.git] / wp-includes / feed-atom-comments.php
1 <?php
2 /**
3  * Atom Feed Template for displaying Atom Comments feed.
4  *
5  * @package WordPress
6  */
7
8 header('Content-Type: application/atom+xml; charset=' . get_option('blog_charset'), true);
9 echo '<?xml version="1.0" encoding="' . get_option('blog_charset') . '" ?' . '>';
10 ?>
11 <feed
12         xmlns="http://www.w3.org/2005/Atom"
13         xml:lang="<?php echo get_option('rss_language'); ?>"
14         <?php do_action('atom_ns'); ?>
15 >
16         <title type="text"><?php
17                 if ( is_singular() )
18                         printf(__('Comments on: %s'), get_the_title_rss());
19                 elseif ( is_search() )
20                         printf(__('Comments for %1$s searching on %2$s'), get_bloginfo_rss( 'name' ), attribute_escape(get_search_query()));
21                 else
22                         printf(__('Comments for %s'), get_bloginfo_rss( 'name' ) . get_wp_title_rss());
23         ?></title>
24         <subtitle type="text"><?php bloginfo_rss('description'); ?></subtitle>
25
26         <updated><?php echo mysql2date('Y-m-d\TH:i:s\Z', get_lastcommentmodified('GMT')); ?></updated>
27         <?php the_generator( 'atom' ); ?>
28
29 <?php if ( is_singular() ) { ?>
30         <link rel="alternate" type="<?php bloginfo_rss('html_type'); ?>" href="<?php echo get_comments_link(); ?>" />
31         <link rel="self" type="application/atom+xml" href="<?php echo get_post_comments_feed_link('', 'atom'); ?>" />
32         <id><?php echo get_post_comments_feed_link('', 'atom'); ?></id>
33 <?php } elseif(is_search()) { ?>
34         <link rel="alternate" type="<?php bloginfo_rss('html_type'); ?>" href="<?php echo get_option('home') . '?s=' . attribute_escape(get_search_query()); ?>" />
35         <link rel="self" type="application/atom+xml" href="<?php echo get_search_comments_feed_link('', 'atom'); ?>" />
36         <id><?php echo get_search_comments_feed_link('', 'atom'); ?></id>
37 <?php } else { ?>
38         <link rel="alternate" type="<?php bloginfo_rss('html_type'); ?>" href="<?php bloginfo_rss('home'); ?>" />
39         <link rel="self" type="application/atom+xml" href="<?php bloginfo_rss('comments_atom_url'); ?>" />
40         <id><?php bloginfo_rss('comments_atom_url'); ?></id>
41 <?php } ?>
42
43 <?php
44 if ( have_comments() ) : while ( have_comments() ) : the_comment();
45         $comment_post = get_post($comment->comment_post_ID);
46         get_post_custom($comment_post->ID);
47 ?>
48         <entry>
49                 <title><?php
50                         if ( !is_singular() ) {
51                                 $title = get_the_title($comment_post->ID);
52                                 $title = apply_filters('the_title_rss', $title);
53                                 printf(__('Comment on %1$s by %2$s'), $title, get_comment_author_rss());
54                         } else {
55                                 printf(__('By: %s'), get_comment_author_rss());
56                         }
57                 ?></title>
58                 <link rel="alternate" href="<?php comment_link(); ?>" type="<?php bloginfo_rss('html_type'); ?>" />
59
60                 <author>
61                         <name><?php comment_author_rss(); ?></name>
62                         <?php if (get_comment_author_url()) echo '<uri>' . get_comment_author_url() . '</uri>'; ?>
63
64                 </author>
65
66                 <id><?php comment_link(); ?></id>
67                 <updated><?php echo mysql2date('Y-m-d\TH:i:s\Z', get_comment_time('Y-m-d H:i:s', true), false); ?></updated>
68                 <published><?php echo mysql2date('Y-m-d\TH:i:s\Z', get_comment_time('Y-m-d H:i:s', true), false); ?></published>
69 <?php if (!empty($comment_post->post_password) && $_COOKIE['wp-postpass'] != $comment_post->post_password) : ?>
70                 <content type="html" xml:base="<?php comment_link(); ?>"><![CDATA[<?php echo get_the_password_form(); ?>]]></content>
71 <?php else : // post pass ?>
72                 <content type="html" xml:base="<?php comment_link(); ?>"><![CDATA[<?php comment_text(); ?>]]></content>
73 <?php endif; // post pass
74         do_action('comment_atom_entry', $comment->comment_ID, $comment_post->ID);
75 ?>
76         </entry>
77 <?php endwhile; endif; ?>
78 </feed>