]> CyberLeo.Net >> Repos - SourceForge/phpwiki.git/blob - lib/display.php
PhpWiki 1.2.7 backport cvs release-1_2-branch enhancements never released with 1...
[SourceForge/phpwiki.git] / lib / display.php
1 <?php
2    // display.php: fetch page or get default content
3    // calls transform.php for actual transformation of wiki markup to HTML
4    rcs_id('$Id: display.php,v 1.5.2.5 2005-01-07 14:23:04 rurban Exp $');
5  
6    // if we got GET data, the first item is always a page name
7    // if it wasn't this file would not have been included
8
9    if (empty($QUERY_STRING) && isset($argv[0]))
10       $QUERY_STRING = $argv[0];
11   
12    if (isset($QUERY_STRING) && preg_match('/^[-_.+%\w]+$/', $QUERY_STRING)) {
13       $pagename = urldecode($QUERY_STRING);
14    } elseif (isset($QUERY_STRING) && preg_match('/^([-_.+%\w]+)&.+$/', $QUERY_STRING, $m)) {
15       $pagename = urldecode($m[1]);
16    } else {
17       $pagename = gettext("FrontPage");
18
19       // if there is no FrontPage, create a basic set of Wiki pages
20       if (! IsWikiPage($dbi, $pagename)) {
21          include "lib/setupwiki.php";
22       }
23    }
24
25    $html = "";
26    $enc_name = rawurlencode($pagename);
27    $pagehash = RetrievePage($dbi, $pagename, $WikiPageStore);
28
29    // we render the page if it exists, else ask the user to write one.
30    if (is_array($pagehash)) {
31       // transform.php returns $html containing all the HTML markup
32       include("lib/transform.php");
33    } else {
34       $html .= sprintf(gettext("Describe %s here."),
35                        "$pagename<a href=\"$ScriptUrl?edit=$enc_name\">?</a>");
36    }
37
38    GeneratePage('BROWSE', $html, $pagename, $pagehash);
39    flush();
40
41    IncreaseHitCount($dbi, $pagename);
42 ?>