b2evolution PHP Cross Reference Blogging Systems

Source: /skins/_rss/comments.main.php - 98 lines - 3056 bytes - Text - Print

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

   1  <?php
   2  /**
   3   * This template generates an RSS 0.92 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/rss092}
   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  $post_ID = NULL;
  34  if( isset($Item) )
  35  {    // Comments for a specific Item:
  36    $post_ID = $Item->ID;
  37  }
  38  
  39  $CommentList = new CommentList2( $Blog );
  40  
  41  // Filter list:
  42  $CommentList->set_filters( array(
  43          'types' => array( 'comment' ),
  44          'statuses' => array ( 'published' ),
  45          'post_ID' => $post_ID,
  46          'order' => 'DESC',
  47          'comments' => $Blog->get_setting('comments_per_feed'),
  48      ) );
  49  
  50  // Get ready for display (runs the query):
  51  $CommentList->display_init();
  52  
  53  headers_content_mightcache( 'application/xml' );        // In most situations, you do NOT want to cache dynamic content!
  54  
  55  echo '<?xml version="1.0" encoding="'.$io_charset.'"?'.'>';
  56  ?>
  57  <!-- generator="<?php echo $app_name; ?>/<?php echo $app_version ?>" -->
  58  <rss version="0.92">
  59      <channel>
  60          <title><?php
  61              $Blog->disp( 'name', 'xml' );
  62              // ------------------------- TITLE FOR THE CURRENT REQUEST -------------------------
  63              request_title( array(
  64                      'title_before'=> ' - ',
  65                      'title_after' => '',
  66                      'title_none'  => '',
  67                      'glue'        => ' - ',
  68                      'title_single_disp' => true,
  69                      'format'      => 'xml',
  70                  ) );
  71              // ------------------------------ END OF REQUEST TITLE -----------------------------
  72          ?></title>
  73          <link><?php $Blog->disp( 'lastcommentsurl', 'xml' ) ?></link>
  74          <description></description>
  75          <language><?php $Blog->disp( 'locale', 'xml' ) ?></language>
  76          <docs>http://backend.userland.com/rss092</docs>
  77          <?php while( $Comment = & $CommentList->get_next() )
  78          { // Loop through comments:
  79              // Load comment's Item:
  80              $Comment->get_Item();
  81              ?>
  82          <item>
  83              <title><?php echo format_to_output( T_('In response to:'), 'xml' ) ?> <?php $Comment->Item->title( array(
  84                  'format' => 'xml',
  85                  'link_type' => 'none',
  86              ) ); ?></title>
  87              <?php
  88              $content = $Comment->get_content();
  89              if( $feed_content == 'excerpt' )
  90              {
  91                  $content = excerpt($content);
  92              }
  93              ?><description><?php echo format_to_output( make_rel_links_abs($content), 'entityencoded' ); ?></description>
  94              <link><?php $Comment->permanent_url() ?></link>
  95          </item>
  96          <?php } // End of comment loop. ?>
  97    </channel>
  98  </rss>

title

Description

title

Description

title

Description

title

title

Body