| 1 | <?php |
| 2 | |
| 3 | // $Id: Phplookup.php,v 1.7 2004/09/25 19:05:14 pmjones Exp $ |
| 4 | |
| 5 | class 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. |
| 39 | $target = htmlspecialchars($target); |
| 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 | |
| 51 | $q = htmlspecialchars($q); |
| 52 | $text = htmlspecialchars($text); |
| 53 | |
| 54 | // finish and return |
| 55 | $output .= " href=\"http://php.net/$q\">$text</a>"; |
| 56 | return $output; |
| 57 | } |
| 58 | } |
| 59 | ?> |