2 /***************************************************************************
3 * Copyright (C) 2003-2011 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) {
62 $wp->removePageCache();
63 $cache_exists = false
;
66 // we leave pmwiki do whatever it wants and store everything
68 require_once($globals->spoolroot
. '/wiki/pmwiki.php');
70 $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);
88 } elseif (Env
::v('action')) {
89 $page->assign('pl_extra_header', substr($wikiAll, 0, $i));
90 $wikiAll = substr($wikiAll, $j);
92 if (!$cache_exists && $wiki_exists) {
93 $wikiAll = substr($wikiAll, $j);
94 file_put_contents($wiki_cache, $wikiAll);
95 } elseif ($cache_exists) {
96 $wikiAll = file_get_contents($wiki_cache);
97 } elseif (S
::admin()) {
98 $wikiAll = "<p>La page de wiki $n n'existe pas. "
99 . "Il te suffit de <a href='" . str_replace('.', '/', $n) . "?action=edit'>l'éditer</a></p>";
107 $wp->applyReadPerms();
109 $page->assign('perms', array($wp->readPerms(), $wp->writePerms()));
110 $page->assign('perms_opts', PlWikiPage
::permOptions());
112 $page->assign('canedit', $wp->canWrite());
113 $page->assign('has_perms', S
::admin());
115 $page->assign('wikipage', str_replace('.', '/', $n));
116 if (!$feed && $wp->writePerms() == 'admin' && !Env
::v('action') && $wiki_exists) {
117 $page->assign('pmwiki_cache', $wiki_cache);
119 $page->assign('pmwiki', $wikiAll);
120 $page->assign('text', true
);
122 $page->addCssLink('wiki.css');
123 $page->addJsLink('wiki.js');
124 if (!Env
::v('action')) {
125 $url = '/' . str_replace('.', '/', $n) . '?action=rss';
127 $url .= '&user=' . S
::user()->login() . '&hash=' . S
::v('core_rss_hash');
129 $page->setRssLink($n, $url);
134 // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: