1<?php 2/* 3 * Yurii's Gantt Plugin 4 * 5 * Copyright (C) 2020 Yurii K. 6 * 7 * This program is free software: you can redistribute it and/or modify 8 * it under the terms of the GNU General Public License as published by 9 * the Free Software Foundation, either version 3 of the License, or 10 * (at your option) any later version. 11 * 12 * This program is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 * 17 * You should have received a copy of the GNU General Public License 18 * along with this program. If not, see http://www.gnu.org/licenses 19 */ 20 21use \dokuwiki\plugin\yuriigantt\src\JsonRequest; 22use dokuwiki\plugin\yuriigantt\src\Driver\Embedded; 23 24class action_plugin_yuriigantt extends DokuWiki_Action_Plugin //\dokuwiki\Extension\ActionPlugin 25{ 26 /** 27 * {@inheritdoc} 28 */ 29 public function register(\Doku_Event_Handler $controller) 30 { 31 $controller->register_hook('AJAX_CALL_UNKNOWN', 'BEFORE', $this, 'callback'); 32 } 33 34 35 public function callback(Doku_Event $event, $param) 36 { 37 global $INPUT; 38 39 if ($event->data !== 'plugin_' . $this->getPluginName()) { 40 return; 41 } 42 43 //no other ajax call handlers needed 44 $event->stopPropagation(); 45 $event->preventDefault(); 46 47 header('Content-Type: application/json'); 48 echo (new JsonRequest(new Embedded(), $INPUT->param('csrf'), $INPUT->param('payload')))->handle(); 49 } 50} 51