works like a charm, after the fixes..
but it has a real annoying bug.
If you use the tooltips , it replaces the keywords in the definitions.
Example (from a medical site)
2 keywords
ED => Erectile Dysfunction, medical treatment etc...
SF => Serotonine function is used to do this and that.
In the tooltips, the definition is parsed (has to be) but with keyword.
so you get:
Tooltip:
ED => Erectile DySFunction, mEDical treatment etc...
SF => Serotonine function is usED to do this and that.
If you have Like 100 definitions with 2 letters it gets really annoying.
I wrote a short fix... that seems to work.
in the install.xml (or the subs.php - for testing)
find:
$prefix = 'wgYBA1Mq@Xn8y#zWL';
foreach($arr_unique_words as $elem)
array_push($arr_prefixed_words,$prefix.$elem);
$words = array();
foreach($arr_unique_defs as $def){
array_push($arr_treated_defs,str_ireplace($arr_unique_words, $arr_prefixed_words, $def));
}
replace with:
$prefix = 'wgYBA1Mq@Xn8y#zWL';
//foreach($arr_unique_words as $elem)
// array_push($arr_prefixed_words,$prefix.$elem);
$words = array();
foreach($arr_unique_defs as $def)
{
foreach($arr_unique_words as $elem)
{
$def = preg_replace("@(.*)(".$elem.")(.*)@i",'$1'. $prefix .'$2$3', $def);
}
array_push($arr_treated_defs,$def);
}
Now i dont like nested foreach...
i didnt find a better way to do it.
The thing is.. you have to prefix all the keywords in the definitions, so you dont get nested span tags that would break the layout.
If someone has a better way... please post.
I am not to good at regex, but the best would be to leave that part out completely, and just do it with the final parsing in the final preg_match.
Like :
Skip all replacement within a span tag -> then do the replacement.
I tried, but my low regex skills made me fail, so I came up with this one.
Luc
PS: BTW.. I found a stupid bug.. when a word is in "double quotes" like "this".. it somehow breaks the layout...