Update of /cvsroot/phpwiki/phpwiki/lib
In directory usw-pr-cvs1:/tmp/cvs-serv9145/lib
Modified Files:
config.php display.php Template.php
Log Message:
Name the wiki (SF task #34142).
New config define: WIKI_NAME, which is used to generate a KEYWORDS
meta tag, and also for the channel title in RSS output.
Index: config.php
===================================================================
RCS file: /cvsroot/phpwiki/phpwiki/lib/config.php,v
retrieving revision 1.46
retrieving revision 1.47
diff -C2 -r1.46 -r1.47
*** config.php 2001/11/29 03:00:19 1.46
--- config.php 2001/12/11 22:41:39 1.47
***************
*** 268,271 ****
--- 268,275 ----
}
+ if (!defined('WIKI_NAME')) {
+ define('WIKI_NAME', "An unnamed PhpWiki");
+ }
+
// FIXME: delete
// Access log
Index: display.php
===================================================================
RCS file: /cvsroot/phpwiki/phpwiki/lib/display.php,v
retrieving revision 1.11
retrieving revision 1.12
diff -C2 -r1.11 -r1.12
*** display.php 2001/09/19 03:24:36 1.11
--- display.php 2001/12/11 22:41:40 1.12
***************
*** 7,10 ****
--- 7,44 ----
require_once('lib/transform.php');
+ /**
+ * Guess a short description of the page.
+ *
+ * Algorithm:
+ *
+ * This algorithm was suggested on MeatballWiki by
+ * Alex Schroeder <ken...@ya...>.
+ *
+ * Use the first paragraph in the page which contains at least two sentences.
+ *
+ * @see http://www.usemod.com/cgi-bin/mb.pl?MeatballWikiSuggestions
+ */
+ function GleanDescription ($rev) {
+ $two_sentences
+ = pcre_fix_posix_classes("/[.?!]\s+[[:upper:])]"
+ . ".*"
+ . "[.?!]\s*([[:upper:])]|$)/sx");
+
+ $content = $rev->getPackedContent();
+
+ // Iterate through paragraphs.
+ while (preg_match('/(?: ^ \w .* $ \n? )+/mx', $content, $m)) {
+ $paragraph = $m[0];
+
+ // Return paragraph if it contains at least two sentences.
+ if (preg_match($two_sentences, $paragraph)) {
+ return preg_replace("/\s*\n\s*/", " ", trim($paragraph));
+ }
+
+ $content = substr(strstr($content, $paragraph), strlen($paragraph));
+ }
+ return '';
+ }
+
function displayPage($dbi, $request) {
$pagename = $request->getArg('pagename');
***************
*** 24,27 ****
--- 58,62 ----
$template->setPageRevisionTokens($revision);
$template->replace('CONTENT', do_transform($revision->getContent()));
+ $template->qreplace('PAGE_DESCRIPTION', GleanDescription($revision));
echo $template->getExpansion();
flush();
Index: Template.php
===================================================================
RCS file: /cvsroot/phpwiki/phpwiki/lib/Template.php,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -r1.4 -r1.5
*** Template.php 2001/11/29 02:59:21 1.4
--- Template.php 2001/12/11 22:41:40 1.5
***************
*** 277,280 ****
--- 277,281 ----
$this->qreplace('BROWSE', WikiURL(''));
$this->qreplace('CSS_URL', DataURL(CSS_URL));
+ $this->qreplace('WIKI_NAME', WIKI_NAME);
if (isset($user))
|