Properly fix htmlspecialchars.
[diogenes.git] / include / Text / Wiki / Render / Xhtml / Phplookup.php
CommitLineData
6855525e
JL
1<?php
2
3// $Id: Phplookup.php,v 1.7 2004/09/25 19:05:14 pmjones Exp $
4
5class Text_Wiki_Render_Xhtml_Phplookup extends Text_Wiki_Render {
6
7 var $conf = array(
8 'target' => '_blank',
9 'css' => null
10 );
11
12
13 /**
14 *
15 * Renders a token into text matching the requested format.
16 *
17 * @access public
18 *
19 * @param array $options The "options" portion of the token (second
20 * element).
21 *
22 * @return string The text rendered from the token options.
23 *
24 */
25
26 function token($options)
27 {
28 $text = trim($options['text']);
29 $css = $this->formatConf(' class="%s"', 'css');
30
31 // start the html
32 $output = "<a$css";
33
34 // are we targeting another window?
35 $target = $this->getConf('target', '');
36 if ($target) {
37 // use a "popup" window. this is XHTML compliant, suggested by
38 // Aaron Kalin. uses the $target as the new window name.
60181dfb 39 $target = htmlspecialchars($target, ENT_COMPAT | ENT_HTML401, "ISO-8859-1");
6855525e
JL
40 $output .= " onclick=\"window.open(this.href, '$target');";
41 $output .= " return false;\"";
42 }
43
44 // take off the final parens for functions
45 if (substr($text, -2) == '()') {
46 $q = substr($text, 0, -2);
47 } else {
48 $q = $text;
49 }
50
60181dfb
RB
51 $q = htmlspecialchars($q, ENT_COMPAT | ENT_HTML401, "ISO-8859-1");
52 $text = htmlspecialchars($text, ENT_COMPAT | ENT_HTML401, "ISO-8859-1");
6855525e
JL
53
54 // finish and return
55 $output .= " href=\"http://php.net/$q\">$text</a>";
56 return $output;
57 }
58}
60181dfb 59?>