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