Skip to content
Permalink
Browse files

Updated meta information, reformatted code

  • Loading branch information...
jdehaan committed Jan 12, 2019
1 parent 8def23a commit 64959c9c2c373e259c94ac4f94805eef72fe37a9
@@ -1,7 +1,7 @@
NOTE: The License text was taken over from the bpmn.io project,
as bpmn.io provides the actual functionality.

Copyright (c) 2016 Jaap de Haan, Dokuwiki wrapper for bpmn.io
Copyright (c) 2016-2019 Jaap de Haan, Dokuwiki wrapper for bpmn.io


Permission is hereby granted, free of charge, to any person obtaining a copy of
@@ -1,4 +1,5 @@
# dokuwiki-plugin-bpmnio
Renders BPMN 2.0 xml using the bpmn.io js librarywithin dokuwiki

Renders BPMN 2.0 xml using the bpmn.io js library within dokuwiki

Refer to this page for details: https://www.dokuwiki.org/plugin:bpmnio
@@ -3,95 +3,110 @@
/**
* @license See LICENSE file
* @author Jaap de Haan <jaap.dehaan@color-of-code.de>
*/
*/
// must be run within DokuWiki
if(!defined('DOKU_INC')) die();
if (!defined('DOKU_INC')) {
die();
}
if (!defined('DOKU_PLUGIN')) {
define('DOKU_PLUGIN', DOKU_INC . 'lib/plugins/');
}
if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/');
require_once(DOKU_PLUGIN.'action.php');
require_once DOKU_PLUGIN . 'action.php';
// See help: https://www.dokuwiki.org/devel:toolbar
// See help: https://www.dokuwiki.org/devel:section_editor
class action_plugin_bpmnio extends DokuWiki_Action_Plugin {
class action_plugin_bpmnio extends DokuWiki_Action_Plugin
{
function register(Doku_Event_Handler $controller){
public function register(Doku_Event_Handler $controller)
{
$controller->register_hook('TPL_METAHEADER_OUTPUT', 'BEFORE', $this, 'handle_tpl_metaheader_output');
$controller->register_hook('TOOLBAR_DEFINE', 'AFTER', $this, 'handle_toolbar', array ());
$controller->register_hook('TOOLBAR_DEFINE', 'AFTER', $this, 'handle_toolbar', array());
$controller->register_hook('HTML_SECEDIT_BUTTON', 'BEFORE', $this, 'handle_section_edit_button');
}
/**
* Add <script> blocks to the meta headers
*/
public function handle_tpl_metaheader_output(Doku_Event &$event, $param) {
public function handle_tpl_metaheader_output(Doku_Event &$event, $param)
{
$event->data['link'][] = $this->create_css("assets/diagram-js.css");
$event->data['link'][] = $this->create_css("assets/diagram-js.css");
$event->data['link'][] = $this->create_css("assets/bpmn-font/css/bpmn-embedded.css");
// Load bpmn.io
$event->data['script'][] = $this->create_js("bpmn-viewer.min.js");
$event->data['script'][] = $this->create_js("bpmn-viewer.production.min.js");
// If activated we can edit but we cannot save
// $event->data['script'][] = $this->create_js("bpmn-modeler.min.js");
// $event->data['script'][] = $this->create_js("bpmn-modeler.production.min.js");
$event->data['script'][] = $this->create_js("script.js");
}
private function create_css($rel) {
private function create_css($rel)
{
return array(
'type' => 'text/css',
'rel' => 'stylesheet',
'href' => $this->to_abs_url($rel),
'type' => 'text/css',
'rel' => 'stylesheet',
'href' => $this->to_abs_url($rel),
);
}
private function create_js($rel) {
private function create_js($rel)
{
return array(
'type' => 'text/javascript',
'type' => 'text/javascript',
'charset' => 'utf-8',
'src' => $this->to_abs_url($rel),
'_data' => '',
'src' => $this->to_abs_url($rel),
'_data' => '',
);
}
private function to_abs_url($rel) {
return DOKU_BASE."lib/plugins/bpmnio/".$rel;
private function to_abs_url($rel)
{
return DOKU_BASE . "lib/plugins/bpmnio/" . $rel;
}
function handle_toolbar(Doku_Event $event, $param) {
$event->data[] = array (
public function handle_toolbar(Doku_Event $event, $param)
{
$event->data[] = array(
'type' => 'picker',
'title' => $this->getLang('picker'),
'icon' => '../../plugins/bpmnio/images/toolbar/picker.png',
'list' => array(
array(
'type' => 'format',
'title' => $this->getLang('add'),
'icon' => '../../plugins/bpmnio/images/toolbar/bpmn_add.png',
'open' => '<bpmnio zoom=1.0>\n' . $this->_get_open_text(),
'close' => $this->_get_close_text() . '\n</bpmnio>\n',
'type' => 'format',
'title' => $this->getLang('add'),
'icon' => '../../plugins/bpmnio/images/toolbar/bpmn_add.png',
'open' => '<bpmnio zoom=1.0>\n' . $this->_get_open_text(),
'close' => $this->_get_close_text() . '\n</bpmnio>\n',
),
)
),
);
}
public function handle_section_edit_button(Doku_Event $event, $param) {
if($event->data['target'] !== 'plugin_bpmnio') {
public function handle_section_edit_button(Doku_Event $event, $param)
{
if ($event->data['target'] !== 'plugin_bpmnio') {
return;
}
$event->data['name'] = $this->getLang('section_name');
}
private function _get_open_text() {
private function _get_open_text()
{
return '<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:omgdi="http://www.omg.org/spec/DD/20100524/DI" xmlns:omgdc="http://www.omg.org/spec/DD/20100524/DC" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="sid-38422fae-e03e-43a3-bef4-bd33b32041b2" targetNamespace="http://bpmn.io/bpmn" exporter="http://bpmn.io" exporterVersion="0.10.1">
<collaboration id="Collaboration_1oh70al">
<participant id="Participant_1r8g02m" name="';
}
private function _get_close_text() {
private function _get_close_text()
{
return '" processRef="Process_1" />
</collaboration>
<process id="Process_1" isExecutable="false">
@@ -195,4 +210,3 @@ private function _get_close_text() {
</definitions>';
}
}
File renamed without changes.
File renamed without changes.
@@ -1,7 +1,7 @@
base bpmnio
author Jaap de Haan
email jaap.dehaan@color-of-code.de
date 2018-06-08
date 2019-01-12
name bpmnio
desc Renders BPMN 2.0 xml using the bpmn.io js library
url http://www.dokuwiki.org/plugin:bpmnio
@@ -2,53 +2,66 @@
/**
* @license See LICENSE file
* @author Jaap de Haan <jaap.dehaan@color-of-code.de>
*/
*/
// must be run within DokuWiki
if(!defined('DOKU_INC')) die();
if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/');
require_once DOKU_PLUGIN.'syntax.php';
if (!defined('DOKU_INC')) {
die();
}
if (!defined('DOKU_PLUGIN')) {
define('DOKU_PLUGIN', DOKU_INC . 'lib/plugins/');
}
require_once DOKU_PLUGIN . 'syntax.php';
// See help: https://www.dokuwiki.org/devel:syntax_plugins
class syntax_plugin_bpmnio extends DokuWiki_Syntax_Plugin {
class syntax_plugin_bpmnio extends DokuWiki_Syntax_Plugin
{
public function getPType() {
public function getPType()
{
return 'block';
}
public function getType() {
public function getType()
{
return 'protected';
}
public function getSort() {
public function getSort()
{
return 0;
}
public function connectTo($mode) {
public function connectTo($mode)
{
$this->Lexer->addEntryPattern('<bpmnio.*?>(?=.*?</bpmnio>)', $mode, 'plugin_bpmnio');
}
public function postConnect() {
public function postConnect()
{
$this->Lexer->addExitPattern('</bpmnio>', 'plugin_bpmnio');
}
public function handle($match, $state, $pos, Doku_Handler $handler) {
public function handle($match, $state, $pos, Doku_Handler $handler)
{
$end = $pos + strlen($match);
$match = base64_encode($match);
return array($match, $state, $pos, $end);
}
public function render($mode, Doku_Renderer $renderer, $data) {
public function render($mode, Doku_Renderer $renderer, $data)
{
// $data is returned by handle()
if ($mode == 'xhtml' || $mode == 'odt') {
if ($mode == 'xhtml' || $mode == 'odt') {
list($match, $state, $pos, $end) = $data;
switch ($state) {
case DOKU_LEXER_ENTER :
case DOKU_LEXER_ENTER:
break;
case DOKU_LEXER_UNMATCHED :
case DOKU_LEXER_UNMATCHED:
$bpmnid = uniqid('__bpmnio_');
$sectionEditData = ['target' => 'plugin_bpmnio'];
if (!defined('SEC_EDIT_PATTERN')) {
@@ -58,15 +71,15 @@ public function render($mode, Doku_Renderer $renderer, $data) {
$class = $renderer->startSectionEdit($data[$pos], $sectionEditData);
$renderer->doc .= '<div class="' . $class . '">';
$renderer->doc .= '<div style="overflow:auto;">';
$renderer->doc .= '<textarea class="bpmnio_data" id="'.$bpmnid.'" style="visibility:hidden;">';
$renderer->doc .= '<textarea class="bpmnio_data" id="' . $bpmnid . '" style="visibility:hidden;">';
$renderer->doc .= trim($match);
$renderer->doc .= '</textarea>';
//$renderer->doc .= '<div class="bpmnio_canvas" id="'.$bpmnid.'"></div>';
$renderer->doc .= '</div>';
$renderer->doc .= '</div>';
$renderer->finishSectionEdit($data[$end]);
break;
case DOKU_LEXER_EXIT :
case DOKU_LEXER_EXIT:
break;
}
return true;

0 comments on commit 64959c9

Please sign in to comment.
You can’t perform that action at this time.