[ PHPXref.com ] [ Generated: Sun Jul 20 16:35:25 2008 ] [ bBlog 0.7.6 ]
[ Index ]     [ Variables ]     [ Functions ]     [ Classes ]     [ Constants ]     [ Statistics ]

title

Body

[close]

/bblog/bBlog_plugins/ -> modifier.simple.php (source)

   1  <?php
   2  /*
   3  ** bBlog Weblog http://www.bblog.com/
   4  ** Copyright (C) 2003  Eaden McKee <email@eadz.co.nz>
   5  **
   6  ** This program is free software; you can redistribute it and/or modify
   7  ** it under the terms of the GNU General Public License as published by
   8  ** the Free Software Foundation; either version 2 of the License, or
   9  ** (at your option) any later version.
  10  **
  11  ** This program is distributed in the hope that it will be useful,
  12  ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  13  ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14  ** GNU General Public License for more details.
  15  **
  16  ** You should have received a copy of the GNU General Public License
  17  ** along with this program; if not, write to the Free Software
  18  ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  19  */
  20  function identify_modifier_simple () {
  21      return array (
  22      'name'           =>'simple',
  23      'type'             =>'modifier',
  24      'nicename'     =>'Newlines and URLS',
  25      'description'   =>'Converts breaks to newlines and URLs into clickable links',
  26      'authors'        =>'Eaden McKee, phpBB Authors',
  27      'licence'         =>'GPL',
  28      'help'        => 'This is a simple modifier that simply converts new lines ( returns ) into html breaks, any urls ( e.g. http://www.bblog.com/ or www.bblog.com into clickable links.'
  29    );
  30  }
  31  ////
  32  // !a simple modifier combining nl2br and make clickable
  33  function smarty_modifier_simple ($ret) {
  34                  // pad it with a space so we can match things at the start of the 1st line.
  35      $ret = ' ' . $ret;
  36  
  37      // matches an "xxxx://yyyy" URL at the start of a line, or after a space.
  38      // xxxx can only be alpha characters.
  39      // yyyy is anything up to the first space, newline, comma, double quote or <
  40      $ret = preg_replace("#([\t\r\n ])([a-z0-9]+?){1}://([\w\-]+\.([\w\-]+\.)*[\w]+(:[0-9]+)?(/[^ \"\n\r\t<]*)?)#i", '\1<a href="\2://\3" target="_blank">\2://\3</a>', $ret);
  41  
  42      // matches a "www|ftp.xxxx.yyyy[/zzzz]" kinda lazy URL thing
  43      // Must contain at least 2 dots. xxxx contains either alphanum, or "-"
  44      // zzzz is optional.. will contain everything up to the first space, newline,
  45      // comma, double quote or <.
  46      $ret = preg_replace("#([\t\r\n ])(www|ftp)\.(([\w\-]+\.)*[\w]+(:[0-9]+)?(/[^ \"\n\r\t<]*)?)#i", '\1<a href="http://\2.\3" target="_blank">\2.\3</a>', $ret);
  47  
  48      // matches an email@domain type address at the start of a line, or after a space.
  49      // Note: Only the followed chars are valid; alphanums, "-", "_" and or ".".
  50      $ret = preg_replace("#([\n ])([a-z0-9\-_.]+?)@([\w\-]+\.([\w\-\.]+\.)*[\w]+)#i", "\\1<a href=\"mailto:\\2@\\3\">\\2@\\3</a>", $ret);
  51  
  52      // Remove our padding..
  53      $ret = substr($ret, 1);
  54  
  55       return nl2br($ret);
  56  }
  57  
  58  
  59  ?>


[ Powered by PHPXref - Served by Debian GNU/Linux ]