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.
32 class ApiHelpParamValueMessage
extends Message
{
34 protected $paramValue;
35 protected $deprecated;
38 * @see Message::__construct
40 * @param string $paramValue Parameter value being documented
41 * @param string $text Message to use.
42 * @param array $params Parameters for the message.
43 * @param bool $deprecated Whether the value is deprecated
44 * @throws InvalidArgumentException
45 * @since 1.30 Added the `$deprecated` parameter
47 public function __construct( $paramValue, $text, $params = [], $deprecated = false ) {
48 parent
::__construct( $text, $params );
49 $this->paramValue
= $paramValue;
50 $this->deprecated
= (bool)$deprecated;
54 * Fetch the parameter value
57 public function getParamValue() {
58 return $this->paramValue
;
62 * Fetch the 'deprecated' flag
66 public function isDeprecated() {
67 return $this->deprecated
;
74 public function fetchMessage() {
75 if ( $this->message
=== null ) {
77 if ( $this->isDeprecated() ) {
78 $msg = new Message( 'api-help-param-deprecated' );
79 $msg->interface = $this->interface;
80 $msg->language
= $this->language
;
81 $msg->useDatabase
= $this->useDatabase
;
82 $msg->title
= $this->title
;
83 $dep = '<span class="apihelp-deprecated">' . $msg->fetchMessage() . '</span> ';
85 $this->message
= ";<span dir=\"ltr\" lang=\"en\">{$this->paramValue}</span>:"
86 . $dep . parent
::fetchMessage();
88 return $this->message
;