Commit | Line | Data |
---|---|---|
6855525e JL |
1 | <?php |
2 | ||
3 | /** | |
4 | * | |
5 | * Parses for image placement. | |
6 | * | |
7 | * @category Text | |
8 | * | |
9 | * @package Text_Wiki | |
10 | * | |
11 | * @author Paul M. Jones <pmjones@php.net> | |
12 | * | |
13 | * @license LGPL | |
14 | * | |
15 | * @version $Id: Image.php,v 1.3 2005/02/23 17:38:29 pmjones Exp $ | |
16 | * | |
17 | */ | |
18 | ||
19 | /** | |
20 | * | |
21 | * Parses for image placement. | |
22 | * | |
23 | * @category Text | |
24 | * | |
25 | * @package Text_Wiki | |
26 | * | |
27 | * @author Paul M. Jones <pmjones@php.net> | |
28 | * | |
29 | */ | |
30 | ||
31 | class Text_Wiki_Parse_Image extends Text_Wiki_Parse { | |
32 | ||
33 | ||
34 | /** | |
35 | * | |
36 | * The regular expression used to find source text matching this | |
37 | * rule. | |
38 | * | |
39 | * @access public | |
40 | * | |
41 | * @var string | |
42 | * | |
43 | */ | |
44 | ||
45 | var $regex = '/(\[\[image )(.+?)(\]\])/i'; | |
46 | ||
47 | ||
48 | /** | |
49 | * | |
50 | * Generates a token entry for the matched text. Token options are: | |
51 | * | |
52 | * 'src' => The image source, typically a relative path name. | |
53 | * | |
54 | * 'opts' => Any macro options following the source. | |
55 | * | |
56 | * @access public | |
57 | * | |
58 | * @param array &$matches The array of matches from parse(). | |
59 | * | |
60 | * @return A delimited token number to be used as a placeholder in | |
61 | * the source text. | |
62 | * | |
63 | */ | |
64 | ||
65 | function process(&$matches) | |
66 | { | |
67 | $pos = strpos($matches[2], ' '); | |
68 | ||
69 | if ($pos === false) { | |
70 | $options = array( | |
71 | 'src' => $matches[2], | |
72 | 'attr' => array()); | |
73 | } else { | |
74 | // everything after the space is attribute arguments | |
75 | $options = array( | |
76 | 'src' => substr($matches[2], 0, $pos), | |
77 | 'attr' => $this->getAttrs(substr($matches[2], $pos+1)) | |
78 | ); | |
79 | } | |
80 | ||
81 | return $this->wiki->addToken($this->rule, $options); | |
82 | } | |
83 | } | |
84 | ?> |