1<?php 2/** 3 * @license See LICENSE file 4 * @author Jaap de Haan <jaap.dehaan@color-of-code.de> 5 */ 6 7// See help: https://www.dokuwiki.org/devel:toolbar 8 9class action_plugin_bpmnio_toolbar extends DokuWiki_Action_Plugin 10{ 11 12 public function register(Doku_Event_Handler $controller) 13 { 14 $controller->register_hook('TOOLBAR_DEFINE', 'AFTER', $this, 'handle_toolbar'); 15 } 16 17 public function handle_toolbar(Doku_Event $event) 18 { 19 $basedir = DOKU_BASE . 'lib/plugins/bpmnio/images/toolbar/'; 20 $event->data[] = array( 21 'type' => 'picker', 22 'title' => $this->getLang('picker'), 23 'icon' => $basedir . 'picker.png', 24 'list' => array( 25 array( 26 'type' => 'format', 27 'class' => 'plugin-bpmnio icon-large', 28 'title' => $this->getLang('bpmn_add'), 29 'icon' => $basedir . 'bpmn_add.png', 30 'open' => '<bpmnio type="bpmn">\n' . $this->_get_open_text_bpmn(), 31 'close' => $this->_get_close_text_bpmn() . '\n</bpmnio>\n', 32 ), 33 array( 34 'type' => 'format', 35 'class' => 'plugin-bpmnio icon-large', 36 'title' => $this->getLang('dmn_add'), 37 'icon' => $basedir . 'dmn_add.png', 38 'open' => '<bpmnio type="dmn">\n' . $this->_get_open_text_dmn(), 39 'close' => $this->_get_close_text_dmn() . '\n</bpmnio>\n', 40 ) 41 ), 42 ); 43 } 44 45 private function _get_open_text_bpmn() 46 { 47 return <<<XML 48 <?xml version="1.0" encoding="UTF-8"?> 49 <definitions 50 xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL" 51 xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" 52 xmlns:omgdi="http://www.omg.org/spec/DD/20100524/DI" 53 xmlns:omgdc="http://www.omg.org/spec/DD/20100524/DC" 54 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 55 id="sid-38422fae-e03e-43a3-bef4-bd33b32041b2" 56 targetNamespace="http://bpmn.io/bpmn" exporter="http://bpmn.io" exporterVersion="0.10.1"> 57 <collaboration id="Collaboration_1oh70al"> 58 <participant id="Participant_1r8g02m" name=" 59 XML; 60 } 61 62 private function _get_close_text_bpmn() 63 { 64 return <<<XML 65 " processRef="Process_1" /> 66 </collaboration> 67 <process id="Process_1" isExecutable="false"> 68 <startEvent id="StartEvent_1" name="Start"> 69 <outgoing>SequenceFlow_1</outgoing> 70 </startEvent> 71 <task id="Task_1" name="Do Something"> 72 <incoming>SequenceFlow_1</incoming> 73 <incoming>SequenceFlow_121ul2c</incoming> 74 <incoming>SequenceFlow_0nuwads</incoming> 75 <outgoing>SequenceFlow_2</outgoing> 76 </task> 77 <exclusiveGateway id="ExclusiveGateway_1" name="Result OK" gatewayDirection="Diverging"> 78 <incoming>SequenceFlow_2</incoming> 79 <outgoing>SequenceFlow_0snv4kp</outgoing> 80 <outgoing>SequenceFlow_0nuwads</outgoing> 81 </exclusiveGateway> 82 <task id="Task_17knw8l" name="Monitor"> 83 <outgoing>SequenceFlow_121ul2c</outgoing> 84 </task> 85 <endEvent id="EndEvent_0oj7l6x" name="End"> 86 <incoming>SequenceFlow_0snv4kp</incoming> 87 </endEvent> 88 <sequenceFlow id="SequenceFlow_1" name="" sourceRef="StartEvent_1" targetRef="Task_1" /> 89 <sequenceFlow id="SequenceFlow_121ul2c" sourceRef="Task_17knw8l" targetRef="Task_1" /> 90 <sequenceFlow id="SequenceFlow_0nuwads" name="No" sourceRef="ExclusiveGateway_1" targetRef="Task_1" /> 91 <sequenceFlow id="SequenceFlow_2" sourceRef="Task_1" targetRef="ExclusiveGateway_1" /> 92 <sequenceFlow id="SequenceFlow_0snv4kp" name="Yes" sourceRef="ExclusiveGateway_1" targetRef="EndEvent_0oj7l6x" /> 93 </process> 94 <bpmndi:BPMNDiagram id="BpmnDiagram_1"> 95 <bpmndi:BPMNPlane id="BpmnPlane_1" bpmnElement="Collaboration_1oh70al"> 96 <bpmndi:BPMNShape id="Participant_1r8g02m_di" bpmnElement="Participant_1r8g02m"> 97 <omgdc:Bounds x="104" y="78" width="668" height="297" /> 98 </bpmndi:BPMNShape> 99 <bpmndi:BPMNShape id="StartEvent_1_gui" bpmnElement="StartEvent_1"> 100 <omgdc:Bounds x="242" y="187" width="30" height="30" /> 101 <bpmndi:BPMNLabel> 102 <omgdc:Bounds x="212" y="219" width="90" height="22" /> 103 </bpmndi:BPMNLabel> 104 </bpmndi:BPMNShape> 105 <bpmndi:BPMNShape id="Task_1_gui" bpmnElement="Task_1"> 106 <omgdc:Bounds x="340" y="162" width="100" height="80" /> 107 <bpmndi:BPMNLabel> 108 <omgdc:Bounds x="118.85714721679688" y="47" width="82.28570556640625" height="12" /> 109 </bpmndi:BPMNLabel> 110 </bpmndi:BPMNShape> 111 <bpmndi:BPMNShape id="ExclusiveGateway_1_gui" bpmnElement="ExclusiveGateway_1" isMarkerVisible="true"> 112 <omgdc:Bounds x="508" y="182" width="40" height="40" /> 113 <bpmndi:BPMNLabel> 114 <omgdc:Bounds x="483" y="234" width="90" height="24" /> 115 </bpmndi:BPMNLabel> 116 </bpmndi:BPMNShape> 117 <bpmndi:BPMNShape id="Task_17knw8l_di" bpmnElement="Task_17knw8l"> 118 <omgdc:Bounds x="340" y="275" width="100" height="80" /> 119 </bpmndi:BPMNShape> 120 <bpmndi:BPMNShape id="EndEvent_0oj7l6x_di" bpmnElement="EndEvent_0oj7l6x"> 121 <omgdc:Bounds x="648" y="184" width="36" height="36" /> 122 <bpmndi:BPMNLabel> 123 <omgdc:Bounds x="621" y="220" width="90" height="20" /> 124 </bpmndi:BPMNLabel> 125 </bpmndi:BPMNShape> 126 <bpmndi:BPMNEdge id="SequenceFlow_1_gui" bpmnElement="SequenceFlow_1"> 127 <omgdi:waypoint xsi:type="omgdc:Point" x="272" y="202" /> 128 <omgdi:waypoint xsi:type="omgdc:Point" x="340" y="202" /> 129 <bpmndi:BPMNLabel> 130 <omgdc:Bounds x="225" y="140" width="90" height="20" /> 131 </bpmndi:BPMNLabel> 132 </bpmndi:BPMNEdge> 133 <bpmndi:BPMNEdge id="SequenceFlow_121ul2c_di" bpmnElement="SequenceFlow_121ul2c"> 134 <omgdi:waypoint xsi:type="omgdc:Point" x="390" y="275" /> 135 <omgdi:waypoint xsi:type="omgdc:Point" x="390" y="242" /> 136 <bpmndi:BPMNLabel> 137 <omgdc:Bounds x="358" y="273" width="90" height="20" /> 138 </bpmndi:BPMNLabel> 139 </bpmndi:BPMNEdge> 140 <bpmndi:BPMNEdge id="SequenceFlow_0nuwads_di" bpmnElement="SequenceFlow_0nuwads"> 141 <omgdi:waypoint xsi:type="omgdc:Point" x="528" y="182" /> 142 <omgdi:waypoint xsi:type="omgdc:Point" x="528" y="110" /> 143 <omgdi:waypoint xsi:type="omgdc:Point" x="390" y="110" /> 144 <omgdi:waypoint xsi:type="omgdc:Point" x="390" y="162" /> 145 <bpmndi:BPMNLabel> 146 <omgdc:Bounds x="495" y="140" width="90" height="20" /> 147 </bpmndi:BPMNLabel> 148 </bpmndi:BPMNEdge> 149 <bpmndi:BPMNEdge id="SequenceFlow_2_di" bpmnElement="SequenceFlow_2"> 150 <omgdi:waypoint xsi:type="omgdc:Point" x="440" y="202" /> 151 <omgdi:waypoint xsi:type="omgdc:Point" x="508" y="202" /> 152 <bpmndi:BPMNLabel> 153 <omgdc:Bounds x="433" y="192" width="90" height="20" /> 154 </bpmndi:BPMNLabel> 155 </bpmndi:BPMNEdge> 156 <bpmndi:BPMNEdge id="SequenceFlow_0snv4kp_di" bpmnElement="SequenceFlow_0snv4kp"> 157 <omgdi:waypoint xsi:type="omgdc:Point" x="548" y="202" /> 158 <omgdi:waypoint xsi:type="omgdc:Point" x="648" y="202" /> 159 <bpmndi:BPMNLabel> 160 <omgdc:Bounds x="550" y="183" width="90" height="20" /> 161 </bpmndi:BPMNLabel> 162 </bpmndi:BPMNEdge> 163 </bpmndi:BPMNPlane> 164 </bpmndi:BPMNDiagram> 165 </definitions> 166 XML; 167 } 168 169 private function _get_open_text_dmn() 170 { 171 return <<<XML 172 <?xml version="1.0" encoding="UTF-8"?> 173 <definitions 174 xmlns="https://www.omg.org/spec/DMN/20191111/MODEL/" 175 xmlns:dmndi="https://www.omg.org/spec/DMN/20191111/DMNDI/" 176 xmlns:dc="http://www.omg.org/spec/DMN/20180521/DC/" 177 xmlns:di="http://www.omg.org/spec/DMN/20180521/DI/" 178 id="dmn_diagram" name=" 179 XML; 180 } 181 182 private function _get_close_text_dmn() 183 { 184 return <<<XML 185 " namespace="http://camunda.org/schema/1.0/dmn"> 186 <inputData id="dayType_id" name="Type of day"> 187 <variable id="dayType_ii" name="Type of day" typeRef="string" /> 188 </inputData> 189 <inputData id="temperature_id" name="Weather in Celsius"> 190 <variable id="temperature_ii" name="Weather in Celsius" typeRef="integer" /> 191 </inputData> 192 <knowledgeSource id="host_ks" name="Host" /> 193 <knowledgeSource id="guest_ks" name="Guest Type"> 194 <authorityRequirement id="AuthorityRequirement_0hyfuzo"> 195 <requiredDecision href="#guestCount" /> 196 </authorityRequirement> 197 </knowledgeSource> 198 <businessKnowledgeModel id="elMenu" name="El menú" /> 199 <decision id="dish-decision" name="Dish Decision"> 200 <informationRequirement id="InformationRequirement_05tgz9d"> 201 <requiredDecision href="#guestCount" /> 202 </informationRequirement> 203 <informationRequirement id="InformationRequirement_1r8doop"> 204 <requiredDecision href="#season" /> 205 </informationRequirement> 206 <authorityRequirement id="AuthorityRequirement_1sk6rin"> 207 <requiredAuthority href="#host_ks" /> 208 </authorityRequirement> 209 <decisionTable id="dishDecisionTable"> 210 <input id="seasonInput" label="Season"> 211 <inputExpression id="seasonInputExpression" typeRef="string"> 212 <text>season</text> 213 </inputExpression> 214 </input> 215 <input id="guestCountInput" label="How many guests"> 216 <inputExpression id="guestCountInputExpression" typeRef="integer"> 217 <text>guestCount</text> 218 </inputExpression> 219 </input> 220 <output id="output1" label="Dish" name="desiredDish" typeRef="string" /> 221 <rule id="row-495762709-1"> 222 <inputEntry id="UnaryTests_1nxcsjr"> 223 <text>"Winter"</text> 224 </inputEntry> 225 <inputEntry id="UnaryTests_1r9yorj"> 226 <text><= 8</text> 227 </inputEntry> 228 <outputEntry id="LiteralExpression_1mtwzqz"> 229 <text>"Spareribs"</text> 230 </outputEntry> 231 </rule> 232 <rule id="row-495762709-2"> 233 <inputEntry id="UnaryTests_1lxjbif"> 234 <text>"Winter"</text> 235 </inputEntry> 236 <inputEntry id="UnaryTests_0nhiedb"> 237 <text>> 8</text> 238 </inputEntry> 239 <outputEntry id="LiteralExpression_1h30r12"> 240 <text>"Pasta"</text> 241 </outputEntry> 242 </rule> 243 <rule id="row-495762709-3"> 244 <inputEntry id="UnaryTests_0ifgmfm"> 245 <text>"Summer"</text> 246 </inputEntry> 247 <inputEntry id="UnaryTests_12cib9m"> 248 <text>> 10</text> 249 </inputEntry> 250 <outputEntry id="LiteralExpression_0wgaegy"> 251 <text>"Light salad"</text> 252 </outputEntry> 253 </rule> 254 <rule id="row-495762709-7"> 255 <inputEntry id="UnaryTests_0ozm9s7"> 256 <text>"Summer"</text> 257 </inputEntry> 258 <inputEntry id="UnaryTests_0sesgov"> 259 <text><= 10</text> 260 </inputEntry> 261 <outputEntry id="LiteralExpression_1dvc5x3"> 262 <text>"Beans salad"</text> 263 </outputEntry> 264 </rule> 265 <rule id="row-445981423-3"> 266 <inputEntry id="UnaryTests_1er0je1"> 267 <text>"Spring"</text> 268 </inputEntry> 269 <inputEntry id="UnaryTests_1uzqner"> 270 <text>< 10</text> 271 </inputEntry> 272 <outputEntry id="LiteralExpression_1pxy4g1"> 273 <text>"Stew"</text> 274 </outputEntry> 275 </rule> 276 <rule id="row-445981423-4"> 277 <inputEntry id="UnaryTests_06or48g"> 278 <text>"Spring"</text> 279 </inputEntry> 280 <inputEntry id="UnaryTests_0wa71sy"> 281 <text>>= 10</text> 282 </inputEntry> 283 <outputEntry id="LiteralExpression_09ggol9"> 284 <text>"Steak"</text> 285 </outputEntry> 286 </rule> 287 </decisionTable> 288 </decision> 289 <decision id="season" name="Season decision"> 290 <informationRequirement id="InformationRequirement_1vzoh7s"> 291 <requiredInput href="#temperature_id" /> 292 </informationRequirement> 293 <decisionTable id="seasonDecisionTable"> 294 <input id="temperatureInput" label="Weather in Celsius"> 295 <inputExpression id="temperatureInputExpression" typeRef="integer"> 296 <text>temperature</text> 297 </inputExpression> 298 </input> 299 <output id="seasonOutput" label="season" name="season" typeRef="string" /> 300 <rule id="row-495762709-5"> 301 <inputEntry id="UnaryTests_1fd0eqo"> 302 <text>>30</text> 303 </inputEntry> 304 <outputEntry id="LiteralExpression_0l98klb"> 305 <text>"Summer"</text> 306 </outputEntry> 307 </rule> 308 <rule id="row-495762709-6"> 309 <inputEntry id="UnaryTests_1nz6at2"> 310 <text><10</text> 311 </inputEntry> 312 <outputEntry id="LiteralExpression_08moy1k"> 313 <text>"Winter"</text> 314 </outputEntry> 315 </rule> 316 <rule id="row-445981423-2"> 317 <inputEntry id="UnaryTests_1a0imxy"> 318 <text>[10..30]</text> 319 </inputEntry> 320 <outputEntry id="LiteralExpression_1poftw4"> 321 <text>"Spring"</text> 322 </outputEntry> 323 </rule> 324 </decisionTable> 325 </decision> 326 <decision id="guestCount" name="Guest Count"> 327 <informationRequirement id="InformationRequirement_038230q"> 328 <requiredInput href="#dayType_id" /> 329 </informationRequirement> 330 <knowledgeRequirement id="KnowledgeRequirement_0cql475"> 331 <requiredKnowledge href="#elMenu" /> 332 </knowledgeRequirement> 333 <decisionTable id="guestCountDecisionTable"> 334 <input id="typeOfDayInput" label="Type of day"> 335 <inputExpression id="typeOfDayInputExpression" typeRef="string"> 336 <text>dayType</text> 337 </inputExpression> 338 </input> 339 <output id="guestCountOutput" label="Guest count" name="guestCount" typeRef="integer" /> 340 <rule id="row-495762709-8"> 341 <inputEntry id="UnaryTests_0l72u8n"> 342 <text>"Weekday"</text> 343 </inputEntry> 344 <outputEntry id="LiteralExpression_0wuwqaz"> 345 <text>4</text> 346 </outputEntry> 347 </rule> 348 <rule id="row-495762709-9"> 349 <inputEntry id="UnaryTests_03a73o9"> 350 <text>"Holiday"</text> 351 </inputEntry> 352 <outputEntry id="LiteralExpression_1whn119"> 353 <text>10</text> 354 </outputEntry> 355 </rule> 356 <rule id="row-495762709-10"> 357 <inputEntry id="UnaryTests_12tygwt"> 358 <text>"Weekend"</text> 359 </inputEntry> 360 <outputEntry id="LiteralExpression_1b5k9t8"> 361 <text>15</text> 362 </outputEntry> 363 </rule> 364 </decisionTable> 365 </decision> 366 <textAnnotation id="TextAnnotation_1"> 367 <text>Week day or week end</text> 368 </textAnnotation> 369 <association id="Association_18hoj4i"> 370 <sourceRef href="#dayType_id" /> 371 <targetRef href="#TextAnnotation_1" /> 372 </association> 373 <dmndi:DMNDI> 374 <dmndi:DMNDiagram id="DMNDiagram_1ejukud"> 375 <dmndi:DMNShape id="DMNShape_1pny77l" dmnElementRef="dayType_id"> 376 <dc:Bounds height="45" width="125" x="303" y="363" /> 377 </dmndi:DMNShape> 378 <dmndi:DMNShape id="DMNShape_1b88mi9" dmnElementRef="temperature_id"> 379 <dc:Bounds height="45" width="125" x="105" y="316" /> 380 </dmndi:DMNShape> 381 <dmndi:DMNShape id="DMNShape_0w9hu9e" dmnElementRef="host_ks"> 382 <dc:Bounds height="63" width="100" x="595" y="56" /> 383 </dmndi:DMNShape> 384 <dmndi:DMNShape id="DMNShape_0159egh" dmnElementRef="guest_ks"> 385 <dc:Bounds height="63" width="100" x="587" y="194" /> 386 </dmndi:DMNShape> 387 <dmndi:DMNEdge id="DMNEdge_1gafs9m" dmnElementRef="AuthorityRequirement_0hyfuzo"> 388 <di:waypoint x="510" y="226" /> 389 <di:waypoint x="587" y="226" /> 390 </dmndi:DMNEdge> 391 <dmndi:DMNShape id="DMNShape_0j9biml" dmnElementRef="elMenu"> 392 <dc:Bounds height="46" width="135" x="542" y="364" /> 393 </dmndi:DMNShape> 394 <dmndi:DMNShape id="DMNShape_1f9xq97" dmnElementRef="dish-decision"> 395 <dc:Bounds height="80" width="180" x="250" y="56" /> 396 </dmndi:DMNShape> 397 <dmndi:DMNEdge id="DMNEdge_0wk9owu" dmnElementRef="InformationRequirement_05tgz9d"> 398 <di:waypoint x="395" y="186" /> 399 <di:waypoint x="365" y="136" /> 400 </dmndi:DMNEdge> 401 <dmndi:DMNEdge id="DMNEdge_0glygnk" dmnElementRef="InformationRequirement_1r8doop"> 402 <di:waypoint x="243" y="186" /> 403 <di:waypoint x="297" y="136" /> 404 </dmndi:DMNEdge> 405 <dmndi:DMNEdge id="DMNEdge_1jf14ck" dmnElementRef="AuthorityRequirement_1sk6rin"> 406 <di:waypoint x="595" y="89" /> 407 <di:waypoint x="430" y="94" /> 408 </dmndi:DMNEdge> 409 <dmndi:DMNShape id="DMNShape_1dlhv62" dmnElementRef="season"> 410 <dc:Bounds height="80" width="180" x="110" y="186" /> 411 </dmndi:DMNShape> 412 <dmndi:DMNEdge id="DMNEdge_01c572k" dmnElementRef="InformationRequirement_1vzoh7s"> 413 <di:waypoint x="180" y="316" /> 414 <di:waypoint x="191" y="266" /> 415 </dmndi:DMNEdge> 416 <dmndi:DMNShape id="DMNShape_0tndkvg" dmnElementRef="guestCount"> 417 <dc:Bounds height="80" width="180" x="330" y="186" /> 418 </dmndi:DMNShape> 419 <dmndi:DMNEdge id="DMNEdge_0wrc9rz" dmnElementRef="KnowledgeRequirement_0cql475"> 420 <di:waypoint x="591" y="364" /> 421 <di:waypoint x="510" y="265" /> 422 </dmndi:DMNEdge> 423 <dmndi:DMNEdge id="DMNEdge_0m045nr" dmnElementRef="InformationRequirement_038230q"> 424 <di:waypoint x="369" y="363" /> 425 <di:waypoint x="405" y="266" /> 426 </dmndi:DMNEdge> 427 <dmndi:DMNShape id="DMNShape_1izzhzd" dmnElementRef="TextAnnotation_1"> 428 <dc:Bounds height="45" width="125" x="273" y="466" /> 429 </dmndi:DMNShape> 430 <dmndi:DMNEdge id="DMNEdge_1mkr3rl" dmnElementRef="Association_18hoj4i"> 431 <di:waypoint x="366" y="408" /> 432 <di:waypoint x="336" y="466" /> 433 </dmndi:DMNEdge> 434 </dmndi:DMNDiagram> 435 </dmndi:DMNDI> 436 </definitions> 437 XML; 438 } 439} 440