1 <?php
2 /* vim: set expandtab tabstop=4 shiftwidth=4: */
3 // +----------------------------------------------------------------------+
4 // | PHP Version 4 |
5 // +----------------------------------------------------------------------+
6 // | Copyright (c) 1997-2003 The PHP Group |
7 // +----------------------------------------------------------------------+
8 // | This source file is subject to version 2.02 of the PHP license, |
9 // | that is bundled with this package in the file LICENSE, and is |
10 // | available at through the world-wide-web at |
11 // | http://www.php.net/license/2_02.txt. |
12 // | If you did not receive a copy of the PHP license and are unable to |
13 // | obtain it through the world-wide-web, please send a note to |
14 // | license@php.net so we can mail you a copy immediately. |
15 // +----------------------------------------------------------------------+
16 // | Author: Stijn de Reede <sjr@gmx.co.uk> |
17 // +----------------------------------------------------------------------+
18 //
19 // $Id: Email.php,v 1.5 2007/07/02 16:54:25 cweiske Exp $
20 //
21
22 /**
23 * @package sapphire
24 * @subpackage misc
25 * @author Stijn de Reede <sjr@gmx.co.uk>
26 */
27
28
29 /**
30 */
31 require_once 'HTML/BBCodeParser/Filter.php';
32
33
34
35
36 /**
37 * @package sapphire
38 * @subpackage misc
39 */
40 class SSHTMLBBCodeParser_Filter_EmailLinks extends SSHTMLBBCodeParser_Filter
41 {
42
43 /**
44 * An array of tags parsed by the engine
45 *
46 * @access private
47 * @var array
48 */
49 var $_definedTags = array( 'email' => array( 'htmlopen' => 'a',
50 'htmlclose' => 'a',
51 'allowed' => 'none^img',
52 'attributes'=> array('email' =>'href=%2$smailto:%1$s%2$s')
53
54 )
55 );
56
57
58 /**
59 * Executes statements before the actual array building starts
60 *
61 * This method should be overwritten in a filter if you want to do
62 * something before the parsing process starts. This can be useful to
63 * allow certain short alternative tags which then can be converted into
64 * proper tags with preg_replace() calls.
65 * The main class walks through all the filters and and calls this
66 * method if it exists. The filters should modify their private $_text
67 * variable.
68 *
69 * @return none
70 * @access private
71 * @see $_text
72 * @author Stijn de Reede <sjr@gmx.co.uk>
73 */
74 function _preparse()
75 {
76 $options = SSHTMLBBCodeParser::getStaticProperty('SSHTMLBBCodeParser','_options');
77 $o = $options['open'];
78 $c = $options['close'];
79 $oe = $options['open_esc'];
80 $ce = $options['close_esc'];
81 $pattern = array( "!(^|\s)([-a-z0-9_.]+@[-a-z0-9.]+\.[a-z]{2,4})!i",
82 "!".$oe."email(".$ce."|\s.*".$ce.")(.*)".$oe."/email".$ce."!Ui");
83 $replace = array( "\\1".$o."email=\\2".$c."\\2".$o."/email".$c,
84 $o."email=\\2\\1\\2".$o."/email".$c);
85 $this->_preparsed = preg_replace($pattern, $replace, $this->_text);
86 }
87
88
89 }
90
91
92 ?>
93