<?php
/***************************************************************************
- * Copyright (C) 2003-2007 Polytechnique.org *
+ * Copyright (C) 2003-2008 Polytechnique.org *
* http://opensource.polytechnique.org/ *
* *
* This program is free software; you can redistribute it and/or modify *
new_skinned_page('core/wiki.tpl');
$perms = wiki_get_perms($n);
+$feed = false;
// Check user perms
switch (Env::v('action')) {
- case '': case 'search': case 'rss': case 'atom':
+ case 'rss': case 'atom': case 'sdf': case 'dc':
+ wiki_apply_feed_perms($perms[0]);
+ $feed = true;
+ case '': case 'search':
break;
case 'edit':
// Generate cache even if we don't have access rights
$wiki_cache = wiki_work_dir().'/cache_'.wiki_filename($n).'.tpl';
$cache_exists = file_exists($wiki_cache);
-$feed = in_array(Env::v('action'), array('rss', 'atom', 'sdf', 'dc'));
if (Env::v('action') || !$cache_exists) {
if ($cache_exists && !$feed) {
unlink($wiki_cache);
require_once($globals->spoolroot.'/wiki/pmwiki.php');
$wikiAll = ob_get_clean();
+ pl_clear_errors();
+
// the pmwiki skin we are using (almost empty) has these keywords:
$i = strpos($wikiAll, "<!--/HeaderText-->");
$j = strpos($wikiAll, "<!--/PageLeftFmt-->", $i);
$wiki_exists = file_exists(wiki_work_dir() . '/' . wiki_filename($n));
-if (Env::v('action') && !$feed) {
+if ($feed) {
+ $wikiAll = str_replace('dc:contributor', 'author', $wikiAll);
+ $wikiAll = preg_replace('!<author>.*?\..*?\.(\d{4})\|(.*?)</author>!u', '<author>$2 (X$1)</author>', $wikiAll);
+ $wikiAll = str_replace('<link>./', '<link>' . $globals->baseurl . '/' . $platal->ns, $wikiAll);
+ echo $wikiAll;
+ pl_clear_errors();
+ exit;
+} elseif (Env::v('action')) {
$page->assign('xorg_extra_header', substr($wikiAll, 0, $i));
$wikiAll = substr($wikiAll, $j);
-} elseif (!$feed) {
+} else {
if (!$cache_exists && $wiki_exists) {
$wikiAll = substr($wikiAll, $j);
wiki_putfile($wiki_cache, $wikiAll);
// Check user perms
wiki_apply_perms($perms[0]);
-if ($feed) {
- echo $wikiAll;
- exit;
-}
-
$page->assign('perms', $perms);
$page->assign('perms_opts', wiki_perms_options());
$page->addCssLink('wiki.css');
$page->addJsLink('wiki.js');
if (!Env::v('action')) {
- $page->setRssLink($n, '/' . str_replace('.', '/', $n) . '?action=rss');
+ $url = '/' . str_replace('.', '/', $n) . '?action=rss';
+ if (S::logged()) {
+ $url .= '&user=' . S::v('forlife') . '&hash=' . S::v('core_rss_hash');
+ }
+ $page->setRssLink($n, $url);
}
$page->run();