*
* Created on Aug 29, 2014
*
- * Copyright © 2014 Brad Jorsch <bjorsch@wikimedia.org>
+ * Copyright © 2014 Wikimedia Foundation and contributors
*
* 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
if ( is_array( $type ) ) {
$count = count( $type );
+ $deprecatedValues = isset( $settings[ApiBase::PARAM_DEPRECATED_VALUES] )
+ ? $settings[ApiBase::PARAM_DEPRECATED_VALUES]
+ : [];
$links = isset( $settings[ApiBase::PARAM_VALUE_LINKS] )
? $settings[ApiBase::PARAM_VALUE_LINKS]
: [];
- $values = array_map( function ( $v ) use ( $links ) {
- // We can't know whether this contains LTR or RTL text.
- $ret = $v === '' ? $v : Html::element( 'span', [ 'dir' => 'auto' ], $v );
+ $values = array_map( function ( $v ) use ( $links, $deprecatedValues ) {
+ $attr = [];
+ if ( $v !== '' ) {
+ // We can't know whether this contains LTR or RTL text.
+ $attr['dir'] = 'auto';
+ }
+ if ( isset( $deprecatedValues[$v] ) ) {
+ $attr['class'] = 'apihelp-deprecated-value';
+ }
+ $ret = $attr ? Html::element( 'span', $attr, $v ) : $v;
if ( isset( $links[$v] ) ) {
$ret = "[[{$links[$v]}|$ret]]";
}
switch ( $type ) {
case 'submodule':
$groups[] = $name;
+
if ( isset( $settings[ApiBase::PARAM_SUBMODULE_MAP] ) ) {
$map = $settings[ApiBase::PARAM_SUBMODULE_MAP];
- ksort( $map );
- $submodules = [];
- foreach ( $map as $v => $m ) {
- $submodules[] = "[[Special:ApiHelp/{$m}|{$v}]]";
- }
+ $defaultAttrs = [];
} else {
- $submodules = $module->getModuleManager()->getNames( $name );
- sort( $submodules );
- $prefix = $module->isMain()
- ? '' : ( $module->getModulePath() . '+' );
- $submodules = array_map( function ( $name ) use ( $prefix ) {
- $text = Html::element( 'span', [ 'dir' => 'ltr', 'lang' => 'en' ], $name );
- return "[[Special:ApiHelp/{$prefix}{$name}|{$text}]]";
- }, $submodules );
+ $prefix = $module->isMain() ? '' : ( $module->getModulePath() . '+' );
+ $map = [];
+ foreach ( $module->getModuleManager()->getNames( $name ) as $submoduleName ) {
+ $map[$submoduleName] = $prefix . $submoduleName;
+ }
+ $defaultAttrs = [ 'dir' => 'ltr', 'lang' => 'en' ];
+ }
+ ksort( $map );
+
+ $submodules = [];
+ $deprecatedSubmodules = [];
+ foreach ( $map as $v => $m ) {
+ $attrs = $defaultAttrs;
+ $arr = &$submodules;
+ try {
+ $submod = $module->getModuleFromPath( $m );
+ if ( $submod ) {
+ if ( $submod->isDeprecated() ) {
+ $arr = &$deprecatedSubmodules;
+ $attrs['class'] = 'apihelp-deprecated-value';
+ }
+ }
+ } catch ( ApiUsageException $ex ) {
+ // Ignore
+ }
+ if ( $attrs ) {
+ $v = Html::element( 'span', $attrs, $v );
+ }
+ $arr[] = "[[Special:ApiHelp/{$m}|{$v}]]";
}
+ $submodules = array_merge( $submodules, $deprecatedSubmodules );
$count = count( $submodules );
$info[] = $context->msg( 'api-help-param-list' )
->params( $multi ? 2 : 1 )
*
* Created on Dec 22, 2014
*
- * Copyright © 2014 Brad Jorsch <bjorsch@wikimedia.org>
+ * Copyright © 2014 Wikimedia Foundation and contributors
*
* 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
class ApiHelpParamValueMessage extends Message {
protected $paramValue;
+ protected $deprecated;
/**
* @see Message::__construct
* @param string $paramValue Parameter value being documented
* @param string $text Message to use.
* @param array $params Parameters for the message.
+ * @param bool $deprecated Whether the value is deprecated
* @throws InvalidArgumentException
+ * @since 1.30 Added the `$deprecated` parameter
*/
- public function __construct( $paramValue, $text, $params = [] ) {
+ public function __construct( $paramValue, $text, $params = [], $deprecated = false ) {
parent::__construct( $text, $params );
$this->paramValue = $paramValue;
+ $this->deprecated = (bool)$deprecated;
}
/**
return $this->paramValue;
}
+ /**
+ * Fetch the 'deprecated' flag
+ * @since 1.30
+ * @return bool
+ */
+ public function isDeprecated() {
+ return $this->deprecated;
+ }
+
/**
* Fetch the message.
* @return string
*/
public function fetchMessage() {
if ( $this->message === null ) {
+ $dep = '';
+ if ( $this->isDeprecated() ) {
+ $msg = new Message( 'api-help-param-deprecated' );
+ $msg->interface = $this->interface;
+ $msg->language = $this->language;
+ $msg->useDatabase = $this->useDatabase;
+ $msg->title = $this->title;
+ $dep = '<span class="apihelp-deprecated">' . $msg->fetchMessage() . '</span> ';
+ }
$this->message = ";<span dir=\"ltr\" lang=\"en\">{$this->paramValue}</span>:"
- . parent::fetchMessage();
+ . $dep . parent::fetchMessage();
}
return $this->message;
}
*
* Copyright © 2006 Yuri Astrakhan "<Firstname><Lastname>@gmail.com"
* Copyright © 2008 Brion Vibber <brion@wikimedia.org>
- * Copyright © 2014 Brad Jorsch <bjorsch@wikimedia.org>
+ * Copyright © 2014 Wikimedia Foundation and contributors
*
* 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
break;
case 'xml':
- // http://msdn.microsoft.com/en-us/library/cc891508%28v=vs.85%29.aspx
+ // https://msdn.microsoft.com/en-us/library/cc891508(v=vs.85).aspx
$imageKeys = [
'source' => true,
'alt' => true,
<?php
/**
- * Copyright © 2016 Brad Jorsch <bjorsch@wikimedia.org>
+ * Copyright © 2016 Wikimedia Foundation and contributors
*
* 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
return $this->hasAnyRoutes;
}
- protected function getDescriptionMessage() {
+ protected function getExtendedDescription() {
if ( !$this->hasAnyRoutes() ) {
- return 'apihelp-resetpassword-description-noroutes';
+ return 'apihelp-resetpassword-extended-description-noroutes';
}
- return parent::getDescriptionMessage();
+ return parent::getExtendedDescription();
}
public function execute() {