490e261640ac5cb6be4748d67bf0aaf676485f07
2 /***************************************************************************
3 * Copyright (C) 2003-2006 Polytechnique.org *
4 * http://opensource.polytechnique.org/ *
6 * This program is free software; you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License as published by *
8 * the Free Software Foundation; either version 2 of the License, or *
9 * (at your option) any later version. *
11 * This program is distributed in the hope that it will be useful, *
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14 * GNU General Public License for more details. *
16 * You should have received a copy of the GNU General Public License *
17 * along with this program; if not, write to the Free Software *
19 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
20 ***************************************************************************/
22 require_once 'xorg.inc.php';
24 new_skinned_page('wiki.tpl');
25 if (!S
::identified()) {
26 XorgSession
::doAuth();
29 require_once 'wiki.inc.php';
31 if ($n = wiki_pagename()) {
32 $wiki_template = wiki_work_dir().'/cache_'.$n.'.tpl';
33 $tmpfile_exists = file_exists($wiki_template);
35 if (Env
::get('action') ||
!$tmpfile_exists) {
36 if ($tmpfile_exists) {
37 @unlink
($wiki_template);
38 $page->clear_compiled_tpl($wiki_template);
41 // we leave pmwiki do whatever it wants and store everything
43 require_once($globals->spoolroot
.'/wiki/pmwiki.php');
45 $wikiAll = ob_get_clean();
46 // the pmwiki skin we are using (almost empty) has these keywords:
47 $i = strpos($wikiAll, "<!--/HeaderText-->");
48 $j = strpos($wikiAll, "<!--/PageLeftFmt-->", $i);
51 if (Env
::get('action')) {
52 // clean old tmp files
55 // create new tmp files with editing page from wiki engine
56 $page->assign('xorg_extra_header', substr($wikiAll, 0, $i));
57 $wikiAll = substr($wikiAll, $j);
58 $wiki_template = wiki_create_tmp($wikiAll);
60 if (!$tmpfile_exists) {
61 $f = fopen($wiki_template, 'w');
62 $wikiAll = substr($wikiAll, $j);
66 $wikiAll = file_get_contents($wiki_template);
70 $page->assign('wikipage', str_replace('.', '/', $n));
73 $page->assign('pmwiki', $wikiAll);
75 $page->addCssLink('css/wiki.css');