Commit | Line | Data |
---|---|---|
6855525e JL |
1 | <?php |
2 | ||
3 | class Text_Wiki_Render_Latex_Wikilink extends Text_Wiki_Render { | |
4 | var $conf = array( | |
5 | 'pages' => array(), | |
6 | 'view_url' => 'http://example.com/index.php?page=%s', | |
7 | 'new_url' => 'http://example.com/new.php?page=%s', | |
8 | 'new_text' => '?' | |
9 | ); | |
10 | ||
11 | /** | |
12 | * | |
13 | * Renders a token into XHTML. | |
14 | * | |
15 | * @access public | |
16 | * | |
17 | * @param array $options The "options" portion of the token (second | |
18 | * element). | |
19 | * | |
20 | * @return string The text rendered from the token options. | |
21 | * | |
22 | */ | |
23 | ||
24 | function token($options) | |
25 | { | |
26 | // make nice variable names (page, anchor, text) | |
27 | extract($options); | |
28 | ||
29 | // are we checking page existence? | |
30 | $list =& $this->getConf('pages'); | |
31 | if (is_array($list)) { | |
32 | // yes, check against the page list | |
33 | $exists = in_array($page, $list); | |
34 | } else { | |
35 | // no, assume it exists | |
36 | $exists = true; | |
37 | } | |
38 | ||
39 | // convert *after* checking against page names so as not to mess | |
40 | // up what the user typed and what we're checking. | |
41 | $page = htmlspecialchars($page); | |
42 | $anchor = htmlspecialchars($anchor); | |
43 | $text = htmlspecialchars($text); | |
44 | ||
45 | $href = $this->getConf('view_url'); | |
46 | ||
47 | if (strpos($href, '%s') === false) { | |
48 | // use the old form (page-at-end) | |
49 | $href = $href . $page . $anchor; | |
50 | } else { | |
51 | // use the new form (sprintf format string) | |
52 | $href = sprintf($href, $page . $anchor); | |
53 | } | |
54 | ||
55 | // get the CSS class and generate output | |
56 | $css = $this->formatConf(' class="%s"', 'css'); | |
57 | return "$text\\footnote\{$href}"; | |
58 | } | |
59 | } | |
60 | ?> |