Index: trunk/phase3/includes/api/ApiRender.php |
— | — | @@ -0,0 +1,94 @@ |
| 2 | +<?php
|
| 3 | +
|
| 4 | +/*
|
| 5 | + * Created on Oct 06, 2007
|
| 6 | + *
|
| 7 | + * API for MediaWiki 1.8+
|
| 8 | + *
|
| 9 | + * Copyright (C) 2007 Yuri Astrakhan <Firstname><Lastname>@gmail.com
|
| 10 | + *
|
| 11 | + * This program is free software; you can redistribute it and/or modify
|
| 12 | + * it under the terms of the GNU General Public License as published by
|
| 13 | + * the Free Software Foundation; either version 2 of the License, or
|
| 14 | + * (at your option) any later version.
|
| 15 | + *
|
| 16 | + * This program is distributed in the hope that it will be useful,
|
| 17 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 18 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 19 | + * GNU General Public License for more details.
|
| 20 | + *
|
| 21 | + * You should have received a copy of the GNU General Public License along
|
| 22 | + * with this program; if not, write to the Free Software Foundation, Inc.,
|
| 23 | + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
| 24 | + * http://www.gnu.org/copyleft/gpl.html
|
| 25 | + */
|
| 26 | +
|
| 27 | +if (!defined('MEDIAWIKI')) {
|
| 28 | + // Eclipse helper - will be ignored in production
|
| 29 | + require_once ("ApiBase.php");
|
| 30 | +}
|
| 31 | +
|
| 32 | +/**
|
| 33 | + * @addtogroup API
|
| 34 | + */
|
| 35 | +class ApiRender extends ApiBase {
|
| 36 | +
|
| 37 | + public function __construct($main, $action) {
|
| 38 | + parent :: __construct($main, $action);
|
| 39 | + }
|
| 40 | +
|
| 41 | + public function execute() {
|
| 42 | + // Get parameters
|
| 43 | + $params = $this->extractRequestParams();
|
| 44 | + $text = $params['text'];
|
| 45 | + $title = $params['title'];
|
| 46 | + $retval = '';
|
| 47 | +
|
| 48 | + //Create title for parser
|
| 49 | + $title_obj = Title :: newFromText($params['title']);
|
| 50 | + if(!$title_obj)
|
| 51 | + $title_obj = Title :: newFromText("API"); // Default title is "API". For example, ExpandTemplates uses "ExpendTemplates" for it
|
| 52 | +
|
| 53 | + // Parse text
|
| 54 | + global $wgParser;
|
| 55 | + $p_result = $wgParser->parse( $text, $title_obj, new ParserOptions() );
|
| 56 | + $retval = $p_result->getText();
|
| 57 | +
|
| 58 | + // Return result
|
| 59 | + $result = $this->getResult();
|
| 60 | + $retval_array = array();
|
| 61 | + $result->setContent( $retval_array, $retval );
|
| 62 | + $result->addValue( null, 'render', $retval_array );
|
| 63 | + }
|
| 64 | +
|
| 65 | + protected function getAllowedParams() {
|
| 66 | + return array (
|
| 67 | + 'title' => array(
|
| 68 | + ApiBase :: PARAM_DFLT => 'API',
|
| 69 | + ),
|
| 70 | + 'text' => null
|
| 71 | + );
|
| 72 | + }
|
| 73 | +
|
| 74 | + protected function getParamDescription() {
|
| 75 | + return array (
|
| 76 | + 'text' => 'Wikitext to render',
|
| 77 | + 'title' => 'Title of page',
|
| 78 | + );
|
| 79 | + }
|
| 80 | +
|
| 81 | + protected function getDescription() {
|
| 82 | + return 'This module allows to get rendered wikitext';
|
| 83 | + }
|
| 84 | +
|
| 85 | + protected function getExamples() {
|
| 86 | + return array (
|
| 87 | + 'api.php?action=render&text={{Project:Sandbox}}'
|
| 88 | + );
|
| 89 | + }
|
| 90 | +
|
| 91 | + public function getVersion() {
|
| 92 | + return __CLASS__ . ': $Id$';
|
| 93 | + }
|
| 94 | +}
|
| 95 | +
|
Index: trunk/phase3/includes/api/ApiMain.php |
— | — | @@ -54,6 +54,8 @@ |
55 | 55 | private static $Modules = array ( |
56 | 56 | 'login' => 'ApiLogin', |
57 | 57 | 'query' => 'ApiQuery', |
| 58 | + 'expandtemplates' => 'ApiExpandTemplates', |
| 59 | + 'render' => 'ApiRender', |
58 | 60 | 'opensearch' => 'ApiOpenSearch', |
59 | 61 | 'feedwatchlist' => 'ApiFeedWatchlist', |
60 | 62 | 'help' => 'ApiHelp', |
— | — | @@ -539,3 +541,4 @@ |
540 | 542 | } |
541 | 543 | } |
542 | 544 | |
| 545 | + |
Index: trunk/phase3/includes/api/ApiExpandTemplates.php |
— | — | @@ -0,0 +1,93 @@ |
| 2 | +<?php
|
| 3 | +
|
| 4 | +/*
|
| 5 | + * Created on Oct 05, 2007
|
| 6 | + *
|
| 7 | + * API for MediaWiki 1.8+
|
| 8 | + *
|
| 9 | + * Copyright (C) 2007 Yuri Astrakhan <Firstname><Lastname>@gmail.com
|
| 10 | + *
|
| 11 | + * This program is free software; you can redistribute it and/or modify
|
| 12 | + * it under the terms of the GNU General Public License as published by
|
| 13 | + * the Free Software Foundation; either version 2 of the License, or
|
| 14 | + * (at your option) any later version.
|
| 15 | + *
|
| 16 | + * This program is distributed in the hope that it will be useful,
|
| 17 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 18 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 19 | + * GNU General Public License for more details.
|
| 20 | + *
|
| 21 | + * You should have received a copy of the GNU General Public License along
|
| 22 | + * with this program; if not, write to the Free Software Foundation, Inc.,
|
| 23 | + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
| 24 | + * http://www.gnu.org/copyleft/gpl.html
|
| 25 | + */
|
| 26 | +
|
| 27 | +if (!defined('MEDIAWIKI')) {
|
| 28 | + // Eclipse helper - will be ignored in production
|
| 29 | + require_once ("ApiBase.php");
|
| 30 | +}
|
| 31 | +
|
| 32 | +/**
|
| 33 | + * @addtogroup API
|
| 34 | + */
|
| 35 | +class ApiExpandTemplates extends ApiBase {
|
| 36 | +
|
| 37 | + public function __construct($main, $action) {
|
| 38 | + parent :: __construct($main, $action);
|
| 39 | + }
|
| 40 | +
|
| 41 | + public function execute() {
|
| 42 | + // Get parameters
|
| 43 | + $params = $this->extractRequestParams();
|
| 44 | + $text = $params['text'];
|
| 45 | + $title = $params['title'];
|
| 46 | + $retval = '';
|
| 47 | +
|
| 48 | + //Create title for parser
|
| 49 | + $title_obj = Title :: newFromText($params['title']);
|
| 50 | + if(!$title_obj)
|
| 51 | + $title_obj = Title :: newFromText("API"); // Default title is "API". For example, ExpandTemplates uses "ExpendTemplates" for it
|
| 52 | +
|
| 53 | + // Parse text
|
| 54 | + global $wgParser;
|
| 55 | + $retval = $wgParser->preprocess( $text, $title_obj, new ParserOptions() );
|
| 56 | +
|
| 57 | + // Return result
|
| 58 | + $result = $this->getResult();
|
| 59 | + $retval_array = array();
|
| 60 | + $result->setContent( $retval_array, $retval );
|
| 61 | + $result->addValue( null, 'expandtemplates', $retval_array );
|
| 62 | + }
|
| 63 | +
|
| 64 | + protected function getAllowedParams() {
|
| 65 | + return array (
|
| 66 | + 'title' => array(
|
| 67 | + ApiBase :: PARAM_DFLT => 'API',
|
| 68 | + ),
|
| 69 | + 'text' => null
|
| 70 | + );
|
| 71 | + }
|
| 72 | +
|
| 73 | + protected function getParamDescription() {
|
| 74 | + return array (
|
| 75 | + 'text' => 'Wikitext to convert',
|
| 76 | + 'title' => 'Title of page',
|
| 77 | + );
|
| 78 | + }
|
| 79 | +
|
| 80 | + protected function getDescription() {
|
| 81 | + return 'This module expand all templates in wikitext';
|
| 82 | + }
|
| 83 | +
|
| 84 | + protected function getExamples() {
|
| 85 | + return array (
|
| 86 | + 'api.php?action=expandtemplates&text={{Project:Sandbox}}'
|
| 87 | + );
|
| 88 | + }
|
| 89 | +
|
| 90 | + public function getVersion() {
|
| 91 | + return __CLASS__ . ': $Id$';
|
| 92 | + }
|
| 93 | +}
|
| 94 | +
|
Index: trunk/phase3/includes/AutoLoader.php |
— | — | @@ -308,6 +308,7 @@ |
309 | 309 | 'ApiLogin' => 'includes/api/ApiLogin.php', |
310 | 310 | 'ApiMain' => 'includes/api/ApiMain.php', |
311 | 311 | 'ApiOpenSearch' => 'includes/api/ApiOpenSearch.php', |
| 312 | + 'ApiExpandTemplates' => 'includes/api/ApiExpandTemplates.php', |
312 | 313 | 'ApiPageSet' => 'includes/api/ApiPageSet.php', |
313 | 314 | 'ApiQuery' => 'includes/api/ApiQuery.php', |
314 | 315 | 'ApiQueryAllpages' => 'includes/api/ApiQueryAllpages.php', |
— | — | @@ -333,6 +334,7 @@ |
334 | 335 | 'ApiQuerySiteinfo' => 'includes/api/ApiQuerySiteinfo.php', |
335 | 336 | 'ApiQueryUserInfo' => 'includes/api/ApiQueryUserInfo.php', |
336 | 337 | 'ApiQueryWatchlist' => 'includes/api/ApiQueryWatchlist.php', |
| 338 | + 'ApiRender' => 'includes/api/ApiRender.php', |
337 | 339 | 'ApiResult' => 'includes/api/ApiResult.php', |
338 | 340 | ); |
339 | 341 | |
Index: trunk/phase3/RELEASE-NOTES |
— | — | @@ -108,6 +108,8 @@ |
109 | 109 | * Fixed rvlimit of the revisions query to only enforce the lower query limit if |
110 | 110 | revision content is requested. |
111 | 111 | * Include svn revision number (if install is checked-out from svn) in siteinfo query. |
| 112 | +* (bug 11173) Allow limited wikicode rendering via api.php |
| 113 | +* (bug 11572) API should provide interface for expanding templates |
112 | 114 | |
113 | 115 | === Languages updated in 1.12 === |
114 | 116 | |