https://www.mediawiki.org/wiki/Special:Code/MediaWiki/113138

Revision: 113138
Author:   maxsem
Date:     2012-03-06 14:27:40 +0000 (Tue, 06 Mar 2012)
Log Message:
-----------
Moved API modules to their own directory

Modified Paths:
--------------
    trunk/extensions/MobileFrontend/MobileFrontend.php

Added Paths:
-----------
    trunk/extensions/MobileFrontend/api/
    trunk/extensions/MobileFrontend/api/ApiParseExtender.php
    trunk/extensions/MobileFrontend/api/ApiQueryExcerpts.php

Removed Paths:
-------------
    trunk/extensions/MobileFrontend/ApiParseExtender.php
    trunk/extensions/MobileFrontend/ApiQueryExcerpts.php

Deleted: trunk/extensions/MobileFrontend/ApiParseExtender.php
===================================================================
--- trunk/extensions/MobileFrontend/ApiParseExtender.php        2012-03-06 
14:00:28 UTC (rev 113137)
+++ trunk/extensions/MobileFrontend/ApiParseExtender.php        2012-03-06 
14:27:40 UTC (rev 113138)
@@ -1,92 +0,0 @@
-<?php
-
-/**
- * Extends API action=parse with mobile goodies
- */
-class ApiParseExtender {
-       /**
-        * APIGetAllowedParams hook handler
-        * @see https://www.mediawiki.org/wiki/Manual:Hooks/APIGetAllowedParams
-        * @param ApiBase $module
-        * @param array|bool $params
-        */
-       public static function onAPIGetAllowedParams( ApiBase &$module, 
&$params ) {
-               if ( $module->getModuleName() == 'parse' ) {
-                       $params['mobileformat'] = array(
-                               ApiBase::PARAM_TYPE => array( 'wml', 'html' ),
-                       );
-                       $params['noimages'] = false;
-                       $params['mainpage'] = false;
-               }
-               return true;
-       }
-
-       /**
-        * APIGetParamDescription hook handler
-        * @see: 
https://www.mediawiki.org/wiki/Manual:Hooks/APIGetParamDescription
-        * @param ApiBase $module
-        * @param Array|bool $params
-        */
-       public static function onAPIGetParamDescription( ApiBase &$module, 
&$params ) {
-               if ( $module->getModuleName() == 'parse' ) {
-                       $params['mobileformat'] = 'Return parse output in a 
format suitable for mobile devices';
-                       $params['noimages'] = 'Disable images in mobile output';
-                       $params['mainpage'] = 'Apply mobile main page 
transformations';
-               }
-               return true;
-       }
-
-       /**
-        * APIGetDescription hook handler
-        * @see: https://www.mediawiki.org/wiki/Manual:Hooks/APIGetDescription
-        * @param ApiBase $module
-        * @param Array|string $desc
-        */
-       public static function onAPIGetDescription( ApiBase &$module, &$desc ) {
-               if ( $module->getModuleName() == 'parse' ) {
-                       $desc = (array)$desc;
-                       $desc[] = 'Extended by MobileFrontend';
-               }
-               return true;
-       }
-
-       /**
-        * APIAfterExecute hook handler
-        * @see: https://www.mediawiki.org/wiki/Manual:Hooks/
-        * @param ApiBase $module
-        */
-       public static function onAPIAfterExecute( ApiBase &$module ) {
-               if ( $module->getModuleName() == 'parse' ) {
-                       wfProfileIn( __METHOD__ );
-                       $data = $module->getResultData();
-                       $params = $module->extractRequestParams();
-                       if ( isset( $data['parse']['text'] ) && isset( 
$params['mobileformat'] ) ) {
-                               $result = $module->getResult();
-                               $result->reset();
-
-                               $title = Title::newFromText( 
$data['parse']['title'] );
-                               $context = new WmlContext();
-                               $context->setCurrentUrl( 
$title->getCanonicalURL() );
-                               $context->setRequestedSegment( isset( 
$params['section'] )
-                                       ? $params['section'] + 1 // Segment 
numbers start from 1
-                                       : 0
-                               );
-                               $context->setUseFormat( 'wml' ); // Force WML 
links just in case
-                               $context->setOnlyThisSegment( isset( 
$params['section'] ) );
-                               $mf = new MobileFormatter( 
MobileFormatter::wrapHTML( $data['parse']['text']['*'] ),
-                                       $title,
-                                       ExtMobileFrontend::parseContentFormat( 
$params['mobileformat'] ),
-                                       $context
-                               );
-                               $mf->removeImages( $params['noimages'] );
-                               $mf->setIsMainPage( $params['mainpage'] );
-                               $mf->filterContent();
-                               $data['parse']['text'] = $mf->getText( 
'content' );
-
-                               $result->addValue( null, 
$module->getModuleName(), $data['parse'] );
-                       }
-                       wfProfileOut( __METHOD__ );
-               }
-               return true;
-       }
-}

