b2evolution PHP Cross Reference Blogging Systems

Source: /skins/_rss2/index.main.php - 274 lines - 9455 bytes - Text - Print

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

   1  <?php
   2  /**
   3   * This template generates an RSS 2.0 feed for the requested blog's latest posts
   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   * @todo iTunes podcast tags: http://www.apple.com/itunes/store/podcaststechspecs.html
  11   * Note: itunes support: .m4a, .mp3, .mov, .mp4, .m4v, and .pdf.
  12   *
  13   * @package evoskins
  14   * @subpackage rss
  15   *
  16   * @version $Id: index.main.php 3157 2013-03-06 04:34:44Z fplanque $
  17   */
  18  if( !defined('EVO_MAIN_INIT') ) die( 'Please, do not access this page directly.' );
  19  
  20  
  21  // EXTERNAL FEED PROVIDER?
  22  $rss2_redirect = $Blog->get_setting( 'rss2_redirect' );
  23  if ( ! empty( $rss2_redirect ) && empty( $Chapter ) && $redir == 'yes' )
  24  {
  25      header_redirect( $rss2_redirect, 301 );
  26      exit( 0 );
  27  }
  28  
  29  
  30  // Note: even if we request the same post as $Item earlier, the following will do more restrictions (dates, etc.)
  31  // Init the MainList object:
  32  init_MainList( $Blog->get_setting('posts_per_feed') );
  33  
  34  // What level of detail do we want?
  35  $feed_content = $Blog->get_setting('feed_content');
  36  if( $feed_content == 'none' )
  37  {    // We don't want to provide this feed!
  38      // This will normaly have been detected earlier but just for security:
  39      debug_die( 'Feeds are disabled.');
  40  }
  41  
  42  $image_size = $Blog->get_setting( 'image_size' );
  43  
  44  headers_content_mightcache( 'application/xml' );        // In most situations, you do NOT want to cache dynamic content!
  45  
  46  // Add caching headers
  47  header('Last-Modified: '.$MainList->get_lastpostdate('r'));
  48  header('Expires: '.date('r', time() + 300)); // TODO: dh> should be a centralized setting. Maybe through the Skin class, if type is "feed"?
  49  
  50  
  51  echo '<?xml version="1.0" encoding="'.$io_charset.'"?'.'>';
  52  ?>
  53  <!-- generator="<?php echo $app_name ?>/<?php echo $app_version ?>" -->
  54  <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:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom">
  55      <channel>
  56          <title><?php
  57              $Blog->disp( 'name', 'xml' );
  58              // ------------------------- TITLE FOR THE CURRENT REQUEST -------------------------
  59              request_title( array(
  60                      'title_before'=> ' - ',
  61                      'title_after' => '',
  62                      'title_none'  => '',
  63                      'glue'        => ' - ',
  64                      'title_single_disp' => true,
  65                      'format'      => 'xml',
  66                  ) );
  67              // ------------------------------ END OF REQUEST TITLE -----------------------------
  68          ?></title>
  69          <link><?php $Blog->disp( 'url', 'xml' ) ?></link>
  70          <atom:link rel="self" type="application/rss+xml" href="<?php $Blog->disp( 'rss2_url', 'xmlattr' ); ?>" />
  71          <description><?php $Blog->disp( 'shortdesc', 'xml' ) ?></description>
  72          <language><?php $Blog->disp( 'locale', 'xml' ) ?></language>
  73          <docs>http://blogs.law.harvard.edu/tech/rss</docs>
  74          <admin:generatorAgent rdf:resource="http://b2evolution.net/?v=<?php echo $app_version ?>"/>
  75          <ttl>60</ttl>
  76          <?php
  77          while( $Item = & mainlist_get_item() )
  78          {    // For each blog post, do everything below up to the closing curly brace "}"
  79              ?>
  80          <item>
  81              <title><?php $Item->title( array(
  82                  'format' => 'xml',
  83                  'link_type' => 'none',
  84              ) ); ?></title>
  85              <link><?php $Item->permanent_url( 'single' ) ?></link>
  86              <?php
  87                  $Item->issue_date( array(
  88                          'before'      => '<pubDate>',
  89                          'after'       => '</pubDate>',
  90                          'date_format' => 'r',
  91                         'use_GMT'     => true,
  92                      ) );
  93              ?>
  94              <dc:creator><?php $Item->get_creator_User(); $Item->creator_User->preferred_name('xml') ?></dc:creator>
  95              <?php
  96                  $Item->categories( array(
  97                      'before'          => '',
  98                      'after'           => '',
  99                      'include_main'    => true,
 100                      'include_other'   => true,
 101                      'include_external'=> true,
 102                      'before_main'     => '<category domain="main">',
 103                      'after_main'      => '</category>',
 104                      'before_other'    => '<category domain="alt">',
 105                      'after_other'     => '</category>',
 106                      'before_external' => '<category domain="external">',
 107                      'after_external'  => '</category>',
 108                      'link_categories' => false,
 109                      'separator'       => "\n",
 110                      'format'          => 'htmlbody', // TODO: "xml" eats away the tags!!
 111                  ) );
 112              ?>
 113              <guid isPermaLink="false"><?php $Item->ID() ?>@<?php echo $baseurl ?></guid>
 114              <?php
 115                  // PODCAST ------------------------------------------------------------------------
 116                  if( $Item->ptyp_ID == 2000 )
 117                  {    // This is a podcast Item !
 118                      echo '<enclosure url="'.$Item->url.'" />';
 119                      // TODO: add length="12216320" type="audio/mpeg"
 120                  }
 121  
 122                  if( $feed_content == 'excerpt' )
 123                  {    // EXCERPTS ---------------------------------------------------------------------
 124  
 125                      ?>
 126              <description><?php
 127                  $content = $Item->get_excerpt();
 128  
 129                  // Get content as "htmlbody", otherwise make_rel_links_abs() can't catch <a> and <img> tags
 130                  // TODO: clean solution : work in format_to_output!
 131                  echo format_to_output( make_rel_links_abs($content), 'entityencoded' );
 132  
 133                  // Display Item footer text (text can be edited in Blog Settings):
 134                  $Item->footer( array(
 135                          'mode'        => 'xml',
 136                          'block_start' => '<div class="item_footer">',
 137                          'block_end'   => '</div>',
 138                          'format'      => 'entityencoded',
 139                      ) );
 140              ?></description>
 141              <content:encoded><![CDATA[<?php
 142                  echo $Item->get_excerpt( 'htmlfeed' );
 143  
 144                  // Display Item footer text (text can be edited in Blog Settings):
 145                  $Item->footer( array(
 146                          'mode'        => 'xml',
 147                          'block_start' => '<div class="item_footer">',
 148                          'block_end'   => '</div>',
 149                          'format'      => 'htmlfeed',
 150                      ) );
 151              ?>]]></content:encoded>
 152                      <?php
 153  
 154                  }
 155                  elseif( $feed_content == 'normal'
 156                              || $feed_content == 'full' )
 157                  {    // POST CONTENTS -----------------------------------------------------------------
 158  
 159                      ?>
 160              <description><?php
 161                  // URL link, if the post has one: (TODO: move below the text, because in summaries or podcasts it blows to have this on top)
 162                  $Item->url_link( array(
 163                          'before'        => '<p>',
 164                          'after'         => '</p>',
 165                          'format'        => 'entityencoded',
 166                          'podcast'       => false,
 167                      ) );
 168  
 169                  // Display images that are linked to this post:
 170                  $content = $Item->get_images( array(
 171                          'before' =>              '<div>',
 172                          'before_image' =>        '<div>',
 173                          'before_image_legend' => '<div><i>',
 174                          'after_image_legend' =>  '</i></div>',
 175                          'after_image' =>         '</div>',
 176                          'after' =>               '</div>',
 177                          'image_size' =>          $image_size,
 178                      ), 'htmlbody' );
 179  
 180                  $content .= $Item->get_content_teaser( 1, false );
 181  
 182                  if( $feed_content == 'normal' )
 183                  {    // Teasers only
 184                      $content .= $Item->get_more_link( array(
 185                              'before'    => '',
 186                              'after'     => '',
 187                              'disppage'  => 1,
 188                          ) );
 189                  }
 190                  else
 191                  {    // Full contents
 192                      $content .= $Item->get_content_extension( 1, true );
 193                  }
 194  
 195                  // Get content as "htmlbody", otherwise make_rel_links_abs() can't catch <a> and <img> tags
 196                  // TODO: clean solution : work in format_to_output!
 197                  echo format_to_output( make_rel_links_abs($content), 'entityencoded' );
 198  
 199                  // Display Item footer text (text can be edited in Blog Settings):
 200                  $Item->footer( array(
 201                          'mode'        => 'xml',
 202                          'block_start' => '<div class="item_footer">',
 203                          'block_end'   => '</div>',
 204                          'format'      => 'entityencoded',
 205                      ) );
 206              ?></description>
 207              <content:encoded><![CDATA[<?php
 208                  // URL link, if the post has one:
 209                  $Item->url_link( array(
 210                          'before'    => '<p>',
 211                          'after'     => '</p>',
 212                          'podcast'   => false,
 213                          'format'    => 'htmlfeed',
 214                      ) );
 215  
 216                  // Display images that are linked to this post:
 217                  $Item->images( array(
 218                          'before' =>              '<div>',
 219                          'before_image' =>        '<div>',
 220                          'before_image_legend' => '<div><i>',
 221                          'after_image_legend' =>  '</i></div>',
 222                          'after_image' =>         '</div>',
 223                          'after' =>               '</div>',
 224                          'image_size' =>          'fit-320x320'
 225                      ), 'htmlfeed' );
 226  
 227                  $Item->content_teaser( array(
 228                          'disppage'            => 1,
 229                          'stripteaser'         => false,
 230                          'format'              => 'htmlfeed',
 231                          'before_image'        => '<div>',
 232                          'before_image_legend' => '<div><i>',
 233                          'after_image_legend'  => '</i></div>',
 234                          'after_image'         => '</div>',
 235                          'image_size'          => 'fit-320x320',
 236                      ) );
 237  
 238                  if( $feed_content == 'normal' )
 239                  {    // Teasers only
 240                      $Item->more_link( array(
 241                              'before'    => '',
 242                              'after'     => '',
 243                              'disppage'  => 1,
 244                              'format'    => 'htmlfeed',
 245                          ) );
 246                  }
 247                  else
 248                  {    // Full contents
 249                      $Item->content_extension( array(
 250                              'disppage'    => 1,
 251                              'force_more'  => true,
 252                              'format'      => 'htmlfeed',
 253                          ) );
 254                  }
 255  
 256                  // Display Item footer text (text can be edited in Blog Settings):
 257                  $Item->footer( array(
 258                          'mode'        => 'xml',
 259                          'block_start' => '<div class="item_footer">',
 260                          'block_end'   => '</div>',
 261                          'format'      => 'htmlfeed',
 262                      ) );
 263              ?>]]></content:encoded>
 264                      <?php
 265                  }
 266              ?>
 267              <comments><?php echo $Item->get_single_url( 'auto' ); ?>#comments</comments>
 268              <wfw:commentRss><?php echo format_to_output( $Item->get_feedback_feed_url( '_rss2' ), 'xml' ); ?></wfw:commentRss>
 269          </item>
 270          <?php
 271          }
 272          ?>
 273      </channel>
 274  </rss>

title

Description

title

Description

title

Description

title

title

Body