2 /***************************************************************************
3 * Copyright (C) 2003-2008 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();
85 // the pmwiki skin we are using (almost empty) has these keywords:
86 $i = strpos($wikiAll, "<!--/HeaderText-->");
87 $j = strpos($wikiAll, "<!--/PageLeftFmt-->", $i);
90 $wiki_exists = file_exists(wiki_work_dir() . '/' . wiki_filename($n));
93 $wikiAll = str_replace('dc:contributor', 'author', $wikiAll);
94 $wikiAll = preg_replace('!<author>.*?\..*?\.(\d{4})\|(.*?)</author>!u', '<author>$2 (X$1)</author>', $wikiAll);
95 $wikiAll = str_replace('<link>./', '<link>' . $globals->baseurl
. '/' . $platal->ns
, $wikiAll);
99 } elseif (Env
::v('action')) {
100 $page->assign('xorg_extra_header', substr($wikiAll, 0, $i));
101 $wikiAll = substr($wikiAll, $j);
103 if (!$cache_exists && $wiki_exists) {
104 $wikiAll = substr($wikiAll, $j);
105 wiki_putfile($wiki_cache, $wikiAll);
106 } elseif ($cache_exists) {
107 $wikiAll = file_get_contents($wiki_cache);
108 } elseif (S
::has_perms()) {
109 $wikiAll = "<p>La page de wiki $n n'existe pas. "
110 . "Il te suffit de <a href='" . str_replace('.', '/', $n) . "?action=edit'>l'éditer</a></p>";
112 $page->changeTpl('core/404.tpl');
117 wiki_apply_perms($perms[0]);
119 $page->assign('perms', $perms);
120 $page->assign('perms_opts', wiki_perms_options());
122 $page->assign('canedit', wiki_may_have_perms($perms[1]));
123 $page->assign('has_perms', wiki_may_have_perms('admin'));
125 $page->assign('wikipage', str_replace('.', '/', $n));
126 if (!$feed && $perms[1] == 'admin' && !Env
::v('action') && $wiki_exists) {
127 $page->assign('pmwiki_cache', $wiki_cache);
129 $page->assign('pmwiki', $wikiAll);
130 $page->assign('text', true
);
132 $page->addCssLink('wiki.css');
133 $page->addJsLink('wiki.js');
134 if (!Env
::v('action')) {
135 $url = '/' . str_replace('.', '/', $n) . '?action=rss';
137 $url .= '&user=' . S
::v('forlife') . '&hash=' . S
::v('core_rss_hash');
139 $page->setRssLink($n, $url);
144 // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: