Commit 1bc35984 authored by Krzysztof Kutt's avatar Krzysztof Kutt
Browse files

BPMN XML -> SimpleBPMN converter; support for indexmenu plugin in templates (2012-09-06)

parent 12a0c1cc
......@@ -20,13 +20,13 @@ require_once DOKU_PLUGIN.'action.php';
class action_plugin_simplebpmn_findtemplate extends DokuWiki_Action_Plugin {
public function register(Doku_Event_Handler &$controller) {
public function register(Doku_Event_Handler &$controller) {
$controller->register_hook('COMMON_PAGETPL_LOAD', 'BEFORE', $this, 'handle_common_pagetpl_load');
$controller->register_hook('COMMON_PAGETPL_LOAD', 'BEFORE', $this, 'handle_common_pagetpl_load');
}
}
public function handle_common_pagetpl_load(Doku_Event &$event, $param) {
public function handle_common_pagetpl_load(Doku_Event &$event, $param) {
global $conf;
if(empty($event->data['tpl'])){
......@@ -77,8 +77,7 @@ class action_plugin_simplebpmn_findtemplate extends DokuWiki_Action_Plugin {
$event->data['tpl'] = io_readFile($event->data['tplfile']);
}
if($event->data['doreplace']) parsePageTemplate($event->data);
}
}
}
// vim:ts=4:sw=4:et:
......@@ -12,24 +12,38 @@ require_once (DOKU_PLUGIN . 'action.php');
class action_plugin_simplebpmn_wysiwyg extends DokuWiki_Action_Plugin {
/**
* Register the eventhandlers
*/
function register(&$controller) {
$controller->register_hook('TOOLBAR_DEFINE', 'AFTER', $this, 'bpmn_button', array ());
}
/**
* Register the eventhandlers
*/
function register(&$controller) {
$controller->register_hook('TOOLBAR_DEFINE', 'AFTER', $this, 'bpmn_button', array ());
$controller->register_hook('TOOLBAR_DEFINE', 'AFTER', $this, 'converter_button', array ());
}
/**
* Inserts the toolbar button
*/
function bpmn_button(&$event, $param) {
$event->data[] = array (
'type' => 'format',
'title' => 'SimpleBPMN Notation',
'icon' => '../../plugins/simplebpmn/img/bpmn_button.png',
'open' => '<bpmn subprocesses=collapse diagram=before>',
'close' => '</bpmn>',
);
}
}
/**
* Inserts the BPMN toolbar button
*/
function bpmn_button(&$event, $param) {
$event->data[] = array (
'type' => 'format',
'title' => 'SimpleBPMN Notation',
'icon' => '../../plugins/simplebpmn/img/bpmn_button.png',
'open' => '<bpmn subprocesses=collapse diagram=before>',
'close' => '</bpmn>',
);
}
/**
* Inserts the converter toolbar button
*/
function converter_button(&$event, $param) {
$event->data[] = array (
'type' => 'mediapopup',
'title' => 'BPMN XML -> SimpleBPMN Converter',
'icon' => '../../plugins/simplebpmn/img/converter_button.png',
'name' => 'BPMN XML -> SimpleBPMN Converter',
'url' => 'lib/plugins/simplebpmn/converter.php?',
'options' => 'height=428,width=600,top=100,left=100,location=no,menubar=no,status=no,toolbar=no'
);
}
}
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" dir="ltr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>BPMN XML <-> SimpleBPMN Converter</title>
<link rel="stylesheet" media="screen" type="text/css" href="../../exe/css.php" />
</head>
<body class="bpmn-converter">
<div class="dokuwiki">
<div class="field">
<label for="code_xml">Please paste your BPMN XML here:</label>
<textarea cols="68" rows="20" id="code_xml"></textarea>
</div>
<div class="field">
<label for="code_simple">Resulting SimpleBPMN:</label>
<textarea cols="68" rows="2" id="code_simple" readonly="readonly"></textarea>
</div>
<ul class="buttons">
<li><button id="convert" title="Convert BPMN DI to SimpleBPMN">Convert</button></li>
<li><button id="insert" title="Inserts generated code at cursor position in page editing window" disabled="disabled">Insert into page</button></li>
</ul>
</div>
<script type="text/javascript" src="../../scripts/jquery/jquery.min.js"></script>
<script type="text/javascript" src="../../plugins/simplebpmn/js/jquery.caret.1.02.min.js"></script>
<script type="text/javascript" src="../../plugins/simplebpmn/js/converter.js"></script>
<script type="text/javascript">
$(document).ready(function(){
Converter.init("<?php echo $_GET['edid']; ?>");
});
</script>
</body>
</html>
;(function ($) {
/* Adds few useful things to canvas */
/* Adds few useful things to canvas */
CanvasRenderingContext2D.prototype.canvasPlus = {};
CanvasRenderingContext2D.prototype.canvasPlus = {};
CanvasRenderingContext2D.prototype.getDottedPattern = function(refresh) {
if( !this.canvasPlus.dottedPattern || refresh){
var w = 3*this.lineWidth;
var dp = document.createElement('canvas');
dp.width=w;
dp.height=w;
var context = dp.getContext("2d");
context.fillStyle = this.strokeStyle;
context.fillRect(0,0,2,2);
this.canvasPlus.dottedPattern = this.createPattern(dp,'repeat');
}
return this.canvasPlus.dottedPattern;
};
CanvasRenderingContext2D.prototype.getDottedPattern = function(refresh) {
if( !this.canvasPlus.dottedPattern || refresh){
var w = 3*this.lineWidth;
var dp = document.createElement('canvas');
dp.width=w;
dp.height=w;
var context = dp.getContext("2d");
context.fillStyle = this.strokeStyle;
context.fillRect(0,0,2,2);
this.canvasPlus.dottedPattern = this.createPattern(dp,'repeat');
}
return this.canvasPlus.dottedPattern;
};
CanvasRenderingContext2D.prototype.getLineHeight = function (refresh){
if( !this.canvasPlus.lineHeight || refresh ) {
var $d = $('<div></div>').css({
'font': this.font,
'visibility': 'hidden',
'position': 'absolute',
'top': 0,
'left': 0
}).text('`1234567890-=qwertyuiop[]\\asdfghjkl;\'zxcvbnm,./~!@#$%^&*()_+QWERTYUIOP{}|ASDFGHJKL:"ZXCVBNM<>?').appendTo('body');
this.canvasPlus.lineHeight = $d.height();
$d.remove();
}
return this.canvasPlus.lineHeight;
};
CanvasRenderingContext2D.prototype.getLineHeight = function (refresh){
if( !this.canvasPlus.lineHeight || refresh ) {
var $d = $('<div></div>').css({
'font': this.font,
'visibility': 'hidden',
'position': 'absolute',
'top': 0,
'left': 0
}).text('`1234567890-=qwertyuiop[]\\asdfghjkl;\'zxcvbnm,./~!@#$%^&*()_+QWERTYUIOP{}|ASDFGHJKL:"ZXCVBNM<>?').appendTo('body');
this.canvasPlus.lineHeight = $d.height();
$d.remove();
}
return this.canvasPlus.lineHeight;
};
CanvasRenderingContext2D.prototype.getTextLines = function (text, maxWidth) {
var lines = [];
var words = text.split(" ");
var line = "";
for (var n = 0; n < words.length; n++) {
var testLine = line + words[n] + " ";
var metrics = this.measureText(testLine);
var testWidth = metrics.width;
if (testWidth > maxWidth) {
lines.push(line);
line = words[n] + " ";
}
else {
line = testLine;
}
}
if( $.trim(line).length ) {
lines.push(line);
}
return lines;
};
CanvasRenderingContext2D.prototype.getTextLines = function (text, maxWidth) {
var lines = [];
var words = text.split(" ");
var line = "";
for (var n = 0; n < words.length; n++) {
var testLine = line + words[n] + " ";
var metrics = this.measureText(testLine);
var testWidth = metrics.width;
if (testWidth > maxWidth) {
lines.push(line);
line = words[n] + " ";
}
else {
line = testLine;
}
}
if( $.trim(line).length ) {
lines.push(line);
}
return lines;
};
CanvasRenderingContext2D.prototype.getTextHeight = function (text, maxWidth) {
var lines = this.getTextLines(text,maxWidth);
return this.getLineHeight(true)*lines.length;
};
CanvasRenderingContext2D.prototype.getTextHeight = function (text, maxWidth) {
var lines = this.getTextLines(text,maxWidth);
return this.getLineHeight(true)*lines.length;
};
CanvasRenderingContext2D.prototype.fillWrapText = function (text, x, y, maxWidth){
var lines = this.getTextLines(text,maxWidth);
CanvasRenderingContext2D.prototype.fillWrapText = function (text, x, y, maxWidth){
var lines = this.getTextLines(text,maxWidth);
for (var n = 0; n < lines.length; n++) {
this.fillText(lines[n], x, y);
y += this.getLineHeight();
}
};
for (var n = 0; n < lines.length; n++) {
this.fillText(lines[n], x, y);
y += this.getLineHeight();
}
};
CanvasRenderingContext2D.prototype.strokeRoundedRect = function (x,y,w,h,r){
this.beginPath();
this.moveTo(x+r,y);
this.lineTo(x+w-r, y);
this.arcTo(x+w, y, x+w, y+r, r);
this.lineTo(x+w, y+h-r);
this.arcTo(x+w, y+h, x+w-r, y+h, r);
this.lineTo(x+r, y+h);
this.arcTo(x, y+h, x, y+h-r, r);
this.lineTo(x, y+r);
this.arcTo(x, y, x+15, y, r);
this.stroke();
};
CanvasRenderingContext2D.prototype.strokeRoundedRect = function (x,y,w,h,r){
this.beginPath();
this.moveTo(x+r,y);
this.lineTo(x+w-r, y);
this.arcTo(x+w, y, x+w, y+r, r);
this.lineTo(x+w, y+h-r);
this.arcTo(x+w, y+h, x+w-r, y+h, r);
this.lineTo(x+r, y+h);
this.arcTo(x, y+h, x, y+h-r, r);
this.lineTo(x, y+r);
this.arcTo(x, y, x+15, y, r);
this.stroke();
};
})(jQuery);
var Geometry = {
/**
* Return distance between two points
*/
distance: function(start,end) {
return Math.sqrt( Math.pow( start[0] - end[0], 2 ) + Math.pow( start[1] - end[1], 2 ) );
},
/**
* Is point inside the box?
*/
inside: function(box,point) {
return point[0] > box[0] && point[0] < box[0] + box[2] && point[1] > box[1] && point[1] < box[1] + box[3];
},
/**
* Does ab line cross cd line?
*/
cross: function(a,b,c,d) {
var detA = Geometry.det(c,d,a);
var detB = Geometry.det(c,d,b);
var detC = Geometry.det(a,b,c);
var detD = Geometry.det(a,b,d);
if( !detA || !detB || !detC || !detD ) {
return (!detA && Geometry.in_range(c,d,a)) || (!detB && Geometry.in_range(c,d,b)) || (!detC && Geometry.in_range(a,b,c)) || (!detD && Geometry.in_range(a,b,d));
} else {
return Geometry.sign(detA) != Geometry.sign(detB) && Geometry.sign(detC) != Geometry.sign(detD);
}
},
det: function(a,b,c){
return a[0]*b[1] + b[0]*c[1] + c[0]*a[1] - c[0]*b[1] - a[0]*c[1] - b[0]*a[1]
},
in_range: function(a,b,c) {
return Math.min(a[0], b[0]) <= c[0] && c[0] <= Math.max(a[0], b[0]) && Math.min(a[1], b[1]) <= c[1] && c[1] <= Math.max(a[1], b[1]);
},
sign: function(a) {
return a > 0 ? 1 : (a < 0 ? -1 : 0);
}
/**
* Return distance between two points
*/
distance: function(start,end) {
return Math.sqrt( Math.pow( start[0] - end[0], 2 ) + Math.pow( start[1] - end[1], 2 ) );
},
/**
* Is point inside the box?
*/
inside: function(box,point) {
return point[0] > box[0] && point[0] < box[0] + box[2] && point[1] > box[1] && point[1] < box[1] + box[3];
},
/**
* Does ab line cross cd line?
*/
cross: function(a,b,c,d) {
var detA = Geometry.det(c,d,a);
var detB = Geometry.det(c,d,b);
var detC = Geometry.det(a,b,c);
var detD = Geometry.det(a,b,d);
if( !detA || !detB || !detC || !detD ) {
return (!detA && Geometry.in_range(c,d,a)) || (!detB && Geometry.in_range(c,d,b)) || (!detC && Geometry.in_range(a,b,c)) || (!detD && Geometry.in_range(a,b,d));
} else {
return Geometry.sign(detA) != Geometry.sign(detB) && Geometry.sign(detC) != Geometry.sign(detD);
}
},
det: function(a,b,c){
return a[0]*b[1] + b[0]*c[1] + c[0]*a[1] - c[0]*b[1] - a[0]*c[1] - b[0]*a[1]
},
in_range: function(a,b,c) {
return Math.min(a[0], b[0]) <= c[0] && c[0] <= Math.max(a[0], b[0]) && Math.min(a[1], b[1]) <= c[1] && c[1] <= Math.max(a[1], b[1]);
},
sign: function(a) {
return a > 0 ? 1 : (a < 0 ? -1 : 0);
}
};
This diff is collapsed.
This diff is collapsed.
/*
*
* Copyright (c) 2010 C. F., Wong (<a href="http://cloudgen.w0ng.hk">Cloudgen Examplet Store</a>)
* Licensed under the MIT License:
* http://www.opensource.org/licenses/mit-license.php
*
*/
(function(k,e,i,j){k.fn.caret=function(b,l){var a,c,f=this[0],d=k.browser.msie;if(typeof b==="object"&&typeof b.start==="number"&&typeof b.end==="number"){a=b.start;c=b.end}else if(typeof b==="number"&&typeof l==="number"){a=b;c=l}else if(typeof b==="string")if((a=f.value.indexOf(b))>-1)c=a+b[e];else a=null;else if(Object.prototype.toString.call(b)==="[object RegExp]"){b=b.exec(f.value);if(b!=null){a=b.index;c=a+b[0][e]}}if(typeof a!="undefined"){if(d){d=this[0].createTextRange();d.collapse(true);
d.moveStart("character",a);d.moveEnd("character",c-a);d.select()}else{this[0].selectionStart=a;this[0].selectionEnd=c}this[0].focus();return this}else{if(d){c=document.selection;if(this[0].tagName.toLowerCase()!="textarea"){d=this.val();a=c[i]()[j]();a.moveEnd("character",d[e]);var g=a.text==""?d[e]:d.lastIndexOf(a.text);a=c[i]()[j]();a.moveStart("character",-d[e]);var h=a.text[e]}else{a=c[i]();c=a[j]();c.moveToElementText(this[0]);c.setEndPoint("EndToEnd",a);g=c.text[e]-a.text[e];h=g+a.text[e]}}else{g=
f.selectionStart;h=f.selectionEnd}a=f.value.substring(g,h);return{start:g,end:h,text:a,replace:function(m){return f.value.substring(0,g)+m+f.value.substring(h,f.value[e])}}}}})(jQuery,"length","createRange","duplicate");
\ No newline at end of file
base simplebpmn
author Urszula Ciaputa
email u.ciaputa@gmail.com
date 2012-06-13
date 2012-09-06
name simplebpmn plugin
desc Simple plugin that allows rendering of the diagrams specified in SimpleBPMN notation
;var BPMN_IMG_PATH = DOKU_BASE+'lib/plugins/simplebpmn/img/';
/* No need to include jQuery, DokuWiki is shipped with it */
/* DOKUWIKI:include_once jquery.mousewheel.js */
/* DOKUWIKI:include_once js/jquery.mousewheel.js */
/* DOKUWIKI:include_once js/minify.json.js */
/* DOKUWIKI:include_once js/jquery.caret.1.02.min.js */
/* DOKUWIKI:include_once js/Base.js */
/* DOKUWIKI:include js/minify.json.js */
/* DOKUWIKI:include_once js/CanvasPlus.js */
/* DOKUWIKI:include_once js/Geometry.js */
/* DOKUWIKI:include js/Base.js */
/* DOKUWIKI:include js/CanvasPlus.js */
/* DOKUWIKI:include js/Geometry.js */
/* DOKUWIKI:include js/bpmn.js */
/* DOKUWIKI:include_once js/bpmn.js */
jQuery().ready(function(){
/* Diagrams visualization */
jQuery('.bpmn-code').BPMNDiagram({
auto: true,
hideCode: false,
debug: false
});
/* Auto select in edit */
var $wt = jQuery('#wiki__text');
if( $wt.length ) {
m = $wt.val().match(/<bpmn.*?>([\s\S]+)(?=<\/bpmn>)/i);
if( m ) {
$wt.caret(m[1]);
}
}
});
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
====== @!!PAGE@ ======
{{indexmenu>@NS@#1|js#simplebpmn navbar notoc}}
++++ @!!PAGE@ code |
<bpmn subprocesses=collapse diagram=before>{
name: "@!!PAGE@",
......
====== @!!PAGE@ ======
{{indexmenu>@NS@#1|js#simplebpmn navbar notoc}}
<bpmn subprocesses=collapse diagram=before>{
name: "@!!PAGE@",
type: none|service|send|receive|user|manual|business|script,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment