54 lines
1.2 KiB
PHP
54 lines
1.2 KiB
PHP
<?php
|
|
|
|
$SITENAME = 'Visiome Platform';
|
|
$HOSTNAME = 'visiome';
|
|
$FQDN = $HOSTNAME.'.neuroinf.jp';
|
|
$URL = 'https://'.$FQDN;
|
|
$XOOPS_URL = $URL;
|
|
$JSON = __DIR__.'/../src/database/assets/recent-contents.json';
|
|
|
|
if (!file_exists($JSON)) {
|
|
echo 'Error: Json file not found:'.$JSON.PHP_EOL;
|
|
exit(1);
|
|
}
|
|
|
|
$items = json_decode(file_get_contents($JSON), true);
|
|
|
|
//var_dump($items);
|
|
|
|
$xml = <<< HEAD
|
|
<?xml version="1.0" encoding="UTF-8" ?>
|
|
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
|
|
<channel>
|
|
<atom:link href="${XOOPS_URL}/rss.xml" rel="self" type="application/rss+xml" />
|
|
<title>${SITENAME}</title>
|
|
<link>${URL}</link>
|
|
<description>${SITENAME}</description>
|
|
<language>en</language>
|
|
|
|
HEAD;
|
|
|
|
foreach($items as $item) {
|
|
$title = htmlspecialchars($item['title'], ENT_QUOTES);
|
|
$url = $XOOPS_URL.'/modules/xoonips/detail.php?'.($item['doi'] !== '' ? 'id='.$item['doi'] : 'item_id='.$item['item_id']);
|
|
$pubDate = gmdate(DATE_RSS, $item['last_update_date']);
|
|
$xml .= <<< ITEM
|
|
<item>
|
|
<title>$title</title>
|
|
<link>$url</link>
|
|
<pubDate>$pubDate</pubDate>
|
|
<guid>$url</guid>
|
|
<description></description>
|
|
<category>Incoming Public Item</category>
|
|
</item>
|
|
|
|
ITEM;
|
|
}
|
|
|
|
$xml .= <<< FOOTER
|
|
</channel>
|
|
</rss>
|
|
FOOTER;
|
|
|
|
file_put_contents(__DIR__.'/rss.xml', $xml);
|