lilalo
diff l3pre.php @ 151:80691b40e6db
см. предыдущий коммит
author | igor@chub.in |
---|---|
date | Tue Jun 23 01:17:30 2009 +0300 (2009-06-23) |
parents | 51a232faeb27 |
children |
line diff
1.1 --- a/l3pre.php Wed Jul 23 00:41:26 2008 +0300 1.2 +++ b/l3pre.php Tue Jun 23 01:17:30 2009 +0300 1.3 @@ -1,14 +1,35 @@ 1.4 <? 1.5 +$wgHooks['ParserAfterTidy'][] = 'wfLiLaLoParserAfterTidy'; 1.6 $wgExtensionFunctions[] = "wfLiLaLoExtension"; 1.7 1.8 +/* 1.9 + 1.10 +More on this technic: 1.11 +http://www.mediawiki.org/wiki/Manual:Tag_extensions#How_can_I_avoid_modification_of_my_extension.27s_HTML_output.3F 1.12 + 1.13 + 1.14 +HTML tooltips from: 1.15 +http://www.walterzorn.com/tooltip/tooltip_e.htm#download 1.16 + 1.17 +Also: 1.18 +http://sixrevisions.com/tutorials/javascript_tutorial/create_lightweight_javascript_tooltip/ 1.19 + 1.20 +*/ 1.21 + 1.22 function wfLiLaLoExtension() { 1.23 global $wgParser; 1.24 $wgParser->setHook( "lilalo", "renderLiLaLoPRE" ); 1.25 + global $wgOut; 1.26 + $wgOut->addHTML('<script src="/js/wz_tooltip.js"></script>'); 1.27 } 1.28 1.29 +$markerList = array(); 1.30 + 1.31 function renderLiLaLoPRE( $input ) { 1.32 + global $markerList; 1.33 preg_match('/[^\n]*l3: local_session_id=([0-9-]*)[^\n]*[\n]/', $input, $matches); 1.34 $session_id=$matches[1]; 1.35 + if ($session_id) { 1.36 preg_match('/([0-9]*)-([0-9]*)/', $session_id, $matches); 1.37 $session_start_time = intval($matches[2]); 1.38 $hour=intval(date('G', $session_start_time)); 1.39 @@ -21,7 +42,36 @@ 1.40 .'">$5</a></b>\'', 1.41 $input); 1.42 # .strval($session_start_time+3600*(intval($2)-$hour)+60*(intval($3)-$min)+(intval($4)-$sec)) 1.43 - return "<pre>$hour:$min:$sec $input</pre>"; 1.44 + $time_prefix="$hour:$min:$sec "; 1.45 + } 1.46 + else 1.47 + { 1.48 + $tip_text='<table><tr><td>-n</td><td>show numerical addresses instead of trying to determine symbolic host names.<br/> This is useful if you are trying to determine why the route to your nameserver has vanished.</td></tr></table>'; 1.49 + #$tip_text='<dv>1</dv>'; 1.50 + $tip=" onmouseover=\"Tip('".$tip_text."')\" onmouseout=\"UnTip()\""; 1.51 + $input = preg_replace('/(%#.*)/', '<span style="font-weight:bold"'.$tip.'>$1</span>', $input); 1.52 + } 1.53 + $output = "<pre>$time_prefix$input</pre>"; 1.54 + $markercount = count($markerList); 1.55 + $marker = "xx-lilalo-marker".$markercount."-xx"; 1.56 + $markerList[$markercount] = $output; 1.57 + return $marker; 1.58 + 1.59 } 1.60 1.61 +function wfLiLaLoParserAfterTidy(&$parser, &$text) { 1.62 + // find markers in $text 1.63 + // replace markers with actual output 1.64 + global $markerList; 1.65 + $keys = array(); 1.66 + $marker_count = count($markerList); 1.67 + 1.68 + for ($i = 0; $i < $marker_count; $i++) { 1.69 + $keys[$i] = 'xx-lilalo-marker' . $i . '-xx'; 1.70 + } 1.71 + 1.72 + $text = str_replace($keys, $markerList, $text); 1.73 +#$text = $marker_count; 1.74 + return true; 1.75 +} 1.76 ?>