| 1 | <?php |
| 2 | /*************************************************************************** |
| 3 | * Copyright (C) 2003-2006 Polytechnique.org * |
| 4 | * http://opensource.polytechnique.org/ * |
| 5 | * * |
| 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. * |
| 10 | * * |
| 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. * |
| 15 | * * |
| 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 * |
| 18 | * Foundation, Inc., * |
| 19 | * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * |
| 20 | ***************************************************************************/ |
| 21 | |
| 22 | require_once 'xorg.inc.php'; |
| 23 | |
| 24 | new_skinned_page(''); |
| 25 | if (!S::identified()) { |
| 26 | XorgSession::doAuth(); |
| 27 | } |
| 28 | |
| 29 | require_once 'wiki.inc.php'; |
| 30 | |
| 31 | if ($n = wiki_pagename()) { |
| 32 | $wiki_template = wiki_work_dir().'/cache_'.$n.'.tpl'; |
| 33 | $tmpfile_exists = file_exists($wiki_template); |
| 34 | |
| 35 | if (Env::get('action') || !$tmpfile_exists) { |
| 36 | if ($tmpfile_exists) { |
| 37 | @unlink($wiki_template); |
| 38 | $page->clear_compiled_tpl($wiki_template); |
| 39 | } |
| 40 | |
| 41 | // we leave pmwiki do whatever it wants and store everything |
| 42 | ob_start(); |
| 43 | require_once($globals->spoolroot.'/wiki/pmwiki.php'); |
| 44 | |
| 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); |
| 49 | } |
| 50 | |
| 51 | if (Env::get('action')) { |
| 52 | // clean old tmp files |
| 53 | wiki_clean_tmp(); |
| 54 | $page->assign('xorg_extra_header', substr($wikiAll, 0, $i)); |
| 55 | |
| 56 | // create new tmp files with editing page from wiki engine |
| 57 | $wiki_template = wiki_create_tmp(substr($wikiAll, $j)); |
| 58 | } else { |
| 59 | if (!$tmpfile_exists) { |
| 60 | $f = fopen($wiki_template, 'w'); |
| 61 | fputs($f, substr($wikiAll, $j)); |
| 62 | fclose($f); |
| 63 | } |
| 64 | } |
| 65 | } |
| 66 | $page->changeTpl($wiki_template); |
| 67 | |
| 68 | wiki_assign_auth(); |
| 69 | $page->addCssLink('css/wiki.css'); |
| 70 | |
| 71 | $page->run(); |
| 72 | ?> |