Index: trunk/phase3/includes/api/ApiRender.php
===================================================================
--- trunk/phase3/includes/api/ApiRender.php (revision 0)
+++ trunk/phase3/includes/api/ApiRender.php (revision 26501)
@@ -0,0 +1,94 @@
+<?php
+
+/*
+ * Created on Oct 06, 2007
+ *
+ * API for MediaWiki 1.8+
+ *
+ * Copyright (C) 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
+ * 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.,
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * http://www.gnu.org/copyleft/gpl.html
+ */
+
+if (!defined('MEDIAWIKI')) {
+ // Eclipse helper - will be ignored in production
+ require_once ("ApiBase.php");
+}
+
+/**
+ * @addtogroup API
+ */
+class ApiRender extends ApiBase {
+
+ public function __construct($main, $action) {
+ parent :: __construct($main, $action);
+ }
+
+ public function execute() {
+ // Get parameters
+ $params = $this->extractRequestParams();
+ $text = $params['text'];
+ $title = $params['title'];
+ $retval = '';
+
+ //Create title for parser
+ $title_obj = Title :: newFromText($params['title']);
+ if(!$title_obj)
+ $title_obj = Title :: newFromText("API"); // Default title is "API". For example, ExpandTemplates uses "ExpendTemplates" for it
+
+ // Parse text
+ global $wgParser;
+ $p_result = $wgParser->parse( $text, $title_obj, new ParserOptions() );
+ $retval = $p_result->getText();
+
+ // Return result
+ $result = $this->getResult();
+ $retval_array = array();
+ $result->setContent( $retval_array, $retval );
+ $result->addValue( null, 'render', $retval_array );
+ }
+
+ protected function getAllowedParams() {
+ return array (
+ 'title' => array(
+ ApiBase :: PARAM_DFLT => 'API',
+ ),
+ 'text' => null
+ );
+ }
+
+ protected function getParamDescription() {
+ return array (
+ 'text' => 'Wikitext to render',
+ 'title' => 'Title of page',
+ );
+ }
+
+ protected function getDescription() {
+ return 'This module allows to get rendered wikitext';
+ }
+
+ protected function getExamples() {
+ return array (
+ 'api.php?action=render&text={{Project:Sandbox}}'
+ );
+ }
+
+ public function getVersion() {
+ return __CLASS__ . ': $Id$';
+ }
+}
+
Index: trunk/phase3/includes/api/ApiMain.php
===================================================================
--- trunk/phase3/includes/api/ApiMain.php (revision 26500)
+++ trunk/phase3/includes/api/ApiMain.php (revision 26501)
@@ -54,6 +54,8 @@
private static $Modules = array (
'login' => 'ApiLogin',
'query' => 'ApiQuery',
+ 'expandtemplates' => 'ApiExpandTemplates',
+ 'render' => 'ApiRender',
'opensearch' => 'ApiOpenSearch',
'feedwatchlist' => 'ApiFeedWatchlist',
'help' => 'ApiHelp',
@@ -539,3 +541,4 @@
}
}
+
Index: trunk/phase3/includes/api/ApiExpandTemplates.php
===================================================================
--- trunk/phase3/includes/api/ApiExpandTemplates.php (revision 0)
+++ trunk/phase3/includes/api/ApiExpandTemplates.php (revision 26501)
@@ -0,0 +1,93 @@
+<?php
+
+/*
+ * Created on Oct 05, 2007
+ *
+ * API for MediaWiki 1.8+
+ *
+ * Copyright (C) 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
+ * 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.,
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * http://www.gnu.org/copyleft/gpl.html
+ */
+
+if (!defined('MEDIAWIKI')) {
+ // Eclipse helper - will be ignored in production
+ require_once ("ApiBase.php");
+}
+
+/**
+ * @addtogroup API
+ */
+class ApiExpandTemplates extends ApiBase {
+
+ public function __construct($main, $action) {
+ parent :: __construct($main, $action);
+ }
+
+ public function execute() {
+ // Get parameters
+ $params = $this->extractRequestParams();
+ $text = $params['text'];
+ $title = $params['title'];
+ $retval = '';
+
+ //Create title for parser
+ $title_obj = Title :: newFromText($params['title']);
+ if(!$title_obj)
+ $title_obj = Title :: newFromText("API"); // Default title is "API". For example, ExpandTemplates uses "ExpendTemplates" for it
+
+ // Parse text
+ global $wgParser;
+ $retval = $wgParser->preprocess( $text, $title_obj, new ParserOptions() );
+
+ // Return result
+ $result = $this->getResult();
+ $retval_array = array();
+ $result->setContent( $retval_array, $retval );
+ $result->addValue( null, 'expandtemplates', $retval_array );
+ }
+
+ protected function getAllowedParams() {
+ return array (
+ 'title' => array(
+ ApiBase :: PARAM_DFLT => 'API',
+ ),
+ 'text' => null
+ );
+ }
+
+ protected function getParamDescription() {
+ return array (
+ 'text' => 'Wikitext to convert',
+ 'title' => 'Title of page',
+ );
+ }
+
+ protected function getDescription() {
+ return 'This module expand all templates in wikitext';
+ }
+
+ protected function getExamples() {
+ return array (
+ 'api.php?action=expandtemplates&text={{Project:Sandbox}}'
+ );
+ }
+
+ public function getVersion() {
+ return __CLASS__ . ': $Id$';
+ }
+}
+
Index: trunk/phase3/includes/AutoLoader.php
===================================================================
--- trunk/phase3/includes/AutoLoader.php (revision 26500)
+++ trunk/phase3/includes/AutoLoader.php (revision 26501)
@@ -308,6 +308,7 @@
'ApiLogin' => 'includes/api/ApiLogin.php',
'ApiMain' => 'includes/api/ApiMain.php',
'ApiOpenSearch' => 'includes/api/ApiOpenSearch.php',
+ 'ApiExpandTemplates' => 'includes/api/ApiExpandTemplates.php',
'ApiPageSet' => 'includes/api/ApiPageSet.php',
'ApiQuery' => 'includes/api/ApiQuery.php',
'ApiQueryAllpages' => 'includes/api/ApiQueryAllpages.php',
@@ -333,6 +334,7 @@
'ApiQuerySiteinfo' => 'includes/api/ApiQuerySiteinfo.php',
'ApiQueryUserInfo' => 'includes/api/ApiQueryUserInfo.php',
'ApiQueryWatchlist' => 'includes/api/ApiQueryWatchlist.php',
+ 'ApiRender' => 'includes/api/ApiRender.php',
'ApiResult' => 'includes/api/ApiResult.php',
);
Index: trunk/phase3/RELEASE-NOTES
===================================================================
--- trunk/phase3/RELEASE-NOTES (revision 26500)
+++ trunk/phase3/RELEASE-NOTES (revision 26501)
@@ -108,6 +108,8 @@
* Fixed rvlimit of the revisions query to only enforce the lower query limit if
revision content is requested.
* Include svn revision number (if install is checked-out from svn) in siteinfo query.
+* (bug 11173) Allow limited wikicode rendering via api.php
+* (bug 11572) API should provide interface for expanding templates
=== Languages updated in 1.12 ===