My favorites | Sign in
Project Home Downloads Wiki Issues Source
Checkout   Browse   Changes    
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
<?php
/**
Author: Pierre Lindenbaum PhD
Mail: plindenbaum@yahoo.fr

Installation:
install this file in

${MWROOT}/extensions/ucsciframe/ucsciframe.php

and add the following line at the end of ${MWROOT}/LocalSettings.php :

require_once("$IP/extensions/ucsciframe/ucsciframe.php");
**/


/**
* Protect against register_globals vulnerabilities.
* This line must be present before any global variable is referenced.
**/
if(!defined('MEDIAWIKI')){
echo("This is an extension to the MediaWiki package and cannot be run standalone.\n" );
die(-1);
}

/* Avoid unstubbing $wgParser on setHook() too early on modern (1.12+) MW versions */
if ( defined( 'MW_SUPPORTS_PARSERFIRSTCALLINIT' ) ) {
$wgHooks['ParserFirstCallInit'][] = 'myUcscIFrame';
} else {
$wgExtensionFunctions[] = 'myUcscIFrame';
}


/**
* An array of extension types and inside that their names, versions, authors and urls. This credit information gets added to the wiki's Special:Version page, allowing users to see which extensions are installed, and to find more information about them.
**/
$wgExtensionCredits['parserhook'][] = array(
'name' => 'ucsciframe',
'version' => '0.1',
'author' => '[http://plindenbaum.blogspot.com Pierre Lindenbaum]',
'url' => 'http://code.google.com/p/code915/source/browse/trunk/mediawiki/extensions/ucsciframe/ucsciframe.php',
'description' => 'Creates an iframe for the UCSC genome browser'
);

function myUcscIFrame()
{
global $wgParser;
$wgParser->setHook( 'ucsciframe', 'myRenderUcscIFrame' );
return true;
}

function myRenderUcscIFrame( $input, $args, $parser )
{
if( !(isset($args['chrom']))) return "<span style='color:red;'>@chrom missing</span>";
if( !(isset($args['start']))) return "<span style='color:red;'>@start missing</span>";
if( !(isset($args['end']))) return "<span style='color:red;'>@end missing</span>";
$chrom=trim($args['chrom']);
if(strlen($chrom)==0) return "<span style='color:red;'>bad @chrom</span>";
if(substr($chrom,0,3)!='chr') $chrom="chr".$chrom;
$start=(int)trim(str_replace(',','',$args['start']));
$end=(int)trim(str_replace(',','',$args['end']));
if(!is_int($start)) return "<span style='color:red;'>bad @start</span>";
if(!is_int($end)) return "<span style='color:red;'>bad @end</span>";

$url="http://genome.ucsc.edu/cgi-bin/hgTracks?org=".
(isset($args['org'])?$args['org']:"Human").
"&db=".(isset($args['db'])?$args['db']:"hg18").
"&position=".$chrom."%3A".$start."-".$end;

$html= "<div style='text-align:center;margin:10pt;'>".
"<a href='".$url."' target='_blank'>".$chrom.":".$start."-".$end."</a><br/>".
"<iframe height='".(isset($args['height'])?$args['height']:"500px")."' width='90%' src ='".$url."' />".
"</iframe></div>"
;
return $html;
}

?>

Change log

r198 by plindenbaum.u915 on Aug 6, 2010   Diff
url fixed
Go to: 
Project members, sign in to write a code review

Older revisions

r197 by plindenbaum.u915 on Aug 6, 2010   Diff
fixed params for ucsciframe
r196 by plindenbaum.u915 on Aug 6, 2010   Diff
ucsc iframe for media wiki
r195 by plindenbaum.u915 on Aug 6, 2010   Diff
cont
All revisions of this file

File info

Size: 2842 bytes, 78 lines
Powered by Google Project Hosting