I had idea for an auto link finder for wikipedia when posting article, similar to trillians(the chat client) has as you type. I wrote some test code to test feasibility of making the module, and was able to get a simple and crude sample script working below. Of course, I left alot to anyone who would want to do this. For one, my strips existing formatting and does not go back and put the newly found article link in original. I suppose you could get around this by using a really nice regular expression that to account for html, code, and whatever else before inserting link. Also i could imagine it being implemented similar to the Glossary filter that puts the superscript I beside words found. One thing I have no idea how you could deal with is articles in reference to word found. I think possible ask user which he wants and doesn't. Again, I don't know that is possible to do with an input filter. Of course this was mostly a proof of concept. I am looking at possible writing this into either Windows Live Writer as a plugin or Xinha the WYSWYG editor, again as a plugin. I think it could be more useful there where the user to view article before posting and edit out wikipedia parts that don't apply.
<?php
//try to get info from wikipedia
define('WIKIPEDIAOS','http://en.wikipedia.org/w/api.php?action=opensearch&search=');
function in_arrayi($str, &$array){
$arrReturn = preg_grep('/(?i)'.$str.'/', $array);
return (is_array($arrReturn)) ? $arrReturn[0] : false;
}
function search_wikipedia($term)
{
$str=file_get_contents(WIKIPEDIAOS.$term);
$m = search_str_to_array($term,$str);
return in_arrayi($term,$m);
}
function search_str_to_array(&$term,&$str)
{
$str = substr($str,strlen($term)+4);
$matches = preg_split('/[\[",\]]/',$str,-1,PREG_SPLIT_NO_EMPTY);
return $matches;
}
function split_words(&$str)
{
$words = strip_tags($str);
$words = preg_split('/\W/',$words);
//now loop over words
foreach ($words as &$word)
{
if(strlen($word)>4)
{
$r=search_wikipedia($word);
if ($r)
{
$word="{$word}";
}
}
}
print implode(" ",$words);
}
$str = '
Launchy is a "keystroke" launcher for windows. Basically, it allows you to quickly launch programs by typing in a few keys of the name. Its works off a hotkey(alt +space), which birngs up a window where you can type a partial name of the intended application, and hit enter to launch. By default, Launchy indexes your desktop and start menu(it reads shortcut files), but it can be set to scan any number of file types and directories. So, for instance, you could have it set to scan all your mp3s and quick launch your favorite song quickly without ever going to windows explorer or your media player. I\'ve been using Launchy for nearly 6 months now, and I can say it has truly changed and improved my computer experience. Also, one aspect of my digital experience it has defiantly freed me from is my scouring start menus and directories for a program I haven\'t used in months. If I can remember part of the name, or even just the icon, I can find it on Launchy. Launchy is available for free over at http://www.launchy.net/, so go get your copy today.