Subversion Repositories Applications.papyrus

Rev

Rev 1372 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
248 jpm 1
<?php
2
// $Id: Image.php,v 1.1 2005-01-20 19:43:20 jpm Exp $
3
 
4
 
5
/**
6
*
7
* This class implements a Text_Wiki_Parse to embed the contents of a URL
8
* inside the page.  Typically used to get script output.
9
*
10
* This rule is inherently not secure; it allows cross-site scripting to
11
* occur if the embedded output has <script> or other similar tags.  Be
12
* careful.
13
*
14
* In the future, we'll add a rule config options to set the base embed
15
* path so that it is limited to one directory.
16
*
17
* @author Paul M. Jones <pmjones@ciaweb.net>
18
*
19
* @package Text_Wiki
20
*
21
*/
22
 
23
class Text_Wiki_Parse_Image extends Text_Wiki_Parse {
24
 
25
 
26
    /**
27
    *
28
    * The regular expression used to find source text matching this
29
    * rule.
30
    *
31
    * @access public
32
    *
33
    * @var string
34
    *
35
    */
36
 
37
    var $regex = '/(\[\[image )(.+?)(\]\])/i';
38
 
39
 
40
    /**
41
    *
42
    * Generates a token entry for the matched text.  Token options are:
43
    *
44
    * 'src' => The image source, typically a relative path name.
45
    *
46
    * 'opts' => Any macro options following the source.
47
    *
48
    * @access public
49
    *
50
    * @param array &$matches The array of matches from parse().
51
    *
52
    * @return A delimited token number to be used as a placeholder in
53
    * the source text.
54
    *
55
    */
56
 
57
    function process(&$matches)
58
    {
59
        $pos = strpos($matches[2], ' ');
60
 
61
        if ($pos === false) {
62
            $options = array(
63
                'src' => $matches[2],
64
                'attr' => array());
65
        } else {
66
            // everything after the space is attribute arguments
67
            $options = array(
68
                'src' => substr($matches[2], 0, $pos),
69
                'attr' => $this->getAttrs(substr($matches[2], $pos+1))
70
            );
71
        }
72
 
73
        return $this->wiki->addToken($this->rule, $options);
74
    }
75
}
76
?>