MediaWiki REL1_39
MessageContent.php
Go to the documentation of this file.
1<?php
38
42 protected $mMessage;
43
48 public function __construct( $msg, $params = null ) {
49 wfDeprecated( __CLASS__, '1.38' );
50 # XXX: messages may be wikitext, html or plain text! and maybe even something else entirely.
51 parent::__construct( CONTENT_MODEL_WIKITEXT );
52
53 if ( is_string( $msg ) ) {
54 $this->mMessage = wfMessage( $msg );
55 } else {
56 $this->mMessage = clone $msg;
57 }
58
59 if ( $params ) {
60 $this->mMessage = $this->mMessage->params( $params );
61 }
62 }
63
69 public function getWikitext() {
70 return $this->mMessage->text();
71 }
72
80 public function getNativeData() {
81 return $this->getMessage();
82 }
83
91 public function getMessage() {
92 // NOTE: Message objects are mutable. Cloning here makes MessageContent immutable.
93 return clone $this->mMessage;
94 }
95
101 public function getTextForSearchIndex() {
102 return $this->mMessage->plain();
103 }
104
110 public function getWikitextForTransclusion() {
111 return $this->getWikitext();
112 }
113
121 public function getTextForSummary( $maxlength = 250 ) {
122 return $this->mMessage->getLanguage()->truncateForDatabase(
123 $this->mMessage->plain(), $maxlength, '' );
124 }
125
131 public function getSize() {
132 return strlen( $this->mMessage->plain() );
133 }
134
140 public function copy() {
141 // MessageContent is immutable (because getNativeData() and getMessage()
142 // returns a clone of the Message object)
143 return $this;
144 }
145
153 public function isCountable( $hasLinks = null ) {
154 return false;
155 }
156}
const CONTENT_MODEL_WIKITEXT
Definition Defines.php:211
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.
Base implementation for content objects.
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)
The Message class deals with fetching and processing of interface message into a variety of formats.
Definition Message.php:140