3 * Copyright © 2014 Wikimedia Foundation and contributors
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
24 * Message subclass that prepends wikitext for API help.
26 * This exists so the apihelp-*-paramvalue-*-* messages don't all have to
27 * include markup wikitext while still keeping the
28 * 'APIGetParamDescriptionMessages' hook simple.
33 class ApiHelpParamValueMessage
extends Message
{
35 protected $paramValue;
36 protected $deprecated;
39 * @see Message::__construct
41 * @param string $paramValue Parameter value being documented
42 * @param string $text Message to use.
43 * @param array $params Parameters for the message.
44 * @param bool $deprecated Whether the value is deprecated
45 * @throws InvalidArgumentException
46 * @since 1.30 Added the `$deprecated` parameter
48 public function __construct( $paramValue, $text, $params = [], $deprecated = false ) {
49 parent
::__construct( $text, $params );
50 $this->paramValue
= $paramValue;
51 $this->deprecated
= (bool)$deprecated;
55 * Fetch the parameter value
58 public function getParamValue() {
59 return $this->paramValue
;
63 * Fetch the 'deprecated' flag
67 public function isDeprecated() {
68 return $this->deprecated
;
75 public function fetchMessage() {
76 if ( $this->message
=== null ) {
78 if ( $this->isDeprecated() ) {
79 $msg = new Message( 'api-help-param-deprecated' );
80 $msg->interface = $this->interface;
81 $msg->language
= $this->language
;
82 $msg->useDatabase
= $this->useDatabase
;
83 $msg->title
= $this->title
;
84 $dep = '<span class="apihelp-deprecated">' . $msg->fetchMessage() . '</span> ';
86 $this->message
= ";<span dir=\"ltr\" lang=\"en\">{$this->paramValue}</span>:"
87 . $dep . parent
::fetchMessage();
89 return $this->message
;