b2evolution PHP Cross Reference Blogging Systems

Source: /skins/_atom/comments.main.php - 115 lines - 3819 bytes - Text - Print

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

   1  <?php
   2  /**
   3   * This template generates an Atom 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://atompub.org/2005/07/11/draft-ietf-atompub-format-10.html}
   9   *
  10   * @package evoskins
  11   * @subpackage atom
  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  
  54  if($debug)
  55  {
  56      headers_content_mightcache( 'application/xml' );        // In most situations, you do NOT want to cache dynamic content!
  57  }
  58  else
  59  {
  60      headers_content_mightcache( 'application/atom+xml' );        // In most situations, you do NOT want to cache dynamic content!
  61  }
  62  
  63  
  64  echo '<?xml version="1.0" encoding="'.$io_charset.'"?'.'>';
  65  ?>
  66  <feed xml:lang="<?php $Blog->disp( 'locale', 'xml' ) ?>" xmlns="http://www.w3.org/2005/Atom">
  67      <title><?php
  68          $Blog->disp( 'name', 'xml' );
  69          // ------------------------- TITLE FOR THE CURRENT REQUEST -------------------------
  70          request_title( array(
  71                  'title_before'=> ' - ',
  72                  'title_after' => '',
  73                  'title_none'  => '',
  74                  'glue'        => ' - ',
  75                  'title_single_disp' => true,
  76                  'format'      => 'xml',
  77              ) );
  78          // ------------------------------ END OF REQUEST TITLE -----------------------------
  79      ?></title>
  80      <link rel="alternate" type="text/html" href="<?php $Blog->disp( 'lastcommentsurl', 'xml' ) ?>" />
  81      <link rel="self" type="application/atom+xml" href="<?php $Blog->disp( 'comments_atom_url', 'xmlattr' ) ?>" />
  82      <id><?php $Blog->disp( 'comments_atom_url', 'xmlattr' ) /* TODO: may need a regenerate_url() */ ?></id>
  83      <generator uri="http://b2evolution.net/" version="<?php echo $app_version ?>"><?php echo $app_name ?></generator>
  84      <updated><?php echo gmdate('Y-m-d\TH:i:s\Z'); ?></updated>
  85      <?php while( $Comment = & $CommentList->get_next() )
  86      {    /* Loop through comments: */ ?>
  87      <entry>
  88          <title type="text"><?php
  89              echo format_to_output( T_('In response to:'), 'xml' ).' ';
  90                  $Comment->get_Item();
  91                  $Comment->Item->title( array(
  92                  'format' => 'xml',
  93                  'link_type' => 'none',
  94              ) ); ?></title>
  95          <link rel="alternate" type="text/html" href="<?php $Comment->permanent_url() ?>" />
  96          <author>
  97              <name><?php $Comment->author( '', '#', '', '#', 'xml' ) ?></name>
  98              <?php $Comment->author_url( '', '<uri>', "</uri>\n", false ) ?>
  99          </author>
 100          <id><?php $Comment->permanent_url() ?></id>
 101          <published><?php $Comment->date( 'isoZ', true ); ?></published>
 102          <updated><?php $Comment->date( 'isoZ', true ); ?></updated>
 103          <?php
 104          $content = $Comment->get_content();
 105          if( $feed_content == 'excerpt' )
 106          {
 107              $content = excerpt($content);
 108          }
 109          ?>
 110          <content type="html"><![CDATA[<?php echo format_to_output( $content, 'htmlfeed' ); ?>]]></content>
 111      </entry>
 112      <?php
 113      } // End of comment loop.
 114      ?>
 115  </feed>

title

Description

title

Description

title

Description

title

title

Body