I found a good script, but I need help to chage its usage.
It basically uses a text file to search keywords, and if found it links the word with the url from the text file, and give the link a little definition. The text file has each keyword in a separate line in thae following form:
keyword|URL|definition
I need to remove the URL part, and replace the url with:
<u class=info>keyword<span>definition</span></u>
(It uses a nice CSS rule to give pure CSS tooltips)
Here is the php script:
PHP Code:
<?
/*
Word2URL Modification (Version 1.52)
Programmed by: primetime
Module Id: 1060805578
Bugfix: 001
------------------------
This script cannot be distributed without the permission of the original author.
*/
class Word2URL
{
function openData($txt)
{
global $ibforums;
if(!isset($ibforums->input['preview']))
{
$i = 0;
$data = file('./mods/word2url.txt');
foreach($data as $line)
{
list($key[$i], $link[$i], $tooltip[$i]) = explode("|", $line);
// Clean up the data before we do anything nasty to it
$key[$i] = preg_quote(trim($key[$i]), "/");
$link[$i] = trim($link[$i]);
$tooltip[$i] = trim($tooltip[$i]);
// Search the text for the "keywords" and auto-link them
if($key[$i] != "")
{
$txt = preg_replace("#\b".$key[$i]."\b#is", "[autolink]\\0[/autolink]", $txt);
$txt = preg_replace("#\[url.+?\[\/url\]#ies", "Word2URL::cleanUp('\\0')", $txt);
$txt = preg_replace("#\[autolink\]".$key[$i]."\[\/autolink\]\.com#ies", "Word2URL::cleanUp('\\0')", $txt);
$txt = preg_replace("#<.+".$key[$i].".+>#ies", "Word2URL::cleanUp('\\0')", $txt);
$txt = preg_replace("#\[autolink\]".$key[$i]."\[\/autolink\]#ies", "Word2URL::createLink('\\0', '$link[$i]', '$tooltip[$i]')", $txt);
}
$i++;
}
$txt = Word2URL::cleanUp($txt);
}
return $txt;
}
function createLink($key, $url, $def)
{
if($key != "")
{
return "<!--WORD2URL-01--><a href='".$url."' title='".$def."' target='_blank'><!--END WORD2URL-01-->".$key."<!--WORD2URL-02--></a><!--END WORD2URL-02-->";
}
else
return $key;
}
function unLink($txt)
{
$txt = preg_replace("#<!--WORD2URL-01-->.+?<!--END WORD2URL-01-->#is", "", $txt);
$txt = preg_replace("#<!--WORD2URL-02-->.+?<!--END WORD2URL-02-->#is", "", $txt);
return $txt;
}
function cleanUp($txt)
{
$txt = preg_replace("#\[autolink\]#is", "", $txt);
$txt = preg_replace("#\[\/autolink\]#is", "", $txt);
return $txt;
}
}
?>