lilalo
view l3pre.php @ 154:71d6b2a6b8eb
Ветка с поддержкой sqlite в l3-agent'е
author | igor@book.xt.vpn |
---|---|
date | Mon Dec 28 22:00:37 2009 +0300 (2009-12-28) |
parents | 51a232faeb27 |
children |
line source
1 <?
2 $wgHooks['ParserAfterTidy'][] = 'wfLiLaLoParserAfterTidy';
3 $wgExtensionFunctions[] = "wfLiLaLoExtension";
5 /*
7 More on this technic:
8 http://www.mediawiki.org/wiki/Manual:Tag_extensions#How_can_I_avoid_modification_of_my_extension.27s_HTML_output.3F
11 HTML tooltips from:
12 http://www.walterzorn.com/tooltip/tooltip_e.htm#download
14 Also:
15 http://sixrevisions.com/tutorials/javascript_tutorial/create_lightweight_javascript_tooltip/
17 */
19 function wfLiLaLoExtension() {
20 global $wgParser;
21 $wgParser->setHook( "lilalo", "renderLiLaLoPRE" );
22 global $wgOut;
23 $wgOut->addHTML('<script src="/js/wz_tooltip.js"></script>');
24 }
26 $markerList = array();
28 function renderLiLaLoPRE( $input ) {
29 global $markerList;
30 preg_match('/[^\n]*l3: local_session_id=([0-9-]*)[^\n]*[\n]/', $input, $matches);
31 $session_id=$matches[1];
32 if ($session_id) {
33 preg_match('/([0-9]*)-([0-9]*)/', $session_id, $matches);
34 $session_start_time = intval($matches[2]);
35 $hour=intval(date('G', $session_start_time));
36 $min=intval(date('i', $session_start_time));
37 $sec=intval(date('s', $session_start_time));
38 $input = preg_replace('/[^\n]*l3: local_session_id=([0-9-]*)[^\n]*[\n]/', '', $input);
39 $input = preg_replace('/((..):(..):(...)(#[^\n]*))/e',
40 '\'$2:$3:$4<b><a href="http://xgu.ru/l3?page='.$session_id.'&id='
41 .'\'.strval($session_start_time+3600*(intval("$2")-$hour)+60*(intval("$3")-$min)+1*(intval("$4")-$sec)).\''
42 .'">$5</a></b>\'',
43 $input);
44 # .strval($session_start_time+3600*(intval($2)-$hour)+60*(intval($3)-$min)+(intval($4)-$sec))
45 $time_prefix="$hour:$min:$sec ";
46 }
47 else
48 {
49 $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>';
50 #$tip_text='<dv>1</dv>';
51 $tip=" onmouseover=\"Tip('".$tip_text."')\" onmouseout=\"UnTip()\"";
52 $input = preg_replace('/(%#.*)/', '<span style="font-weight:bold"'.$tip.'>$1</span>', $input);
53 }
54 $output = "<pre>$time_prefix$input</pre>";
55 $markercount = count($markerList);
56 $marker = "xx-lilalo-marker".$markercount."-xx";
57 $markerList[$markercount] = $output;
58 return $marker;
60 }
62 function wfLiLaLoParserAfterTidy(&$parser, &$text) {
63 // find markers in $text
64 // replace markers with actual output
65 global $markerList;
66 $keys = array();
67 $marker_count = count($markerList);
69 for ($i = 0; $i < $marker_count; $i++) {
70 $keys[$i] = 'xx-lilalo-marker' . $i . '-xx';
71 }
73 $text = str_replace($keys, $markerList, $text);
74 #$text = $marker_count;
75 return true;
76 }
77 ?>