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 $wp = PlWikiPage
::currentPage();
27 switch (Env
::v('action')) {
28 case 'rss': case 'atom': case 'sdf': case 'dc':
31 case '': case 'search':
35 $wp->applyWritePerms();
39 $wp->applyReadPerms();
43 if ($p = Post
::v('setrperms')) {
44 $wp->applyPerms('admin');
45 if ($wp->setPerms($p, $wp->writePerms())) {
46 Platal
::page()->trigSuccess('Permissions mises à jour');
50 if ($p = Post
::v('setwperms')) {
51 $wp->applyPerms('admin');
52 if ($wp->setPerms($wp->readPerms(), $p)) {
53 Platal
::page()->trigSuccess('Permissions mises à jour');
57 // Generate cache even if we don't have access rights
58 $wiki_cache = $wp->cacheFilename();
59 $cache_exists = file_exists($wiki_cache);
60 if (Env
::v('action') ||
!$cache_exists) {
61 if ($cache_exists && !$feed) {
65 // we leave pmwiki do whatever it wants and store everything
67 require_once($globals->spoolroot
. '/wiki/pmwiki.php');
69 $wikiAll = ob_get_clean();
72 // the pmwiki skin we are using (almost empty) has these keywords:
73 $i = strpos($wikiAll, "<!--/HeaderText-->");
74 $j = strpos($wikiAll, "<!--/PageLeftFmt-->", $i);
77 $wiki_exists = file_exists($wp->filename());
79 $page =& Platal
::page();
80 $page->coreTpl('wiki.tpl');
83 $wikiAll = str_replace('dc:contributor', 'author', $wikiAll);
84 $wikiAll = preg_replace('!<author>.*?\..*?\.(\d{4})\|(.*?)</author>!u', '<author>$2 (X$1)</author>', $wikiAll);
85 $wikiAll = str_replace('<link>./', '<link>' . $globals->baseurl
. '/' . $platal->ns
, $wikiAll);
89 } elseif (Env
::v('action')) {
90 $page->assign('pl_extra_header', substr($wikiAll, 0, $i));
91 $wikiAll = substr($wikiAll, $j);
93 if (!$cache_exists && $wiki_exists) {
94 $wikiAll = substr($wikiAll, $j);
95 file_put_contents($wiki_cache, $wikiAll);
96 } elseif ($cache_exists) {
97 $wikiAll = file_get_contents($wiki_cache);
98 } elseif (S
::has_perms()) {
99 $wikiAll = "<p>La page de wiki $n n'existe pas. "
100 . "Il te suffit de <a href='" . str_replace('.', '/', $n) . "?action=edit'>l'éditer</a></p>";
108 $wp->applyReadPerms();
110 $page->assign('perms', array($wp->readPerms(), $wp->writePerms()));
111 $page->assign('perms_opts', PlWikiPage
::permOptions());
113 $page->assign('canedit', $wp->canWrite());
114 $page->assign('has_perms', S
::has_perms());
116 $page->assign('wikipage', str_replace('.', '/', $n));
117 if (!$feed && $wp->writePerms() == 'admin' && !Env
::v('action') && $wiki_exists) {
118 $page->assign('pmwiki_cache', $wiki_cache);
120 $page->assign('pmwiki', $wikiAll);
121 $page->assign('text', true
);
123 $page->addCssLink('wiki.css');
124 $page->addJsLink('wiki.js');
125 if (!Env
::v('action')) {
126 $url = '/' . str_replace('.', '/', $n) . '?action=rss';
128 $url .= '&user=' . S
::v('forlife') . '&hash=' . S
::v('core_rss_hash');
130 $page->setRssLink($n, $url);
135 // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: