2 /***************************************************************************
3 * Copyright (C) 2003-2007 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 'wiki.inc.php';
29 new_skinned_page('core/wiki.tpl');
30 $perms = wiki_get_perms($n);
34 switch (Env
::v('action')) {
35 case 'rss': case 'atom': case 'sdf': case 'dc':
36 wiki_apply_feed_perms($perms['0']);
38 case '': case 'search':
42 wiki_apply_perms($perms[1]);
46 wiki_apply_perms('admin');
50 if ($p = Post
::v('setrperms')) {
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');
58 if ($p = Post
::v('setwperms')) {
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');
66 // Generate cache even if we don't have access rights
67 $wiki_cache = wiki_work_dir().'/cache_'.wiki_filename($n).'.tpl';
68 $cache_exists = file_exists($wiki_cache);
69 if (Env
::v('action') ||
!$cache_exists) {
70 if ($cache_exists && !$feed) {
72 $files = glob($globals->spoolroot
. '/spool/templates_c/*cache_' . wiki_filename($n) . '.tpl*');
73 foreach ($files as $file) {
78 // we leave pmwiki do whatever it wants and store everything
80 require_once($globals->spoolroot
.'/wiki/pmwiki.php');
82 $wikiAll = ob_get_clean();
83 // the pmwiki skin we are using (almost empty) has these keywords:
84 $i = strpos($wikiAll, "<!--/HeaderText-->");
85 $j = strpos($wikiAll, "<!--/PageLeftFmt-->", $i);
88 $wiki_exists = file_exists(wiki_work_dir() . '/' . wiki_filename($n));
91 $wikiAll = str_replace('dc:contributor', 'author', $wikiAll);
92 $wikiAll = preg_replace('!<author>.*?\..*?\.(\d{4})\|(.*?)</author>!u', '<author>$2 (X$1)</author>', $wikiAll);
96 } elseif (Env
::v('action')) {
97 $page->assign('xorg_extra_header', substr($wikiAll, 0, $i));
98 $wikiAll = substr($wikiAll, $j);
100 if (!$cache_exists && $wiki_exists) {
101 $wikiAll = substr($wikiAll, $j);
102 wiki_putfile($wiki_cache, $wikiAll);
103 } elseif ($cache_exists) {
104 $wikiAll = file_get_contents($wiki_cache);
105 } elseif (S
::has_perms()) {
106 $wikiAll = "<p>La page de wiki $n n'existe pas. "
107 . "Il te suffit de <a href='" . str_replace('.', '/', $n) . "?action=edit'>l'éditer</a></p>";
109 $page->changeTpl('core/404.tpl');
114 wiki_apply_perms($perms[0]);
116 $page->assign('perms', $perms);
117 $page->assign('perms_opts', wiki_perms_options());
119 $page->assign('canedit', wiki_may_have_perms($perms[1]));
120 $page->assign('has_perms', wiki_may_have_perms('admin'));
122 $page->assign('wikipage', str_replace('.', '/', $n));
123 if (!$feed && $perms[1] == 'admin' && !Env
::v('action') && $wiki_exists) {
124 $page->assign('pmwiki_cache', $wiki_cache);
126 $page->assign('pmwiki', $wikiAll);
127 $page->assign('text', true
);
129 $page->addCssLink('wiki.css');
130 $page->addJsLink('wiki.js');
131 if (!Env
::v('action')) {
132 $url = '/' . str_replace('.', '/', $n) . '?action=rss';
134 $url .= '&user=' . S
::v('forlife') . '&hash=' . S
::v('core_rss_hash');
136 $page->setRssLink($n, $url);
141 // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: