| 1 | <?php |
| 2 | |
| 3 | class Text_Wiki_Render_Latex_Interwiki extends Text_Wiki_Render { |
| 4 | |
| 5 | var $conf = array( |
| 6 | 'sites' => array( |
| 7 | 'MeatBall' => 'http://www.usemod.com/cgi-bin/mb.pl?%s', |
| 8 | 'Advogato' => 'http://advogato.org/%s', |
| 9 | 'Wiki' => 'http://c2.com/cgi/wiki?%s' |
| 10 | ), |
| 11 | 'target' => '_blank' |
| 12 | ); |
| 13 | |
| 14 | |
| 15 | /** |
| 16 | * |
| 17 | * Renders a token into text matching the requested format. |
| 18 | * |
| 19 | * @access public |
| 20 | * |
| 21 | * @param array $options The "options" portion of the token (second |
| 22 | * element). |
| 23 | * |
| 24 | * @return string The text rendered from the token options. |
| 25 | * |
| 26 | */ |
| 27 | |
| 28 | function token($options) |
| 29 | { |
| 30 | $site = $options['site']; |
| 31 | $page = $options['page']; |
| 32 | $text = $options['text']; |
| 33 | |
| 34 | if (isset($this->conf['sites'][$site])) { |
| 35 | $href = $this->conf['sites'][$site]; |
| 36 | } else { |
| 37 | return $text; |
| 38 | } |
| 39 | |
| 40 | // old form where page is at end, |
| 41 | // or new form with %s placeholder for sprintf()? |
| 42 | if (strpos($href, '%s') === false) { |
| 43 | // use the old form |
| 44 | $href = $href . $page; |
| 45 | } else { |
| 46 | // use the new form |
| 47 | $href = sprintf($href, $page); |
| 48 | } |
| 49 | |
| 50 | // allow for alternative targets |
| 51 | $target = $this->getConf('target', ''); |
| 52 | |
| 53 | if ($target && trim($target) != '') { |
| 54 | $target = " target=\"$target\""; |
| 55 | } |
| 56 | |
| 57 | return "$text\\footnote\{$href}"; |
| 58 | } |
| 59 | } |
| 60 | ?> |