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'; |
f6ce9a88 |
23 | require_once 'wiki.inc.php'; |
2907d401 |
24 | |
f6ce9a88 |
25 | require_once dirname(__FILE__).'/../classes/Platal.php'; |
26 | require_once dirname(__FILE__).'/../classes/PLModule.php'; |
27 | |
28 | $n = wiki_pagename(); |
29 | if (!$n) { |
30 | pl_redirect(''); |
d575b75c |
31 | } |
bf98922c |
32 | |
f6ce9a88 |
33 | new_skinned_page('wiki.tpl'); |
89232034 |
34 | $perms = wiki_get_perms($n); |
f6ce9a88 |
35 | |
5e2307dc |
36 | switch (Env::v('action')) { |
f6ce9a88 |
37 | case '': |
99ce0a25 |
38 | wiki_apply_perms($perms[0]); |
f6ce9a88 |
39 | break; |
06a5e65b |
40 | |
f6ce9a88 |
41 | case 'edit': |
99ce0a25 |
42 | wiki_apply_perms($perms[1]); |
f6ce9a88 |
43 | break; |
6bc327ec |
44 | |
f6ce9a88 |
45 | default: |
46 | wiki_apply_perms('admin'); |
47 | break; |
48 | } |
6bc327ec |
49 | |
5e2307dc |
50 | if ($p = Post::v('setrperms')) { |
89232034 |
51 | wiki_apply_perms('admin'); |
52 | if (wiki_set_perms($n, $p, $perms[1])) { |
53 | $perms = wiki_get_perms($n); |
54 | $page->trig('Permissions mises à jour'); |
55 | } |
56 | } |
57 | |
5e2307dc |
58 | if ($p = Post::v('setwperms')) { |
89232034 |
59 | wiki_apply_perms('admin'); |
60 | if (wiki_set_perms($n, $perms[0], $p)) { |
61 | $perms = wiki_get_perms($n); |
62 | $page->trig('Permissions mises à jour'); |
63 | } |
64 | } |
65 | |
f6ce9a88 |
66 | $wiki_cache = wiki_work_dir().'/cache_'.$n.'.tpl'; |
67 | $cache_exists = file_exists($wiki_cache); |
6bc327ec |
68 | |
5e2307dc |
69 | if (Env::v('action') || !$cache_exists) { |
f6ce9a88 |
70 | @unlink($wiki_cache); |
71 | |
72 | // we leave pmwiki do whatever it wants and store everything |
73 | ob_start(); |
74 | require_once($globals->spoolroot.'/wiki/pmwiki.php'); |
6bc327ec |
75 | |
f6ce9a88 |
76 | $wikiAll = ob_get_clean(); |
77 | // the pmwiki skin we are using (almost empty) has these keywords: |
78 | $i = strpos($wikiAll, "<!--/HeaderText-->"); |
79 | $j = strpos($wikiAll, "<!--/PageLeftFmt-->", $i); |
80 | } |
81 | |
5e2307dc |
82 | if (Env::v('action')) { |
f6ce9a88 |
83 | $page->assign('xorg_extra_header', substr($wikiAll, 0, $i)); |
84 | $wikiAll = substr($wikiAll, $j); |
85 | } else { |
86 | if (!$cache_exists) { |
d1b62b48 |
87 | $wikiAll = substr($wikiAll, $j); |
89232034 |
88 | wiki_putfile($wiki_cache, $wikiAll); |
6bc327ec |
89 | } else { |
f6ce9a88 |
90 | $wikiAll = file_get_contents($wiki_cache); |
6bc327ec |
91 | } |
33ec1a8f |
92 | } |
93 | |
99ce0a25 |
94 | $page->assign('perms', $perms); |
95 | $page->assign('perms_opts', |
96 | array('public' => 'Public', 'logged' => 'Connecté', |
97 | 'mdp' => 'Authentifié', 'admin' => 'Admin')); |
98 | |
99 | $page->assign('canedit', wiki_may_have_perms($perms[1])); |
100 | $page->assign('has_perms', wiki_may_have_perms('admin')); |
101 | |
f6ce9a88 |
102 | $page->assign('wikipage', str_replace('.', '/', $n)); |
99ce0a25 |
103 | $page->assign('pmwiki', $wikiAll); |
104 | |
52165f0e |
105 | $page->addCssLink('css/wiki.css'); |
5e35f1b7 |
106 | $page->addJsLink('javascript/wiki.js'); |
bf98922c |
107 | |
108 | $page->run(); |
109 | ?> |