X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fapi%2FApiFormatBase.php;h=a8d69f5dc9bec75fb5b45fc23525f02d4e3c622d;hb=67e23ec357d2265bc487bdd4b63e30fcaf5871c7;hp=0dd697c33709379c8aad3fba08b02e72ec095fa2;hpb=dcce018701f12ef7b3831caa8f66ea8b7dca7e94;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/api/ApiFormatBase.php b/includes/api/ApiFormatBase.php index 0dd697c337..a8d69f5dc9 100644 --- a/includes/api/ApiFormatBase.php +++ b/includes/api/ApiFormatBase.php @@ -4,7 +4,7 @@ * * Created on Sep 19, 2006 * - * Copyright © 2006 Yuri Astrakhan @gmail.com + * Copyright © 2006 Yuri Astrakhan "@gmail.com" * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -24,11 +24,6 @@ * @file */ -if ( !defined( 'MEDIAWIKI' ) ) { - // Eclipse helper - will be ignored in production - require_once( 'ApiBase.php' ); -} - /** * This is the abstract base class for API formatters. * @@ -168,8 +163,10 @@ abstract class ApiFormatBase extends ApiBase {
You are looking at the HTML representation of the mFormat ); ?> format.
-HTML is good for debugging, but probably is not suitable for your application.
-See complete documentation, or +HTML is good for debugging, but is unsuitable for application use.
+Specify the format parameter to change the output format.
+To see the non HTML representation of the mFormat ); ?> format, set format=mFormat ) ); ?>.
+See the complete documentation, or API help for more information.
complete documentation, or public function getBuffer() { return $this->mBuffer; } + /** * Set the flag to buffer the result instead of printing it. + * @param $value bool */ public function setBufferResult( $value ) { $this->mBufferResult = $value; @@ -261,13 +260,14 @@ See complete documentation, or $text = htmlspecialchars( $text ); // encode all comments or tags as safe blue strings - $text = preg_replace( '/\<(!--.*?--|.*?)\>/', '<\1>', $text ); + $text = str_replace( '<', '<', $text ); + $text = str_replace( '>', '>', $text ); // identify URLs - $protos = wfUrlProtocols(); + $protos = wfUrlProtocolsWithoutProtRel(); // This regex hacks around bug 13218 (" included in the URL) $text = preg_replace( "#(($protos).*?)(")?([ \\'\"<>\n]|<|>|")#", '\\1\\3\\4', $text ); // identify requests to api.php - $text = preg_replace( "#api\\.php\\?[^ \\()<\n\t]+#", '\\0', $text ); + $text = preg_replace( "#api\\.php\\?[^ <\n\t]+#", '\\0', $text ); if ( $this->mHelp ) { // make strings inside * bold $text = preg_replace( "#\\*[^<>\n]+\\*#", '\\0', $text ); @@ -288,12 +288,15 @@ See complete documentation, or return $text; } - protected function getExamples() { - return 'api.php?action=query&meta=siteinfo&siprop=namespaces&format=' . $this->getModuleName(); + public function getExamples() { + return array( + 'api.php?action=query&meta=siteinfo&siprop=namespaces&format=' . $this->getModuleName() + => "Format the query result in the {$this->getModuleName()} format", + ); } public function getHelpUrls() { - return 'http://www.mediawiki.org/wiki/API:Data_formats'; + return 'https://www.mediawiki.org/wiki/API:Data_formats'; } public function getDescription() { @@ -323,7 +326,7 @@ class ApiFormatFeedWrapper extends ApiFormatBase { */ public static function setResult( $result, $feed, $feedItems ) { // Store output in the Result data. - // This way we can check during execution if any error has occured + // This way we can check during execution if any error has occurred // Disable size checking for this because we can't continue // cleanly; size checking would cause more problems than it'd // solve @@ -335,6 +338,8 @@ class ApiFormatFeedWrapper extends ApiFormatBase { /** * Feed does its own headers + * + * @return null */ public function getMimeType() { return null; @@ -342,6 +347,8 @@ class ApiFormatFeedWrapper extends ApiFormatBase { /** * Optimization - no need to sanitize data that will not be needed + * + * @return bool */ public function getNeedsRawData() { return true; @@ -364,7 +371,7 @@ class ApiFormatFeedWrapper extends ApiFormatBase { } $feed->outFooter(); } else { - // Error has occured, print something useful + // Error has occurred, print something useful ApiBase::dieDebug( __METHOD__, 'Invalid feed class/item' ); } }