b2evolution PHP Cross Reference Blogging Systems

Source: /skins/_atom/index.main.php - 203 lines - 6502 bytes - Text - Print

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

   1  <?php
   2  /**
   3   * This template generates an Atom 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://atompub.org/2005/07/11/draft-ietf-atompub-format-10.html}
   9   *
  10   * @package evoskins
  11   * @subpackage atom
  12   *
  13   * @todo dh> isn't this missing a call to skin_init()!? - if so, other feeds are missing it, too. fp> no this is very much on purpose. there is a comment somewhere (don't know exactly)
  14   *
  15   * @version $Id: index.main.php 3157 2013-03-06 04:34:44Z fplanque $
  16   */
  17  if( !defined('EVO_MAIN_INIT') ) die( 'Please, do not access this page directly.' );
  18  
  19  
  20  // EXTERNAL FEED PROVIDER?
  21  $atom_redirect = $Blog->get_setting( 'atom_redirect' );
  22  if ( ! empty( $atom_redirect ) && empty( $Chapter ) && $redir == 'yes' )
  23  {
  24      header_redirect( $atom_redirect, 301 );
  25      exit( 0 );
  26  }
  27  
  28  
  29  // Note: even if we request the same post as $Item earlier, the following will do more restrictions (dates, etc.)
  30  // Init the MainList object:
  31  init_MainList( $Blog->get_setting('posts_per_feed') );
  32  
  33  // What level of detail do we want?
  34  $feed_content = $Blog->get_setting('feed_content');
  35  if( $feed_content == 'none' )
  36  {    // We don't want to provide this feed!
  37      // This will normaly have been detected earlier but just for security:
  38      debug_die( 'Feeds are disabled.');
  39  }
  40  
  41  $image_size = $Blog->get_setting( 'image_size' );
  42  
  43  
  44  if($debug)
  45  {
  46      headers_content_mightcache( 'application/xml' );        // In most situations, you do NOT want to cache dynamic content!
  47  }
  48  else
  49  {
  50      headers_content_mightcache( 'application/atom+xml' );        // In most situations, you do NOT want to cache dynamic content!
  51  }
  52  
  53  
  54  echo '<?xml version="1.0" encoding="'.$io_charset.'"?'.'>';
  55  ?>
  56  <feed xml:lang="<?php $Blog->disp( 'locale', 'xml' ) ?>" xmlns="http://www.w3.org/2005/Atom">
  57      <title><?php
  58          $Blog->disp( 'name', 'xml' );
  59          // ------------------------- TITLE FOR THE CURRENT REQUEST -------------------------
  60          request_title( array(
  61                  'title_before'=> ' - ',
  62                  'title_after' => '',
  63                  'title_none'  => '',
  64                  'glue'        => ' - ',
  65                  'title_single_disp' => true,
  66                  'format'      => 'xml',
  67              ) );
  68          // ------------------------------ END OF REQUEST TITLE -----------------------------
  69      ?></title>
  70      <link rel="alternate" type="text/html" href="<?php $Blog->disp( 'url', 'xml' ) ?>" />
  71      <link rel="self" type="application/atom+xml" href="<?php $Blog->disp( 'atom_url', 'xmlattr' ) ?>" />
  72      <id><?php $Blog->disp( 'atom_url', 'xmlattr' ); /* TODO: may need a regenerate_url() */ ?></id>
  73      <subtitle><?php $Blog->disp( 'shortdesc', 'xml' ) ?></subtitle>
  74      <generator uri="http://b2evolution.net/" version="<?php echo $app_version ?>"><?php echo $app_name ?></generator>
  75      <updated><?php echo gmdate('Y-m-d\TH:i:s\Z'); ?></updated>
  76      <?php
  77      while( $Item = & mainlist_get_item() )
  78      {    // For each blog post, do everything below up to the closing curly brace "}"
  79          // Load Item's creator User:
  80          $Item->get_creator_User();
  81          ?>
  82  
  83      <entry>
  84          <title type="text"><?php $Item->title( array(
  85                  'format' => 'xml',
  86                  'link_type' => 'none',
  87              ) ); ?></title>
  88          <link rel="alternate" type="text/html" href="<?php $Item->permanent_url( 'single' ) ?>" />
  89          <author>
  90              <name><?php $Item->creator_User->preferred_name( 'xml' ) ?></name>
  91              <?php $Item->creator_User->url( '<uri>', "</uri>\n", 'xml' ) ?>
  92          </author>
  93          <?php
  94          $Chapters = $Item->get_Chapters();
  95          foreach ( $Chapters as $Chapter )
  96          {
  97              // walter> if adding categories in the feed for all categories is expensive,
  98              // we can add it just for the main category
  99              //  $Chapter = $Item->get_main_Chapter();
 100              //  $cat_name = $Chapter->dget( 'name', 'xmlattr' );
 101              $cat_name = $Chapter->dget( 'name', 'xmlattr' );
 102          ?>
 103          <category term="<?php echo $cat_name; ?>" />
 104          <?php
 105          }
 106          ?>
 107          <id><?php $Item->permanent_url( 'single' ) ?></id>
 108          <?php
 109              $Item->issue_date( array(
 110                      'before'      => '<published>',
 111                      'after'       => '</published>',
 112                      'date_format' => 'isoZ',
 113                      'use_GMT'     => true,
 114                  ) );
 115          ?>
 116          <updated><?php $Item->mod_date( 'isoZ', true ) ?></updated>
 117          <?php
 118              if( $feed_content == 'excerpt' )
 119              {    // EXCERPTS ---------------------------------------------------------------------
 120                  ?>
 121          <content type="html"><![CDATA[<?php
 122                  echo $Item->get_excerpt('htmlfeed');
 123  
 124                  // Display Item footer text (text can be edited in Blog Settings):
 125                  $Item->footer( array(
 126                          'mode'        => 'xml',
 127                          'block_start' => '<div class="item_footer">',
 128                          'block_end'   => '</div>',
 129                          'format'      => 'htmlfeed',
 130                      ) );
 131          ?>]]></content>
 132                  <?php
 133              }
 134              elseif( $feed_content == 'normal'
 135                          || $feed_content == 'full' )
 136              {    // POST CONTENTS -----------------------------------------------------------------
 137                  ?>
 138          <content type="html"><![CDATA[<?php
 139                  // URL link, if the post has one:
 140                  $Item->url_link( array(
 141                          'before'    => '<p>',
 142                          'after'     => '</p>',
 143                          'podcast'   => false,
 144                          'format'    => 'htmlfeed',
 145                      ) );
 146  
 147                  // Display images that are linked to this post:
 148                  $Item->images( array(
 149                          'before' =>              '<div>',
 150                          'before_image' =>        '<div>',
 151                          'before_image_legend' => '<div><i>',
 152                          'after_image_legend' =>  '</i></div>',
 153                          'after_image' =>         '</div>',
 154                          'after' =>               '</div>',
 155                          'image_size' =>          $image_size,
 156                      ), 'htmlfeed' );
 157  
 158                  $Item->content_teaser( array(
 159                          'disppage'            => 1,
 160                          'stripteaser'         => false,
 161                          'format'              => 'htmlfeed',
 162                          'before_image'        => '<div>',
 163                          'before_image_legend' => '<div><i>',
 164                          'after_image_legend'  => '</i></div>',
 165                          'after_image'         => '</div>',
 166                          'image_size'          => $image_size,
 167                      ) );
 168  
 169                  if( $feed_content == 'normal' )
 170                  {    // Teasers only
 171                      $Item->more_link( array(
 172                              'before'    => '',
 173                              'after'     => '',
 174                              'disppage'  => 1,
 175                              'format'    => 'htmlfeed',
 176                          ) );
 177                  }
 178                  else
 179                  {    // Full contents
 180                      $Item->content_extension( array(
 181                              'disppage'    => 1,
 182                              'force_more'  => true,
 183                              'format'      => 'htmlfeed',
 184                          ) );
 185                  }
 186  
 187                  // Display Item footer text (text can be edited in Blog Settings):
 188                  $Item->footer( array(
 189                          'mode'        => 'xml',
 190                          'block_start' => '<div class="item_footer">',
 191                          'block_end'   => '</div>',
 192                          'format'      => 'htmlfeed',
 193                      ) );
 194          ?>]]></content>
 195              <?php
 196          }
 197      ?>
 198      </entry>
 199  
 200      <?php
 201      }
 202      ?>
 203  </feed>

title

Description

title

Description

title

Description

title

title

Body