xref: /dokuwiki/lib/plugins/extension/action.php (revision 4c005e3f9adeb9180a879cc38518d1cff63e9261)
172dda0b4SAndreas Gohr<?php
272dda0b4SAndreas Gohr/** DokuWiki Plugin extension (Action Component)
372dda0b4SAndreas Gohr *
472dda0b4SAndreas Gohr * @license GPL 2 http://www.gnu.org/licenses/gpl-2.0.html
572dda0b4SAndreas Gohr * @author  Andreas Gohr <andi@splitbrain.org>
672dda0b4SAndreas Gohr */
772dda0b4SAndreas Gohr
872dda0b4SAndreas Gohr// must be run within Dokuwiki
972dda0b4SAndreas Gohrif(!defined('DOKU_INC')) die();
1072dda0b4SAndreas Gohr
1172dda0b4SAndreas Gohrclass action_plugin_extension extends DokuWiki_Action_Plugin {
1272dda0b4SAndreas Gohr
1372dda0b4SAndreas Gohr    /**
1472dda0b4SAndreas Gohr     * Registers a callback function for a given event
1572dda0b4SAndreas Gohr     *
1672dda0b4SAndreas Gohr     * @param Doku_Event_Handler $controller DokuWiki's event controller object
1772dda0b4SAndreas Gohr     * @return void
1872dda0b4SAndreas Gohr     */
19*4c005e3fSAndreas Gohr    public function register(Doku_Event_Handler $controller) {
2072dda0b4SAndreas Gohr
2172dda0b4SAndreas Gohr        $controller->register_hook('AJAX_CALL_UNKNOWN', 'BEFORE', $this, 'info');
2272dda0b4SAndreas Gohr
2372dda0b4SAndreas Gohr    }
2472dda0b4SAndreas Gohr
25*4c005e3fSAndreas Gohr    /**
26*4c005e3fSAndreas Gohr     * Create the detail info for a single plugin
27*4c005e3fSAndreas Gohr     *
28*4c005e3fSAndreas Gohr     * @param Doku_Event $event
29*4c005e3fSAndreas Gohr     * @param            $param
30*4c005e3fSAndreas Gohr     */
3172dda0b4SAndreas Gohr    public function info(Doku_Event &$event, $param){
3272dda0b4SAndreas Gohr        global $INPUT;
3372dda0b4SAndreas Gohr        if($event->data != 'plugin_extension') return;
3472dda0b4SAndreas Gohr        $event->preventDefault();
3572dda0b4SAndreas Gohr        $event->stopPropagation();
3672dda0b4SAndreas Gohr
3772dda0b4SAndreas Gohr        header('Content-Type: text/html; charset=utf-8');
3872dda0b4SAndreas Gohr
3972dda0b4SAndreas Gohr        $ext = $INPUT->str('ext');
4072dda0b4SAndreas Gohr        if(!$ext) {
4172dda0b4SAndreas Gohr            echo 'no extension given';
4272dda0b4SAndreas Gohr            return;
4372dda0b4SAndreas Gohr        }
4472dda0b4SAndreas Gohr
4572dda0b4SAndreas Gohr        /** @var helper_plugin_extension_extension $extension */
4672dda0b4SAndreas Gohr        $extension = plugin_load('helper', 'extension_extension');
4772dda0b4SAndreas Gohr        $extension->setExtension($ext);
4872dda0b4SAndreas Gohr
4972dda0b4SAndreas Gohr        /** @var helper_plugin_extension_list $list */
5072dda0b4SAndreas Gohr        $list = plugin_load('helper', 'extension_list');
5172dda0b4SAndreas Gohr
5272dda0b4SAndreas Gohr
5372dda0b4SAndreas Gohr        echo $list->make_info($extension);
5472dda0b4SAndreas Gohr    }
5572dda0b4SAndreas Gohr
5672dda0b4SAndreas Gohr}
5772dda0b4SAndreas Gohr
58