cvs: presentations /slides/powerpear/examples/htdocs Wiki.php
| From: | Stig Bakken | Date: | Tue, 26 Nov 2002 01:00:24 +0000 |
| Subject: | cvs: presentations /slides/powerpear/examples/htdocs Wiki.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-7599@lists.php.net to get a copy of this message | ||
ssb Mon Nov 25 20:00:24 2002 EDT
Modified files:
/presentations/slides/powerpear/examples/htdocs Wiki.php
Log:
* fix the "two macros per page" bug
Index: presentations/slides/powerpear/examples/htdocs/Wiki.php
diff -u presentations/slides/powerpear/examples/htdocs/Wiki.php:1.1
presentations/slides/powerpear/examples/htdocs/Wiki.php:1.2
--- presentations/slides/powerpear/examples/htdocs/Wiki.php:1.1 Mon Nov 4 02:05:12 2002
+++ presentations/slides/powerpear/examples/htdocs/Wiki.php Mon Nov 25 20:00:24 2002
@@ -16,6 +16,7 @@
function process($contents)
{
+ // First, substitute macros
if (preg_match_all('/{([a-z-]+)\s*([^}]*?)}/s', $contents, $matches)) {
list($strings, $funcs, $args) = $matches;
for ($i = 0; $i < sizeof($strings); $i++) {
@@ -23,18 +24,18 @@
$contents = str_replace($strings[$i], $replace, $contents);
}
}
- if (preg_match_all('#\b([A-Z]+[a-z]+[A-Z\d][A-Za-z\d]*)\b#s', $contents,
$matches)) {
- list($strings, $nodes) = $matches;
+ // Finally, add Wiki-links
+ if (preg_match_all('#(.*?)\b([A-Z]+[a-z]+[A-Z\d][A-Za-z\d]*)\b(.*?)#s',
$contents, $matches)) {
+ list(, $pre_text, $nodes, $post_text) = $matches;
$self = $_SERVER['SCRIPT_NAME'];
- for ($i = 0; $i < sizeof($strings); $i++) {
-// if (Wiki::nodeExists($nodes[$i])) {
- $spaced = Wiki::formatWord($nodes[$i]);
- $replace = "<a
href=\"{$self}/{$nodes[$i]}\">$spaced</a>";
- $contents = str_replace($strings[$i], $replace, $contents, 1);
-// }
+ $tmp = '';
+ for ($i = 0; $i < sizeof($nodes); $i++) {
+ $spaced = Wiki::formatWord($nodes[$i]);
+ $replace = "<a
href=\"{$self}/{$nodes[$i]}\">$spaced</a>";
+ $tmp .= $pre_text[$i] . $replace . $post_text[$i];
}
+ $contents = $tmp;
}
- //$contents = str_replace('@@@', "{$self}/", $contents);
return nl2br($contents);
}