blob: e5f90e918fbbb633735fedde8f4acc6217c044ec (
plain)
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
68
69
70
71
72
73
74
75
76
77
|
<?php
/**
* @version $Header$
* @package fisheye
* @subpackage functions
*/
/**
* Initialization
*/
namespace Bitweaver\Fisheye;
use Bitweaver\KernelTools;
use Bitweaver\BitBase;
use Bitweaver\Rss\FeedItem;
require_once "../kernel/includes/setup_inc.php";
$gBitSystem->verifyPackage( 'fisheye' );
$gBitSystem->verifyPackage( 'rss' );
$gBitSystem->verifyFeature( 'fisheye_rss' );
require_once RSS_PKG_INCLUDE_PATH.'rss_inc.php';
$rss->title = $gBitSystem->getConfig( 'fisheye_rss_title', $gBitSystem->getConfig( 'site_title' ).' - '.KernelTools::tra( 'Image Galleries' ) );
$rss->description = $gBitSystem->getConfig( 'fisheye_rss_description', $gBitSystem->getConfig( 'site_title' ).' - '.KernelTools::tra( 'RSS Feed' ) );
// check permission to view fisheye images
if( !$gBitUser->hasPermission( 'p_fisheye_view' ) ) {
require_once RSS_PKG_PATH."rss_error.php";
} else {
$listHash = [
'max_records' => $gBitSystem->getConfig( 'fisheye_rss_max_records', 10 ),
'sort_mode' => 'last_modified_desc',
'gallery_id' => !empty( $_REQUEST['gallery_id'] ) ? $_REQUEST['gallery_id'] : null,
'user_id' => !empty( $_REQUEST['user_id'] ) ? $_REQUEST['user_id'] : null,
];
// check if we want to use the cache file
$cacheFile = TEMP_PKG_PATH.RSS_PKG_NAME.'/'.FISHEYE_PKG_NAME.'/'."g{$listHash['gallery_id']}u{$listHash['user_id']}".$cacheFileTail;
$rss->useCached( $rss_version_name, $cacheFile, $gBitSystem->getConfig( 'rssfeed_cache_time' ));
// if we have a gallery we can work with - load it
if( BitBase::verifyId( $_REQUEST['gallery_id'] ?? 0 ) ) {
$gallery = new FisheyeGallery( $_REQUEST['gallery_id'] );
$gallery->load();
$rss->title .= " - {$gallery->getTitle()}";
}
$fisheye = new FisheyeImage();
$feeds = $fisheye->getList( $listHash );
// set the rss link
$rss->link = 'http://'.$_SERVER['HTTP_HOST'].FISHEYE_PKG_URL;
global $gBitSystem;
// get all the data ready for the feed creator
foreach( $feeds as $feed ) {
$item = new FeedItem();
$item->title = $feed['title'];
$item->link = $feed['display_url'];
$item->description = '<a href="'.$feed['display_url'].'"><img src="'.$feed['thumbnail_url'].'" /></a>';
$item->description .= '<p>'.$feed['data'].'</p>';
$item->date = ( int )$feed['last_modified'];
$item->source = 'http://'.$_SERVER['HTTP_HOST'].BIT_ROOT_URL;
$item->author = $gBitUser->getDisplayName( false, $feed );
$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 );
}
|