Subversion Repositories Applications.papyrus

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
248 jpm 1
<?php
2
 
3
/**
4
*
5
* This class implements a Text_Wiki_Parse to add an anchor target name
6
* in the wiki page.
7
*
8
* @author Manuel Holtgrewe <purestorm at ggnore dot net>
9
*
10
* @author Paul M. Jones <pmjones at ciaweb dot net>
11
*
12
* @package Text_Wiki
13
*
14
*/
15
 
16
class Text_Wiki_Parse_Anchor extends Text_Wiki_Parse {
17
 
18
 
19
    /**
20
    *
21
    * The regular expression used to find source text matching this
22
    * rule.
23
    *
24
    * @access public
25
    *
26
    * @var string
27
    *
28
    */
29
 
30
    var $regex = '/(\[\[# )([-_A-Za-z0-9.]+?)( .+)?(\]\])/i';
31
 
32
 
33
    /**
34
    *
35
    * Generates a token entry for the matched text.  Token options are:
36
    *
37
    * 'text' => The full matched text, not including the <code></code> tags.
38
    *
39
    * @access public
40
    *
41
    * @param array &$matches The array of matches from parse().
42
    *
43
    * @return A delimited token number to be used as a placeholder in
44
    * the source text.
45
    *
46
    */
47
 
48
    function process(&$matches) {
49
 
50
        $name = $matches[2];
51
        $text = $matches[3];
52
 
53
        $start = $this->wiki->addToken(
54
            $this->rule,
55
            array('type' => 'start', 'name' => $name)
56
        );
57
 
58
        $end = $this->wiki->addToken(
59
            $this->rule,
60
            array('type' => 'end', 'name' => $name)
61
        );
62
 
63
        // done, place the script output directly in the source
64
        return $start . trim($text) . $end;
65
    }
66
}
67
?>