Deleted: trunk/extensions/MobileFrontend/ApiQueryExcerpts.php
===================================================================
--- trunk/extensions/MobileFrontend/ApiQueryExcerpts.php        2012-03-06 
14:00:28 UTC (rev 113137)
+++ trunk/extensions/MobileFrontend/ApiQueryExcerpts.php        2012-03-06 
14:27:40 UTC (rev 113138)
@@ -1,214 +0,0 @@
-<?php
-
-class ApiQueryExcerpts extends ApiQueryBase {
-       /**
-        * @var ParserOptions
-        */
-       private $parserOptions;
-
-       public function __construct( $query, $moduleName ) {
-               parent::__construct( $query, $moduleName, 'ex' );
-       }
-
-       public function execute() {
-               wfProfileIn( __METHOD__ );
-               $titles = $this->getPageSet()->getGoodTitles();
-               if ( count( $titles ) == 0 ) {
-                       wfProfileOut( __METHOD__ );
-                       return;
-               }
-               $params = $this->extractRequestParams();
-               $continue = 0;
-               if ( isset( $params['continue'] ) ) {
-                       $continue = intval( $params['continue'] );
-                       if ( $continue < 0 || $continue > count( $titles ) ) {
-                               $this->dieUsageMsg( '_badcontinue' );
-                       }
-                       $titles = array_slice( $titles, $continue, null, true );
-               }
-               $count = 0;
-               foreach ( $titles as $id => $t ) {
-                       if ( ++$count > $params['limit'] ) {
-                               $this->setContinueEnumParameter( 'continue', 
$continue + $count - 1 );
-                               break;
-                       }
-                       $text = $this->getExcerpt( $t, $params['plaintext'] );
-                       if ( isset( $params['length'] ) ) {
-                               $text = $this->trimText( $text, 
$params['length'], $params['plaintext'] );
-                       }
-                       $fit = $this->addPageSubItem( $id, $text );
-                       if ( !$fit ) {
-                               $this->setContinueEnumParameter( 'continue', 
$continue + $count - 1 );
-                               break;
-                       }
-               }
-               wfProfileOut( __METHOD__ );
-       }
-
-       /**
-        * Returns a processed, but not trimmed excerpt
-        * @param Title $title
-        * @return string 
-        */
-       private function getExcerpt( Title $title, $plainText ) {
-               global $wgMemc;
-
-               wfProfileIn( __METHOD__ );
-               $page = WikiPage::factory( $title );
-               $key = wfMemcKey( 'mf', 'excerpt', $plainText, 
$title->getArticleID(), $page->getLatest() );
-               $text = $wgMemc->get( $key );
-               if ( $text !== false ) {
-                       wfProfileOut( __METHOD__ );
-                       return $text;
-               }
-               $text = $this->parse( $page );
-               $text = $this->convertText( $text, $title, $plainText );
-               $wgMemc->set( $key, $text );
-               wfProfileOut( __METHOD__ );
-               return $text;
-       }
-
-       /**
-        * Returns HTML of page's zeroth section
-        * @param WikiPage $page
-        * @return string
-        */
-       private function parse( WikiPage $page ) {
-               wfProfileIn( __METHOD__ );
-               if ( !$this->parserOptions ) {
-                       $this->parserOptions = new ParserOptions( new User( 
'127.0.0.1' ) );
-               }
-               // first try finding full page in parser cache
-               if ( $page->isParserCacheUsed( $this->parserOptions, 0 ) ) {
-                       $pout = ParserCache::singleton()->get( $page, 
$this->parserOptions );
-                       if ( $pout ) {
-                               $text = $pout->getText();
-                               $s = preg_replace( '/<h[1-6].*$/s', '', $text );
-                               wfProfileOut( __METHOD__ );
-                               return $s;
-                       }
-               }
-               // in case of cache miss, render just the needed section
-               $apiMain = new ApiMain( new FauxRequest(
-                       array( 'page' => $page->getTitle()->getPrefixedText(), 
'section' => 0, 'prop' => 'text' ) )
-               );
-               $apiParse = new ApiParse( $apiMain, 'parse' );
-               $apiParse->execute();
-               $data = $apiParse->getResultData();
-               wfProfileOut( __METHOD__ );
-               return $data['parse']['text']['*'];
-       }
-
-       /**
-        * Converts page HTML into an excerpt
-        * @param string $text
-        * @param Title $title
-        * @param bool $plainText
-        * @return string 
-        */
-       private function convertText( $text, Title $title, $plainText ) {
-               wfProfileIn( __METHOD__ );
-               $mf = new MobileFormatter( MobileFormatter::wrapHTML( $text, 
false ), $title, 'XHTML' );
-               $mf->removeImages();
-               $mf->remove( array( 'table', 'div', 'sup.reference', 
'span.coordinates',
-                       'span.geo-multi-punct', 'span.geo-nondefault', 
'.noexcerpt', '.error' )
-               );
-               if ( $plainText ) {
-                       $mf->flatten( '[?!]?[a-z0-9]+' );
-               } else {
-                       $mf->flatten( array( 'span', 'a' ) );
-               }
-               $mf->filterContent();
-               $text = $mf->getText();
-               $text = preg_replace( '/<!--.*?-->|^.*?<body>|<\/body>.*$/s', 
'', $text );
-               if ( $plainText ) {
-                       $text = html_entity_decode( $text );
-               }
-               wfProfileOut( __METHOD__ );
-               return trim( $text );
-       }
-
-       /**
-        * 
-        * @param string $text
-        * @param int $requestedLength
-        * @param bool $plainText
-        * @return string
-        */
-       private function trimText( $text, $requestedLength, $plainText ) {
-               global $wgUseTidy;
-
-               wfProfileIn( __METHOD__ );
-               $length = mb_strlen( $text );
-               if ( $length <= $requestedLength ) {
-                       wfProfileOut( __METHOD__ );
-                       return $text;
-               }
-               $pattern = "#^.{{$requestedLength}}[\\w/]*>?#su";
-               preg_match( $pattern, $text, $m );
-               $text = $m[0];
-               // Fix possibly unclosed tags
-               if ( $wgUseTidy && !$plainText ) {
-                       $text = trim ( MWTidy::tidy( $text ) );
-               }
-               $text .= wfMessage( 'ellipsis' )->inContentLanguage()->text();
-               wfProfileOut( __METHOD__ );
-               return $text;
-       }
-
-       public function getAllowedParams() {
-               return array(
-                       'length' => array(
-                               ApiBase::PARAM_TYPE => 'integer',
-                               ApiBase::PARAM_MIN => 1,
-                       ),
-                       'limit' => array(
-                               ApiBase::PARAM_DFLT => 1,
-                               ApiBase::PARAM_TYPE => 'limit',
-                               ApiBase::PARAM_MIN => 1,
-                               ApiBase::PARAM_MAX => 20,
-                               ApiBase::PARAM_MAX2 => 20,
-                       ),
-                       'plaintext' => false,
-                       'continue' => array(
-                               ApiBase::PARAM_TYPE => 'integer',
-                       ),
-               );
-       }
-
-       public function getParamDescription() {
-               return array(
-                       'length' => 'How many characters to return, actual text 
returned might be slightly longer.',
-                       'limit' => 'How many excerpts to return',
-                       'plaintext' => 'Return excerpts as plaintext instead of 
limited HTML',
-                       'continue' => 'When more results are available, use 
this to continue',
-               );
-       }
-
-       public function getDescription() {
-               return 'Returns excerpts of the given page(s)';
-       }
-
-       public function getPossibleErrors() {
-               return array_merge( parent::getPossibleErrors(), array(
-                       array( 'code' => '_badcontinue', 'info' => 'Invalid 
continue param. You should pass the original value returned by the previous 
query' ),
-               ) );
-       }
-
-       public function getExamples() {
-               return array(
-                       
'api.php?action=query&prop=excerpt&length=175&titles=Therion' => 'Get a 
175-character excerpt',
-               );
-       }
-
-
-       public function getHelpUrls() {
-               return 
'https://www.mediawiki.org/wiki/Extension:MobileFrontend#New_API';
-       }
-
-       public function getVersion() {
-               return __CLASS__ . ': $Id$';
-       }
-}
-
-

Modified: trunk/extensions/MobileFrontend/MobileFrontend.php
===================================================================
--- trunk/extensions/MobileFrontend/MobileFrontend.php  2012-03-06 14:00:28 UTC 
(rev 113137)
+++ trunk/extensions/MobileFrontend/MobileFrontend.php  2012-03-06 14:27:40 UTC 
(rev 113138)
@@ -44,13 +44,14 @@
 $autoloadClasses = array (
        'ExtMobileFrontend' => 'MobileFrontend.body',
 
-       'ApiParseExtender' => 'ApiParseExtender',
-       'ApiQueryExcerpts' => 'ApiQueryExcerpts',
        'CssDetection' => 'CssDetection',
        'DeviceDetection' => 'DeviceDetection',
        'MobileFormatter' => 'MobileFormatter',
        'WmlContext' => 'WmlContext',
 
+       'ApiParseExtender' => 'api/ApiParseExtender',
+       'ApiQueryExcerpts' => 'api/ApiQueryExcerpts',
+
        'MobileFrontendTemplate' => 'templates/MobileFrontendTemplate',
        'ApplicationTemplate' => 'templates/ApplicationTemplate',
        'SearchTemplate'  => 'templates/SearchTemplate',

Copied: trunk/extensions/MobileFrontend/api/ApiParseExtender.php (from rev 
113077, trunk/extensions/MobileFrontend/ApiParseExtender.php)
===================================================================
--- trunk/extensions/MobileFrontend/api/ApiParseExtender.php                    
        (rev 0)
+++ trunk/extensions/MobileFrontend/api/ApiParseExtender.php    2012-03-06 
14:27:40 UTC (rev 113138)
@@ -0,0 +1,92 @@
+<?php
+
+/**
+ * Extends API action=parse with mobile goodies
+ */
+class ApiParseExtender {
+       /**
+        * APIGetAllowedParams hook handler
+        * @see https://www.mediawiki.org/wiki/Manual:Hooks/APIGetAllowedParams
+        * @param ApiBase $module
+        * @param array|bool $params
+        */
+       public static function onAPIGetAllowedParams( ApiBase &$module, 
&$params ) {
+               if ( $module->getModuleName() == 'parse' ) {
+                       $params['mobileformat'] = array(
+                               ApiBase::PARAM_TYPE => array( 'wml', 'html' ),
+                       );
+                       $params['noimages'] = false;
+                       $params['mainpage'] = false;
+               }
+               return true;
+       }
+
+       /**
+        * APIGetParamDescription hook handler
+        * @see: 
https://www.mediawiki.org/wiki/Manual:Hooks/APIGetParamDescription
+        * @param ApiBase $module
+        * @param Array|bool $params
+        */
+       public static function onAPIGetParamDescription( ApiBase &$module, 
&$params ) {
+               if ( $module->getModuleName() == 'parse' ) {
+                       $params['mobileformat'] = 'Return parse output in a 
format suitable for mobile devices';
+                       $params['noimages'] = 'Disable images in mobile output';
+                       $params['mainpage'] = 'Apply mobile main page 
transformations';
+               }
+               return true;
+       }
+
+       /**
+        * APIGetDescription hook handler
+        * @see: https://www.mediawiki.org/wiki/Manual:Hooks/APIGetDescription
+        * @param ApiBase $module
+        * @param Array|string $desc
+        */
+       public static function onAPIGetDescription( ApiBase &$module, &$desc ) {
+               if ( $module->getModuleName() == 'parse' ) {
+                       $desc = (array)$desc;
+                       $desc[] = 'Extended by MobileFrontend';
+               }
+               return true;
+       }
+
+       /**
+        * APIAfterExecute hook handler
+        * @see: https://www.mediawiki.org/wiki/Manual:Hooks/
+        * @param ApiBase $module
+        */
+       public static function onAPIAfterExecute( ApiBase &$module ) {
+               if ( $module->getModuleName() == 'parse' ) {
+                       wfProfileIn( __METHOD__ );
+                       $data = $module->getResultData();
+                       $params = $module->extractRequestParams();
+                       if ( isset( $data['parse']['text'] ) && isset( 
$params['mobileformat'] ) ) {
+                               $result = $module->getResult();
+                               $result->reset();
+
+                               $title = Title::newFromText( 
$data['parse']['title'] );
+                               $context = new WmlContext();
+                               $context->setCurrentUrl( 
$title->getCanonicalURL() );
+                               $context->setRequestedSegment( isset( 
$params['section'] )
+                                       ? $params['section'] + 1 // Segment 
numbers start from 1
+                                       : 0
+                               );
+                               $context->setUseFormat( 'wml' ); // Force WML 
links just in case
+                               $context->setOnlyThisSegment( isset( 
$params['section'] ) );
+                               $mf = new MobileFormatter( 
MobileFormatter::wrapHTML( $data['parse']['text']['*'] ),
+                                       $title,
+                                       ExtMobileFrontend::parseContentFormat( 
$params['mobileformat'] ),
+                                       $context
+                               );
+                               $mf->removeImages( $params['noimages'] );
+                               $mf->setIsMainPage( $params['mainpage'] );
+                               $mf->filterContent();
+                               $data['parse']['text'] = $mf->getText( 
'content' );
+
+                               $result->addValue( null, 
$module->getModuleName(), $data['parse'] );
+                       }
+                       wfProfileOut( __METHOD__ );
+               }
+               return true;
+       }
+}

Copied: trunk/extensions/MobileFrontend/api/ApiQueryExcerpts.php (from rev 
113093, trunk/extensions/MobileFrontend/ApiQueryExcerpts.php)
===================================================================
--- trunk/extensions/MobileFrontend/api/ApiQueryExcerpts.php                    
        (rev 0)
+++ trunk/extensions/MobileFrontend/api/ApiQueryExcerpts.php    2012-03-06 
14:27:40 UTC (rev 113138)
@@ -0,0 +1,214 @@
+<?php
+
+class ApiQueryExcerpts extends ApiQueryBase {
+       /**
+        * @var ParserOptions
+        */
+       private $parserOptions;
+
+       public function __construct( $query, $moduleName ) {
+               parent::__construct( $query, $moduleName, 'ex' );
+       }
+
+       public function execute() {
+               wfProfileIn( __METHOD__ );
+               $titles = $this->getPageSet()->getGoodTitles();
+               if ( count( $titles ) == 0 ) {
+                       wfProfileOut( __METHOD__ );
+                       return;
+               }
+               $params = $this->extractRequestParams();
+               $continue = 0;
+               if ( isset( $params['continue'] ) ) {
+                       $continue = intval( $params['continue'] );
+                       if ( $continue < 0 || $continue > count( $titles ) ) {
+                               $this->dieUsageMsg( '_badcontinue' );
+                       }
+                       $titles = array_slice( $titles, $continue, null, true );
+               }
+               $count = 0;
+               foreach ( $titles as $id => $t ) {
+                       if ( ++$count > $params['limit'] ) {
+                               $this->setContinueEnumParameter( 'continue', 
$continue + $count - 1 );
+                               break;
+                       }
+                       $text = $this->getExcerpt( $t, $params['plaintext'] );
+                       if ( isset( $params['length'] ) ) {
+                               $text = $this->trimText( $text, 
$params['length'], $params['plaintext'] );
+                       }
+                       $fit = $this->addPageSubItem( $id, $text );
+                       if ( !$fit ) {
+                               $this->setContinueEnumParameter( 'continue', 
$continue + $count - 1 );
+                               break;
+                       }
+               }
+               wfProfileOut( __METHOD__ );
+       }
+
+       /**
+        * Returns a processed, but not trimmed excerpt
+        * @param Title $title
+        * @return string 
+        */
+       private function getExcerpt( Title $title, $plainText ) {
+               global $wgMemc;
+
+               wfProfileIn( __METHOD__ );
+               $page = WikiPage::factory( $title );
+               $key = wfMemcKey( 'mf', 'excerpt', $plainText, 
$title->getArticleID(), $page->getLatest() );
+               $text = $wgMemc->get( $key );
+               if ( $text !== false ) {
+                       wfProfileOut( __METHOD__ );
+                       return $text;
+               }
+               $text = $this->parse( $page );
+               $text = $this->convertText( $text, $title, $plainText );
+               $wgMemc->set( $key, $text );
+               wfProfileOut( __METHOD__ );
+               return $text;
+       }
+
+       /**
+        * Returns HTML of page's zeroth section
+        * @param WikiPage $page
+        * @return string
+        */
+       private function parse( WikiPage $page ) {
+               wfProfileIn( __METHOD__ );
+               if ( !$this->parserOptions ) {
+                       $this->parserOptions = new ParserOptions( new User( 
'127.0.0.1' ) );
+               }
+               // first try finding full page in parser cache
+               if ( $page->isParserCacheUsed( $this->parserOptions, 0 ) ) {
+                       $pout = ParserCache::singleton()->get( $page, 
$this->parserOptions );
+                       if ( $pout ) {
+                               $text = $pout->getText();
+                               $s = preg_replace( '/<h[1-6].*$/s', '', $text );
+                               wfProfileOut( __METHOD__ );
+                               return $s;
+                       }
+               }
+               // in case of cache miss, render just the needed section
+               $apiMain = new ApiMain( new FauxRequest(
+                       array( 'page' => $page->getTitle()->getPrefixedText(), 
'section' => 0, 'prop' => 'text' ) )
+               );
+               $apiParse = new ApiParse( $apiMain, 'parse' );
+               $apiParse->execute();
+               $data = $apiParse->getResultData();
+               wfProfileOut( __METHOD__ );
+               return $data['parse']['text']['*'];
+       }
+
+       /**
+        * Converts page HTML into an excerpt
+        * @param string $text
+        * @param Title $title
+        * @param bool $plainText
+        * @return string 
+        */
+       private function convertText( $text, Title $title, $plainText ) {
+               wfProfileIn( __METHOD__ );
+               $mf = new MobileFormatter( MobileFormatter::wrapHTML( $text, 
false ), $title, 'XHTML' );
+               $mf->removeImages();
+               $mf->remove( array( 'table', 'div', 'sup.reference', 
'span.coordinates',
+                       'span.geo-multi-punct', 'span.geo-nondefault', 
'.noexcerpt', '.error' )
+               );
+               if ( $plainText ) {
+                       $mf->flatten( '[?!]?[a-z0-9]+' );
+               } else {
+                       $mf->flatten( array( 'span', 'a' ) );
+               }
+               $mf->filterContent();
+               $text = $mf->getText();
+               $text = preg_replace( '/<!--.*?-->|^.*?<body>|<\/body>.*$/s', 
'', $text );
+               if ( $plainText ) {
+                       $text = html_entity_decode( $text );
+               }
+               wfProfileOut( __METHOD__ );
+               return trim( $text );
+       }
+
+       /**
+        * 
+        * @param string $text
+        * @param int $requestedLength
+        * @param bool $plainText
+        * @return string
+        */
+       private function trimText( $text, $requestedLength, $plainText ) {
+               global $wgUseTidy;
+
+               wfProfileIn( __METHOD__ );
+               $length = mb_strlen( $text );
+               if ( $length <= $requestedLength ) {
+                       wfProfileOut( __METHOD__ );
+                       return $text;
+               }
+               $pattern = "#^.{{$requestedLength}}[\\w/]*>?#su";
+               preg_match( $pattern, $text, $m );
+               $text = $m[0];
+               // Fix possibly unclosed tags
+               if ( $wgUseTidy && !$plainText ) {
+                       $text = trim ( MWTidy::tidy( $text ) );
+               }
+               $text .= wfMessage( 'ellipsis' )->inContentLanguage()->text();
+               wfProfileOut( __METHOD__ );
+               return $text;
+       }
+
+       public function getAllowedParams() {
+               return array(
+                       'length' => array(
+                               ApiBase::PARAM_TYPE => 'integer',
+                               ApiBase::PARAM_MIN => 1,
+                       ),
+                       'limit' => array(
+                               ApiBase::PARAM_DFLT => 1,
+                               ApiBase::PARAM_TYPE => 'limit',
+                               ApiBase::PARAM_MIN => 1,
+                               ApiBase::PARAM_MAX => 20,
+                               ApiBase::PARAM_MAX2 => 20,
+                       ),
+                       'plaintext' => false,
+                       'continue' => array(
+                               ApiBase::PARAM_TYPE => 'integer',
+                       ),
+               );
+       }
+
+       public function getParamDescription() {
+               return array(
+                       'length' => 'How many characters to return, actual text 
returned might be slightly longer.',
+                       'limit' => 'How many excerpts to return',
+                       'plaintext' => 'Return excerpts as plaintext instead of 
limited HTML',
+                       'continue' => 'When more results are available, use 
this to continue',
+               );
+       }
+
+       public function getDescription() {
+               return 'Returns excerpts of the given page(s)';
+       }
+
+       public function getPossibleErrors() {
+               return array_merge( parent::getPossibleErrors(), array(
+                       array( 'code' => '_badcontinue', 'info' => 'Invalid 
continue param. You should pass the original value returned by the previous 
query' ),
+               ) );
+       }
+
+       public function getExamples() {
+               return array(
+                       
'api.php?action=query&prop=excerpt&length=175&titles=Therion' => 'Get a 
175-character excerpt',
+               );
+       }
+
+
+       public function getHelpUrls() {
+               return 
'https://www.mediawiki.org/wiki/Extension:MobileFrontend#New_API';
+       }
+
+       public function getVersion() {
+               return __CLASS__ . ': $Id$';
+       }
+}
+
+


_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to