X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=htdocs%2Fwiki.php;h=33697b14fa797556d1509ecd56dff83de0816f16;hb=5e2307dcebc38ebb0ffe469967a377eb3baed571;hp=ab6daa2f0328e81d15631e34fdd435060182ae63;hpb=6bc327ec0f618294b1438914bc2219e08e1036c1;p=platal.git diff --git a/htdocs/wiki.php b/htdocs/wiki.php index ab6daa2..33697b1 100644 --- a/htdocs/wiki.php +++ b/htdocs/wiki.php @@ -20,54 +20,90 @@ ***************************************************************************/ require_once 'xorg.inc.php'; +require_once 'wiki.inc.php'; + +require_once dirname(__FILE__).'/../classes/Platal.php'; +require_once dirname(__FILE__).'/../classes/PLModule.php'; -new_skinned_page(''); -if (!S::identified()) { - XorgSession::doAuth(); +$n = wiki_pagename(); +if (!$n) { + pl_redirect(''); } -require_once 'wiki.inc.php'; +new_skinned_page('wiki.tpl'); +$perms = wiki_get_perms($n); + +switch (Env::v('action')) { + case '': + wiki_apply_perms($perms[0]); + break; -if ($n = wiki_pagename()) { - $wiki_template = wiki_work_dir().'/cache_'.$n.'.tpl'; - $tmpfile_exists = file_exists($wiki_template); + case 'edit': + wiki_apply_perms($perms[1]); + break; - if (Env::get('action') || !$tmpfile_exists) { - if ($tmpfile_exists) { - @unlink($wiki_template); - $page->clear_compiled_tpl($wiki_template); - } + default: + wiki_apply_perms('admin'); + break; +} - // we leave pmwiki do whatever it wants and store everything - ob_start(); - require_once($globals->spoolroot.'/wiki/pmwiki.php'); +if ($p = Post::v('setrperms')) { + wiki_apply_perms('admin'); + if (wiki_set_perms($n, $p, $perms[1])) { + $perms = wiki_get_perms($n); + $page->trig('Permissions mises à jour'); + } +} - $wikiAll = ob_get_clean(); - // the pmwiki skin we are using (almost empty) has these keywords: - $i = strpos($wikiAll, ""); - $j = strpos($wikiAll, "", $i); +if ($p = Post::v('setwperms')) { + wiki_apply_perms('admin'); + if (wiki_set_perms($n, $perms[0], $p)) { + $perms = wiki_get_perms($n); + $page->trig('Permissions mises à jour'); } +} - if (Env::get('action')) { - // clean old tmp files - wiki_clean_tmp(); - $page->assign('xorg_extra_header', substr($wikiAll, 0, $i)); - $page->addJsLink('javascript/wiki.js'); +$wiki_cache = wiki_work_dir().'/cache_'.$n.'.tpl'; +$cache_exists = file_exists($wiki_cache); - // create new tmp files with editing page from wiki engine - $wiki_template = wiki_create_tmp(substr($wikiAll, $j)); +if (Env::v('action') || !$cache_exists) { + @unlink($wiki_cache); + + // we leave pmwiki do whatever it wants and store everything + ob_start(); + require_once($globals->spoolroot.'/wiki/pmwiki.php'); + + $wikiAll = ob_get_clean(); + // the pmwiki skin we are using (almost empty) has these keywords: + $i = strpos($wikiAll, ""); + $j = strpos($wikiAll, "", $i); +} + +if (Env::v('action')) { + $page->assign('xorg_extra_header', substr($wikiAll, 0, $i)); + $wikiAll = substr($wikiAll, $j); +} else { + if (!$cache_exists) { + $wikiAll = substr($wikiAll, $j); + wiki_putfile($wiki_cache, $wikiAll); } else { - if (!$tmpfile_exists) { - $f = fopen($wiki_template, 'w'); - fputs($f, substr($wikiAll, $j)); - fclose($f); - } + $wikiAll = file_get_contents($wiki_cache); } } -$page->changeTpl($wiki_template); -wiki_assign_auth(); +$page->assign('perms', $perms); +$page->assign('perms_opts', + array('public' => 'Public', 'logged' => 'Connecté', + 'mdp' => 'Authentifié', 'admin' => 'Admin')); + +$page->assign('canedit', wiki_may_have_perms($perms[1])); +$page->assign('has_perms', wiki_may_have_perms('admin')); + +$page->assign('wikipage', str_replace('.', '/', $n)); +$page->assign('pmwiki', $wikiAll); + $page->addCssLink('css/wiki.css'); +$page->addJsLink('javascript/wiki.js'); $page->run(); ?>