wfMsgForContentNoTrans() was removed
[mediawiki.git] / includes / specials / SpecialApiHelp.php
blobb43911f56d94e4046b80db1f22bece791b010aa5
1 <?php
2 /**
3 * Implements Special:ApiHelp
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * http://www.gnu.org/copyleft/gpl.html
20 * @file
21 * @ingroup SpecialPage
24 /**
25 * Special page to redirect to API help pages, for situations where linking to
26 * the api.php endpoint is not wanted.
28 * @ingroup SpecialPage
30 class SpecialApiHelp extends UnlistedSpecialPage {
31 public function __construct() {
32 parent::__construct( 'ApiHelp' );
35 public function execute( $par ) {
36 if ( empty( $par ) ) {
37 $par = 'main';
40 // These come from transclusions
41 $request = $this->getRequest();
42 $options = array(
43 'action' => 'help',
44 'nolead' => true,
45 'submodules' => $request->getCheck( 'submodules' ),
46 'recursivesubmodules' => $request->getCheck( 'recursivesubmodules' ),
47 'title' => $request->getVal( 'title', $this->getPageTitle( '$1' )->getPrefixedText() ),
50 // These are for linking from wikitext, since url parameters are a pain
51 // to do.
52 while ( true ) {
53 if ( substr( $par, 0, 4 ) === 'sub/' ) {
54 $par = substr( $par, 4 );
55 $options['submodules'] = 1;
56 continue;
59 if ( substr( $par, 0, 5 ) === 'rsub/' ) {
60 $par = substr( $par, 5 );
61 $options['recursivesubmodules'] = 1;
62 continue;
65 $moduleName = $par;
66 break;
69 if ( !$this->including() ) {
70 unset( $options['nolead'], $options['title'] );
71 $options['modules'] = $moduleName;
72 $link = wfAppendQuery( wfExpandUrl( wfScript( 'api' ), PROTO_CURRENT ), $options );
73 $this->getOutput()->redirect( $link );
74 return;
77 $main = new ApiMain( $this->getContext(), false );
78 try {
79 $module = $main->getModuleFromPath( $moduleName );
80 } catch ( UsageException $ex ) {
81 $this->getOutput()->addHTML( Html::rawElement( 'span', array( 'class' => 'error' ),
82 $this->msg( 'apihelp-no-such-module', $moduleName )->inContentLanguage()->parse()
83 ) );
84 return;
87 ApiHelp::getHelp( $this->getContext(), $module, $options );
90 public function isIncludable() {
91 return true;