1<?php 2/** 3 * AJAX call handler for Dokutranslate plugin 4 * Based on built-in ACL plugin 5 * 6 * @license GPL 2 (http://www.gnu.org/licenses/gpl.html) 7 * @author Martin Doucha <next_ghost@quick.cz> 8 * @author Andreas Gohr <andi@splitbrain.org> 9 */ 10 11//fix for Opera XMLHttpRequests 12if(!count($_POST) && !empty($HTTP_RAW_POST_DATA)){ 13 parse_str($HTTP_RAW_POST_DATA, $_POST); 14} 15 16if(!defined('DOKU_INC')) define('DOKU_INC',dirname(__FILE__).'/../../../'); 17require_once(DOKU_INC.'inc/init.php'); 18//close session 19session_write_close(); 20 21if(!auth_isadmin()) die('for admins only'); 22if(!checkSecurityToken()) die('CRSF Attack'); 23 24$ID = getID(); 25 26$dokutranslate = plugin_load('admin','dokutranslate'); 27$dokutranslate->handle(); 28 29$ajax = $_REQUEST['ajax']; 30header('Content-Type: text/html; charset=utf-8'); 31 32if($ajax == 'modform'){ 33 $dokutranslate->_html_modform(); 34}elseif($ajax == 'tree'){ 35 global $conf; 36 global $ID; 37 38 $dir = $conf['datadir']; 39 $ns = $_REQUEST['ns']; 40 41 if($ns == '*'){ 42 $ns =''; 43 } 44 45 $ns = cleanID($ns); 46 $lvl = count(explode(':',$ns)); 47 $ns = utf8_encodeFN(str_replace(':','/',$ns)); 48 49 $data = $dokutranslate->_get_tree($ns,$ns); 50 51 foreach(array_keys($data) as $item){ 52 $data[$item]['level'] = $lvl+1; 53 } 54 55 echo html_buildlist($data, 'dokutranslate', array($dokutranslate, '_html_list_acl'), array($dokutranslate, '_html_li_acl')); 56} 57 58