1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
<?LassoScript //[
/*
#############################################################################################################
## Custom_tag: [text_to_url]
## Version: 1.1.1
## Date: 18-11-2005
## Author: Asle Benoni - asle@benoni.no || use it as you like but at your own risk ;-)
## Function: Takes a textinput containing URLs (HTTP, HTTPS, FTP) and email adresses and converts them to clickable links
## Platform: Lasso 7 and Lasso 6.
## Availability: FREE - but I would be glad to hear if you are using it or have suggestions/requests for changes
## -> and if you keep the author information here ;-)
##
## A simple tag to make URL and MAILTO links from a text input or field.
## It searches for any links beginning with "www..." and converts them to <a href> links.
## A link without "www" will also be clickable as long as there it starts with "http://"
## Of course it cannot decide if a text like "blueworld.com" is a URL.
## The tag should guess all kinds of weird URLS
## If the text includes i.ex. <a href="http://bw.com">Click here</a> links it does not treat them since
## these are hardcoded already and you don`t want to change them. It only treats obvious links that
## are not already clickable.
##
## Usage:
## text_to_url:'Please visit us at www.sample.com'
## -> Please visit us at <a href="http://www.sample.com">http://www.sample.com</a>
##
## text_to_url:'Please visit us at http://sample.com'
## -> Please visit us at <a href="http://sample.com">http://sample.com</a>
##
## text_to_url:'Please contact us at support@sample.com'
## -> Please visit us at <a href="mailto:support@sample.com">suppport@sample.com</a>
##
## If you want to leave out the "http://" in the link text you must change the value of local:'linktext'
##
#############################################################################################################
*/
define_tag: 'text_to_url_lp6', -Required='Field';
local:'urltext'= '';
local:'linktext'= '\\1'; // Change this value to '\\3' if you DO NOT want the link text to show a leading 'http://'
// First we change all "www.xx.xx" to "http://...."
#urltext = (String_ReplaceRegExp:#Field, -Find='((?<!://)www\\.)', -Replace='http://\\1', -EncodeNone);
// Then we change http://.... til clickable URLs (but NOT those already hardcoded i.ex. "<a href="http://sample.com"> Visit us </a>"
#urltext=(String_ReplaceRegExp:#urltext, -Find='((?<!"|>)(https?://|ftp://)((([A-Za-z0-9$_.+!*(),;/?:@&~=-])|%[A-Fa-f0-9]{2})+(#([a-zA-Z0-9][a-zA-Z0-9$_.+!*(),;/?:@&~=%-]*))?))', -Replace='<a href=\"\\1\">'+ #linktext +'</a>', -EncodeNone);
// Create email-links from found email
#urltext = (String_ReplaceRegExp:#urltext, -Find='([a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,4})', -Replace='<a href=\"mailto:\\1\"> \\1 </a>', -EncodeNone);
#urltext = (String_Replace: -Find='\n', -Replace='<br>\n', #urltext, -EncodeNone);
return: @#urltext;
/define_tag;
//]
?>
|