articles
[ class tree: articles ] [ index: articles ] [ all elements ]

Source for file articles_rss.php

Documentation is available at articles_rss.php

  1. <?php
  2. /**
  3.  * @version $Header$
  4.  * @package articles
  5.  * @subpackage functions
  6.  */
  7.  
  8. /**
  9.  * Initialization
  10.  */
  11. // ensure that we use absolute URLs everywhere
  12. $_REQUEST['uri_mode'TRUE;
  13. require_once '../kernel/setup_inc.php';
  14.  
  15. $gBitSystem->verifyPackage'articles' );
  16. $gBitSystem->verifyPackage'rss' );
  17. $gBitSystem->verifyFeature'articles_rss' );
  18.  
  19. require_onceARTICLES_PKG_PATH."BitArticle.php" );
  20. require_onceRSS_PKG_PATH."rss_inc.php" );
  21.  
  22. $rss->title $gBitSystem->getConfig'articles_rss_title'$gBitSystem->getConfig'site_title' ).' - '.tra'Articles' ) );
  23. $rss->description $gBitSystem->getConfig'articles_rss_description'$gBitSystem->getConfig'site_title' ).' - '.tra'RSS Feed' ) );
  24.  
  25. // check permission to view articles
  26. if!$gBitUser->hasPermission'p_articles_read' ) ) {
  27.     require_onceRSS_PKG_PATH."rss_error.php" );
  28. else {
  29.     // check if we want to use the cache file
  30.     $cacheFile TEMP_PKG_PATH.RSS_PKG_NAME.'/'.ARTICLES_PKG_NAME.'/'.$cacheFileTail;
  31.     $rss->useCached$rss_version_name$cacheFile$gBitSystem->getConfig'rssfeed_cache_time' ));
  32.  
  33.     $articles new BitArticle();
  34.     $listHash array(
  35.         'status_id' => ARTICLE_STATUS_APPROVED,
  36.         'sort_mode' => 'publish_date_desc',
  37.         'max_records' => $gBitSystem->getConfig'articles_rss_max_records'10 ),
  38.     );
  39.     $feeds $articles->getList$listHash );
  40.  
  41.     // set the rss link
  42.     $rss->link = ARTICLES_PKG_URI;
  43.  
  44.     // get all the data ready for the feed creator
  45.     foreach$feeds as $feed {
  46.         $item new FeedItem();
  47.         $item->title $feed['title'];
  48.         $item->link = $articles->getDisplayUrlFromHash$feed );
  49.  
  50.         // show the full article in the feed
  51.         $parseHash['content_id'$feed['content_id'];
  52.         $parseHash['format_guid'$feed['format_guid'];
  53.         $parseHash['data'preg_replaceLIBERTY_SPLIT_REGEX""$feed['data');
  54.         $item->description $articles->parseData$parseHash );
  55.  
  56.         $item->date = (int) $feed['publish_date'];
  57.         $item->source BIT_ROOT_URI;
  58.         $item->author $feed['author_name'];
  59.  
  60.         $item->descriptionTruncSize $gBitSystem->getConfig'rssfeed_truncate'5000 );
  61.         $item->descriptionHtmlSyndicated FALSE;
  62.  
  63.         // pass the item on to the rss feed creator
  64.         $rss->addItem$item );
  65.     }
  66.  
  67.     // finally we are ready to serve the data
  68.     echo $rss->saveFeed$rss_version_name$cacheFile );
  69. }

Documentation generated on Wed, 29 Jul 2015 13:55:34 +0000 by phpDocumentor 1.5.0-lsces