b2evolution PHP Cross Reference Blogging Systems

Source: /skins/_rss2/comments.main.php - 116 lines - 4413 bytes - Text - Print

Description: This template generates an RSS 2.0 feed for the requested blog's latest comments

   1  <?php
   2  /**
   3   * This template generates an RSS 2.0 feed for the requested blog's latest comments
   4   *
   5   * For a quick explanation of b2evo 2.0 skins, please start here:
   6   * {@link http://b2evolution.net/man/skin-structure}
   7   *
   8   * See {@link http://backend.userland.com/rss}
   9   *
  10   * @package evoskins
  11   * @subpackage rss
  12   *
  13   * @version $Id: comments.main.php 3157 2013-03-06 04:34:44Z fplanque $
  14   */
  15  if( !defined('EVO_MAIN_INIT') ) die( 'Please, do not access this page directly.' );
  16  
  17  
  18  // What level of detail do we want?
  19  $feed_content = $Blog->get_setting('comment_feed_content');
  20  if( $feed_content == 'none' )
  21  {    // We don't want to provide this feed!
  22      // This will normaly have been detected earlier but just for security:
  23      debug_die( 'Feeds are disabled.');
  24  }
  25  
  26  if( !$Blog->get_setting( 'comments_latest' ) )
  27  { // The latest comments are disabled for current blog
  28      // Redirect to page with text/html mime type
  29      header_redirect( get_dispctrl_url( 'comments' ), 302 );
  30      // will have exited
  31  }
  32  
  33  if( isset($Item) )
  34  {    // Comments for a specific Item:
  35      $post_ID = $Item->ID;
  36      $selfurl = format_to_output( $Item->get_feedback_feed_url( '_rss2' ), 'xmlattr' );
  37  }
  38  else
  39  {    // Comments for the blog:
  40      $post_ID = NULL;
  41      $selfurl = format_to_output( $Blog->get_comment_feed_url( '_rss2' ), 'xmlattr' );
  42  }
  43  $CommentList = new CommentList2( $Blog );
  44  
  45  // Filter list:
  46  $CommentList->set_filters( array(
  47          'types' => array( 'comment' ),
  48          'statuses' => array ( 'published' ),
  49          'post_ID' => $post_ID,
  50          'order' => 'DESC',
  51          'comments' => $Blog->get_setting('comments_per_feed'),
  52      ) );
  53  
  54  // Get ready for display (runs the query):
  55  $CommentList->display_init();
  56  
  57  headers_content_mightcache( 'application/xml' );        // In most situations, you do NOT want to cache dynamic content!
  58  
  59  // Add caching headers
  60  // TODO: Last-Modified
  61  header('Expires: '.date('r', time() + 300)); // TODO: dh> should be a centralized setting. Maybe through the Skin class, if type is "feed"?
  62  
  63  
  64  echo '<?xml version="1.0" encoding="'.$io_charset.'"?'.'>';
  65  ?>
  66  <!-- generator="<?php echo $app_name ?>/<?php echo $app_version ?>" -->
  67  <rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:admin="http://webns.net/mvcb/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom">
  68      <channel>
  69          <title><?php
  70              $Blog->disp( 'name', 'xml' );
  71              // ------------------------- TITLE FOR THE CURRENT REQUEST -------------------------
  72              request_title( array(
  73                      'title_before'=> ' - ',
  74                      'title_after' => '',
  75                      'title_none'  => '',
  76                      'glue'        => ' - ',
  77                      'title_single_disp' => true,
  78                      'format'      => 'xml',
  79                  ) );
  80              // ------------------------------ END OF REQUEST TITLE -----------------------------
  81          ?></title>
  82          <link><?php $Blog->disp( 'lastcommentsurl', 'xml' ) ?></link>
  83          <atom:link rel="self" type="application/rss+xml" href="<?php echo $selfurl; ?>" />
  84          <description></description>
  85          <language><?php $Blog->disp( 'locale', 'xml' ) ?></language>
  86          <docs>http://backend.userland.com/rss</docs>
  87          <admin:generatorAgent rdf:resource="http://b2evolution.net/?v=<?php echo $app_version ?>"/>
  88          <ttl>60</ttl>
  89          <?php while( $Comment = & $CommentList->get_next() )
  90          { // Loop through comments:
  91              // Load comment's Item:
  92              $Comment->get_Item();
  93          ?><item>
  94              <title><?php echo format_to_output( sprintf( /* TRANS: First %s: Commentator's name, second %s: post title */ T_( '%s in response to: %s' ),
  95                                                      $Comment->get_author( array( 'format' => 'raw', 'link_to' => '' ) ),
  96                                                      $Comment->Item->get_title( array(
  97                                                          'format' => 'raw',
  98                                                          'link_type' => 'none',
  99                                                      ) ) ),
 100                                                  'xml' ); ?></title>
 101              <pubDate><?php $Comment->time( 'r', true ); ?></pubDate>
 102              <dc:creator><?php $Comment->author( '', '#', '', '#', 'xml' ); ?></dc:creator>
 103              <guid isPermaLink="false">c<?php $Comment->ID() ?>@<?php echo $baseurl ?></guid>
 104              <?php
 105              $content = $Comment->get_content();
 106              if( $feed_content == 'excerpt' )
 107              {
 108                  $content = excerpt($content);
 109              }
 110              ?><description><?php echo format_to_output( make_rel_links_abs($content), 'entityencoded' ); ?></description>
 111              <content:encoded><![CDATA[<?php echo format_to_output( $content, 'htmlfeed' ); ?>]]></content:encoded>
 112              <link><?php $Comment->permanent_url() ?></link>
 113          </item>
 114          <?php } /* End of comment loop. */ ?>
 115      </channel>
 116  </rss>

title

Description

title

Description

title

Description

title

title

Body