MediaWiki master
MessageContent.php
Go to the documentation of this file.
1<?php
29
40
44 protected $mMessage;
45
50 public function __construct( $msg, $params = null ) {
51 wfDeprecated( __CLASS__, '1.38' );
52 # XXX: messages may be wikitext, html or plain text! and maybe even something else entirely.
53 parent::__construct( CONTENT_MODEL_WIKITEXT );
54
55 if ( is_string( $msg ) ) {
56 $this->mMessage = wfMessage( $msg );
57 } else {
58 $this->mMessage = clone $msg;
59 }
60
61 if ( $params ) {
62 $this->mMessage = $this->mMessage->params( $params );
63 }
64 }
65
71 public function getWikitext() {
72 return $this->mMessage->text();
73 }
74
82 public function getNativeData() {
83 return $this->getMessage();
84 }
85
93 public function getMessage() {
94 // NOTE: Message objects are mutable. Cloning here makes MessageContent immutable.
95 return clone $this->mMessage;
96 }
97
103 public function getTextForSearchIndex() {
104 return $this->mMessage->plain();
105 }
106
112 public function getWikitextForTransclusion() {
113 return $this->getWikitext();
114 }
115
123 public function getTextForSummary( $maxlength = 250 ) {
124 return mb_strcut( $this->mMessage->plain(), 0, $maxlength );
125 }
126
132 public function getSize() {
133 return strlen( $this->mMessage->plain() );
134 }
135
141 public function copy() {
142 // MessageContent is immutable (because getNativeData() and getMessage()
143 // returns a clone of the Message object)
144 return $this;
145 }
146
154 public function isCountable( $hasLinks = null ) {
155 return false;
156 }
157}
const CONTENT_MODEL_WIKITEXT
Definition Defines.php:222
wfMessage( $key,... $params)
This is the function for getting translated interface messages.
wfDeprecated( $function, $version=false, $component=false, $callerOffset=2)
Logs a warning that a deprecated feature was used.
array $params
The job parameters.
Base implementation for content objects.
The Message class deals with fetching and processing of interface message into a variety of formats.
Definition Message.php:158
Wrapper allowing us to handle a system message as a Content object.
getMessage()
Returns the message object, with any parameters already substituted.
getNativeData()
Returns the message object, with any parameters already substituted.
isCountable( $hasLinks=null)
getWikitext()
Returns the message text.
getTextForSummary( $maxlength=250)
__construct( $msg, $params=null)