5 * Created on Dec 22, 2014
7 * Copyright © 2014 Brad Jorsch <bjorsch@wikimedia.org>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write to the Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
22 * http://www.gnu.org/copyleft/gpl.html
28 * Message subclass that prepends wikitext for API help.
30 * This exists so the apihelp-*-paramvalue-*-* messages don't all have to
31 * include markup wikitext while still keeping the
32 * 'APIGetParamDescriptionMessages' hook simple.
36 class ApiHelpParamValueMessage
extends Message
{
38 protected $paramValue;
39 protected $deprecated;
42 * @see Message::__construct
44 * @param string $paramValue Parameter value being documented
45 * @param string $text Message to use.
46 * @param array $params Parameters for the message.
47 * @param bool $deprecated Whether the value is deprecated
48 * @throws InvalidArgumentException
49 * @since 1.30 Added the `$deprecated` parameter
51 public function __construct( $paramValue, $text, $params = [], $deprecated = false ) {
52 parent
::__construct( $text, $params );
53 $this->paramValue
= $paramValue;
54 $this->deprecated
= (bool)$deprecated;
58 * Fetch the parameter value
61 public function getParamValue() {
62 return $this->paramValue
;
66 * Fetch the 'deprecated' flag
70 public function isDeprecated() {
71 return $this->deprecated
;
78 public function fetchMessage() {
79 if ( $this->message
=== null ) {
81 if ( $this->isDeprecated() ) {
82 $msg = new Message( 'api-help-param-deprecated' );
83 $msg->interface = $this->interface;
84 $msg->language
= $this->language
;
85 $msg->useDatabase
= $this->useDatabase
;
86 $msg->title
= $this->title
;
87 $dep = '<span class="apihelp-deprecated">' . $msg->fetchMessage() . '</span> ';
89 $this->message
= ";<span dir=\"ltr\" lang=\"en\">{$this->paramValue}</span>:"
90 . $dep . parent
::fetchMessage();
92 return $this->message
;