Revision 2432712 of "Extension:Flowchart" on mediawikiwiki{{delete|As it is old, no public reports of being used, its a single days effort, gots lots of bug, I am the original author and nobody touched it since, including me}}
{{TNT|XSS alert}}
{{TNT|Extension
|name = Flowchart
|status =
|type = tag
|author = [[m:User:Ruudschramp|User:Ruudschramp]]
|image =
|version =
|update =
|mediawiki =
|download = see below
|readme =
|changelog =
|description = Allows making ASCII art drawing of protocol flows
|parameters=
|rights =
|example =
}}
'''Flowchart''' extension allows making ASCII art drawings of protocol flows. The intention of course was to make something more fancy with real graphical arows, but this is the effort of just as single evening.
'''I would currently advise to use [[Extension:MscGen|MscGen]] which does the same in a graphical way.'''
== Example input ==
<pre>
<flowchart>TCPClient:TCPServer:Server
'''TCPClient TCPServer Syn'''
TCPServer TCPClient Syn+Ack
TCPClient TCPServer Syn+Ack
TCPClient Server HTTPGet
Server TCPClient HTTPResponse</flowchart>
</pre>
== The corresponding output ==
this is how it looks aproximately.
<pre>
TCPClient TCPServer Server
| Syn | |
| ------> | |
| | |
| Syn+Ack | |
| <------ | |
| | |
| Syn+Ack | |
| ------> | |
| | |
| HTTPGet |
| ------> ------> |
| | |
| HTTPResponse |
| <------ <------ |
| | |
</pre>
== The code ==
<source lang="php">
<?php
# To activate the extension, include it from your LocalSettings.php
# with: include("extensions/YourExtensionName.php");
$wgExtensionFunctions[] = "wfFlowChartExtension";
function wfFlowChartExtension() {
global $wgParser;
# register the extension with the WikiText parser
# the first parameter is the name of the new tag.
# In this case it defines the tag <flowchart> ... </flowchart>
# the second parameter is the callback function for
# processing the text between the tags
$wgParser->setHook( "flowchart", "renderFlowChart" );
}
# The callback function for converting the input text to HTML output
function renderFlowChart( $input ) {
# $argv is an array containing any arguments passed to the
# extension like <example argument="foo" bar>..
$lines=split("\n",$input);
$colums=split(":",$lines[0]);
$count=count($colums);
$output .= "<CENTER><TABLE cellpadding=\"0\" border=\"0\">\n<TR>";
foreach($colums as $Name)
$output .= "<TH>$Name</TH><TD/><TD/>";
array_shift($lines); #remove first line
foreach($lines as $line)
if ($line != "") { #ignoring empty lines
$output.="</TR>\n<TR>";
$fields=split(" ",$line,$count);
$col1=array_search($fields[0],$colums);
$col2=array_search($fields[1],$colums);
$mes=$fields[2];
$dir= $col1<$col2 ? "------>" : "<------";
$skip=min($col1,$col2);
for($i=0;$i<$skip;$i++)
$output.="<TD>|</TD><TD/><TD/>";
$length=(abs($col1-$col2)*3)-1;
$output.="<TD>|</TD><TD colspan=$length>$mes</TD>";
$skip=$count-max($col1,$col2);
for($i=0;$i<$skip;$i++)
$output.="<TD>|</TD><TD/><TD/>";
$output.="</TR>\n<TR>";
$skip=min($col1,$col2);
for($i=0;$i<$skip;$i++)
$output.="<TD>|</TD><TD/><TD/>";
$length=abs($col1-$col2)-1;
$output.="<TD>|</TD><TD colspan=2>$dir</TD>";
for($i=0;$i<$length;$i++)
$output.="<TD colspan=3>$dir</TD>";
$skip=$count-max($col1,$col2);
for($i=0;$i<$skip;$i++)
$output.="<TD>|</TD><TD/><TD/>";
$output.="</TR>\n<TR>";
};
$output .= "</TR>\n</TABLE></CENTER>";
return $output;
}
?>
</source>
[[Category:Graph extensions]]All content in the above text box is licensed under the Creative Commons Attribution-ShareAlike license Version 4 and was originally sourced from https://mediawiki.org/w/index.php?oldid=2432712.
![]() ![]() This site is not affiliated with or endorsed in any way by the Wikimedia Foundation or any of its affiliates. In fact, we fucking despise them.
|