Topic: Wikipedia markup...?
Hi all;
I wanted to ask is there are any kind of mod which can display the key word in [[..]] and link that key workd to wikipedia?
Ex: i like to link "PUNBB" word to wikipedia then in text area i will type like this [[PUNBB]] and it will be linked to http://en.wikipedia.com/PUNBB
I though the code would look like this:
// $this->currentItem->body = preg_replace( "/\[\[(.+?)\|(.+?)\]\]/", "<a href=\"http://en.wikipedia.org/wiki/\\1\" target=\"_blank\" title=\"Wikipedia: \\2\">\\2</a>", $this->currentItem->body );
// $this->currentItem->more = preg_replace( "/\[\[(.+?)\|(.+?)\]\]/", "<a href=\"http://en.wikipedia.org/wiki/\\1\" target=\"_blank\" title=\"Wikipedia: \\2\">\\2</a>", $this->currentItem->more );
// $this->currentItem->body = preg_replace( "/\[\[(.+?)\]\]/", "<a href=\"http://en.wikipedia.org/wiki/\\1\" target=\"_blank\" title=\"Wikipedia: \\1\">\\1</a>", $this->currentItem->body );
// $this->currentItem->more = preg_replace( "/\[\[(.+?)\]\]/", "<a href=\"http://en.wikipedia.org/wiki/\\1\" target=\"_blank\" title=\"Wikipedia: \\1\">\\1</a>", $this->currentItem->more );
}
function wikiLink( $text ) {
$links = preg_match_all( "/(\[\[.+?\]\])/", $text, $wiki, PREG_SET_ORDER );
for( $i=0; $i<$links; $i++ ) {
$link = preg_match( "/^\[\[(.+?)\]\]$/", $wiki[$i][0], $item );
//$info .= $item[1];
$split = explode( "|", $item[1] );
if ( count($split) == 2 ) {
$linkage = "<a href=\"http://en.wikipedia.org/wiki/$split[0]\" target=\"_blank\" title=\"Wikipedia: $split[0]\">$split[1]</a>";
} else {
$linkage = "<a href=\"http://en.wikipedia.org/wiki/$split[0]\" target=\"_blank\" title=\"Wikipedia: $split[0]\">$split[0]</a>";
}
$text = str_replace( $item[0], $linkage, $text );
}
return($text);
any idea out there please?
Thanks