Page MenuHomePhabricator

action-render.patch

Authored By
bzimport
Nov 21 2014, 9:49 PM
Size
3 KB
Referenced Files
None
Subscribers
None

action-render.patch

Index: api/ApiMain.php
===================================================================
--- api/ApiMain.php (revision 26450)
+++ api/ApiMain.php (working copy)
@@ -54,6 +54,7 @@
private static $Modules = array (
'login' => 'ApiLogin',
'query' => 'ApiQuery',
+ 'render' => 'ApiRender',
'opensearch' => 'ApiOpenSearch',
'feedwatchlist' => 'ApiFeedWatchlist',
'help' => 'ApiHelp',
Index: api/ApiRender.php
===================================================================
--- api/ApiRender.php (revision 0)
+++ api/ApiRender.php (revision 0)
@@ -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: AutoLoader.php
===================================================================
--- AutoLoader.php (revision 26450)
+++ AutoLoader.php (working copy)
@@ -333,6 +333,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',
);

File Metadata

Mime Type
text/x-diff
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3562
Default Alt Text
action-render.patch (3 KB)

Event Timeline