xref: /dokuwiki/lib/plugins/extension/action.php (revision b15cd32d2f75fbf943eda38a7b90f05d2806dae5)
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     */
194c005e3fSAndreas 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
254c005e3fSAndreas Gohr    /**
264c005e3fSAndreas Gohr     * Create the detail info for a single plugin
274c005e3fSAndreas Gohr     *
284c005e3fSAndreas Gohr     * @param Doku_Event $event
294c005e3fSAndreas Gohr     * @param            $param
304c005e3fSAndreas Gohr     */
3172dda0b4SAndreas Gohr    public function info(Doku_Event &$event, $param){
32da5f0eeeSAndreas Gohr        global $USERINFO;
3372dda0b4SAndreas Gohr        global $INPUT;
34da5f0eeeSAndreas Gohr
35*b15cd32dSjgpcx
36*b15cd32dSjgpcx        if($event->data != 'plugin_extension') return;
37*b15cd32dSjgpcx        $event->preventDefault();
38*b15cd32dSjgpcx        $event->stopPropagation();
39*b15cd32dSjgpcx
40da5f0eeeSAndreas Gohr        if(empty($_SERVER['REMOTE_USER']) || !auth_isadmin($_SERVER['REMOTE_USER'], $USERINFO['grps'])){
41da5f0eeeSAndreas Gohr            http_status(403);
42da5f0eeeSAndreas Gohr            echo 'Forbidden';
43da5f0eeeSAndreas Gohr            exit;
44da5f0eeeSAndreas Gohr        }
45da5f0eeeSAndreas Gohr
4672dda0b4SAndreas Gohr        header('Content-Type: text/html; charset=utf-8');
4772dda0b4SAndreas Gohr
4872dda0b4SAndreas Gohr        $ext = $INPUT->str('ext');
4972dda0b4SAndreas Gohr        if(!$ext) {
5072dda0b4SAndreas Gohr            echo 'no extension given';
5172dda0b4SAndreas Gohr            return;
5272dda0b4SAndreas Gohr        }
5372dda0b4SAndreas Gohr
5472dda0b4SAndreas Gohr        /** @var helper_plugin_extension_extension $extension */
5572dda0b4SAndreas Gohr        $extension = plugin_load('helper', 'extension_extension');
5672dda0b4SAndreas Gohr        $extension->setExtension($ext);
5772dda0b4SAndreas Gohr
5872dda0b4SAndreas Gohr        /** @var helper_plugin_extension_list $list */
5972dda0b4SAndreas Gohr        $list = plugin_load('helper', 'extension_list');
6072dda0b4SAndreas Gohr
6172dda0b4SAndreas Gohr
6272dda0b4SAndreas Gohr        echo $list->make_info($extension);
6372dda0b4SAndreas Gohr    }
6472dda0b4SAndreas Gohr
6572dda0b4SAndreas Gohr}
6672dda0b4SAndreas Gohr
67