diff --git a/includes/AjaxDispatcher.php b/includes/AjaxDispatcher.php index 2084c36..68f7399 100644 --- a/includes/AjaxDispatcher.php +++ b/includes/AjaxDispatcher.php @@ -56,6 +56,7 @@ class AjaxDispatcher { $this->args = array(); } } + if (!is_array($this->args)) $this->args = array($this->args); wfProfileOut( 'AjaxDispatcher::AjaxDispatcher' ); } @@ -69,9 +70,9 @@ class AjaxDispatcher { if (! in_array( $this->func_name, $wgAjaxExportList ) ) { echo "-:{$this->func_name} not callable"; } else { - echo "+:"; +// WERELATE - remove echo and have ajaxcachepolicy write the content type +// echo "+:"; $result = call_user_func_array($this->func_name, $this->args); - header( 'Content-Type: text/html; charset=utf-8', true ); $wgAjaxCachePolicy->writeHeader(); echo $result; } diff --git a/includes/AjaxFunctions.php b/includes/AjaxFunctions.php index 4387a60..f776164 100644 --- a/includes/AjaxFunctions.php +++ b/includes/AjaxFunctions.php @@ -47,7 +47,7 @@ function js_unescape($source, $iconv_to = 'UTF-8') { if ($iconv_to != "UTF-8") { $decodedStr = iconv("UTF-8", $iconv_to, $decodedStr); } - + return $decodedStr; } @@ -70,18 +70,29 @@ function code2utf($num){ return ''; } +// WERELATE - added setting and writing contentType + class AjaxCachePolicy { var $policy; + var $contentType; function AjaxCachePolicy( $policy = null ) { $this->policy = $policy; + $this->contentType = 'text/xml'; } function setPolicy( $policy ) { $this->policy = $policy; } + // WERELATE + function setContentType($contentType) { + $this->contentType = $contentType; + } + function writeHeader() { + // WERELATE + header( "Content-Type: {$this->contentType}; charset=utf-8", true ); header ("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); if ( is_null( $this->policy ) ) { // Bust cache in the head @@ -95,15 +106,15 @@ class AjaxCachePolicy { } } } - + function wfSajaxSearch( $term ) { global $wgContLang, $wgAjaxCachePolicy, $wgOut; $limit = 16; - + $l = new Linker; - $term = str_replace( ' ', '_', $wgContLang->ucfirst( + $term = str_replace( ' ', '_', $wgContLang->ucfirst( $wgContLang->checkTitleEncoding( $wgContLang->recodeInput( js_unescape( $term ) ) ) ) ); @@ -140,7 +151,7 @@ function wfSajaxSearch( $term ) { $subtitle = $wgOut->parse( wfMsg( $subtitlemsg, wfEscapeWikiText($term) ) ); $term = htmlspecialchars( $term ); - return '
' + return '
' . wfMsg( 'hideresults' ) . '
' . '

'.wfMsg('search') . '

'. $subtitle . '