1: <?php
2: 3: 4: 5: 6: 7: 8:
9:
10:
11: $plugin_is_filter = 900 | FEATURE_PLUGIN;
12: $plugin_description = gettext('The Zenphoto <em>RSS</em> handler.');
13: $plugin_notice = gettext('This plugin must be enabled to supply <em>RSS</em> feeds.') . '<br />' . gettext('<strong>Note:</strong> Theme support is required to display RSS links.');
14:
15: $plugin_author = "Stephen Billard (sbillard)";
16:
17: $option_interface = 'rss_options';
18:
19: class rss_options {
20:
21: function __construct() {
22: global $plugin_is_filter;
23: if (OFFSET_PATH == 2) {
24: setOptionDefault('zp_plugin_rss', $plugin_is_filter);
25:
26: setOptionDefault('RSS_items', getOption('feed_items'));
27: setOptionDefault('RSS_imagesize', getOption('feed_imagesize'));
28: setOptionDefault('RSS_sortorder', getOption('feed_sortorder'));
29: setOptionDefault('RSS_items_albums', getOption('feed_items_albums'));
30: setOptionDefault('RSS_imagesize_albums', getOption('feed_imagesize_albums'));
31: setOptionDefault('RSS_sortorder_albums', getOption('feed_sortorder_albums'));
32: setOptionDefault('RSS_enclosure', getOption('feed_enclosure'));
33: setOptionDefault('RSS_mediarss', getOption('feed_mediarss'));
34: setOptionDefault('RSS_cache', getOption('feed_cache'));
35: setOptionDefault('RSS_cache_expire', getOption('feed_cache_expire'));
36: setOptionDefault('RSS_hitcounter', getOption('feed_hitcounter'));
37: setOptionDefault('RSS_title', getOption('feed_title'));
38: setOptionDefault('RSS_truncate_length', getOption('zenpage_rss_length'));
39: setOptionDefault('RSS_zenpage_items', getOption('zenpage_rss_items'));
40:
41:
42: purgeOption('feed_items');
43: purgeOption('feed_imagesize');
44: purgeOption('feed_sortorder');
45: purgeOption('feed_items_albums');
46: purgeOption('feed_imagesize_albums');
47: purgeOption('feed_sortorder_albums');
48: purgeOption('feed_enclosure');
49: purgeOption('feed_mediarss');
50: purgeOption('feed_cache');
51: purgeOption('feed_cache_expire');
52: purgeOption('feed_hitcounter');
53: purgeOption('feed_title');
54: purgeOption('zenpage_rss_length');
55: purgeOption('zenpage_rss_items');
56:
57: setOptionDefault('RSS_truncate_length', '100');
58: setOptionDefault('RSS_zenpage_items', '10');
59: setOptionDefault('RSS_items', 10);
60: setOptionDefault('RSS_imagesize', 240);
61: setOptionDefault('RSS_sortorder', 'latest');
62: setOptionDefault('RSS_items_albums', 10);
63: setOptionDefault('RSS_imagesize_albums', 240);
64: setOptionDefault('RSS_sortorder_albums', 'latest');
65: setOptionDefault('RSS_enclosure', '0');
66: setOptionDefault('RSS_mediarss', '0');
67: setOptionDefault('RSS_cache', '1');
68: setOptionDefault('RSS_cache_expire', 86400);
69: setOptionDefault('RSS_hitcounter', 1);
70: setOptionDefault('RSS_title', 'both');
71: }
72: }
73:
74: function getOptionsSupported() {
75: $options = array(gettext('RSS feeds enabled:') => array('key' => 'RSS_feed_list', 'type' => OPTION_TYPE_CHECKBOX_ARRAY,
76: 'order' => 0,
77: 'checkboxes' => array(gettext('Gallery') => 'RSS_album_image',
78: gettext('Gallery Comments') => 'RSS_comments',
79: gettext('All News') => 'RSS_articles',
80: gettext('All Pages') => 'RSS_pages',
81: gettext('News/Page Comments') => 'RSS_article_comments'
82: ),
83: 'desc' => gettext('Check each RSS feed you wish to activate.')),
84: gettext('Image feed items:') => array('key' => 'RSS_items', 'type' => OPTION_TYPE_TEXTBOX,
85: 'order' => 1,
86: 'desc' => gettext("The number of new images and comments you want to appear in your site’s RSS feed")),
87: gettext('Album feed items:') => array('key' => 'RSS_items_albums', 'type' => OPTION_TYPE_TEXTBOX,
88: 'order' => 2,
89: 'desc' => gettext("The number of new images and comments you want to appear in your site’s RSS feed")),
90: gettext('Image size') => array('key' => 'RSS_imagesize', 'type' => OPTION_TYPE_TEXTBOX,
91: 'order' => 3,
92: 'desc' => gettext('Size of RSS image feed images:')),
93: gettext('Album image size') => array('key' => 'RSS_imagesize_albums', 'type' => OPTION_TYPE_TEXTBOX,
94: 'order' => 4,
95: 'desc' => gettext('Size of RSS album feed images :')),
96: gettext('Image feed sort order:') => array('key' => 'RSS_sortorder', 'type' => OPTION_TYPE_SELECTOR,
97: 'order' => 6,
98: 'selections' => array(gettext('latest by id') => 'latest',
99: gettext('latest by date') => 'latest-date',
100: gettext('latest by mtime') => 'latest-mtime',
101: gettext('latest by publishdate') => 'latest-publishdate'
102: ),
103: 'desc' => gettext("Choose between latest by id for the latest uploaded, latest by date for the latest uploaded fetched by date, or latest by mtime for the latest uploaded fetched by the file’ last change timestamp.")),
104: gettext('Album feed sort order:') => array('key' => 'RSS_sortorder_albums', 'type' => OPTION_TYPE_SELECTOR,
105: 'selections' => array(gettext('latest by id') => 'latest',
106: gettext('latest by date') => 'latest-date',
107: gettext('latest by mtime') => 'latest-mtime',
108: gettext('latest by publishdate') => 'latest-publishdate',
109: gettext('latest updated') => 'latestupdated'
110: ),
111: 'order' => 7,
112: 'desc' => gettext('Choose between latest by id for the latest uploaded and latest updated')),
113: gettext('RSS enclosure:') => array('key' => 'RSS_enclosure', 'type' => OPTION_TYPE_CHECKBOX,
114: 'order' => 8,
115: 'desc' => gettext('Check if you want to enable the RSS enclosure feature which provides a direct download for full images, movies etc. from within certain RSS reader clients (only Images RSS).')),
116: gettext('Media RSS:') => array('key' => 'RSS_mediarss', 'type' => OPTION_TYPE_CHECKBOX,
117: 'order' => 9,
118: 'desc' => gettext('Check if media RSS support is to be enabled. This support is used by some services and programs (only Images RSS).')),
119: gettext('Cache') => array('key' => 'RSS_cache', 'type' => OPTION_TYPE_CHECKBOX,
120: 'order' => 10,
121: 'desc' => sprintf(gettext('Check if you want to enable static RSS feed caching. The cached file will be placed within the <em>%s</em> folder.'), STATIC_CACHE_FOLDER)),
122: gettext('Cache expiration') => array('key' => 'RSS_cache_expire', 'type' => OPTION_TYPE_TEXTBOX,
123: 'order' => 11,
124: 'desc' => gettext('Cache expire default is 86400 seconds (1 day = 24 hrs * 60 min * 60 sec).')),
125: gettext('Hitcounter') => array('key' => 'RSS_hitcounter', 'type' => OPTION_TYPE_CHECKBOX,
126: 'order' => 12,
127: 'desc' => gettext('Check if you want to store the hitcount on RSS feeds.')),
128: gettext('Title') => array('key' => 'RSS_title', 'type' => OPTION_TYPE_RADIO,
129: 'order' => 13,
130: 'buttons' => array(gettext('Gallery title') => 'gallery', gettext('Website title') => 'website', gettext('Both') => 'both'),
131: 'desc' => gettext("Select what you want to use as the main RSS feed (channel) title. “Both” means Website title followed by Gallery title")),
132: gettext('Portable RSS link') => array('key' => 'RSS_portable_link', 'type' => OPTION_TYPE_CHECKBOX,
133: 'order' => 14,
134: 'desc' => gettext('If checked links generated for logged‑in users will include a token identifying the user. Use of that link when not logged‑in will give the same feed as if the user were logged‑in.'))
135: );
136: if (extensionEnabled('zenpage')) {
137: $options[gettext('Feed text length')] = array('key' => 'RSS_truncate_length', 'type' => OPTION_TYPE_TEXTBOX,
138: 'order' => 5.5,
139: 'desc' => gettext("The text length of the Zenpage RSS feed items. No value for full length."));
140: $options[gettext('Zenpage feed items')] = array('key' => 'RSS_zenpage_items', 'type' => OPTION_TYPE_TEXTBOX,
141: 'order' => 5,
142: 'desc' => gettext("The number of news articles you want to appear in your site’s News RSS feed."));
143: }
144: return $options;
145: }
146:
147: function handleOption($option, $currentValue) {
148:
149: }
150:
151: function handleOptionSave() {
152: if (isset($_POST['saverssoptions'])) {
153: setOption('RSS_items', sanitize($_POST['RSS_items'], 3));
154: setOption('RSS_imagesize', sanitize($_POST['RSS_imagesize'], 3));
155: setOption('RSS_sortorder', sanitize($_POST['RSS_sortorder'], 3));
156: setOption('RSS_items_albums', sanitize($_POST['RSS_items_albums'], 3));
157: setOption('RSS_imagesize_albums', sanitize($_POST['RSS_imagesize_albums'], 3));
158: setOption('RSS_sortorder_albums', sanitize($_POST['RSS_sortorder_albums'], 3));
159: setOption('RSS_title', sanitize($_POST['RSS_title'], 3));
160: setOption('RSS_cache_expire', sanitize($_POST['RSS_cache_expire'], 3));
161: setOption('RSS_enclosure', (int) isset($_POST['RSS_enclosure']));
162: setOption('RSS_mediarss', (int) isset($_POST['RSS_mediarss']));
163: setOption('RSS_cache', (int) isset($_POST['RSS_cache']));
164: setOption('RSS_album_image', (int) isset($_POST['RSS_album_image']));
165: setOption('RSS_comments', (int) isset($_POST['RSS_comments']));
166: setOption('RSS_articles', (int) isset($_POST['RSS_articles']));
167: setOption('RSS_pages', (int) isset($_POST['RSS_pages']));
168: setOption('RSS_article_comments', (int) isset($_POST['RSS_article_comments']));
169: setOption('RSS_hitcounter', (int) isset($_POST['RSS_hitcounter']));
170: setOption('RSS_portable_link', (int) isset($_POST['RSS_portable_link']));
171: $returntab = "&tab=rss";
172: }
173: }
174:
175: }
176:
177: 178: 179: 180: 181: 182: 183: 184: 185: 186: 187: 188: 189: 190: 191: 192: 193: 194: 195: 196: 197: 198: 199:
200: function getRSSLink($option, $lang = NULL, $addl = NULL) {
201: global $_zp_current_album, $_zp_current_image, $_zp_current_admin_obj, $_zp_current_category;
202: if (strtolower($option) == 'newswithimages') {
203: RSS_internal_deprecations::getRSSLink($option);
204: }
205: if (empty($lang)) {
206: $lang = zpFunctions::getLanguageText(getOption('locale'));
207: }
208: $link = NULL;
209: switch (strtolower($option)) {
210: case 'gallery':
211: if (getOption('RSS_album_image')) {
212: $link = array('rss' => 'gallery');
213: }
214: break;
215: case 'album':
216: if (getOption('RSS_album_image')) {
217: if (is_object($addl)) {
218: $album = $addl;
219: } else {
220: $album = $_zp_current_album;
221: }
222: $link = array('rss' => 'gallery', 'albumname' => $album->getFileName());
223: break;
224: }
225: case 'collection':
226: if (getOption('RSS_album_image')) {
227: if (is_object($addl)) {
228: $album = $addl;
229: } else {
230: $album = $_zp_current_album;
231: }
232: $link = array('rss' => 'gallery', 'folder' => $album->getFileName());
233: }
234: break;
235: case 'comments':
236: if (getOption('RSS_comments')) {
237: $link = array('rss' => 'comments', 'type' => 'gallery');
238: }
239: break;
240: case 'comments-image':
241: if (getOption('RSS_comments')) {
242: $link = array('rss' => 'comments', 'id' => (string) $_zp_current_image->getID(), 'type' => 'image');
243: }
244: break;
245: case 'comments-album':
246: if (getOption('RSS_comments')) {
247: $link = array('rss' => 'comments', 'id' => (string) $_zp_current_album->getID(), 'type' => 'album');
248: }
249: break;
250: case 'albumsrss':
251: if (getOption('RSS_album_image')) {
252: $link = array('rss' => 'gallery', 'albumsmode' => '');
253: }
254: break;
255: case 'albumsrsscollection':
256: if (getOption('RSS_album_image')) {
257: $link = array('rss' => 'gallery', 'folder' => $_zp_current_album->getFileName(), 'albumsmode' => '');
258: }
259: break;
260: case 'pages':
261: if (getOption('RSS_pages')) {
262: $link = array('rss' => 'pages');
263: }
264: break;
265: case 'news':
266: if (getOption('RSS_articles')) {
267: $link = array('rss' => 'news');
268: }
269: break;
270: case 'category':
271: if (getOption('RSS_articles')) {
272: if (empty($addl) && !is_null($_zp_current_category)) {
273: $addl = $_zp_current_category->getTitlelink();
274: }
275: if (empty($addl)) {
276: $link = array('rss' => 'news');
277: } else {
278: $link = array('rss' => 'news', 'category' => $addl);
279: }
280: }
281: break;
282: case 'newswithimages':
283: if (getOption('RSS_articles')) {
284: $link = array('rss' => 'news', 'withimages' => '');
285: }
286: break;
287: case 'comments':
288: if (getOption('RSS_article_comments')) {
289: $link = array('comments' => 1, 'type' => 'zenpage');
290: }
291: break;
292: case 'comments-news':
293: if (getOption('RSS_article_comments')) {
294: $link = array('rss' => 'comments', 'id' => (string) getNewsID(), 'type' => 'news');
295: }
296: break;
297: case 'comments-page':
298: if (getOption('RSS_article_comments')) {
299: $link = array('rss' => 'comments', 'id' => (string) getPageID(), 'type' => 'page');
300: }
301: break;
302: case 'comments-all':
303: if (getOption('RSS_article_comments')) {
304: $link = array('rss' => 'comments', 'type' => 'allcomments');
305: }
306: break;
307: }
308: if (is_array($link)) {
309: $link['lang'] = $lang;
310: if (zp_loggedin() && getOption('RSS_portable_link')) {
311: $link['user'] = (string) $_zp_current_admin_obj->getID();
312: $link['token'] = Zenphoto_Authority::passwordHash(serialize($link), '');
313: }
314: $uri = WEBPATH . '/index.php?' . str_replace('=&', '&', http_build_query($link));
315: return $uri;
316: }
317: return NULL;
318: }
319:
320: 321: 322: 323: 324: 325: 326: 327: 328: 329: 330: 331:
332: function printRSSLink($option, $prev, $linktext, $next, $printIcon = true, $class = null, $lang = '', $addl = NULL) {
333: if ($printIcon) {
334: $icon = ' <img src="' . FULLWEBPATH . '/' . ZENFOLDER . '/images/rss.png" alt="RSS Feed" />';
335: } else {
336: $icon = '';
337: }
338: if (!is_null($class)) {
339: $class = 'class="' . $class . '"';
340: }
341: if (empty($lang)) {
342: $lang = zpFunctions::getLanguageText(getOption("locale"));
343: }
344: echo $prev . "<a $class href=\"" . html_encode(getRSSLink($option, $lang, $addl)) . "\" title=\"" . html_encode($linktext) . "\" rel=\"nofollow\">" . $linktext . "$icon</a>" . $next;
345: }
346:
347: 348: 349: 350: 351: 352: 353: 354: 355: 356: 357: 358: 359: 360: 361: 362:
363: function printRSSHeaderLink($option, $linktext, $lang = '', $addl = NULL) {
364: echo "<link rel=\"alternate\" type=\"application/rss+xml\" title=\"" . html_encode(getBare($linktext)) . "\" href=\"" .
365: PROTOCOL . '://' . html_encode($_SERVER["HTTP_HOST"]) . html_encode(getRSSLink($option, $lang, $addl)) . "\" />\n";
366: }
367:
368: require_once(SERVERPATH . '/' . ZENFOLDER . '/class-feed.php');
369: require_once(SERVERPATH . '/' . ZENFOLDER . '/lib-MimeTypes.php');
370:
371: class RSS extends feed {
372:
373: protected $feed = 'RSS';
374:
375: 376: 377: 378:
379: function __construct($options = NULL) {
380: global $_zp_gallery, $_zp_current_admin_obj, $_zp_loggedin;
381: if (empty($options))
382: self::feed404();
383:
384: $this->feedtype = $options['rss'];
385: parent::__construct($options);
386:
387: if (isset($options['token'])) {
388:
389: $link = $options;
390: unset($link['token']);
391: $token = Zenphoto_Authority::passwordHash(serialize($link), '');
392: if ($token == $options['token']) {
393: $adminobj = Zenphoto_Authority::getAnAdmin(array('`id`=' => (int) $link['user']));
394: if ($adminobj) {
395: $_zp_current_admin_obj = $adminobj;
396: $_zp_loggedin = $_zp_current_admin_obj->getRights();
397: }
398: }
399: }
400:
401: $channeltitlemode = getOption('RSS_title');
402: $this->host = html_encode($_SERVER["HTTP_HOST"]);
403:
404:
405: switch ($channeltitlemode) {
406: case 'gallery':
407: $this->channel_title = $_zp_gallery->getBareTitle($this->locale);
408: break;
409: case 'website':
410: $this->channel_title = getBare($_zp_gallery->getWebsiteTitle($this->locale));
411: break;
412: case 'both':
413: $website_title = $_zp_gallery->getWebsiteTitle($this->locale);
414: $this->channel_title = $_zp_gallery->getBareTitle($this->locale);
415: if (!empty($website_title)) {
416: $this->channel_title = $website_title . ' - ' . $this->channel_title;
417: }
418: break;
419: }
420:
421:
422: switch ($this->feedtype) {
423:
424: case 'gallery':
425: if (!getOption('RSS_album_image')) {
426: self::feed404();
427: }
428: $albumname = $this->getChannelTitleExtra();
429: if ($this->albumfolder) {
430: $alb = newAlbum($this->albumfolder, true, true);
431: if ($alb->exists) {
432: $albumtitle = $alb->getTitle();
433: if ($this->mode == 'albums' || $this->collection) {
434: $albumname = ' - ' . html_encode($albumtitle) . $this->getChannelTitleExtra();
435: }
436: } else {
437: self::feed404();
438: }
439: } else {
440: $albumtitle = '';
441: }
442: $albumname = $this->getChannelTitleExtra();
443:
444: $this->channel_title = html_encode($this->channel_title . ' ' . getBare($albumname));
445: $this->imagesize = $this->getImageSize();
446: require_once(SERVERPATH . '/' . ZENFOLDER . '/' . PLUGIN_FOLDER . '/image_album_statistics.php');
447: break;
448:
449: case 'news':
450: if (!getOption('RSS_articles')) {
451: self::feed404();
452: }
453: $titleappendix = gettext(' (Latest news)');
454:
455: switch ($this->newsoption) {
456: case 'withalbums':
457: case 'withalbums_mtime':
458: case 'withalbums_publishdate':
459: case 'withalbums_latestupdated':
460: $titleappendix = gettext(' (Latest news and albums)');
461: break;
462: case 'withimages':
463: case 'withimages_mtime':
464: case 'withimages_publishdate':
465: $titleappendix = gettext(' (Latest news and images)');
466: break;
467: default:
468: switch ($this->sortorder) {
469: case 'popular':
470: $titleappendix = gettext(' (Most popular news)');
471: break;
472: case 'mostrated':
473: $titleappendix = gettext(' (Most rated news)');
474: break;
475: case 'toprated':
476: $titleappendix = gettext(' (Top rated news)');
477: break;
478: case 'random':
479: $titleappendix = gettext(' (Random news)');
480: break;
481: }
482: break;
483: }
484: $this->channel_title = html_encode($this->channel_title . $this->cattitle . $titleappendix);
485: $this->imagesize = $this->getImageSize();
486: $this->itemnumber = getOption("RSS_zenpage_items");
487: require_once(SERVERPATH . '/' . ZENFOLDER . '/' . PLUGIN_FOLDER . '/image_album_statistics.php');
488: require_once(SERVERPATH . '/' . ZENFOLDER . '/' . PLUGIN_FOLDER . '/zenpage/zenpage-template-functions.php');
489:
490: break;
491: case 'pages':
492: if (!getOption('RSS_pages')) {
493: self::feed404();
494: }
495: switch ($this->sortorder) {
496: case 'popular':
497: $titleappendix = gettext(' (Most popular pages)');
498: break;
499: case 'mostrated':
500: $titleappendix = gettext(' (Most rated pages)');
501: break;
502: case 'toprated':
503: $titleappendix = gettext(' (Top rated pages)');
504: break;
505: case 'random':
506: $titleappendix = gettext(' (Random pages)');
507: break;
508: default:
509: $titleappendix = gettext(' (Latest pages)');
510: break;
511: }
512: $this->channel_title = html_encode($this->channel_title . $titleappendix);
513: require_once(SERVERPATH . '/' . ZENFOLDER . '/' . PLUGIN_FOLDER . '/zenpage/zenpage-template-functions.php');
514: break;
515:
516: case 'comments':
517: if (!getOption('RSS_comments')) {
518: self::feed404();
519: }
520: if ($this->id) {
521: switch ($this->commentfeedtype) {
522: case 'album':
523: $table = 'albums';
524: break;
525: case 'image':
526: $table = 'images';
527: break;
528: case 'news':
529: $table = 'news';
530: break;
531: case 'page':
532: $table = 'pages';
533: break;
534: default:
535: self::feed404();
536: break;
537: }
538: $this->itemobj = getItemByID($table, $this->id);
539: if ($this->itemobj) {
540: $title = ' - ' . $this->itemobj->getTitle();
541: } else {
542: self::feed404();
543: }
544: } else {
545: $this->itemobj = NULL;
546: $title = NULL;
547: }
548: $this->channel_title = html_encode($this->channel_title . $title . gettext(' (latest comments)'));
549: if (extensionEnabled('zenpage')) {
550: require_once(SERVERPATH . '/' . ZENFOLDER . '/' . PLUGIN_FOLDER . '/zenpage/zenpage-template-functions.php');
551: }
552: break;
553: case 'null':
554: return;
555: }
556: $this->feeditems = $this->getitems();
557: }
558:
559: 560: 561: 562:
563: protected function hitcounter() {
564: if (!zp_loggedin() && getOption('RSS_hitcounter')) {
565: $rssuri = $this->getCacheFilename();
566: $type = 'rsshitcounter';
567: $checkitem = query_single_row("SELECT `data` FROM " . prefix('plugin_storage') . " WHERE `aux` = " . db_quote($rssuri) . " AND `type` = '" . $type . "'", true);
568: if ($checkitem) {
569: $hitcount = $checkitem['data'] + 1;
570: query("UPDATE " . prefix('plugin_storage') . " SET `data` = " . $hitcount . " WHERE `aux` = " . db_quote($rssuri) . " AND `type` = '" . $type . "'", true);
571: } else {
572: query("INSERT INTO " . prefix('plugin_storage') . " (`type`,`aux`,`data`) VALUES ('" . $type . "'," . db_quote($rssuri) . ",1)", true);
573: }
574: }
575: }
576:
577: 578: 579: 580: 581: 582:
583: protected function getItemGallery($item) {
584: if ($this->mode == "albums") {
585: $albumobj = $item;
586: $totalimages = $albumobj->getNumImages();
587: $itemlink = $this->host . $albumobj->getLink();
588: $thumb = $albumobj->getAlbumThumbImage();
589: $thumburl = '<img border="0" src="' . PROTOCOL . '://' . $this->host . html_encode(pathurlencode($thumb->getCustomImage($this->imagesize, NULL, NULL, NULL, NULL, NULL, NULL, TRUE))) . '" alt="' . html_encode($albumobj->getTitle($this->locale)) . '" />';
590: $title = $albumobj->getTitle($this->locale);
591: if (true || $this->sortorder == "latestupdated") {
592: $filechangedate = filectime(ALBUM_FOLDER_SERVERPATH . internalToFilesystem($albumobj->name));
593: $latestimage = query_single_row("SELECT mtime FROM " . prefix('images') . " WHERE albumid = " . $albumobj->getID() . " AND `show` = 1 ORDER BY id DESC");
594: if ($latestimage && $this->sortorder == 'latestupdated') {
595: $count = db_count('images', "WHERE albumid = " . $albumobj->getID() . " AND mtime = " . $latestimage['mtime']);
596: } else {
597: $count = $totalimages;
598: }
599: if ($count != 0) {
600: $imagenumber = sprintf(ngettext('%s (%u image)', '%s (%u images)', $count), $title, $count);
601: } else {
602: $imagenumber = $title;
603: }
604: $feeditem['desc'] = '<a title="' . $title . '" href="' . PROTOCOL . '://' . $itemlink . '">' . $thumburl . '</a>' .
605: '<p>' . html_encode($imagenumber) . '</p>' . $albumobj->getDesc($this->locale) . '<br />' . sprintf(gettext("Last update: %s"), zpFormattedDate(DATE_FORMAT, $filechangedate));
606: } else {
607: if ($totalimages != 0) {
608: $imagenumber = sprintf(ngettext('%s (%u image)', '%s (%u images)', $totalimages), $title, $totalimages);
609: }
610: $feeditem['desc'] = '<a title="' . html_encode($title) . '" href="' . PROTOCOL . '://' . $itemlink . '">' . $thumburl . '</a>' . $item->getDesc($this->locale) . '<br />' . sprintf(gettext("Date: %s"), zpFormattedDate(DATE_FORMAT, $item->get('mtime')));
611: }
612: $ext = getSuffix($thumb->localpath);
613: } else {
614: $ext = getSuffix($item->localpath);
615: $albumobj = $item->getAlbum();
616: $itemlink = $this->host . $item->getLink();
617: $fullimagelink = $this->host . html_encode(pathurlencode($item->getFullImageURL()));
618: $thumburl = '<img border="0" src="' . PROTOCOL . '://' . $this->host . html_encode(pathurlencode($item->getCustomImage($this->imagesize, NULL, NULL, NULL, NULL, NULL, NULL, TRUE))) . '" alt="' . $item->getTitle($this->locale) . '" /><br />';
619: $title = $item->getTitle($this->locale);
620: $albumtitle = $albumobj->getTitle($this->locale);
621: $datecontent = '<br />Date: ' . zpFormattedDate(DATE_FORMAT, $item->get('mtime'));
622: if ((($ext == "flv") || ($ext == "mp3") || ($ext == "mp4") || ($ext == "3gp") || ($ext == "mov")) AND $this->mode != "album") {
623: $feeditem['desc'] = '<a title="' . html_encode($title) . ' in ' . html_encode($albumobj->getTitle($this->locale)) . '" href="' . PROTOCOL . '://' . $itemlink . '">' . $thumburl . '</a>' . $item->getDesc($this->locale) . $datecontent;
624: } else {
625: $feeditem['desc'] = '<a title="' . html_encode($title) . ' in ' . html_encode($albumobj->getTitle($this->locale)) . '" href="' . PROTOCOL . '://' . $itemlink . '"><img src="' . PROTOCOL . '://' . $this->host . html_encode(pathurlencode($item->getCustomImage($this->imagesize, NULL, NULL, NULL, NULL, NULL, NULL, TRUE))) . '" alt="' . html_encode($title) . '" /></a>' . $item->getDesc($this->locale) . $datecontent;
626: }
627: }
628:
629: if ($this->mode != "albums") {
630: $feeditem['title'] = sprintf('%1$s (%2$s)', $item->getTitle($this->locale), $albumobj->getTitle($this->locale));
631: } else {
632: $feeditem['title'] = $imagenumber;
633: }
634:
635: $feeditem['link'] = PROTOCOL . '://' . $itemlink;
636:
637:
638: $feeditem['enclosure'] = '';
639: if (getOption("RSS_enclosure") AND $this->mode != "albums") {
640: $feeditem['enclosure'] = '<enclosure url="' . PROTOCOL . '://' . $fullimagelink . '" type="' . getMimeString($ext) . '" length="' . filesize($item->localpath) . '" />';
641: }
642:
643: if ($this->mode != "albums") {
644: $feeditem['category'] = html_encode($albumobj->getTitle($this->locale));
645: } else {
646: $feeditem['category'] = html_encode($albumobj->getTitle($this->locale));
647: }
648:
649: $feeditem['media_content'] = '';
650: $feeditem['media_thumbnail'] = '';
651: if (getOption("RSS_mediarss") AND $this->mode != "albums") {
652: $feeditem['media_content'] = '<media:content url="' . PROTOCOL . '://' . $fullimagelink . '" type="image/jpeg" />';
653: $feeditem['media_thumbnail'] = '<media:thumbnail url="' . PROTOCOL . '://' . $fullimagelink . '" width="' . $this->imagesize . '" height="' . $this->imagesize . '" />';
654: }
655:
656: if ($this->mode != "albums") {
657: $feeditem['pubdate'] = date("r", strtotime($item->getDateTime()));
658: } else {
659: $feeditem['pubdate'] = date("r", strtotime($albumobj->getDateTime()));
660: }
661: return $feeditem;
662: }
663:
664: 665: 666: 667: 668: 669:
670: protected function getItemNews($item) {
671: $categories = '';
672: $feeditem['enclosure'] = '';
673: $obj = new ZenpageNews($item['titlelink']);
674: $title = $feeditem['title'] = get_language_string($obj->getTitle('all'), $this->locale);
675: $link = $obj->getLink();
676: $count2 = 0;
677: $plaincategories = $obj->getCategories();
678: $categories = '';
679: foreach ($plaincategories as $cat) {
680: $catobj = new ZenpageCategory($cat['titlelink']);
681: $categories .= get_language_string($catobj->getTitle('all'), $this->locale) . ', ';
682: }
683: $categories = rtrim($categories, ', ');
684: $feeditem['desc'] = shortenContent($obj->getContent($this->locale), getOption('RSS_truncate_length'), '...');
685:
686: if (!empty($categories)) {
687: $feeditem['category'] = html_encode($categories);
688: $feeditem['title'] = $title . ' (' . $categories . ')';
689: }
690: $feeditem['link'] = PROTOCOL . '://' . $this->host . $link;
691: $feeditem['media_content'] = '';
692: $feeditem['media_thumbnail'] = '';
693: $feeditem['pubdate'] = date("r", strtotime($item['date']));
694:
695: return $feeditem;
696: }
697:
698: 699: 700: 701:
702: public function printFeed() {
703: global $_zp_gallery;
704: $feeditems = $this->getitems();
705:
706: if (is_array($feeditems)) {
707: header('Content-Type: application/xml');
708: $this->hitcounter();
709: $this->startCache();
710: echo '<?xml-stylesheet type="text/css" href="' . WEBPATH . '/' . ZENFOLDER . '/' . PLUGIN_FOLDER . '/rss/rss.css" ?>' . "\n";
711: ?>
712: <rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:media="http://search.yahoo.com/mrss/">
713: <channel>
714: <title><![CDATA[<?php echo $this->channel_title; ?>]]></title>
715: <link><?php echo PROTOCOL . '://' . $this->host . WEBPATH; ?></link>
716: <atom:link href="<?php echo PROTOCOL; ?>://<?php echo $this->host; ?><?php echo html_encode(getRequestURI()); ?>" rel="self" type="application/rss+xml" />
717: <description><![CDATA[<?php echo getBare($_zp_gallery->getDesc($this->locale)); ?>]]></description>
718: <language><?php echo $this->locale_xml; ?></language>
719: <pubDate><?php echo date("r", time()); ?></pubDate>
720: <lastBuildDate><?php echo date("r", time()); ?></lastBuildDate>
721: <docs>http:
722: <generator>Zenphoto RSS Generator</generator>
723: <?php
724: foreach ($feeditems as $feeditem) {
725: switch ($this->feedtype) {
726: case 'gallery':
727: $item = $this->getItemGallery($feeditem);
728: break;
729: case 'news':
730: $item = $this->getItemNews($feeditem);
731: break;
732: case 'pages':
733: $item = $this->getitemPages($feeditem, getOption('RSS_truncate_length'));
734: break;
735: case 'comments':
736: $item = $this->getitemComments($feeditem);
737: break;
738: default:
739: $item = $feeditem;
740: break;
741: }
742: ?>
743: <item>
744: <title><![CDATA[<?php echo $item['title']; ?>]]></title>
745: <link><?php echo html_encode($item['link']); ?></link>
746: <description><![CDATA[<?php echo $item['desc']; ?>]]></description>
747: <?php
748: if (!empty($item['enclosure'])) {
749: echo $item['enclosure'];
750: }
751: if (!empty($item['category'])) {
752: ?>
753: <category><![CDATA[<?php echo $item['category']; ?>]]></category>
754: <?php
755: }
756: if (!empty($item['media_content'])) {
757: echo $item['media_content'];
758: }
759: if (!empty($item['media_thumbnail'])) {
760: echo $item['media_thumbnail'];
761: }
762: ?>
763: <guid><?php echo html_encode($item['link']); ?></guid>
764: <pubDate><?php echo html_encode($item['pubdate']); ?></pubDate>
765: </item>
766: <?php
767: }
768: ?>
769: </channel>
770: </rss>
771: <?php
772: $this->endCache();
773: }
774: }
775:
776: }
777:
778: function executeRSS() {
779: if (!$_GET['rss']) {
780: $_GET['rss'] = 'gallery';
781: }
782: $_zp_gallery_page = 'rss.php';
783: $rss = new RSS(sanitize($_GET));
784: $rss->printFeed();
785: exitZP();
786: }
787:
788:
789: if (!OFFSET_PATH && isset($_GET['rss'])) {
790: zp_register_filter('load_theme_script', 'executeRSS', 9999);
791: }
792: ?>