One major problem: The links to h2 und h3 pages do not work. Since all information is read from pagedata.php the complete path to the sub-page is not known.
It would also be nice if the current content of modified pages could be included into the RSS feed.
For my purposes the current functionality is enough. Maybe someone else finds this useful, too.
Here is the code for rss.php:
Code: Select all
<?php
include('./content/pagedata.php');
include('./cmsimple/config.php');
$language = $cf['meta']['content-language'];
include("./cmsimple/languages/$language.php");
$sorted_pages = msort($page_data, 'last_edit',false);
$max = 20;
if( count($page_data) < $max )
$max = count($page_data);
$urlBase = 'http://'.parse_url('http://'.$_SERVER['HTTP_HOST'], PHP_URL_HOST).str_replace('rss.php','',parse_url('http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'], PHP_URL_PATH));
header( "Content-type: text/xml; charset=UTF-8" );
echo '<rss version="2.0" >';
echo '<channel>';
echo '<title>'.$tx['site']['title'].'</title>';
echo "<link>$urlBase</link>";
echo '<description>'.$tx['meta']['description'].'</description>';
echo "<language>$language</language>";
for( $i=0; $i<$max; $i++) {
$title = str_replace('_',' ',html_entity_decode(urldecode($sorted_pages[$i]['url']),ENT_NOQUOTES,'UTF-8'));
echo '<item>';
echo "<title>$title</title>";
echo "<link>$urlBase?".$sorted_pages[$i]['url'].'</link>';
echo '<pubDate>'.date('r',$sorted_pages[$i]['last_edit']).'</pubDate>';
echo '</item>';
}
echo '</channel>';
echo '</rss>';
function msort($array, $id="id", $sort_ascending=true) {
$temp_array = array();
while(count($array)>0) {
$lowest_id = 0;
$index=0;
foreach ($array as $item) {
if (isset($item[$id])) {
if ($array[$lowest_id][$id]) {
if ($item[$id]<$array[$lowest_id][$id]) {
$lowest_id = $index;
}
}
}
$index++;
}
$temp_array[] = $array[$lowest_id];
$array = array_merge(array_slice($array, 0,$lowest_id), array_slice($array, $lowest_id+1));
}
if ($sort_ascending) {
return $temp_array;
} else {
return array_reverse($temp_array);
}
}
?>