2013-12-17 21:20:13 +00:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* 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
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
* http://www.gnu.org/copyleft/gpl.html
|
|
|
|
*/
|
|
|
|
|
2014-12-31 23:02:05 +00:00
|
|
|
namespace TextExtracts;
|
|
|
|
|
|
|
|
use ApiBase;
|
|
|
|
use ApiMain;
|
|
|
|
use ApiQueryBase;
|
2017-05-16 00:13:47 +00:00
|
|
|
use BagOStuff;
|
2014-12-31 23:02:05 +00:00
|
|
|
use Config;
|
|
|
|
use FauxRequest;
|
2017-08-01 21:03:26 +00:00
|
|
|
use MediaWiki\Logger\LoggerFactory;
|
2016-09-23 01:51:12 +00:00
|
|
|
use MediaWiki\MediaWikiServices;
|
2014-12-31 23:02:05 +00:00
|
|
|
use MWTidy;
|
2017-08-02 13:23:48 +00:00
|
|
|
|
2014-12-31 23:02:05 +00:00
|
|
|
use ParserOptions;
|
|
|
|
use Title;
|
2016-11-03 19:16:57 +00:00
|
|
|
use ApiUsageException;
|
2014-12-31 23:02:05 +00:00
|
|
|
use UsageException;
|
|
|
|
use User;
|
|
|
|
use WikiPage;
|
|
|
|
|
2013-12-17 21:20:13 +00:00
|
|
|
class ApiQueryExtracts extends ApiQueryBase {
|
2017-05-12 18:19:51 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Bump when memcache needs clearing
|
|
|
|
*/
|
|
|
|
const CACHE_VERSION = 1;
|
|
|
|
|
2013-12-17 21:20:13 +00:00
|
|
|
/**
|
|
|
|
* @var ParserOptions
|
|
|
|
*/
|
|
|
|
private $parserOptions;
|
|
|
|
private $params;
|
2014-08-13 06:18:34 +00:00
|
|
|
/**
|
|
|
|
* @var Config
|
|
|
|
*/
|
|
|
|
private $config;
|
2013-12-17 21:20:13 +00:00
|
|
|
|
2015-07-30 04:28:41 +00:00
|
|
|
// TODO: Allow extensions to hook into this to opt-in.
|
|
|
|
// This is partly for security reasons; see T107170.
|
|
|
|
/**
|
|
|
|
* @var array
|
|
|
|
*/
|
2016-09-23 01:38:27 +00:00
|
|
|
private $supportedContentModels = [ 'wikitext' ];
|
2015-07-30 04:28:41 +00:00
|
|
|
|
2014-08-13 06:18:34 +00:00
|
|
|
public function __construct( $query, $moduleName, Config $conf ) {
|
2013-12-17 21:20:13 +00:00
|
|
|
parent::__construct( $query, $moduleName, 'ex' );
|
2014-08-13 06:18:34 +00:00
|
|
|
$this->config = $conf;
|
2013-12-17 21:20:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public function execute() {
|
|
|
|
$titles = $this->getPageSet()->getGoodTitles();
|
|
|
|
if ( count( $titles ) == 0 ) {
|
|
|
|
return;
|
|
|
|
}
|
2017-05-19 16:39:27 +00:00
|
|
|
$isXml = $this->getMain()->isInternalMode()
|
|
|
|
|| $this->getMain()->getPrinter()->getFormat() == 'XML';
|
2013-12-17 21:20:13 +00:00
|
|
|
$result = $this->getResult();
|
|
|
|
$params = $this->params = $this->extractRequestParams();
|
|
|
|
$this->requireMaxOneParameter( $params, 'chars', 'sentences' );
|
|
|
|
$continue = 0;
|
|
|
|
$limit = intval( $params['limit'] );
|
|
|
|
if ( $limit > 1 && !$params['intro'] ) {
|
|
|
|
$limit = 1;
|
2017-08-02 13:23:48 +00:00
|
|
|
$this->addWarning( [ 'apiwarn-textextracts-limit', $limit ] );
|
2013-12-17 21:20:13 +00:00
|
|
|
}
|
|
|
|
if ( isset( $params['continue'] ) ) {
|
|
|
|
$continue = intval( $params['continue'] );
|
2016-11-03 19:16:57 +00:00
|
|
|
$this->dieContinueUsageIf( $continue < 0 || $continue > count( $titles ) );
|
2013-12-17 21:20:13 +00:00
|
|
|
$titles = array_slice( $titles, $continue, null, true );
|
|
|
|
}
|
|
|
|
$count = 0;
|
2017-07-07 17:05:07 +00:00
|
|
|
$titleInFileNamespace = false;
|
2013-12-17 21:20:13 +00:00
|
|
|
/** @var Title $t */
|
|
|
|
foreach ( $titles as $id => $t ) {
|
|
|
|
if ( ++$count > $limit ) {
|
|
|
|
$this->setContinueEnumParameter( 'continue', $continue + $count - 1 );
|
|
|
|
break;
|
|
|
|
}
|
2017-07-07 17:05:07 +00:00
|
|
|
|
|
|
|
if ( $t->inNamespace( NS_FILE ) ) {
|
|
|
|
$text = '';
|
|
|
|
$titleInFileNamespace = true;
|
|
|
|
} else {
|
|
|
|
$text = $this->getExtract( $t );
|
|
|
|
$text = $this->truncate( $text );
|
|
|
|
if ( $this->params['plaintext'] ) {
|
|
|
|
$text = $this->doSections( $text );
|
|
|
|
}
|
2013-12-17 21:20:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if ( $isXml ) {
|
2016-09-23 01:38:27 +00:00
|
|
|
$fit = $result->addValue( [ 'query', 'pages', $id ], 'extract', [ '*' => $text ] );
|
2013-12-17 21:20:13 +00:00
|
|
|
} else {
|
2016-09-23 01:38:27 +00:00
|
|
|
$fit = $result->addValue( [ 'query', 'pages', $id ], 'extract', $text );
|
2013-12-17 21:20:13 +00:00
|
|
|
}
|
|
|
|
if ( !$fit ) {
|
|
|
|
$this->setContinueEnumParameter( 'continue', $continue + $count - 1 );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2017-07-07 17:05:07 +00:00
|
|
|
if ( $titleInFileNamespace ) {
|
|
|
|
$this->addWarning( 'apiwarn-textextracts-title-in-file-namespace' );
|
|
|
|
}
|
2013-12-17 21:20:13 +00:00
|
|
|
}
|
|
|
|
|
2014-03-29 11:53:59 +00:00
|
|
|
public function getCacheMode( $params ) {
|
|
|
|
return 'public';
|
|
|
|
}
|
|
|
|
|
2013-12-17 21:20:13 +00:00
|
|
|
/**
|
|
|
|
* Returns a processed, but not trimmed extract
|
|
|
|
* @param Title $title
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
private function getExtract( Title $title ) {
|
2015-07-30 04:28:41 +00:00
|
|
|
$contentModel = $title->getContentModel();
|
|
|
|
if ( !in_array( $contentModel, $this->supportedContentModels, true ) ) {
|
2017-08-02 13:23:48 +00:00
|
|
|
$this->addWarning( [
|
|
|
|
'apiwarn-textextracts-unsupportedmodel',
|
|
|
|
wfEscapeWikiText( $title->getPrefixedText() ),
|
|
|
|
$contentModel
|
|
|
|
] );
|
2015-07-30 04:28:41 +00:00
|
|
|
return '';
|
|
|
|
}
|
|
|
|
|
2013-12-17 21:20:13 +00:00
|
|
|
$page = WikiPage::factory( $title );
|
|
|
|
|
|
|
|
$introOnly = $this->params['intro'];
|
|
|
|
$text = $this->getFromCache( $page, $introOnly );
|
|
|
|
// if we need just first section, try retrieving full page and getting first section out of it
|
|
|
|
if ( $text === false && $introOnly ) {
|
|
|
|
$text = $this->getFromCache( $page, false );
|
|
|
|
if ( $text !== false ) {
|
|
|
|
$text = $this->getFirstSection( $text, $this->params['plaintext'] );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ( $text === false ) {
|
|
|
|
$text = $this->parse( $page );
|
2016-09-23 01:51:12 +00:00
|
|
|
$text = $this->convertText( $text );
|
2013-12-17 21:20:13 +00:00
|
|
|
$this->setCache( $page, $text );
|
|
|
|
}
|
|
|
|
return $text;
|
|
|
|
}
|
|
|
|
|
2017-05-16 00:13:47 +00:00
|
|
|
private function cacheKey( BagOStuff $cache, WikiPage $page, $introOnly ) {
|
|
|
|
return $cache->makeKey( 'textextracts', self::CACHE_VERSION,
|
2017-05-12 18:19:51 +00:00
|
|
|
$page->getId(), $page->getTouched(),
|
2014-06-19 00:57:11 +00:00
|
|
|
$page->getTitle()->getPageLanguage()->getPreferredVariant(),
|
|
|
|
$this->params['plaintext'], $introOnly
|
|
|
|
);
|
2013-12-17 21:20:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private function getFromCache( WikiPage $page, $introOnly ) {
|
|
|
|
global $wgMemc;
|
|
|
|
|
2017-05-16 00:13:47 +00:00
|
|
|
$key = $this->cacheKey( $wgMemc, $page, $introOnly );
|
2013-12-17 21:20:13 +00:00
|
|
|
return $wgMemc->get( $key );
|
|
|
|
}
|
|
|
|
|
|
|
|
private function setCache( WikiPage $page, $text ) {
|
|
|
|
global $wgMemc;
|
|
|
|
|
2017-05-16 00:13:47 +00:00
|
|
|
$key = $this->cacheKey( $wgMemc, $page, $this->params['intro'] );
|
|
|
|
$wgMemc->set( $key, $text, $this->getConfig()->get( 'ParserCacheExpireTime' ) );
|
2013-12-17 21:20:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private function getFirstSection( $text, $plainText ) {
|
|
|
|
if ( $plainText ) {
|
|
|
|
$regexp = '/^(.*?)(?=' . ExtractFormatter::SECTION_MARKER_START . ')/s';
|
|
|
|
} else {
|
|
|
|
$regexp = '/^(.*?)(?=<h[1-6]\b)/s';
|
|
|
|
}
|
|
|
|
if ( preg_match( $regexp, $text, $matches ) ) {
|
|
|
|
$text = $matches[0];
|
|
|
|
}
|
|
|
|
return $text;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns page HTML
|
|
|
|
* @param WikiPage $page
|
2017-08-01 21:03:26 +00:00
|
|
|
* @return string|null
|
|
|
|
* @throws ApiUsageException
|
|
|
|
* @throws UsageException
|
2013-12-17 21:20:13 +00:00
|
|
|
*/
|
|
|
|
private function parse( WikiPage $page ) {
|
2017-08-01 21:03:26 +00:00
|
|
|
$apiException = null;
|
2013-12-17 21:20:13 +00:00
|
|
|
if ( !$this->parserOptions ) {
|
|
|
|
$this->parserOptions = new ParserOptions( new User( '127.0.0.1' ) );
|
2017-05-12 16:20:38 +00:00
|
|
|
if ( is_callable( [ $this->parserOptions, 'setWrapOutputClass' ] ) ) {
|
|
|
|
$this->parserOptions->setWrapOutputClass( false );
|
|
|
|
}
|
2013-12-17 21:20:13 +00:00
|
|
|
}
|
|
|
|
// first try finding full page in parser cache
|
2016-09-23 01:58:55 +00:00
|
|
|
if ( $page->shouldCheckParserCache( $this->parserOptions, 0 ) ) {
|
2017-08-02 13:23:48 +00:00
|
|
|
$pout = MediaWikiServices::getInstance()->getParserCache()->get( $page, $this->parserOptions );
|
2013-12-17 21:20:13 +00:00
|
|
|
if ( $pout ) {
|
|
|
|
$text = $pout->getText();
|
|
|
|
if ( $this->params['intro'] ) {
|
|
|
|
$text = $this->getFirstSection( $text, false );
|
|
|
|
}
|
|
|
|
return $text;
|
|
|
|
}
|
|
|
|
}
|
2016-09-23 01:38:27 +00:00
|
|
|
$request = [
|
2013-12-17 21:20:13 +00:00
|
|
|
'action' => 'parse',
|
|
|
|
'page' => $page->getTitle()->getPrefixedText(),
|
2017-05-12 16:20:38 +00:00
|
|
|
'prop' => 'text',
|
2017-06-28 15:55:00 +00:00
|
|
|
// Invokes special handling when using partial wikitext (T168743)
|
|
|
|
'sectionpreview' => 1,
|
2017-05-12 16:20:38 +00:00
|
|
|
'wrapoutputclass' => '',
|
2016-09-23 01:38:27 +00:00
|
|
|
];
|
2013-12-17 21:20:13 +00:00
|
|
|
if ( $this->params['intro'] ) {
|
|
|
|
$request['section'] = 0;
|
|
|
|
}
|
|
|
|
// in case of cache miss, render just the needed section
|
2016-09-23 01:38:27 +00:00
|
|
|
$api = new ApiMain( new FauxRequest( $request ) );
|
2014-12-17 15:01:06 +00:00
|
|
|
try {
|
|
|
|
$api->execute();
|
2016-09-23 01:38:27 +00:00
|
|
|
$data = $api->getResult()->getResultData( null, [
|
|
|
|
'BC' => [],
|
|
|
|
'Types' => [],
|
|
|
|
] );
|
2016-11-03 19:16:57 +00:00
|
|
|
} catch ( ApiUsageException $e ) {
|
2017-08-01 21:03:26 +00:00
|
|
|
$apiException = $e->__toString();
|
2016-11-03 19:16:57 +00:00
|
|
|
if ( $e->getStatusValue()->hasMessage( 'apierror-nosuchsection' ) ) {
|
|
|
|
// Looks like we tried to get the intro to a page without
|
|
|
|
// sections! Lets just grab what we can get.
|
|
|
|
unset( $request['section'] );
|
|
|
|
$api = new ApiMain( new FauxRequest( $request ) );
|
|
|
|
$api->execute();
|
|
|
|
$data = $api->getResult()->getResultData( null, [
|
|
|
|
'BC' => [],
|
|
|
|
'Types' => [],
|
|
|
|
] );
|
|
|
|
} else {
|
|
|
|
// Some other unexpected error - lets just report it to the user
|
|
|
|
// on the off chance that is the right thing.
|
|
|
|
throw $e;
|
|
|
|
}
|
2014-12-17 15:01:06 +00:00
|
|
|
} catch ( UsageException $e ) {
|
2017-08-01 21:03:26 +00:00
|
|
|
$apiException = $e->__toString();
|
2014-12-17 15:01:06 +00:00
|
|
|
if ( $e->getCodeString() === 'nosuchsection' ) {
|
|
|
|
// Looks like we tried to get the intro to a page without
|
|
|
|
// sections! Lets just grab what we can get.
|
|
|
|
unset( $request['section'] );
|
2016-09-23 01:38:27 +00:00
|
|
|
$api = new ApiMain( new FauxRequest( $request ) );
|
2014-12-17 15:01:06 +00:00
|
|
|
$api->execute();
|
2016-09-23 01:38:27 +00:00
|
|
|
$data = $api->getResult()->getResultData( null, [
|
|
|
|
'BC' => [],
|
|
|
|
'Types' => [],
|
|
|
|
] );
|
2014-12-17 15:01:06 +00:00
|
|
|
} else {
|
|
|
|
// Some other unexpected error - lets just report it to the user
|
|
|
|
// on the off chance that is the right thing.
|
|
|
|
throw $e;
|
|
|
|
}
|
|
|
|
}
|
2017-08-01 21:03:26 +00:00
|
|
|
if ( !array_key_exists( 'parse', $data ) ) {
|
|
|
|
LoggerFactory::getInstance( 'textextracts' )->warning(
|
|
|
|
'API Parse request failed while generating text extract', [
|
|
|
|
'title' => $page->getTitle()->getFullText(),
|
|
|
|
'url' => $this->getRequest()->getFullRequestURL(),
|
|
|
|
'exception' => $apiException,
|
|
|
|
'request' => $request
|
|
|
|
] );
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2013-12-17 21:20:13 +00:00
|
|
|
return $data['parse']['text']['*'];
|
|
|
|
}
|
|
|
|
|
2015-12-09 23:33:24 +00:00
|
|
|
/**
|
2017-11-30 02:56:29 +00:00
|
|
|
* @param \ApiQuery $query API query module
|
|
|
|
* @param string $name Name of this query module
|
2015-12-11 23:11:43 +00:00
|
|
|
* @return ApiQueryExtracts
|
2015-12-09 23:33:24 +00:00
|
|
|
*/
|
2017-11-30 02:56:29 +00:00
|
|
|
public static function factory( $query, $name ) {
|
2016-09-23 01:51:12 +00:00
|
|
|
$config = MediaWikiServices::getInstance()->getConfigFactory()->makeConfig( 'textextracts' );
|
2017-11-30 02:56:29 +00:00
|
|
|
return new self( $query, $name, $config );
|
2015-12-09 23:33:24 +00:00
|
|
|
}
|
|
|
|
|
2013-12-17 21:20:13 +00:00
|
|
|
/**
|
|
|
|
* Converts page HTML into an extract
|
|
|
|
* @param string $text
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
private function convertText( $text ) {
|
2014-08-13 06:18:34 +00:00
|
|
|
$fmt = new ExtractFormatter(
|
|
|
|
$text,
|
|
|
|
$this->params['plaintext'],
|
|
|
|
$this->config
|
|
|
|
);
|
2013-12-17 21:20:13 +00:00
|
|
|
$text = $fmt->getText();
|
|
|
|
|
|
|
|
return trim( $text );
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Truncate the given text to a certain number of characters or sentences
|
|
|
|
* @param string $text The text to truncate
|
|
|
|
* @return string
|
|
|
|
*/
|
2014-04-23 01:12:44 +00:00
|
|
|
private function truncate( $text ) {
|
2013-12-17 21:20:13 +00:00
|
|
|
if ( $this->params['chars'] ) {
|
|
|
|
return $this->getFirstChars( $text, $this->params['chars'] );
|
|
|
|
} elseif ( $this->params['sentences'] ) {
|
2014-04-23 01:12:44 +00:00
|
|
|
return $this->getFirstSentences( $text, $this->params['sentences'] );
|
2013-12-17 21:20:13 +00:00
|
|
|
}
|
|
|
|
return $text;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns no more than a requested number of characters
|
|
|
|
* @param string $text
|
|
|
|
* @param int $requestedLength
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
private function getFirstChars( $text, $requestedLength ) {
|
2014-04-23 01:12:44 +00:00
|
|
|
$text = ExtractFormatter::getFirstChars( $text, $requestedLength );
|
2013-12-17 21:20:13 +00:00
|
|
|
// Fix possibly unclosed tags
|
|
|
|
$text = $this->tidy( $text );
|
|
|
|
$text .= wfMessage( 'ellipsis' )->inContentLanguage()->text();
|
|
|
|
return $text;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param string $text
|
|
|
|
* @param int $requestedSentenceCount
|
|
|
|
* @return string
|
|
|
|
*/
|
2014-04-23 01:12:44 +00:00
|
|
|
private function getFirstSentences( $text, $requestedSentenceCount ) {
|
|
|
|
$text = ExtractFormatter::getFirstSentences( $text, $requestedSentenceCount );
|
2013-12-17 21:20:13 +00:00
|
|
|
$text = $this->tidy( $text );
|
|
|
|
return $text;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* A simple wrapper around tidy
|
|
|
|
* @param string $text
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
private function tidy( $text ) {
|
2017-07-07 18:27:36 +00:00
|
|
|
$tidyConfig = $this->getConfig()->get( 'TidyConfig' );
|
|
|
|
|
|
|
|
if ( $tidyConfig !== null && !$this->params['plaintext'] ) {
|
2016-09-23 01:38:27 +00:00
|
|
|
$text = trim( MWTidy::tidy( $text ) );
|
2013-12-17 21:20:13 +00:00
|
|
|
}
|
|
|
|
return $text;
|
|
|
|
}
|
|
|
|
|
|
|
|
private function doSections( $text ) {
|
|
|
|
$text = preg_replace_callback(
|
2017-05-19 16:39:27 +00:00
|
|
|
"/" . ExtractFormatter::SECTION_MARKER_START . '(\d)' .
|
|
|
|
ExtractFormatter::SECTION_MARKER_END . "(.*?)$/m",
|
2016-09-23 01:38:27 +00:00
|
|
|
[ $this, 'sectionCallback' ],
|
2013-12-17 21:20:13 +00:00
|
|
|
$text
|
|
|
|
);
|
|
|
|
return $text;
|
|
|
|
}
|
|
|
|
|
|
|
|
private function sectionCallback( $matches ) {
|
|
|
|
if ( $this->params['sectionformat'] == 'raw' ) {
|
|
|
|
return $matches[0];
|
|
|
|
}
|
2017-11-30 01:27:15 +00:00
|
|
|
$sectionformat = ucfirst( $this->params['sectionformat'] );
|
|
|
|
$func = __CLASS__ . "::doSection{$sectionformat}";
|
2013-12-17 21:20:13 +00:00
|
|
|
return call_user_func( $func, $matches[1], trim( $matches[2] ) );
|
|
|
|
}
|
|
|
|
|
2017-11-30 01:27:15 +00:00
|
|
|
private static function doSectionWiki( $level, $text ) {
|
2013-12-17 21:20:13 +00:00
|
|
|
$bars = str_repeat( '=', $level );
|
|
|
|
return "\n$bars $text $bars";
|
|
|
|
}
|
|
|
|
|
2017-11-30 01:27:15 +00:00
|
|
|
private static function doSectionPlain( $level, $text ) {
|
2013-12-17 21:20:13 +00:00
|
|
|
return "\n$text";
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getAllowedParams() {
|
2016-09-23 01:38:27 +00:00
|
|
|
return [
|
|
|
|
'chars' => [
|
2013-12-17 21:20:13 +00:00
|
|
|
ApiBase::PARAM_TYPE => 'integer',
|
|
|
|
ApiBase::PARAM_MIN => 1,
|
2017-05-24 22:04:20 +00:00
|
|
|
ApiBase::PARAM_MAX => 1200,
|
2016-09-23 01:38:27 +00:00
|
|
|
],
|
|
|
|
'sentences' => [
|
2013-12-17 21:20:13 +00:00
|
|
|
ApiBase::PARAM_TYPE => 'integer',
|
|
|
|
ApiBase::PARAM_MIN => 1,
|
|
|
|
ApiBase::PARAM_MAX => 10,
|
2016-09-23 01:38:27 +00:00
|
|
|
],
|
|
|
|
'limit' => [
|
2017-05-19 13:37:26 +00:00
|
|
|
ApiBase::PARAM_DFLT => 20,
|
2013-12-17 21:20:13 +00:00
|
|
|
ApiBase::PARAM_TYPE => 'limit',
|
|
|
|
ApiBase::PARAM_MIN => 1,
|
|
|
|
ApiBase::PARAM_MAX => 20,
|
|
|
|
ApiBase::PARAM_MAX2 => 20,
|
2016-09-23 01:38:27 +00:00
|
|
|
],
|
2013-12-17 21:20:13 +00:00
|
|
|
'intro' => false,
|
|
|
|
'plaintext' => false,
|
2016-09-23 01:38:27 +00:00
|
|
|
'sectionformat' => [
|
|
|
|
ApiBase::PARAM_TYPE => [ 'plain', 'wiki', 'raw' ],
|
2013-12-17 21:20:13 +00:00
|
|
|
ApiBase::PARAM_DFLT => 'wiki',
|
2016-09-23 01:38:27 +00:00
|
|
|
],
|
|
|
|
'continue' => [
|
2013-12-17 21:20:13 +00:00
|
|
|
ApiBase::PARAM_TYPE => 'integer',
|
2016-09-20 19:23:03 +00:00
|
|
|
ApiBase::PARAM_HELP_MSG => 'api-help-param-continue',
|
2016-09-23 01:38:27 +00:00
|
|
|
],
|
|
|
|
];
|
2013-12-17 21:20:13 +00:00
|
|
|
}
|
|
|
|
|
2014-10-29 18:50:23 +00:00
|
|
|
/**
|
|
|
|
* @see ApiBase::getExamplesMessages()
|
2017-10-07 09:24:02 +00:00
|
|
|
* @return array
|
2014-10-29 18:50:23 +00:00
|
|
|
*/
|
|
|
|
protected function getExamplesMessages() {
|
2016-09-23 01:38:27 +00:00
|
|
|
return [
|
2014-10-29 18:50:23 +00:00
|
|
|
'action=query&prop=extracts&exchars=175&titles=Therion'
|
|
|
|
=> 'apihelp-query+extracts-example-1',
|
2016-09-23 01:38:27 +00:00
|
|
|
];
|
2014-10-29 18:50:23 +00:00
|
|
|
}
|
2013-12-17 21:20:13 +00:00
|
|
|
|
|
|
|
public function getHelpUrls() {
|
2014-01-14 22:51:08 +00:00
|
|
|
return 'https://www.mediawiki.org/wiki/Extension:TextExtracts#API';
|
2013-12-17 21:20:13 +00:00
|
|
|
}
|
|
|
|
}
|