'.$RssTitle.'
'.$RssLink.'
'.$RssDesc.'
'.$RssLanguage.'
'.$RssCopyright.'
'.$RssEditor.'
'.$RssWebMaster.'
$RssChannelBuildDate
$Version with rsssimple.php v1.1');
SDV($RssItemFmt,'
-
$RssItemTitle
$RssItemLink
$RssItemLink
$RssItemDesc
$RssItemPubDate
');
SDV($HandleRssFmt,array(&$RssChannelFmt,&$RssItems,''));
function HandleRssSimple($pagename, $auth='read') {
global $RssMaxItems,$RssEditor, $RssDesc,
$RssChannelFmt,$RssChannelDesc,$RssChannelBuildDate,
$RssItems,$RssItemFmt,
$HandleRssFmt,$FmtV,$ScriptUrl,$Group,$Name;
$t = ReadTrail($pagename,$pagename);
$page = RetrieveAuthPage($pagename, $auth, false, READPAGE_CURRENT);
if (!$page) Abort("?cannot read $pagename");
$cbgmt = $page['time'];
SDV($RssChannelBuildDate, gmdate('D, d M Y H:i:s \G\M\T', $cbgmt));
$source = $page['text'];
$number_of_items = preg_match_all('/!!!.*::\ /', $source, $dates); // get the number of items and the dates
$dates = $dates[0];
$source_in_html = MarkupToHTML($pagename,$source);
$entries = preg_split('/!!!.*\ ::\ /', $source, -1, PREG_SPLIT_DELIM_CAPTURE);
array_shift($entries); // throw away everything before the first heading
$noitems = count($dates);
if ( $RssMaxItems > 0 && $noitems > $RssMaxItems ) { $noitems = $RssMaxItems; }
for ($i=0; $i<$noitems; $i++) {
# extract the date
preg_match('/[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]/', $dates[$i], $date);
$date = $date[0];
# extract the time
preg_match('/[0-9][0-9]:[0-9][0-9]/', $dates[$i], $time);
$time = $time[0];
# extract the title and the description
$content = preg_split('/\n/', $entries[$i], 2);
# extract link for rss item (anchor or link to a page)
preg_match('/\[\[.*\]\]/', $content[0], $itemLink);
$itemLink = str_replace('[[', '', $itemLink[0]);
$itemLink = trim(str_replace(']]', '', $itemLink));
if (($itemLink != '') && (substr($itemLink, 0, 1) == '#'))
$itemLink = $pagename.$itemLink;
$title = preg_replace('/\[\[.*\]\]/', '', $content[0]);
$title = trim($title);
$description = $content[1];
$description = trim($description);
$description = MarkupToHTML($pagename, $description);
//$description = strip_tags($description); # without html tags
$description = ""; # as cdata enclosure
$link = MakeLink($pagename, $itemLink, NULL, NULL, '$LinkUrl');
// print_r("$date - $time - $title
$description
$link
"); // debug output
SDV($RssDesc,entityencode(FmtPageName($RssDesc,$pagename)));
$FmtV['$RssItemTitle'] = $title;
$FmtV['$RssItemLink'] = $link;
$FmtV['$RssItemDesc'] = $description;
$FmtV['$RssItemAuthor'] = $RssEditor;
$FmtV['$RssItemPubDate'] = gmdate("r", mktime(substr($time,0,2),substr($time,3,2),0,substr($date,5,2),substr($date,8,2),substr($date,0,4)));
//$RssItems[] = entityencode(FmtPageName($RssItemFmt,$title)); // items with entity-encoding
$RssItems[] = FmtPageName($RssItemFmt,$title); // items without entity-encoding
}
header("Content-type: text/xml");
PrintFmt($pagename,$HandleRssFmt);
exit();
}
# entityencode() and $EntitiesTable are used to convert non-ASCII characters
# and named entities into numeric entities, since the RSS and RDF
# specifications don't have a good way of incorporating them by default.
function entityencode($s) {
global $EntitiesTable;
$s = str_replace(array_keys($EntitiesTable),array_values($EntitiesTable),$s);
return preg_replace('/([\\x80-\\xff])/e',"''.ord('\$1').';'",$s);
}
SDVA($EntitiesTable, array(
# entities defined in "http://www.w3.org/TR/xhtml1/DTD/xhtml-lat1.ent"
' ' => ' ',
'¡' => '¡',
'¢' => '¢',
'£' => '£',
'¤' => '¤',
'¥' => '¥',
'¦' => '¦',
'§' => '§',
'¨' => '¨',
'©' => '©',
'ª' => 'ª',
'«' => '«',
'¬' => '¬',
'' => '',
'®' => '®',
'¯' => '¯',
'°' => '°',
'±' => '±',
'²' => '²',
'³' => '³',
'´' => '´',
'µ' => 'µ',
'¶' => '¶',
'·' => '·',
'¸' => '¸',
'¹' => '¹',
'º' => 'º',
'»' => '»',
'¼' => '¼',
'½' => '½',
'¾' => '¾',
'¿' => '¿',
'À' => 'À',
'Á' => 'Á',
'Â' => 'Â',
'Ã' => 'Ã',
'Ä' => 'Ä',
'Å' => 'Å',
'Æ' => 'Æ',
'Ç' => 'Ç',
'È' => 'È',
'É' => 'É',
'Ê' => 'Ê',
'Ë' => 'Ë',
'Ì' => 'Ì',
'Í' => 'Í',
'Î' => 'Î',
'Ï' => 'Ï',
'Ð' => 'Ð',
'Ñ' => 'Ñ',
'Ò' => 'Ò',
'Ó' => 'Ó',
'Ô' => 'Ô',
'Õ' => 'Õ',
'Ö' => 'Ö',
'×' => '×',
'Ø' => 'Ø',
'Ù' => 'Ù',
'Ú' => 'Ú',
'Û' => 'Û',
'Ü' => 'Ü',
'Ý' => 'Ý',
'Þ' => 'Þ',
'ß' => 'ß',
'à' => 'à',
'á' => 'á',
'â' => 'â',
'ã' => 'ã',
'ä' => 'ä',
'å' => 'å',
'æ' => 'æ',
'ç' => 'ç',
'è' => 'è',
'é' => 'é',
'ê' => 'ê',
'ë' => 'ë',
'ì' => 'ì',
'í' => 'í',
'î' => 'î',
'ï' => 'ï',
'ð' => 'ð',
'ñ' => 'ñ',
'ò' => 'ò',
'ó' => 'ó',
'ô' => 'ô',
'õ' => 'õ',
'ö' => 'ö',
'÷' => '÷',
'ø' => 'ø',
'ù' => 'ù',
'ú' => 'ú',
'û' => 'û',
'ü' => 'ü',
'ý' => 'ý',
'þ' => 'þ',
'ÿ' => 'ÿ',
# entities defined in "http://www.w3.org/TR/xhtml1/DTD/xhtml-special.ent"
'"' => '"',
#'&' => '&',
#'<' => '<',
#'>' => '>',
''' => ''',
'Œ' => 'Œ',
'œ' => 'œ',
'Š' => 'Š',
'š' => 'š',
'Ÿ' => 'Ÿ',
'ˆ' => 'ˆ',
'˜' => '˜',
' ' => ' ',
' ' => ' ',
' ' => ' ',
'' => '',
'' => '',
'' => '',
'' => '',
'–' => '–',
'—' => '—',
'‘' => '‘',
'’' => '’',
'‚' => '‚',
'“' => '“',
'”' => '”',
'„' => '„',
'†' => '†',
'‡' => '‡',
'‰' => '‰',
'‹' => '‹',
'›' => '›',
'€' => '€',
# entities defined in "http://www.w3.org/TR/xhtml1/DTD/xhtml-symbol.ent"
'ƒ' => 'ƒ',
'Α' => 'Α',
'Β' => 'Β',
'Γ' => 'Γ',
'Δ' => 'Δ',
'Ε' => 'Ε',
'Ζ' => 'Ζ',
'Η' => 'Η',
'Θ' => 'Θ',
'Ι' => 'Ι',
'Κ' => 'Κ',
'Λ' => 'Λ',
'Μ' => 'Μ',
'Ν' => 'Ν',
'Ξ' => 'Ξ',
'Ο' => 'Ο',
'Π' => 'Π',
'Ρ' => 'Ρ',
'Σ' => 'Σ',
'Τ' => 'Τ',
'Υ' => 'Υ',
'Φ' => 'Φ',
'Χ' => 'Χ',
'Ψ' => 'Ψ',
'Ω' => 'Ω',
'α' => 'α',
'β' => 'β',
'γ' => 'γ',
'δ' => 'δ',
'ε' => 'ε',
'ζ' => 'ζ',
'η' => 'η',
'θ' => 'θ',
'ι' => 'ι',
'κ' => 'κ',
'λ' => 'λ',
'μ' => 'μ',
'ν' => 'ν',
'ξ' => 'ξ',
'ο' => 'ο',
'π' => 'π',
'ρ' => 'ρ',
'ς' => 'ς',
'σ' => 'σ',
'τ' => 'τ',
'υ' => 'υ',
'φ' => 'φ',
'χ' => 'χ',
'ψ' => 'ψ',
'ω' => 'ω',
'ϑ' => 'ϑ',
'ϒ' => 'ϒ',
'ϖ' => 'ϖ',
'•' => '•',
'…' => '…',
'′' => '′',
'″' => '″',
'‾' => '‾',
'⁄' => '⁄',
'℘' => '℘',
'ℑ' => 'ℑ',
'ℜ' => 'ℜ',
'™' => '™',
'ℵ' => 'ℵ',
'←' => '←',
'↑' => '↑',
'→' => '→',
'↓' => '↓',
'↔' => '↔',
'↵' => '↵',
'⇐' => '⇐',
'⇑' => '⇑',
'⇒' => '⇒',
'⇓' => '⇓',
'⇔' => '⇔',
'∀' => '∀',
'∂' => '∂',
'∃' => '∃',
'∅' => '∅',
'∇' => '∇',
'∈' => '∈',
'∉' => '∉',
'∋' => '∋',
'∏' => '∏',
'∑' => '∑',
'−' => '−',
'∗' => '∗',
'√' => '√',
'∝' => '∝',
'∞' => '∞',
'∠' => '∠',
'∧' => '∧',
'∨' => '∨',
'∩' => '∩',
'∪' => '∪',
'∫' => '∫',
'∴' => '∴',
'∼' => '∼',
'≅' => '≅',
'≈' => '≈',
'≠' => '≠',
'≡' => '≡',
'≤' => '≤',
'≥' => '≥',
'⊂' => '⊂',
'⊃' => '⊃',
'⊄' => '⊄',
'⊆' => '⊆',
'⊇' => '⊇',
'⊕' => '⊕',
'⊗' => '⊗',
'⊥' => '⊥',
'⋅' => '⋅',
'⌈' => '⌈',
'⌉' => '⌉',
'⌊' => '⌊',
'⌋' => '⌋',
'〈' => '〈',
'〉' => '〉',
'◊' => '◊',
'♠' => '♠',
'♣' => '♣',
'♥' => '♥',
'♦' => '♦'));