xref: /dokuwiki/lib/plugins/extension/action.php (revision 72dda0b4378651b271f5fb516fb8e21a80ac3ebf)
1*72dda0b4SAndreas Gohr<?php
2*72dda0b4SAndreas Gohr/** DokuWiki Plugin extension (Action Component)
3*72dda0b4SAndreas Gohr *
4*72dda0b4SAndreas Gohr * @license GPL 2 http://www.gnu.org/licenses/gpl-2.0.html
5*72dda0b4SAndreas Gohr * @author  Andreas Gohr <andi@splitbrain.org>
6*72dda0b4SAndreas Gohr */
7*72dda0b4SAndreas Gohr
8*72dda0b4SAndreas Gohr// must be run within Dokuwiki
9*72dda0b4SAndreas Gohrif(!defined('DOKU_INC')) die();
10*72dda0b4SAndreas Gohr
11*72dda0b4SAndreas Gohrclass action_plugin_extension extends DokuWiki_Action_Plugin {
12*72dda0b4SAndreas Gohr
13*72dda0b4SAndreas Gohr    /**
14*72dda0b4SAndreas Gohr     * Registers a callback function for a given event
15*72dda0b4SAndreas Gohr     *
16*72dda0b4SAndreas Gohr     * @param Doku_Event_Handler $controller DokuWiki's event controller object
17*72dda0b4SAndreas Gohr     * @return void
18*72dda0b4SAndreas Gohr     */
19*72dda0b4SAndreas Gohr    public function register(Doku_Event_Handler &$controller) {
20*72dda0b4SAndreas Gohr
21*72dda0b4SAndreas Gohr        $controller->register_hook('AJAX_CALL_UNKNOWN', 'BEFORE', $this, 'info');
22*72dda0b4SAndreas Gohr
23*72dda0b4SAndreas Gohr    }
24*72dda0b4SAndreas Gohr
25*72dda0b4SAndreas Gohr    public function info(Doku_Event &$event, $param){
26*72dda0b4SAndreas Gohr        global $INPUT;
27*72dda0b4SAndreas Gohr        if($event->data != 'plugin_extension') return;
28*72dda0b4SAndreas Gohr        $event->preventDefault();
29*72dda0b4SAndreas Gohr        $event->stopPropagation();
30*72dda0b4SAndreas Gohr
31*72dda0b4SAndreas Gohr        header('Content-Type: text/html; charset=utf-8');
32*72dda0b4SAndreas Gohr
33*72dda0b4SAndreas Gohr        $ext = $INPUT->str('ext');
34*72dda0b4SAndreas Gohr        if(!$ext) {
35*72dda0b4SAndreas Gohr            echo 'no extension given';
36*72dda0b4SAndreas Gohr            return;
37*72dda0b4SAndreas Gohr        }
38*72dda0b4SAndreas Gohr
39*72dda0b4SAndreas Gohr        /** @var helper_plugin_extension_extension $extension */
40*72dda0b4SAndreas Gohr        $extension = plugin_load('helper', 'extension_extension');
41*72dda0b4SAndreas Gohr        $extension->setExtension($ext);
42*72dda0b4SAndreas Gohr
43*72dda0b4SAndreas Gohr        /** @var helper_plugin_extension_list $list */
44*72dda0b4SAndreas Gohr        $list = plugin_load('helper', 'extension_list');
45*72dda0b4SAndreas Gohr
46*72dda0b4SAndreas Gohr
47*72dda0b4SAndreas Gohr        echo $list->make_info($extension);
48*72dda0b4SAndreas Gohr    }
49*72dda0b4SAndreas Gohr
50*72dda0b4SAndreas Gohr}
51*72dda0b4SAndreas Gohr
52