root/trunk/includes/smarty_plugins/modifier.linkalize.php

Revision 1, 1.6 KB (checked in by anonymous, 7 years ago)

initial import

Line 
1<?php
2/****************************************************** Open .node ***
3 * Description:   
4 * Status:        Stable.
5 * Author:        Alexandre Dath <alexandre@dotnode.com>
6 * $Id$
7 *
8 * Copyright (C) 2005 Alexandre Dath <alexandre@dotnode.com>
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software Foundation,
22 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
23 ******************** http://opensource.ikse.net/projects/dotnode ***/
24
25
26function smarty_modifier_linkalize($string)
27{
28    return linkalize($string);
29}
30
31 function linkalize($text, $string='link') {
32      $text = preg_replace("/([^\w\/])(www\.[a-z0-9\-]+\.[a-z0-9\-]+)/i", "$1http://$2", $text); //make sure there is anhttp:// on all URLs
33      $text = preg_replace("/([\w]+:\/\/[\w-?&;,#~=\.\/\@:]+[\w\/])/i", "(<a target=\"_blank\" href=\"$1\" class='link'>$string</a>)", $text); //make all URLs links
34
35      $text = preg_replace("/[\w-\.]+@(\w+[\w-]+\.){0,3}\w+[\w-]+\.[a-zA-Z]{2,4}\b/i","<a href=\"mailto:$0\" class='link'>$0</a>",$text);
36
37      return $text;
38}
39
40?>
Note: See TracBrowser for help on using the browser.