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: Images.php,v 1.8 2007/07/02 17:44:47 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 require_once 'HTML/BBCodeParser/Filter.php';
31
32 /**
33 * @package sapphire
34 * @subpackage misc
35 */
36 class SSHTMLBBCodeParser_Filter_Images extends SSHTMLBBCodeParser_Filter
37 {
38
39 /**
40 * An array of tags parsed by the engine
41 *
42 * @access private
43 * @var array
44 */
45 var $_definedTags = array(
46 'img' => array(
47 'htmlopen' => 'img',
48 'htmlclose' => '',
49 'allowed' => 'none',
50 'attributes'=> array(
51 'img' => 'src=%2$s%1$s%2$s',
52 'w' => 'width=%2$s%1$d%2$s',
53 'h' => 'height=%2$s%1$d%2$s',
54 'alt' => 'alt=%2$s%1$s%2$s',
55 )
56 )
57 );
58
59 /**
60 * Executes statements before the actual array building starts
61 *
62 * This method should be overwritten in a filter if you want to do
63 * something before the parsing process starts. This can be useful to
64 * allow certain short alternative tags which then can be converted into
65 * proper tags with preg_replace() calls.
66 * The main class walks through all the filters and and calls this
67 * method if it exists. The filters should modify their private $_text
68 * variable.
69 *
70 * @return none
71 * @access private
72 * @see $_text
73 * @author Stijn de Reede <sjr@gmx.co.uk>
74 */
75 function _preparse()
76 {
77 $options = SSHTMLBBCodeParser::getStaticProperty('SSHTMLBBCodeParser','_options');
78 $o = $options['open'];
79 $c = $options['close'];
80 $oe = $options['open_esc'];
81 $ce = $options['close_esc'];
82 $this->_preparsed = preg_replace(
83 "!".$oe."img(\s?.*)".$ce."(.*)".$oe."/img".$ce."!Ui",
84 $o."img=\"\$2\"\$1".$c.$o."/img".$c,
85 $this->_text);
86 }
87 }