![Smile :)](./images/smilies/icon_e_smile.gif)
I am setting up a new database system for my website, and the database has well over 3,000 entries in. The database contains information about many 3rd party drivers used in Windows.
Anyway, one of the fields in the database contains a URL to the driver manufactures support site to assist users in updating the drivers on their system. However, in that fields, we also have data that is not a URL. This causes issues. Due to the way AppGini parses URLs when the field behaviour is set to URL, all the text is turned into URLs, which causes issues. For example:
IMAGE
So what I need to do is be able to parse URLs from regular text and then hyperlink them.
Firstly I tried using Rich(HTML) boxes and adding html link tags, but that increased the size of the database dramatically, and as my other colleagues said, HTML in databases can pose security risks.
Therefore I tried using RegEx. However, I cannot get it to work. The RegEx I found online looks like this:
Code: Select all
function jAutoHyperlinkURLs($sInput, $sTarget = "_blank", $sClassName = "") {
return preg_replace("/\\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|]/i", "<a href=\"\\0\" target=\"$sTarget\" class=\"$sClassName\">\\0</a>", $sInput);
}
What I am unsure about is what to do with this. I tried making this hook:
Code: Select all
function drivers_before_insert(&$data, $memberInfo, &$args)
{
$data['source'] = preg_replace("/\\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|]/i", "\\0", $data['source']);
return TRUE;
}
So, I am coming to the forums for help. I know very little PHP (but give me a BSOD and I'll fix that for you!
![Very Happy :D](./images/smilies/icon_e_biggrin.gif)
![Smile :)](./images/smilies/icon_e_smile.gif)
If no one can think of a way to possibly do this, I think it would be a good idea for future releases, since I am sure I'm not the only one with the need to parse URLs from text. Lots of web software can do this, it is surely not too hard to implement. I feel that I've got close, but none of the above scripts have worked. I have purchased the full, pro version of AppGini.$html (passed by reference so that it can be modified inside this hook function) the HTML code of the form ready to be displayed. This could be useful for manipulating the code before displaying it using regular expressions, ... etc.
Thank you for your help in advance.