bf98922c |
1 | <?php |
2 | /*************************************************************************** |
50a40a33 |
3 | * Copyright (C) 2003-2006 Polytechnique.org * |
bf98922c |
4 | * http://opensource.polytechnique.org/ * |
5 | * * |
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. * |
10 | * * |
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. * |
15 | * * |
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 * |
18 | * Foundation, Inc., * |
19 | * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * |
20 | ***************************************************************************/ |
21 | |
801fcad8 |
22 | require_once 'xorg.inc.php'; |
2907d401 |
23 | |
06a5e65b |
24 | new_skinned_page(''); |
25 | if (!S::identified()) { |
26 | XorgSession::doAuth(); |
d575b75c |
27 | } |
bf98922c |
28 | |
06a5e65b |
29 | require_once 'wiki.inc.php'; |
06a5e65b |
30 | |
6bc327ec |
31 | if ($n = wiki_pagename()) { |
32 | $wiki_template = wiki_work_dir().'/cache_'.$n.'.tpl'; |
33 | $tmpfile_exists = file_exists($wiki_template); |
34 | |
35 | if (Env::get('action') || !$tmpfile_exists) { |
36 | if ($tmpfile_exists) { |
37 | @unlink($wiki_template); |
38 | $page->clear_compiled_tpl($wiki_template); |
39 | } |
40 | |
41 | // we leave pmwiki do whatever it wants and store everything |
42 | ob_start(); |
43 | require_once($globals->spoolroot.'/wiki/pmwiki.php'); |
44 | |
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); |
49 | } |
50 | |
51 | if (Env::get('action')) { |
52 | // clean old tmp files |
53 | wiki_clean_tmp(); |
54 | $page->assign('xorg_extra_header', substr($wikiAll, 0, $i)); |
55 | $page->addJsLink('javascript/wiki.js'); |
56 | |
57 | // create new tmp files with editing page from wiki engine |
58 | $wiki_template = wiki_create_tmp(substr($wikiAll, $j)); |
59 | } else { |
60 | if (!$tmpfile_exists) { |
61 | $f = fopen($wiki_template, 'w'); |
62 | fputs($f, substr($wikiAll, $j)); |
63 | fclose($f); |
64 | } |
65 | } |
33ec1a8f |
66 | } |
6bc327ec |
67 | $page->changeTpl($wiki_template); |
33ec1a8f |
68 | |
0df3edb9 |
69 | wiki_assign_auth(); |
52165f0e |
70 | $page->addCssLink('css/wiki.css'); |
bf98922c |
71 | |
72 | $page->run(); |
73 | ?> |