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.18 2002-01-25 01:04:13 dairiki 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));
45 function displayPage(&$request, $tmpl = 'browse') {
46 $pagename = $request->getArg('pagename');
47 $version = $request->getArg('version');
48 $page = $request->getPage();
52 $revision = $page->getRevision($version);
54 NoSuchRevision($request, $page, $version);
57 $revision = $page->getCurrentRevision();
60 $splitname = split_pagename($pagename);
61 $pagetitle = HTML::a(array('href' => WikiURL(_("BackLinks"),
62 array('page' => $pagename)),
63 'class' => 'backlinks'),
65 $pagetitle->addTooltip(sprintf(_("BackLinks for %s"), $pagename));
69 include_once('lib/BlockParser.php');
71 $content = $BlockParser->parse($revision->getPackedContent());
73 $template = Template($tmpl, array('CONTENT' => $content));
76 $template = Template($tmpl, do_transform($revision->getContent()));
79 GeneratePage($template, $pagetitle, $revision,
80 array('ROBOTS_META' => 'index,follow',
81 'PAGE_DESCRIPTION' => GleanDescription($revision)));
83 $page->increaseHitCount();
91 // c-hanging-comment-ender-p: nil
92 // indent-tabs-mode: nil