Improve wiki RSS
authorx2003bruneau <x2003bruneau@839d8a87-29fc-0310-9880-83ba4fa771e5>
Sun, 4 Feb 2007 07:37:59 +0000 (07:37 +0000)
committerx2003bruneau <x2003bruneau@839d8a87-29fc-0310-9880-83ba4fa771e5>
Sun, 4 Feb 2007 07:37:59 +0000 (07:37 +0000)
git-svn-id: svn+ssh://murphy/home/svn/platal/trunk@1476 839d8a87-29fc-0310-9880-83ba4fa771e5

include/globals.inc.php.in
include/wiki/engine.php
include/wiki/farmconfig.php

index 0554899..74fb56c 100644 (file)
@@ -51,7 +51,6 @@ class PlatalGlobals
         $this->read_config();
         $this->setlocale();
 
-        require_once dirname(__FILE__) . '/../classes/xdb.php';
         XDB::connect($this->dbhost, $this->dbuser, $this->dbpwd, $this->dbdb, 'utf8', $this->debug);
     }
 
index 628bdf3..859dd95 100644 (file)
@@ -28,9 +28,12 @@ if (!$n) {
 
 new_skinned_page('core/wiki.tpl');
 $perms = wiki_get_perms($n);
+$feed  = false;
 
 // Check user perms
 switch (Env::v('action')) {
+  case 'rss': case 'atom': case 'sdf': case 'dc':
+    $feed = true;
   case '': case 'search': case 'rss': case 'atom': 
     break;
 
@@ -62,7 +65,6 @@ if ($p = Post::v('setwperms')) {
 // 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);
@@ -84,10 +86,13 @@ if (Env::v('action') || !$cache_exists) {
 
 $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);
+} 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);
index 081a9ed..07977fe 100644 (file)
@@ -20,10 +20,13 @@ $Skin             = 'empty';
 @include_once("$FarmD/cookbook/e-protect.php");
 include_once($FarmD.'/scripts/xlpage-utf-8.php');
 
-if ($action == 'rss'  ||
-    $action == 'atom' ||
-    $action == 'rdf'  ||
-    $action == 'dc') include_once("$FarmD/scripts/feeds.php");
+if ($action == 'rss'  || $action == 'atom' || $action == 'rdf'  || $action == 'dc') {
+    include_once("$FarmD/scripts/feeds.php");
+    $FmtPV['$MarkupExcerpt'] = '$page["text"]';
+    $FeedFmt[$action]['item']['title'] = '[$Group] {$Title}';
+    $FeedFmt[$action]['item']['description'] = '$LastModifiedSummary';
+    $FeedFmt[$action]['feed']['title'] = 'Polytechnique.org :: Wiki :: $FullName';
+}
 
 // Theme-ing {{{
 
@@ -60,6 +63,10 @@ $InputTags['e_form'] = array(
 Markup('[[~platal', '<[[~', '/\[\[~([^|\]]*)(?:\|([^\]]*))?\]\]/e',
     'PreserveText("=", doPlatalLink("$1", "$2"), "")');
 
+// Preserve javascript
+Markup('[[javascript', '<[[javascript:', '/\[\[javascript:([^\|]*)\|([^\]]*)?\]\]/e',
+       'PreserveText("=", \'<a href="javascript:\' . htmlentities("$1") . \'">\', "") . "$2" . PreserveText("=", "</a>", "")');
+
 // prevent restorelinks before block apply (otherwise [[Sécurité]] will give
 //  .../S<span class='e9curit'>e9'>Sécurité</a>
 Markup('restorelinks','<%%',"//", '');