MediaWiki  1.29.1
SpecialApiHelp.php
Go to the documentation of this file.
1 <?php
31  public function __construct() {
32  parent::__construct( 'ApiHelp' );
33  }
34 
35  public function execute( $par ) {
36  if ( empty( $par ) ) {
37  $par = 'main';
38  }
39 
40  // These come from transclusions
41  $request = $this->getRequest();
42  $options = [
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() ),
48  ];
49 
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;
57  }
58 
59  if ( substr( $par, 0, 5 ) === 'rsub/' ) {
60  $par = substr( $par, 5 );
61  $options['recursivesubmodules'] = 1;
62  continue;
63  }
64 
65  $moduleName = $par;
66  break;
67  }
68 
69  if ( !$this->including() ) {
70  unset( $options['nolead'], $options['title'] );
71  $options['modules'] = $moduleName;
73  $this->getOutput()->redirect( $link );
74  return;
75  }
76 
77  $main = new ApiMain( $this->getContext(), false );
78  try {
79  $module = $main->getModuleFromPath( $moduleName );
80  } catch ( ApiUsageException $ex ) {
81  $this->getOutput()->addHTML( Html::rawElement( 'span', [ 'class' => 'error' ],
82  $this->msg( 'apihelp-no-such-module', $moduleName )->inContentLanguage()->parse()
83  ) );
84  return;
85  } catch ( UsageException $ex ) {
86  $this->getOutput()->addHTML( Html::rawElement( 'span', [ 'class' => 'error' ],
87  $this->msg( 'apihelp-no-such-module', $moduleName )->inContentLanguage()->parse()
88  ) );
89  return;
90  }
91 
92  ApiHelp::getHelp( $this->getContext(), $module, $options );
93  }
94 
95  public function isIncludable() {
96  return true;
97  }
98 }
SpecialApiHelp
Special page to redirect to API help pages, for situations where linking to the api....
Definition: SpecialApiHelp.php:30
SpecialPage\getPageTitle
getPageTitle( $subpage=false)
Get a self-referential title object.
Definition: SpecialPage.php:628
ApiMain
This is the main API class, used for both external and internal processing.
Definition: ApiMain.php:45
SpecialApiHelp\__construct
__construct()
Definition: SpecialApiHelp.php:31
ApiUsageException
Exception used to abort API execution with an error.
Definition: ApiUsageException.php:98
$request
error also a ContextSource you ll probably need to make sure the header is varied on $request
Definition: hooks.txt:2612
SpecialPage\getOutput
getOutput()
Get the OutputPage being used for this instance.
Definition: SpecialPage.php:675
UnlistedSpecialPage
Shortcut to construct a special page which is unlisted by default.
Definition: UnlistedSpecialPage.php:29
php
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
Definition: injection.txt:35
wfAppendQuery
wfAppendQuery( $url, $query)
Append a query string to an existing URL, which may or may not already have query string parameters a...
Definition: GlobalFunctions.php:500
SpecialApiHelp\isIncludable
isIncludable()
Whether it's allowed to transclude the special page via {{Special:Foo/params}}.
Definition: SpecialApiHelp.php:95
wfScript
wfScript( $script='index')
Get the path to a specified script file, respecting file extensions; this is a wrapper around $wgScri...
Definition: GlobalFunctions.php:3138
UsageException
This exception will be thrown when dieUsage is called to stop module execution.
Definition: ApiUsageException.php:28
PROTO_CURRENT
const PROTO_CURRENT
Definition: Defines.php:220
SpecialApiHelp\execute
execute( $par)
Default execute method Checks user permissions.
Definition: SpecialApiHelp.php:35
SpecialPage\getContext
getContext()
Gets the context this SpecialPage is executed in.
Definition: SpecialPage.php:648
SpecialPage\msg
msg()
Wrapper around wfMessage that sets the current context.
Definition: SpecialPage.php:746
SpecialPage\getRequest
getRequest()
Get the WebRequest being used for this instance.
Definition: SpecialPage.php:665
ApiHelp\getHelp
static getHelp(IContextSource $context, $modules, array $options)
Generate help for the specified modules.
Definition: ApiHelp.php:94
Html\rawElement
static rawElement( $element, $attribs=[], $contents='')
Returns an HTML element in a string.
Definition: Html.php:209
$link
usually copyright or history_copyright This message must be in HTML not wikitext & $link
Definition: hooks.txt:2929
$options
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist Do not use this to implement individual filters if they are compatible with the ChangesListFilter and ChangesListFilterGroup structure use sub classes of those in conjunction with the ChangesListSpecialPageStructuredFilters hook This hook can be used to implement filters that do not implement that or custom behavior that is not an individual filter e g Watchlist and Watchlist you will want to construct new ChangesListBooleanFilter or ChangesListStringOptionsFilter objects When constructing you specify which group they belong to You can reuse existing or create your you must register them with $special registerFilterGroup removed from all revisions and log entries to which it was applied This gives extensions a chance to take it off their books as the deletion has already been partly carried out by this point or something similar the user will be unable to create the tag set and then return false from the hook function Ensure you consume the ChangeTagAfterDelete hook to carry out custom deletion actions as context called by AbstractContent::getParserOutput May be used to override the normal model specific rendering of page content as context as context $options
Definition: hooks.txt:1049
SpecialPage\including
including( $x=null)
Whether the special page is being evaluated via transclusion.
Definition: SpecialPage.php:226
wfExpandUrl
wfExpandUrl( $url, $defaultProto=PROTO_CURRENT)
Expand a potentially local URL to a fully-qualified URL.
Definition: GlobalFunctions.php:552