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.13 2002-01-09 17:30:39 carstenklapp Exp $');
6 require_once('lib/Template.php');
7 require_once('lib/transform.php');
10 * Guess a short description of the page.
14 * This algorithm was suggested on MeatballWiki by
15 * Alex Schroeder <kensanata@yahoo.com>.
17 * Use the first paragraph in the page which contains at least two
20 * @see http://www.usemod.com/cgi-bin/mb.pl?MeatballWikiSuggestions
22 function GleanDescription ($rev) {
24 = pcre_fix_posix_classes("/[.?!]\s+[[:upper:])]"
26 . "[.?!]\s*([[:upper:])]|$)/sx");
28 $content = $rev->getPackedContent();
30 // Iterate through paragraphs.
31 while (preg_match('/(?: ^ \w .* $ \n? )+/mx', $content, $m)) {
34 // Return paragraph if it contains at least two sentences.
35 if (preg_match($two_sentences, $paragraph)) {
36 return preg_replace("/\s*\n\s*/", " ", trim($paragraph));
39 $content = substr(strstr($content, $paragraph), strlen($paragraph));
44 function displayPage($dbi, $request) {
45 $pagename = $request->getArg('pagename');
46 $version = $request->getArg('version');
48 $page = $dbi->getPage($pagename);
50 $revision = $page->getRevision($version);
52 NoSuchRevision($page, $version);
55 $revision = $page->getCurrentRevision();
58 $template = new WikiTemplate('BROWSE');
59 $template->setPageRevisionTokens($revision);
60 $template->replace('CONTENT', do_transform($revision->getContent()));
61 $template->qreplace('PAGE_DESCRIPTION', GleanDescription($revision));
62 echo $template->getExpansion();
64 $page->increaseHitCount();
72 // c-hanging-comment-ender-p: nil
73 // indent-tabs-mode: nil