4 class Text_Wiki_Render_Xhtml_Url
extends Text_Wiki_Render
{
10 'img_ext' => array('jpg', 'jpeg', 'gif', 'png'),
12 'css_footnote' => null
,
19 * Renders a token into text matching the requested format.
23 * @param array $options The "options" portion of the token (second
26 * @return string The text rendered from the token options.
30 function token($options)
32 // create local variables from the options array (text,
36 // find the rightmost dot and determine the filename
38 $pos = strrpos($href, '.');
39 $ext = strtolower(substr($href, $pos +
1));
40 $href = htmlspecialchars($href);
42 // does the filename extension indicate an image file?
43 if ($this->getConf('images') &&
44 in_array($ext, $this->getConf('img_ext', array()))) {
46 // create alt text for the image
47 if (! isset($text) ||
$text == '') {
48 $text = basename($href);
49 $text = htmlspecialchars($text);
52 // generate an image tag
53 $css = $this->formatConf(' class="%s"', 'css_img');
54 $output = "<img$css src=\"$href\" alt=\"$text\" />";
58 // should we build a target clause?
59 if ($href{0} == '#' ||
60 strtolower(substr($href, 0, 7)) == 'mailto:') {
61 // targets not allowed for on-page anchors
65 // allow targets on non-anchor non-mailto links
66 $target = $this->getConf('target');
69 // generate a regular link (not an image)
70 $text = htmlspecialchars($text);
71 $css = $this->formatConf(' class="%s"', "css_$type");
72 $output = "<a$css href=\"$href\"";
75 // use a "popup" window. this is XHTML compliant, suggested by
76 // Aaron Kalin. uses the $target as the new window name.
77 $target = htmlspecialchars($target);
78 $output .= " onclick=\"window.open(this.href, '$target');";
79 $output .= " return false;\"";
83 $output .= ">$text</a>";
85 // make numbered references look like footnotes when no
86 // CSS class specified, make them superscript by default
87 if ($type == 'footnote' && ! $css) {
88 $output = '<sup>' . $output . '</sup>';