1<?php 2/** 3 * DokuWiki AJAX call handler 4 * 5 * @license GPL 2 (http://www.gnu.org/licenses/gpl.html) 6 * @author Andreas Gohr <andi@splitbrain.org> 7 */ 8 9//fix for Opera XMLHttpRequests 10if(!count($_POST) && $HTTP_RAW_POST_DATA){ 11 parse_str($HTTP_RAW_POST_DATA, $_POST); 12} 13 14if(!defined('DOKU_INC')) define('DOKU_INC',realpath(dirname(__FILE__).'/../../').'/'); 15require_once(DOKU_INC.'inc/init.php'); 16require_once(DOKU_INC.'inc/common.php'); 17require_once(DOKU_INC.'inc/pageutils.php'); 18require_once(DOKU_INC.'inc/auth.php'); 19 20//call the requested function 21$call = 'ajax_'.$_POST['call']; 22if(function_exists($call)){ 23 $call(); 24}else{ 25 print "The called function does not exist!"; 26} 27 28/** 29 * Searches for matching pagenames 30 * 31 * @author Andreas Gohr <andi@splitbrain.org> 32 */ 33function ajax_qsearch(){ 34 global $conf; 35 global $lang; 36 37 $query = cleanID($_POST['q']); 38 if(empty($query)) return; 39 40 $nsdir = str_replace(':','/',getNS($query)); 41 require_once(DOKU_INC.'inc/search.php'); 42 require_once(DOKU_INC.'inc/html.php'); 43 44 $data = array(); 45 search($data,$conf['datadir'],'search_qsearch',array(query => $query),$nsdir); 46 47 if(!count($data)) return; 48 49 print '<b>'.$lang['quickhits'].'</b>'; 50 print html_buildlist($data,'qsearch','html_list_index'); 51} 52 53?> 54