FU r106752: use "media-" instead of "images-" in container names. Long live books...
[lhc/web/wiklou.git] / includes / api / ApiExpandTemplates.php
index 8b3ca15..d570534 100644 (file)
  * @file
  */
 
-if ( !defined( 'MEDIAWIKI' ) ) {
-       // Eclipse helper - will be ignored in production
-       require_once( "ApiBase.php" );
-}
-
 /**
  * API module that functions as a shortcut to the wikitext preprocessor. Expands
  * any templates in a provided string, and returns the result of this expansion
@@ -52,14 +47,14 @@ class ApiExpandTemplates extends ApiBase {
                // Create title for parser
                $title_obj = Title::newFromText( $params['title'] );
                if ( !$title_obj ) {
-                       $title_obj = Title::newFromText( 'API' ); // default
+                       $this->dieUsageMsg( array( 'invalidtitle', $params['title'] ) );
                }
 
                $result = $this->getResult();
 
                // Parse text
                global $wgParser;
-               $options = new ParserOptions();
+               $options = ParserOptions::newFromContext( $this->getContext() );
 
                if ( $params['includecomments'] ) {
                        $options->setRemoveComments( false );
@@ -90,7 +85,10 @@ class ApiExpandTemplates extends ApiBase {
                        'title' => array(
                                ApiBase::PARAM_DFLT => 'API',
                        ),
-                       'text' => null,
+                       'text' => array(
+                               ApiBase::PARAM_TYPE => 'string',
+                               ApiBase::PARAM_REQUIRED => true,
+                       ),
                        'generatexml' => false,
                        'includecomments' => false,
                );
@@ -109,14 +107,20 @@ class ApiExpandTemplates extends ApiBase {
                return 'Expands all templates in wikitext';
        }
 
-       protected function getExamples() {
+       public function getPossibleErrors() {
+               return array_merge( parent::getPossibleErrors(), array(
+                       array( 'invalidtitle', 'title' ),
+               ) );
+       }
+
+       public function getExamples() {
                return array(
                        'api.php?action=expandtemplates&text={{Project:Sandbox}}'
                );
        }
 
        public function getHelpUrls() {
-               return 'http://www.mediawiki.org/wiki/API:Parsing_wikitext';
+               return 'https://www.mediawiki.org/wiki/API:Parsing_wikitext#expandtemplates';
        }
 
        public function getVersion() {