From: Arno H. <aho...@us...> - 2001-02-08 10:29:24
|
Update of /cvsroot/phpwiki/phpwiki/lib In directory usw-pr-cvs1:/tmp/cvs-serv25024 Modified Files: config.php stdlib.php transform.php Added Files: interwiki.map Log Message: added InterWiki linking based on patch by Gary Benson <ga...@ee...> --- NEW FILE --- Wiki http://c2.com/cgi/wiki? PPR http://c2.com/cgi/wiki? C2find http://c2.com/cgi/wiki?FindPage&value= ZWiki http://www.zwiki.org/ OrgPatterns http://www.bell-labs.com/cgi-user/OrgPatterns/OrgPatterns? FoxWiki http://fox.wikis.com/wc.dll?Wiki~ PhpWiki http://phpwiki.sourceforge.net/phpwiki/index.php? DejaNews http://www.deja.com/=dnc/getdoc.xp?AN= MuWeb http://www.dunstable.com/scripts/MuWebWeb? PyWiki http://www.voght.com/cgi-bin/pywiki? Squeak http://minnow.cc.gatech.edu/squeak/ UseMod http://www.usemod.com/cgi-bin/wiki.pl? MeatBall http://www.usemod.com/cgi-bin/mb.pl? MbTest http://www.usemod.com/cgi-bin/mbtest.pl? HammondWiki http://www.dairiki.org/HammondWiki/index.php3? Advogato http://www.advogato.org/ MoinMoin http://www.encrypted.net/~jh/moinmoin/moin.cgi/ EfnetPythonWiki http://www.encrypted.net/~jh/python-wiki/moin.cgi/ EfnetCppWiki http://www.encrypted.net/~jh/cpp-wiki/moin.cgi/ EfnetXmlWiki http://www.encrypted.net/~jh/xml-wiki/moin.cgi/ PolitizenWiki http://www.politizen.com/wiki.asp? DolphinWiki http://www.object-arts.com/wiki/html/Dolphin/ LegoWiki http://www.object-arts.com/wiki/html/Lego-Robotics/ TWiki http://twiki.sourceforge.net/cgi-bin/view/ VisualWorks http://wiki.cs.uiuc.edu/VisualWorks/ StrikiWiki http://ch.twi.tudelft.nl/~mostert/striki/teststriki.pl? BridgesWiki http://c2.com/w2/bridges/ IMDB http://us.imdb.com/Title? JiniWiki http://www.cdegroot.com/cgi-bin/jini? Dictionary http://www.dictionary.com/cgi-bin/dict.pl?term= AndStuff http://andstuff.org/wiki.php? PythonInfo http://www.python.org/cgi-bin/moinmoin/ CreationMatters http://www.ourpla.net/cgi-bin/wiki.pl? CmWiki http://www.ourpla.net/cgi-bin/wiki.pl? BenefitsWiki http://www.benefitslink.com/cgi-bin/wiki.cgi? Why http://clublet.com/c/c/why? SenseisLibrary http://senseis.xmp.net/? Index: config.php =================================================================== RCS file: /cvsroot/phpwiki/phpwiki/lib/config.php,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -r1.25 -r1.26 *** config.php 2001/02/07 22:14:35 1.25 --- config.php 2001/02/08 10:29:44 1.26 *************** *** 173,176 **** --- 173,188 ---- + // InterWiki linking -- wiki-style links to other wikis on the web + // Set InterWikiLinking to 1 if you would like to enable this feature + $InterWikiLinking = 0; + + if ($InterWikiLinking) { + // Intermap file for InterWikiLinks -- define other wikis there + $interwikimap_file = "lib/interwiki.map"; + + include ('lib/interwiki.php'); + // sets also $InterWikiLinkRegexp + } + ///////////////////////////////////////////////////////////////////// Index: stdlib.php =================================================================== RCS file: /cvsroot/phpwiki/phpwiki/lib/stdlib.php,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -r1.24 -r1.25 *** stdlib.php 2001/02/07 22:14:35 1.24 --- stdlib.php 2001/02/08 10:29:44 1.25 *************** *** 4,11 **** Standard functions for Wiki functionality ExitWiki($errormsg) ! LinkExistingWikiWord($wikiword) ! LinkUnknownWikiWord($wikiword) LinkURL($url, $linktext) LinkImage($url, $alt) RenderQuickSearch($value) RenderFullSearch($value) --- 4,12 ---- Standard functions for Wiki functionality ExitWiki($errormsg) ! LinkExistingWikiWord($wikiword, $linktext) ! LinkUnknownWikiWord($wikiword, $linktext) LinkURL($url, $linktext) LinkImage($url, $alt) + LinkInterWikiLink($link, $linktext) RenderQuickSearch($value) RenderFullSearch($value) *************** *** 76,79 **** --- 77,91 ---- } + function LinkInterWikiLink($link, $linktext='') { + global $interwikimap; + + list( $wiki, $page ) = split( ":", $link ); + if(empty($linktext)) + $linktext = htmlspecialchars($link); + $page = urlencode($page); + return "<a href=\"$interwikimap[$wiki]$page\">$linktext</a>"; + } + + function ParseAdminTokens($line) { global $ScriptUrl; *************** *** 131,134 **** --- 143,147 ---- function ParseAndLink($bracketlink) { global $dbi, $ScriptUrl, $AllowedProtocols, $InlineImages; + global $InterWikiLinking, $InterWikiLinkRegexp; // $bracketlink will start and end with brackets; in between *************** *** 172,175 **** --- 185,192 ---- $link['type'] = "footnote-$linktype"; $link['link'] = $URL; + } elseif ($InterWikiLinking && + preg_match("#^$InterWikiLinkRegexp:#", $URL)) { + $link['type'] = "interwiki-$linktype"; + $link['link'] = LinkInterWikiLink($URL, $linkname); } else { $link['type'] = "wiki-unknown-$linktype"; Index: transform.php =================================================================== RCS file: /cvsroot/phpwiki/phpwiki/lib/transform.php,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -r1.11 -r1.12 *** transform.php 2001/02/07 17:21:33 1.11 --- transform.php 2001/02/08 10:29:44 1.12 *************** *** 199,202 **** --- 199,205 ---- $transform->register(WT_TOKENIZER, 'wtt_bracketlinks'); $transform->register(WT_TOKENIZER, 'wtt_urls'); + if ($InterWikiLinking) { + $transform->register(WT_TOKENIZER, 'wtt_interwikilinks'); + } $transform->register(WT_TOKENIZER, 'wtt_bumpylinks'); *************** *** 318,321 **** --- 321,349 ---- return $line; } + + + + // Link InterWiki links + // These can be protected by a '!' like Wiki words. + function wtt_interwikilinks($line, &$trfrm) + { + global $InterWikiLinkRegexp, $WikiNameRegexp; + + $n = $ntok = $trfrm->tokencounter; + $line = wt_tokenize($line, "!?(?<![A-Za-z0-9])$InterWikiLinkRegexp:$WikiNameRegexp", $trfrm->replacements, $ntok); + while ($n < $ntok) { + $old = $trfrm->replacements[$n]; + if ($old[0] == '!') { + $trfrm->replacements[$n] = substr($old,1); + } else { + $trfrm->replacements[$n] = LinkInterWikiLink($old); + } + $n++; + } + + $trfrm->tokencounter = $ntok; + return $line; + } + // Link Wiki words (BumpyText) |