1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
<?php
/**
* @version $Header$
* @package wiki
* @subpackage functions
*/
/**
* Initialization
*/
require_once "../kernel/includes/setup_inc.php";
require_once RSS_PKG_INCLUDE_PATH . 'rss_inc.php';
use Bitweaver\KernelTools;
use Bitweaver\Liberty\LibertyContent;
$gBitSystem->verifyPackage( 'rss' );
$gBitSystem->verifyFeature( 'liberty_rss' );
$rss->title = $gBitSystem->getConfig( 'liberty_rss_title', $gBitSystem->getConfig( 'site_title' ).' - '.KernelTools::tra( 'Liberty' ) );
$rss->description = $gBitSystem->getConfig( 'liberty_rss_description', $gBitSystem->getConfig( 'site_title' ).' - '.KernelTools::tra( 'RSS Feed' ) );
// check if we want to use the cache file
$cacheFile = TEMP_PKG_PATH.RSS_PKG_NAME.'/'.LIBERTY_PKG_NAME.'/'.$cacheFileTail;
$rss->useCached( $rss_version_name, $cacheFile, $gBitSystem->getConfig( 'rssfeed_cache_time' ));
$liberty = new LibertyContent();
$listHash = [
'max_records' => $gBitSystem->getConfig( 'liberty_rss_max_records', 10 ),
'sort_mode' => 'last_modified_desc',
'include_data' => true,
];
$feeds = $liberty->getContentList( $listHash );
// set the rss link
$rss->link = 'http://'.$_SERVER['HTTP_HOST'].LIBERTY_PKG_DIR.'/list_content.php';
// get all the data ready for the feed creator
foreach( $feeds as $feed ) {
$item = new FeedItem();
$item->title = $feed['title'];
$item->link = BIT_BASE_URI.$liberty->getDisplayUrl( $feed['title'], $feed );
// create a page header that we know what type of data we're looking at
$description =
KernelTools::tra( 'Package' ). ': '.ucfirst( $gLibertySystem->mContentTypes[$feed['content_type_guid']]['handler_package'] ).'<br />'.
KernelTools::tra( 'Content Type' ).': '.$gLibertySystem->getContentTypeName( $feed['content_type_guid'] ).'<br />';
// add the parsed data, if there is any
if( !empty( $feed['data'] ) ) {
$description .= '<br /><hr /><br />'.KernelTools::tra( 'Content' ).':<br />'.LibertyContent::parseDataHash( $feed ).'<br /><hr />';
}
$item->description = $description;
$item->date = ( int )$feed['last_modified'];
$item->source = 'http://'.$_SERVER['HTTP_HOST'].LIBERTY_PKG_URL.'/list_content.php';
$item->author = $gBitUser->getDisplayName( false, [ 'real_name' => $feed['modifier_real_name'], 'login' => $feed['modifier_user'] ] );
$item->descriptionTruncSize = $gBitSystem->getConfig( 'rssfeed_truncate', 5000 );
$item->descriptionHtmlSyndicated = false;
// pass the item on to the rss feed creator
$rss->addItem( $item );
}
// finally we are ready to serve the data
echo $rss->saveFeed( $rss_version_name, $cacheFile );
|