Created
November 4, 2019 11:56
-
-
Save joelittlejohn/559469ad85a562e8586144509c6d5d15 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$wgExtensionCredits['parserhook'][] = array( | |
'name' => 'WebServiceSequenceDiagram', | |
'version' => '1.0', | |
'author' => 'Eddie Olsson', | |
'url' => 'http://www.mediawiki.org/wiki/Extension:WebSequenceDiagram', | |
'description' => 'Render inline sequence diagrams using websequencediagrams.com' | |
); | |
if ( defined( 'MW_SUPPORTS_PARSERFIRSTCALLINIT' ) ) { | |
$wgHooks['ParserFirstCallInit'][] = 'webSequenceDiagramSetup'; | |
} else { // Otherwise do things the old fashioned way | |
$wgExtensionFunctions[] = 'webSequenceDiagramSetup'; | |
} | |
function webSequenceDiagramSetup() { | |
global $wgParser; | |
$wgParser->setHook( 'sequencediagram', 'webSequenceDiagramRender' ); | |
return true; | |
} | |
function webSequenceDiagramRender( $input, $args, $parser) { | |
if( isset( $args['style'] ) ) | |
$style= $args['style']; | |
else | |
$style = 'default'; | |
$caption = ''; | |
if( isset( $args['caption'] ) ) | |
$caption = '<div class="thumbcaption">' . $args['caption'] . '</div>'; | |
return "\n" . | |
'<div class="thum tnone"><div class="thumbinner">' . | |
'<div class=wsd wsd_style="' . $style . '"><pre>\n' . | |
$input . "\n" . | |
'</pre></div>' . $caption . '</div><script type="text/javascript" src="//www.websequencediagrams.com/service.js"></script></div>'; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment