From 2f72c1fd6b77e6a901dd1839b087bca490c9f25d Mon Sep 17 00:00:00 2001 From: ahollosi Date: Wed, 8 Nov 2000 16:52:00 +0000 Subject: [PATCH] added named internal links e.g. [wow|FrontPage] -- patch idea from Antti Kaihola git-svn-id: svn://svn.code.sf.net/p/phpwiki/code/trunk@326 96ab9672-09ca-45d6-a79d-3d69d39ca109 --- lib/stdlib.php | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/lib/stdlib.php b/lib/stdlib.php index a915351e9..68ddc437f 100644 --- a/lib/stdlib.php +++ b/lib/stdlib.php @@ -1,5 +1,5 @@ $wikiword"; + if(empty($linktext)) + $linktext = htmlspecialchars($wikiword); + return "$linktext"; } - function LinkUnknownWikiWord($wikiword) { + function LinkUnknownWikiWord($wikiword, $linktext='') { global $ScriptUrl; $enc_word = rawurlencode($wikiword); - $wikiword = htmlspecialchars($wikiword); - return "$wikiword?"; + if(empty($linktext)) + $linktext = htmlspecialchars($wikiword); + return "$linktext?"; } function LinkURL($url) { @@ -465,7 +467,10 @@ $URL = trim($matches[3]); $linkname = htmlspecialchars(trim($matches[1])); // assert proper URL's - if (preg_match("#^($AllowedProtocols):#", $URL)) { + if (IsWikiPage($dbi, $URL)) { + $link['type'] = 'wiki-named'; + $link['link'] = LinkExistingWikiWord($URL, $linkname); + } elseif (preg_match("#^($AllowedProtocols):#", $URL)) { if (preg_match("/($InlineImages)$/i", $URL)) { $link['type'] = 'image-named'; $link['link'] = LinkImage($URL, $linkname); @@ -477,9 +482,8 @@ $link['type'] = 'url-wiki-named'; $link['link'] = "$linkname"; } else { - $link['type'] = 'url-bad'; - $link['link'] = "BAD URL -- links have to start with one" . - "of $AllowedProtocols followed by ':'"; + $link['type'] = 'wiki-unknown-named'; + $link['link'] = LinkUnknownWikiWord($URL, $linkname); } return $link; } -- 2.45.0