]> scripts.mit.edu Git - autoinstalls/mediawiki.git/blobdiff - includes/api/ApiExpandTemplates.php
MediaWiki 1.17.4
[autoinstalls/mediawiki.git] / includes / api / ApiExpandTemplates.php
index afb11402a6a67c87c9a5b45d9982bf3de07aa590..fe281ccc5f0c1e8b2031db6fa75c0f56211e637a 100644 (file)
@@ -1,11 +1,10 @@
 <?php
-
-/*
- * Created on Oct 05, 2007
- *
+/**
  * API for MediaWiki 1.8+
  *
- * Copyright (C) 2007 Yuri Astrakhan <Firstname><Lastname>@gmail.com
+ * Created on Oct 05, 2007
+ *
+ * Copyright © 2007 Yuri Astrakhan <Firstname><Lastname>@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
  *
  * 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.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  * http://www.gnu.org/copyleft/gpl.html
+ *
+ * @file
  */
 
-if (!defined('MEDIAWIKI')) {
+if ( !defined( 'MEDIAWIKI' ) ) {
        // Eclipse helper - will be ignored in production
-       require_once ("ApiBase.php");
+       require_once( "ApiBase.php" );
 }
 
 /**
@@ -37,8 +38,8 @@ if (!defined('MEDIAWIKI')) {
  */
 class ApiExpandTemplates extends ApiBase {
 
-       public function __construct($main, $action) {
-               parent :: __construct($main, $action);
+       public function __construct( $main, $action ) {
+               parent::__construct( $main, $action );
        }
 
        public function execute() {
@@ -48,18 +49,19 @@ class ApiExpandTemplates extends ApiBase {
                // Get parameters
                $params = $this->extractRequestParams();
 
-               //Create title for parser
-               $title_obj = Title :: newFromText( $params['title'] );
-               if(!$title_obj)
-                       $title_obj = Title :: newFromText( "API" ); // default
+               // Create title for parser
+               $title_obj = Title::newFromText( $params['title'] );
+               if ( !$title_obj ) {
+                       $title_obj = Title::newFromText( 'API' ); // default
+               }
 
                $result = $this->getResult();
 
                // Parse text
                global $wgParser;
                $options = new ParserOptions();
-               if ( $params['generatexml'] )
-               {
+
+               if ( $params['generatexml'] ) {
                        $wgParser->startExternalParse( $title_obj, $options, OT_PREPROCESS );
                        $dom = $wgParser->preprocessToDom( $params['text'] );
                        if ( is_callable( array( $dom, 'saveXML' ) ) ) {
@@ -69,7 +71,7 @@ class ApiExpandTemplates extends ApiBase {
                        }
                        $xml_result = array();
                        $result->setContent( $xml_result, $xml );
-                       $result->addValue( null, 'parsetree', $xml_result);
+                       $result->addValue( null, 'parsetree', $xml_result );
                }
                $retval = $wgParser->preprocess( $params['text'], $title_obj, $options );
 
@@ -80,9 +82,9 @@ class ApiExpandTemplates extends ApiBase {
        }
 
        public function getAllowedParams() {
-               return array (
+               return array(
                        'title' => array(
-                               ApiBase :: PARAM_DFLT => 'API',
+                               ApiBase::PARAM_DFLT => 'API',
                        ),
                        'text' => null,
                        'generatexml' => false,
@@ -90,7 +92,7 @@ class ApiExpandTemplates extends ApiBase {
        }
 
        public function getParamDescription() {
-               return array (
+               return array(
                        'text' => 'Wikitext to convert',
                        'title' => 'Title of page',
                        'generatexml' => 'Generate XML parse tree',
@@ -102,12 +104,12 @@ class ApiExpandTemplates extends ApiBase {
        }
 
        protected function getExamples() {
-               return array (
+               return array(
                        'api.php?action=expandtemplates&text={{Project:Sandbox}}'
                );
        }
 
        public function getVersion() {
-               return __CLASS__ . ': $Id: ApiExpandTemplates.php 69986 2010-07-27 03:57:39Z tstarling $';
+               return __CLASS__ . ': $Id$';
        }
 }