wiki.techinc.nl/includes/htmlform/HTMLEditTools.php
Gergő Tisza 8dc5e1857d Unify handling of *-message(s) settings in HTMLForm
*-message(s) settings were documented as message key strings or arrays
of message key strings, but some actually accepted [key, params...]
arrays as well. They did not accept Message objects, which would be
the cleanest and most flexible method of message passing.

The patch adds a new method to process these settings (which accepts
a messages key, a [key, params...] array or a Message object), and
makes all *-message(s) usage call that.

Change-Id: Ida647973a58bea83fdbd53335e63b5a8615c16e4
2016-04-01 17:07:14 +03:00

51 lines
992 B
PHP

<?php
class HTMLEditTools extends HTMLFormField {
public function getInputHTML( $value ) {
return '';
}
public function getTableRow( $value ) {
$msg = $this->formatMsg();
return
'<tr><td></td><td class="mw-input">' .
'<div class="mw-editTools">' .
$msg->parseAsBlock() .
"</div></td></tr>\n";
}
/**
* @param string $value
* @return string
* @since 1.20
*/
public function getDiv( $value ) {
$msg = $this->formatMsg();
return '<div class="mw-editTools">' . $msg->parseAsBlock() . '</div>';
}
/**
* @param string $value
* @return string
* @since 1.20
*/
public function getRaw( $value ) {
return $this->getDiv( $value );
}
protected function formatMsg() {
if ( empty( $this->mParams['message'] ) ) {
$msg = $this->msg( 'edittools' );
} else {
$msg = $this->getMessage( $this->mParams['message'] );
if ( $msg->isDisabled() ) {
$msg = $this->msg( 'edittools' );
}
}
$msg->inContentLanguage();
return $msg;
}
}