b2evolution PHP Cross Reference Blogging Systems

Source: /skins/_rdf/index.main.php - 246 lines - 7994 bytes - Text - Print

Description: This template generates an RSS 1.0 (RDF) feed for the requested blog's latest posts

   1  <?php
   2  /**
   3   * This template generates an RSS 1.0 (RDF) 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://web.resource.org/rss/1.0/}
   9   *
  10   * @package evoskins
  11   * @subpackage rdf
  12   *
  13   * @version $Id: index.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  // Note: even if we request the same post as $Item earlier, the following will do more restrictions (dates, etc.)
  19  // Init the MainList object:
  20  init_MainList( $Blog->get_setting('posts_per_feed') );
  21  
  22  // What level of detail do we want?
  23  $feed_content = $Blog->get_setting('feed_content');
  24  if( $feed_content == 'none' )
  25  {    // We don't want to provide this feed!
  26      // This will normaly have been detected earlier but just for security:
  27      debug_die( 'Feeds are disabled.');
  28  }
  29  
  30  $image_size = $Blog->get_setting( 'image_size' );
  31  
  32  headers_content_mightcache( 'application/xml' );        // In most situations, you do NOT want to cache dynamic content!
  33  
  34  echo '<?xml version="1.0" encoding="'.$io_charset.'"?'.'>';
  35  
  36  ?>
  37  <!-- generator="<?php echo $app_name; ?>/<?php echo $app_version ?>" -->
  38  <rdf:RDF xmlns="http://purl.org/rss/1.0/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:admin="http://webns.net/mvcb/" xmlns:content="http://purl.org/rss/1.0/modules/content/">
  39  <channel rdf:about="<?php $Blog->disp( 'url', 'xmlattr' ) ?>">
  40      <title><?php
  41          $Blog->disp( 'name', 'xml' );
  42          // ------------------------- TITLE FOR THE CURRENT REQUEST -------------------------
  43          request_title( array(
  44                  'title_before'=> ' - ',
  45                  'title_after' => '',
  46                  'title_none'  => '',
  47                  'glue'        => ' - ',
  48                  'title_single_disp' => true,
  49                  'format'      => 'xml',
  50              ) );
  51          // ------------------------------ END OF REQUEST TITLE -----------------------------
  52      ?></title>
  53      <link><?php $Blog->disp( 'url', 'xml' ) ?></link>
  54      <description><?php $Blog->disp( 'shortdesc', 'xml' ) ?></description>
  55      <dc:language><?php $Blog->disp( 'locale', 'xml' ) ?></dc:language>
  56      <admin:generatorAgent rdf:resource="http://b2evolution.net/?v=<?php echo $app_version ?>"/>
  57      <sy:updatePeriod>hourly</sy:updatePeriod>
  58      <sy:updateFrequency>1</sy:updateFrequency>
  59      <sy:updateBase>2000-01-01T12:00+00:00</sy:updateBase>
  60      <items>
  61          <rdf:Seq>
  62          <?php
  63          while( $Item = & mainlist_get_item() )
  64          {    // For each blog post, do everything below up to the closing curly brace "}"
  65              ?>
  66              <rdf:li rdf:resource="<?php $Item->permanent_url( 'single' ) ?>"/>
  67          <?php } ?>
  68          </rdf:Seq>
  69      </items>
  70  </channel>
  71  <?php
  72  $MainList->restart();
  73  while( $Item = & mainlist_get_item() )
  74  {    // For each blog post, do everything below up to the closing curly brace "}"
  75      // Load Item's creator User:
  76      $Item->get_creator_User();
  77      ?>
  78  
  79  <item rdf:about="<?php $Item->permanent_url( 'single' ) ?>">
  80      <title><?php $Item->title( array(
  81                  'format' => 'xml',
  82                  'link_type' => 'none',
  83              ) ); ?></title>
  84      <link><?php $Item->permanent_url( 'single' ) ?></link>
  85      <?php
  86          $Item->issue_date( array(
  87                  'before'      => '<dc:date>',
  88                  'after'       => '</dc:date>',
  89                  'date_format' => 'isoZ',
  90                 'use_GMT'     => true,
  91              ) );
  92      ?>
  93      <dc:creator><?php $Item->creator_User->preferred_name( 'xml' ) ?></dc:creator>
  94      <dc:subject><?php $Item->main_category( 'xml' ) ?></dc:subject>
  95      <?php
  96          if( $feed_content == 'excerpt' )
  97          {    // EXCERPTS ---------------------------------------------------------------------
  98              ?>
  99      <description><?php
 100          $content = $Item->get_excerpt();
 101  
 102          // Get content as "htmlbody", otherwise make_rel_links_abs() can't catch <a> and <img> tags
 103          // TODO: clean solution : work in format_to_output!
 104          echo format_to_output( make_rel_links_abs($content), 'entityencoded' );
 105  
 106          // Display Item footer text (text can be edited in Blog Settings):
 107          $Item->footer( array(
 108                  'mode'        => 'xml',
 109                  'block_start' => '<div class="item_footer">',
 110                  'block_end'   => '</div>',
 111                  'format'      => 'entityencoded',
 112              ) );
 113      ?></description>
 114      <content:encoded><![CDATA[<?php
 115          // Display post excerpt
 116          echo $Item->get_excerpt( 'htmlfeed' );
 117  
 118          // Display Item footer text (text can be edited in Blog Settings):
 119          $Item->footer( array(
 120                  'mode'        => 'xml',
 121                  'block_start' => '<div class="item_footer">',
 122                  'block_end'   => '</div>',
 123                  'format'      => 'htmlfeed',
 124              ) );
 125      ?>]]></content:encoded>
 126              <?php
 127          }
 128          elseif( $feed_content == 'normal'
 129                      || $feed_content == 'full' )
 130          {    // POST CONTENTS -----------------------------------------------------------------
 131              ?>
 132      <description><?php
 133          // URL link, if the post has one:
 134          $Item->url_link( array(
 135                  'before'        => '<p>',
 136                  'after'         => '</p>',
 137                  'format'        => 'entityencoded',
 138                  'podcast'       => false,
 139              ) );
 140  
 141          // Display images that are linked to this post:
 142          $content = $Item->get_images( array(
 143                  'before' =>              '<div>',
 144                  'before_image' =>        '<div>',
 145                  'before_image_legend' => '<div><i>',
 146                  'after_image_legend' =>  '</i></div>',
 147                  'after_image' =>         '</div>',
 148                  'after' =>               '</div>',
 149                  'image_size' =>          $image_size,
 150              ), 'entityencoded' );
 151  
 152          $content .= $Item->get_content_teaser( 1, false, 'entityencoded' );
 153  
 154          if( $feed_content == 'normal' )
 155          {    // Teasers only
 156              $content .= $Item->get_more_link( array(
 157                      'before'    => '',
 158                      'after'     => '',
 159                      'disppage'  => 1,
 160                      'format'    => 'entityencoded',
 161                  ) );
 162          }
 163          else
 164          {    // Full contents
 165              $content .= $Item->get_content_extension( 1, true, 'entityencoded' );
 166          }
 167  
 168          // fp> this is another one of these "oooooh it's just a tiny little change"
 169          // and "we only need to make the links absolute in RSS"
 170          // and then you get half baked code! The URL LINK stays RELATIVE!! :((
 171          // TODO: clean solution : work in format_to_output!
 172          echo make_rel_links_abs( $content );
 173  
 174          // Display Item footer text (text can be edited in Blog Settings):
 175          $Item->footer( array(
 176                  'mode'        => 'xml',
 177                  'block_start' => '<div class="item_footer">',
 178                  'block_end'   => '</div>',
 179                  'format'      => 'entityencoded',
 180              ) );
 181      ?></description>
 182      <content:encoded><![CDATA[<?php
 183          // URL link, if the post has one:
 184          $Item->url_link( array(
 185                  'before'    => '<p>',
 186                  'after'     => '</p>',
 187                  'podcast'   => false,
 188                  'format'    => 'htmlfeed',
 189              ) );
 190  
 191          // Display images that are linked to this post:
 192          $Item->images( array(
 193                  'before' =>              '<div>',
 194                  'before_image' =>        '<div>',
 195                  'before_image_legend' => '<div><i>',
 196                  'after_image_legend' =>  '</i></div>',
 197                  'after_image' =>         '</div>',
 198                  'after' =>               '</div>',
 199                  'image_size' =>          'fit-320x320'
 200              ), 'htmlfeed' );
 201  
 202          $Item->content_teaser( array(
 203                  'disppage'            => 1,
 204                  'stripteaser'         => true, // sam2kb>fp why true? We DO need to display teaser no matter what $feed_content is
 205                  'format'              => 'htmlfeed',
 206                  'before_image'        => '<div>',
 207                  'before_image_legend' => '<div><i>',
 208                  'after_image_legend'  => '</i></div>',
 209                  'after_image'         => '</div>',
 210                  'image_size'          => 'fit-320x320'
 211              ) );
 212  
 213          if( $feed_content == 'normal' )
 214          {    // Teasers only
 215              $Item->more_link( array(
 216                      'before'    => '',
 217                      'after'     => '',
 218                      'disppage'  => 1,
 219                      'format'    => 'htmlfeed',
 220                  ) );
 221          }
 222          else
 223          {    // Full contents
 224              $Item->content_extension( array(
 225                      'disppage'    => 1,
 226                      'force_more'  => true,
 227                      'format'      => 'htmlfeed',
 228                  ) );
 229          }
 230  
 231          // Display Item footer text (text can be edited in Blog Settings):
 232          $Item->footer( array(
 233                  'mode'        => 'xml',
 234                  'block_start' => '<div class="item_footer">',
 235                  'block_end'   => '</div>',
 236                  'format'      => 'htmlfeed',
 237              ) );
 238      ?>]]></content:encoded>
 239              <?php
 240          }
 241      ?>
 242  </item>
 243  <?php
 244  }
 245  ?>
 246  </rdf:RDF>

title

Description

title

Description

title

Description

title

title

Body