[ Index ]
 

Code source de eZ Publish 3.9.0

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/kernel/rss/ -> feed.php (source)

   1  <?php
   2  //
   3  // Created on: <19-Sep-2002 16:45:08 kk>
   4  //
   5  // SOFTWARE NAME: eZ publish
   6  // SOFTWARE RELEASE: 3.9.0
   7  // BUILD VERSION: 17785
   8  // COPYRIGHT NOTICE: Copyright (C) 1999-2006 eZ systems AS
   9  // SOFTWARE LICENSE: GNU General Public License v2.0
  10  // NOTICE: >
  11  //   This program is free software; you can redistribute it and/or
  12  //   modify it under the terms of version 2.0  of the GNU General
  13  //   Public License as published by the Free Software Foundation.
  14  //
  15  //   This program is distributed in the hope that it will be useful,
  16  //   but WITHOUT ANY WARRANTY; without even the implied warranty of
  17  //   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  18  //   GNU General Public License for more details.
  19  //
  20  //   You should have received a copy of version 2.0 of the GNU General
  21  //   Public License along with this program; if not, write to the Free
  22  //   Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
  23  //   MA 02110-1301, USA.
  24  //
  25  //
  26  
  27  $Module =& $Params["Module"];
  28  
  29  if ( !isset ( $Params['RSSFeed'] ) )
  30  {
  31      eZDebug::writeError( 'No RSS feed specified' );
  32      return $Module->handleError( EZ_ERROR_KERNEL_NOT_AVAILABLE, 'kernel' );
  33  }
  34  
  35  include_once ( 'kernel/classes/ezrssexport.php' );
  36  
  37  $feedName = $Params['RSSFeed'];
  38  $RSSExport = eZRSSExport::fetchByName( $feedName );
  39  
  40  // Get and check if RSS Feed exists
  41  if ( !$RSSExport )
  42  {
  43      eZDebug::writeError( 'Could not find RSSExport : ' . $Params['RSSFeed'] );
  44      return $Module->handleError( EZ_ERROR_KERNEL_NOT_AVAILABLE, 'kernel' );
  45  }
  46  
  47  include_once ( 'kernel/classes/ezrssexportitem.php' );
  48  
  49  $config =& eZINI::instance( 'site.ini' );
  50  $cacheTime = intval( $config->variable( 'RSSSettings', 'CacheTime' ) );
  51  
  52  if($cacheTime <= 0)
  53  {
  54      $xmlDoc =& $RSSExport->attribute( 'rss-xml' );
  55      $rssContent = $xmlDoc->toString();
  56  }
  57  else
  58  {
  59      $cacheDir = eZSys::cacheDirectory();
  60      $cacheFilePath = $cacheDir . '/rss/' . md5( $feedName ) . '.xml';
  61  
  62      // If cache directory does not exist, create it. Get permissions settings from site.ini
  63      if ( !is_dir( $cacheDir.'/rss' ) )
  64      {
  65          $mode = $config->variable( 'FileSettings', 'TemporaryPermissions' );
  66          if ( !is_dir( $cacheDir ) )
  67          {
  68              mkdir( $cacheDir );
  69              chmod( $cacheDir, octdec( $mode ) );
  70          }
  71          mkdir( $cacheDir.'/rss' );
  72          chmod( $cacheDir.'/rss', octdec( $mode ) );
  73      }
  74  
  75      // VS-DBFILE
  76  
  77      require_once ( 'kernel/classes/ezclusterfilehandler.php' );
  78      $cacheFile = eZClusterFileHandler::instance( $cacheFilePath );
  79  
  80      if ( !$cacheFile->exists() or ( time() - $cacheFile->mtime() > $cacheTime ) )
  81      {
  82          $xmlDoc =& $RSSExport->attribute( 'rss-xml' );
  83          // Get current charset
  84          include_once ( 'lib/ezi18n/classes/eztextcodec.php' );
  85          $charset = eZTextCodec::internalCharset();
  86          $rssContent = $xmlDoc->toString( $charset );
  87          $cacheFile->storeContents( $rssContent, 'rsscache', 'xml' );
  88      }
  89      else
  90      {
  91          $rssContent = $cacheFile->fetchContents();
  92      }
  93  }
  94  
  95  // Set header settings
  96  $httpCharset = eZTextCodec::httpCharset();
  97  header( 'Content-Type: text/xml; charset=' . $httpCharset );
  98  header( 'Content-Length: '.strlen($rssContent) );
  99  header( 'X-Powered-By: eZ publish' );
 100  
 101  while ( @ob_end_clean() );
 102  
 103  echo $rssContent;
 104  
 105  eZExecution::cleanExit();
 106  
 107  ?>


Généré le : Sat Feb 24 10:30:04 2007 par Balluche grâce à PHPXref 0.7