58 protected readonly
Title $title,
61 protected readonly
string $submitLabel,
64 $this->contentModel = $title->getContentModel();
66 $this->contentFormat = $this->contentHandlerFactory
67 ->getContentHandler( $this->contentModel )
104 $this->title->getNamespace() >=
NS_MAIN &&
108 $namespace = $this->title->getNsText() ?:
'Main';
114 $this->stats->getCounter(
'edit_failure_total' )
115 ->setLabel(
'cause',
'conflict' )
116 ->setLabel(
'namespace', $namespace )
117 ->setLabel(
'user_bucket', $userBucket )
132 $this->title->getNamespace() >=
NS_MAIN &&
136 $namespace = $this->title->getNsText() ?:
'Main';
144 $this->stats->getCounter(
'edit_failure_resolved_total' )
145 ->setLabel(
'cause',
'conflict' )
146 ->setLabel(
'namespace', $namespace )
147 ->setLabel(
'user_bucket', $userBucket )
163 $this->stats->increment( $keyPrefixBase .
'.byUserEdits.' . $this->
getUserBucket( $userEdits ) );
172 if ( $userEdits === null ) {
174 } elseif ( $userEdits > 200 ) {
176 } elseif ( $userEdits > 100 ) {
178 } elseif ( $userEdits > 10 ) {
189 return Html::rawElement(
191 [
'class' =>
'mw-explainconflict' ],
192 $this->out->msg(
'explainconflict', $this->out->msg( $this->submitLabel ) )->parse()
204 $classes = $builder->getTextboxProtectionCSSClasses( $this->title );
207 'aria-label' => $this->out->msg(
'edit-textarea-aria-label' )->text(),
210 $attribs += $customAttribs;
211 foreach ( $classes as $class ) {
212 Html::addClass( $attribs[
'class'], $class );
215 $attribs = $builder->buildTextboxAttribs(
218 $this->out->getUser(),
222 return Html::textarea(
224 $builder->addNewLineAtEnd( $this->storedversion ),
254 $this->out->wrapWikiMsg(
'<h2>$1</h2>',
"yourdiff" );
256 $yourContent = $this->toEditContent( $this->yourtext );
257 $storedContent = $this->toEditContent( $this->storedversion );
258 $handler = $this->contentHandlerFactory->getContentHandler( $this->contentModel );
259 $diffEngine = $handler->createDifferenceEngine( $this->out );
261 $diffEngine->setContent( $yourContent, $storedContent );
262 $diffEngine->showDiff(
263 $this->out->msg(
'yourtext' )->parse(),
264 $this->out->msg(
'storedversion' )->text()
267 $this->out->wrapWikiMsg(
'<h2>$1</h2>',
"yourtext" );
270 $attribs = $builder->buildTextboxAttribs(
272 [
'tabindex' => 6,
'readonly' ],
273 $this->out->getUser(),
278 Html::textarea(
'wpTextbox2', $builder->addNewLineAtEnd( $this->yourtext ), $attribs )
286 private function toEditContent( $text ) {
287 return ContentHandler::makeContent(
if(!defined('MW_SETUP_CALLBACK'))
Base class for content handling.
Exception thrown when an unregistered content model is requested.
Helper for displaying edit conflicts in text content models to users.
incrementConflictStats(?User $user=null)
Record a user encountering an edit conflict.
__construct(protected readonly Title $title, protected readonly OutputPage $out, protected readonly IBufferingStatsdDataFactory|StatsFactory $stats, protected readonly string $submitLabel, private readonly IContentHandlerFactory $contentHandlerFactory)
getUserBucket(?int $userEdits)
null string $contentModel
getEditFormHtmlAfterContent()
Content to go in the edit form after textbox1.
getEditConflictMainTextBox(array $customAttribs=[])
HTML to build the textbox1 on edit conflicts.
showEditFormTextAfterFooters()
Content to go in the edit form after the footers (templates on this page, hidden categories,...
null string $contentFormat
incrementResolvedStats(?User $user=null)
Record when a user has resolved an edit conflict.
setContentFormat( $contentFormat)
setContentModel( $contentModel)
setTextboxes( $yourtext, $storedversion)
incrementStatsByUserEdits( $userEdits, $keyPrefixBase)
Retained temporarily for backwards-compatibility.
getEditFormHtmlBeforeContent()
Content to go in the edit form before textbox1.
Helps EditPage build textboxes.
This is one of the Core classes and should be read at least once by any new developers.
Content objects represent page content, e.g.