1<?php 2/** 3 * DokuWiki Plugin ac (Syntax Component) 4 * 5 * @license GPL 2 http://www.gnu.org/licenses/gpl-2.0.html 6 * @author Adrian Lang <lang@cosmocode.de> 7 */ 8 9if(!defined('DOKU_INC')) die(); 10if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/'); 11require_once DOKU_PLUGIN.'action.php'; 12 13require_once DOKU_PLUGIN . 'ac/common.php'; 14 15class action_plugin_ac extends DokuWiki_Action_Plugin { 16 private $ac = null; 17 18 function __construct() { 19 $this->ac = new syntax_plugin_ac_ac($this->getConf('url'), 20 $this->getConf('token')); 21 } 22 23 function getInfo() { 24 return confToHash(dirname(__FILE__).'/plugin.info.txt'); 25 } 26 27 /** 28 * Register handlers 29 */ 30 function register( Doku_Event_Handler $controller) { 31 $controller->register_hook('AJAX_CALL_UNKNOWN', 'BEFORE', $this, 32 'handle_ajax'); 33 } 34 35 /** 36 * Handle AJAX request 37 */ 38 function handle_ajax($event) { 39 if (!ajax_loader::isLoader('ac', $event->data)) { 40 return; 41 } 42 43 $command = ajax_loader::handleLoad(); 44 $action_classname = 'syntax_plugin_ac_action_' . $command[0]; 45 $action = new $action_classname($this->ac, array_slice($command, 1)); 46 echo $action->exec(); 47 48 $event->stopPropagation(); 49 $event->preventDefault(); 50 } 51 52} 53