[ Index ] |
|
Code source de Serendipity 1.2 |
1 <?php 2 3 class Text_Wiki_Render_Xhtml_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 'css' => null 13 ); 14 15 16 /** 17 * 18 * Renders a token into text matching the requested format. 19 * 20 * @access public 21 * 22 * @param array $options The "options" portion of the token (second 23 * element). 24 * 25 * @return string The text rendered from the token options. 26 * 27 */ 28 29 function token($options) 30 { 31 $site = $options['site']; 32 $page = $options['page']; 33 $text = $options['text']; 34 $css = $this->formatConf(' class="%s"', 'css'); 35 36 if (isset($this->conf['sites'][$site])) { 37 $href = $this->conf['sites'][$site]; 38 } else { 39 return $text; 40 } 41 42 // old form where page is at end, 43 // or new form with %s placeholder for sprintf()? 44 if (strpos($href, '%s') === false) { 45 // use the old form 46 $href = $href . $page; 47 } else { 48 // use the new form 49 $href = sprintf($href, $page); 50 } 51 52 // allow for alternative targets 53 $target = $this->getConf('target'); 54 55 // build base link 56 $text = htmlspecialchars($text); 57 $output = "<a$css href=\"$href\""; 58 59 // are we targeting a specific window? 60 if ($target) { 61 // this is XHTML compliant, suggested by Aaron Kalin. 62 // code tip is actually from youngpup.net, and it 63 // uses the $target as the new window name. 64 $target = htmlspecialchars($target); 65 $output .= " onClick=\"window.open(this.href, '$target');"; 66 $output .= " return false;\""; 67 } 68 69 $output .= ">$text</a>"; 70 71 return $output; 72 } 73 } 74 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Sat Nov 24 09:00:37 2007 | par Balluche grâce à PHPXref 0.7 |
![]() |