1: <?php
2: /**
3: * @package Wicked
4: */
5: class Text_Wiki_Render_Xhtml_Url extends Text_Wiki_Render
6: {
7: public $conf = array(
8: 'target' => '_blank'
9: );
10:
11: /**
12: * Renders a token into text matching the requested format.
13: *
14: * @param array $options The "options" portion of the token (second
15: * element).
16: *
17: * @return string The text rendered from the token options.
18: */
19: public function token($options)
20: {
21: // Create local variables from the options array (text, href,
22: // type).
23: extract($options);
24:
25: // Find the rightmost dot and determine the filename
26: // extension.
27: $pos = strrpos($href, '.');
28: $ext = Horde_String::lower(substr($href, $pos + 1));
29: $href = htmlspecialchars($href);
30:
31: // Allow for alternative targets on non-anchor HREFs.
32: if ($href[0] == '#') {
33: $target = '';
34: } else {
35: $target = $this->getConf('target', '');
36: }
37:
38: $output = Horde::link(Horde::externalUrl($href), $href, 'external', htmlspecialchars($target)) . htmlspecialchars($text) . '</a>';
39:
40: // Make numbered references look like footnotes.
41: if ($type == 'footnote') {
42: $output = '<sup>' . $output . '</sup>';
43: }
44:
45: return $output;
46: }
47: }
48: