From 6bc327ec0f618294b1438914bc2219e08e1036c1 Mon Sep 17 00:00:00 2001 From: x2000habouzit Date: Wed, 19 Jul 2006 21:56:26 +0000 Subject: [PATCH] move the non functionnal code into wiki.php git-svn-id: svn+ssh://murphy/home/svn/platal/trunk@550 839d8a87-29fc-0310-9880-83ba4fa771e5 --- htdocs/wiki.php | 39 ++++++++++++++++++++++++++++++++++++--- include/wiki.inc.php | 38 +------------------------------------- 2 files changed, 37 insertions(+), 40 deletions(-) diff --git a/htdocs/wiki.php b/htdocs/wiki.php index 188a574..ab6daa2 100644 --- a/htdocs/wiki.php +++ b/htdocs/wiki.php @@ -27,11 +27,44 @@ if (!S::identified()) { } require_once 'wiki.inc.php'; -$page->changeTpl($wiki_template); -if (!Env::get('action')) { - $page->addJsLink('javascript/wiki.js'); +if ($n = wiki_pagename()) { + $wiki_template = wiki_work_dir().'/cache_'.$n.'.tpl'; + $tmpfile_exists = file_exists($wiki_template); + + if (Env::get('action') || !$tmpfile_exists) { + if ($tmpfile_exists) { + @unlink($wiki_template); + $page->clear_compiled_tpl($wiki_template); + } + + // 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::get('action')) { + // clean old tmp files + wiki_clean_tmp(); + $page->assign('xorg_extra_header', substr($wikiAll, 0, $i)); + $page->addJsLink('javascript/wiki.js'); + + // create new tmp files with editing page from wiki engine + $wiki_template = wiki_create_tmp(substr($wikiAll, $j)); + } else { + if (!$tmpfile_exists) { + $f = fopen($wiki_template, 'w'); + fputs($f, substr($wikiAll, $j)); + fclose($f); + } + } } +$page->changeTpl($wiki_template); wiki_assign_auth(); $page->addCssLink('css/wiki.css'); diff --git a/include/wiki.inc.php b/include/wiki.inc.php index 7485093..04a43a1 100644 --- a/include/wiki.inc.php +++ b/include/wiki.inc.php @@ -72,7 +72,7 @@ function wiki_clean_tmp() { } function wiki_assign_auth() { - global $page, $wiki_auths; + global $page; $page->assign('true', true); $page->assign('public', true); $page->assign('logged', S::logged()); @@ -80,40 +80,4 @@ function wiki_assign_auth() { $page->assign('has_perms', S::has_perms()); } -// cannot be in a function because pmwiki use all vars as if it was globals -if ($n = wiki_pagename()) { - $wiki_template = wiki_work_dir().'/cache_'.$n.'.tpl'; - $tmpfile_exists = file_exists($wiki_template); - - if (Env::get('action') || !$tmpfile_exists) { - if ($tmpfile_exists) { - @unlink($wiki_template); - $page->clear_compiled_tpl($wiki_template); - } - - // 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::get('action')) { - // clean old tmp files - wiki_clean_tmp(); - $page->assign('xorg_extra_header', substr($wikiAll, 0, $i)); - - // create new tmp files with editing page from wiki engine - $wiki_template = wiki_create_tmp(substr($wikiAll, $j)); - } else { - if (!$tmpfile_exists) { - $f = fopen($wiki_template, 'w'); - fputs($f, substr($wikiAll, $j)); - fclose($f); - } - } -} ?> -- 2.1.4