From: Reini U. <ru...@us...> - 2004-09-25 16:35:19
|
Update of /cvsroot/phpwiki/phpwiki/lib/plugin In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30834 Modified Files: UnfoldSubpages.php PageGroup.php IncludePage.php Log Message: use stdlib firstNWordsOfContent, extractSection Index: UnfoldSubpages.php =================================================================== RCS file: /cvsroot/phpwiki/phpwiki/lib/plugin/UnfoldSubpages.php,v retrieving revision 1.15 retrieving revision 1.16 diff -u -2 -b -p -d -r1.15 -r1.16 --- UnfoldSubpages.php 3 Jul 2004 14:48:18 -0000 1.15 +++ UnfoldSubpages.php 25 Sep 2004 16:35:09 -0000 1.16 @@ -73,48 +73,4 @@ extends WikiPlugin } - // from IncludePage - function firstNWordsOfContent($n, $content) { - $wordcount = 0; - $new = array( ); - foreach ($content as $line) { - $words = explode(' ', $line); - if ($wordcount + count($words) > $n) { - $new[] = implode(' ', array_slice($words, 0, $n - $wordcount)) - . sprintf(_("... first %d words"), $n); - return $new; - } - else { - $wordcount += count($words); - $new[] = $line; - } - } - return $new; - } - - //TODO: move this to stdlib.php - function extractSection ($section, $content, $page, $quiet, $sectionhead) { - $qsection = preg_replace('/\s+/', '\s+', preg_quote($section, '/')); - - if (preg_match("/ ^(!{1,})\\s*$qsection" // section header - . " \\s*$\\n?" // possible blank lines - . " ( (?: ^.*\\n? )*? )" // some lines - . " (?= ^\\1 | \\Z)/xm", // sec header (same - // or higher level) - // (or EOF) - implode("\n", $content), - $match)) { - // Strip trailing blanks lines and ---- <hr>s - $text = preg_replace("/\\s*^-{4,}\\s*$/m", "", $match[2]); - if ($sectionhead) - $text = $match[1] . $section ."\n". $text; - return explode("\n", $text); - } - if ($quiet) - $mesg = $page ." ". $section; - else - $mesg = $section; - return array(sprintf(_("<%s: no such section>"), $mesg)); - } - function run($dbi, $argstr, &$request, $basepage) { static $included_pages = false; @@ -156,5 +112,5 @@ extends WikiPlugin } if ($section) - $c = $this->extractSection($section, $c, $page, $quiet, + $c = extractSection($section, $c, $page, $quiet, $sectionhead); if ($lines) @@ -162,5 +118,5 @@ extends WikiPlugin . sprintf(_(" ... first %d lines"), $bytes); if ($words) - $c = $this->firstNWordsOfContent($words, $c); + $c = firstNWordsOfContent($words, $c); if ($bytes) { if (strlen($c) > $bytes) @@ -197,4 +153,7 @@ extends WikiPlugin // $Log$ +// Revision 1.16 2004/09/25 16:35:09 rurban +// use stdlib firstNWordsOfContent, extractSection +// // Revision 1.15 2004/07/03 14:48:18 rurban // Tested new mysql 4.1.3-beta: binary search bug as fixed. Index: PageGroup.php =================================================================== RCS file: /cvsroot/phpwiki/phpwiki/lib/plugin/PageGroup.php,v retrieving revision 1.8 retrieving revision 1.9 diff -u -2 -b -p -d -r1.8 -r1.9 --- PageGroup.php 14 Jun 2004 11:31:39 -0000 1.8 +++ PageGroup.php 25 Sep 2004 16:35:09 -0000 1.9 @@ -65,5 +65,5 @@ extends WikiPlugin // Stolen from IncludePage.php - function extractSection ($section, $content, $page) { + function extractGroupSection ($section, $content, $page) { $qsection = preg_replace('/\s+/', '\s+', preg_quote($section, '/')); if (preg_match("/ ^(!{1,})\\s*$qsection" // section header @@ -138,5 +138,5 @@ extends WikiPlugin $c = $r->getContent(); - $c = $this->extractSection($section, $c, $parent); + $c = $this->extractGroupSection($section, $c, $parent); $pagename = $request->getArg('pagename'); @@ -211,4 +211,7 @@ extends WikiPlugin // $Log$ +// Revision 1.9 2004/09/25 16:35:09 rurban +// use stdlib firstNWordsOfContent, extractSection +// // Revision 1.8 2004/06/14 11:31:39 rurban // renamed global $Theme to $WikiTheme (gforge nameclash) Index: IncludePage.php =================================================================== RCS file: /cvsroot/phpwiki/phpwiki/lib/plugin/IncludePage.php,v retrieving revision 1.25 retrieving revision 1.26 diff -u -2 -b -p -d -r1.25 -r1.26 --- IncludePage.php 8 Jul 2004 20:30:07 -0000 1.25 +++ IncludePage.php 25 Sep 2004 16:35:09 -0000 1.26 @@ -55,43 +55,4 @@ extends WikiPlugin } - function firstNWordsOfContent( $n, $content ) { - $wordcount = 0; - $new = array( ); - foreach ($content as $line) { - $words = explode(' ', $line); - if ($wordcount + count($words) > $n) { - $new[] = implode(' ', array_slice($words, 0, $n - $wordcount)) - . "... (first $n words)"; - return $new; - } else { - $wordcount += count($words); - $new[] = $line; - } - } - return $new; - } - - function extractSection ($section, $content, $page, $quiet, $sectionhead) { - $qsection = preg_replace('/\s+/', '\s+', preg_quote($section, '/')); - - if (preg_match("/ ^(!{1,})\\s*$qsection" // section header - . " \\s*$\\n?" // possible blank lines - . " ( (?: ^.*\\n? )*? )" // some lines - . " (?= ^\\1 | \\Z)/xm", // sec header (same or higher level) (or EOF) - implode("\n", $content), - $match)) { - // Strip trailing blanks lines and ---- <hr>s - $text = preg_replace("/\\s*^-{4,}\\s*$/m", "", $match[2]); - if ($sectionhead) - $text = $match[1] . $section ."\n". $text; - return explode("\n", $text); - } - if ($quiet) - $mesg = $page ." ". $section; - else - $mesg = $section; - return array(sprintf(_("<%s: no such section>"), $mesg)); - } - function getWikiPageLinks($argstr, $basepage) { extract($this->getArgs($argstr)); @@ -136,15 +97,12 @@ extends WikiPlugin $r = $p->getCurrentRevision(); } - $c = $r->getContent(); if ($section) - $c = $this->extractSection($section, $c, $page, $quiet, - $sectionhead); + $c = extractSection($section, $c, $page, $quiet, $sectionhead); if ($lines) $c = array_slice($c, 0, $lines); if ($words) - $c = $this->firstNWordsOfContent($words, $c); - + $c = firstNWordsOfContent($words, $c); array_push($included_pages, $page); @@ -192,4 +150,7 @@ extends WikiPlugin // $Log$ +// Revision 1.26 2004/09/25 16:35:09 rurban +// use stdlib firstNWordsOfContent, extractSection +// // Revision 1.25 2004/07/08 20:30:07 rurban // plugin->run consistency: request as reference, added basepage. |