be90e7c45274002e4fb5283cda2dbccb874b6a0e
2 /***************************************************************************
3 * Copyright (C) 2003-2006 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 'xorg.inc.php';
25 if (!S
::identified()) {
26 XorgSession
::doAuth();
29 require_once 'wiki.inc.php';
31 if ($n = wiki_pagename()) {
32 $wiki_template = wiki_work_dir().'/cache_'.$n.'.tpl';
33 $tmpfile_exists = file_exists($wiki_template);
35 if (Env
::get('action') ||
!$tmpfile_exists) {
36 if ($tmpfile_exists) {
37 @unlink
($wiki_template);
38 $page->clear_compiled_tpl($wiki_template);
41 // we leave pmwiki do whatever it wants and store everything
43 require_once($globals->spoolroot
.'/wiki/pmwiki.php');
45 $wikiAll = ob_get_clean();
46 // the pmwiki skin we are using (almost empty) has these keywords:
47 $i = strpos($wikiAll, "<!--/HeaderText-->");
48 $j = strpos($wikiAll, "<!--/PageLeftFmt-->", $i);
51 if (Env
::get('action')) {
52 // clean old tmp files
54 $page->assign('xorg_extra_header', substr($wikiAll, 0, $i));
56 // create new tmp files with editing page from wiki engine
57 $wiki_template = wiki_create_tmp(substr($wikiAll, $j));
59 if (!$tmpfile_exists) {
60 $f = fopen($wiki_template, 'w');
61 fputs($f, substr($wikiAll, $j));
66 $page->changeTpl($wiki_template);
69 $page->addCssLink('css/wiki.css');