import of Diogenes 0.9.18
[diogenes.git] / include / Text / Wiki / Render / Latex / Image.php
1 <?php
2 class Text_Wiki_Render_Latex_Image extends Text_Wiki_Render {
3
4 var $conf = array(
5 'base' => '/'
6 );
7
8
9 /**
10 *
11 * Renders a token into text matching the requested format.
12 *
13 * @access public
14 *
15 * @param array $options The "options" portion of the token (second
16 * element).
17 *
18 * @return string The text rendered from the token options.
19 *
20 */
21
22 function token($options)
23 {
24 return 'Image: NI';
25
26 $src = '"' .
27 $this->getConf('base', '/') .
28 $options['src'] . '"';
29
30 if (isset($options['attr']['link'])) {
31
32 // this image has a link
33 if (strpos($options['attr']['link'], '://')) {
34 // it's a URL
35 $href = $options['attr']['link'];
36 } else {
37 $href = $this->wiki->getRenderConf('xhtml', 'wikilink', 'view_url') .
38 $options['attr']['link'];
39 }
40
41 } else {
42 // image is not linked
43 $href = null;
44 }
45
46 // unset these so they don't show up as attributes
47 unset($options['attr']['link']);
48
49 $attr = '';
50 $alt = false;
51 foreach ($options['attr'] as $key => $val) {
52 if (strtolower($key) == 'alt') {
53 $alt = true;
54 }
55 $attr .= " $key=\"$val\"";
56 }
57
58 // always add an "alt" attribute per Stephane Solliec
59 if (! $alt) {
60 $attr .= ' alt="' . basename($options['src']) . '"';
61 }
62
63 if ($href) {
64 return "<a href=\"$href\"><img src=$src$attr/></a>";
65 } else {
66 return "<img src=$src$attr/>";
67 }
68 }
69 }
70 ?>