remove more code.
[platal.git] / htdocs / wiki.php
index 33cc717..be90e7c 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2004 Polytechnique.org                              *
+ *  Copyright (C) 2003-2006 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
  *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
  ***************************************************************************/
 
-require_once("xorg.inc.php");
-if (Env::has('response'))
- new_skinned_page('wiki.tpl', AUTH_MDP);
-else
- new_skinned_page('wiki.tpl', AUTH_PUBLIC);
+require_once 'xorg.inc.php';
 
-require_once('pmwiki.php');
+new_skinned_page('');
+if (!S::identified()) {
+    XorgSession::doAuth();
+}
+
+require_once 'wiki.inc.php';
+
+if ($n = wiki_pagename()) {
+    $wiki_template  = wiki_work_dir().'/cache_'.$n.'.tpl';
+    $tmpfile_exists = file_exists($wiki_template);
+
+    if (Env::get('action') || !$tmpfile_exists) {
+        if ($tmpfile_exists) {
+            @unlink($wiki_template);
+            $page->clear_compiled_tpl($wiki_template);
+        }
+
+        // we leave pmwiki do whatever it wants and store everything
+        ob_start();
+        require_once($globals->spoolroot.'/wiki/pmwiki.php');
+
+        $wikiAll = ob_get_clean();
+        // the pmwiki skin we are using (almost empty) has these keywords:
+        $i = strpos($wikiAll, "<!--/HeaderText-->");
+        $j = strpos($wikiAll, "<!--/PageLeftFmt-->", $i);
+    }
+
+    if (Env::get('action')) {
+        // clean old tmp files
+        wiki_clean_tmp();
+        $page->assign('xorg_extra_header', substr($wikiAll, 0, $i));
+
+        // create new tmp files with editing page from wiki engine
+        $wiki_template = wiki_create_tmp(substr($wikiAll, $j));
+    } else {
+        if (!$tmpfile_exists) {
+            $f = fopen($wiki_template, 'w');
+            fputs($f, substr($wikiAll, $j));
+            fclose($f);
+        }
+    }
+}
+$page->changeTpl($wiki_template);
+
+wiki_assign_auth();
 $page->addCssLink('css/wiki.css');
-$page->assign('xorg_extra_header', substr($wikiAll, 0, $i));
-$page->assign('menu-pmwiki', $wikiMenu);
-$page->assign('pmwiki', $wikiTxt);
 
 $page->run();
 ?>