1<?php 2/** 3 * Move Plugin Tree Loading Functionality 4 * 5 * @license GPL 2 (http://www.gnu.org/licenses/gpl.html) 6 * @author Andreas Gohr <gohr@cosmocode.de> 7 */ 8// must be run within Dokuwiki 9if(!defined('DOKU_INC')) die(); 10 11/** 12 * Class action_plugin_move_rewrite 13 */ 14class action_plugin_move_tree extends DokuWiki_Action_Plugin { 15 16 /** 17 * Register event handlers. 18 * 19 * @param Doku_Event_Handler $controller The plugin controller 20 */ 21 public function register(Doku_Event_Handler $controller) { 22 $controller->register_hook('AJAX_CALL_UNKNOWN', 'BEFORE', $this, 'handle_ajax_call'); 23 } 24 25 /** 26 * Render a subtree 27 * 28 * @param Doku_Event $event 29 * @param $params 30 */ 31 public function handle_ajax_call(Doku_Event $event, $params) { 32 if($event->data != 'plugin_move_tree') return; 33 $event->preventDefault(); 34 $event->stopPropagation(); 35 36 global $INPUT; 37 global $USERINFO; 38 39 if(!auth_ismanager($_SERVER['REMOTE_USER'], $USERINFO['grps'])) { 40 http_status(403); 41 exit; 42 } 43 44 /** @var admin_plugin_move_tree $plugin */ 45 $plugin = plugin_load('admin', 'move_tree'); 46 47 $ns = cleanID($INPUT->str('ns')); 48 if($INPUT->bool('is_media')) { 49 $type = admin_plugin_move_tree::TYPE_MEDIA; 50 } else { 51 $type = admin_plugin_move_tree::TYPE_PAGES; 52 } 53 54 $data = $plugin->tree($type, $ns, $ns); 55 56 echo html_buildlist( 57 $data, 'tree_list', 58 array($plugin, 'html_list'), 59 array($plugin, 'html_li') 60 ); 61 } 62 63}