21 namespace MediaWiki\EditPage;
84 private $contentHandlerFactory;
104 $this->contentHandlerFactory = $contentHandlerFactory;
106 $this->contentFormat = $this->contentHandlerFactory
108 ->getDefaultFormat();
139 $this->stats->increment(
'edit.failures.conflict' );
142 $this->title->getNamespace() >=
NS_MAIN &&
145 $this->stats->increment(
146 'edit.failures.conflict.byNamespaceId.' . $this->title->getNamespace()
159 $this->stats->increment(
'edit.failures.conflict.resolved' );
162 $this->title->getNamespace() >=
NS_MAIN &&
165 $this->stats->increment(
166 'edit.failures.conflict.resolved.byNamespaceId.' . $this->title->getNamespace()
171 $user->getEditCount(),
172 'edit.failures.conflict.resolved'
182 if ( $userEdits ===
null ) {
183 $userBucket =
'anon';
184 } elseif ( $userEdits > 200 ) {
185 $userBucket =
'over200';
186 } elseif ( $userEdits > 100 ) {
187 $userBucket =
'over100';
188 } elseif ( $userEdits > 10 ) {
189 $userBucket =
'over10';
191 $userBucket =
'under11';
193 $this->stats->increment( $keyPrefixBase .
'.byUserEdits.' . $userBucket );
202 [
'class' =>
'mw-explainconflict' ],
203 $this->out->msg(
'explainconflict', $this->out->msg( $this->submitLabel )->text() )->parse()
215 $classes = $builder->getTextboxProtectionCSSClasses( $this->title );
218 'aria-label' => $this->out->msg(
'edit-textarea-aria-label' )->text(),
221 $attribs += $customAttribs;
223 $attribs = $builder->mergeClassesIntoAttributes( $classes, $attribs );
225 $attribs = $builder->buildTextboxAttribs(
228 $this->out->getUser(),
234 $builder->addNewLineAtEnd( $this->storedversion ),
264 $this->out->wrapWikiMsg(
'<h2>$1</h2>',
"yourdiff" );
266 $yourContent = $this->toEditContent( $this->yourtext );
267 $storedContent = $this->toEditContent( $this->storedversion );
268 $handler = $this->contentHandlerFactory->getContentHandler( $this->contentModel );
269 $diffEngine = $handler->createDifferenceEngine( $this->out );
271 $diffEngine->setContent( $yourContent, $storedContent );
272 $diffEngine->showDiff(
273 $this->out->msg(
'yourtext' )->parse(),
274 $this->out->msg(
'storedversion' )->text()
277 $this->out->wrapWikiMsg(
'<h2>$1</h2>',
"yourtext" );
280 $attribs = $builder->buildTextboxAttribs(
282 [
'tabindex' => 6,
'readonly' ],
283 $this->out->getUser(),
288 Html::textarea(
'wpTextbox2', $builder->addNewLineAtEnd( $this->yourtext ), $attribs )
296 private function toEditContent( $text ) {
A content handler knows how do deal with a specific type of content on a wiki page.
static makeContent( $text, Title $title=null, $modelId=null, $format=null)
Convenience function for creating a Content object from a given textual representation.
Exception thrown when an unregistered content model is requested.
Helper for displaying edit conflicts in text content models to users.
incrementResolvedStats(User $user=null)
Record when a user has resolved an edit conflict.
null string $contentModel
getEditFormHtmlAfterContent()
Content to go in the edit form after textbox1.
getEditConflictMainTextBox(array $customAttribs=[])
HTML to build the textbox1 on edit conflicts.
__construct(Title $title, OutputPage $out, IBufferingStatsdDataFactory $stats, $submitLabel, IContentHandlerFactory $contentHandlerFactory)
showEditFormTextAfterFooters()
Content to go in the edit form after the footers (templates on this page, hidden categories,...
incrementConflictStats(User $user=null)
Record a user encountering an edit conflict.
null string $contentFormat
IBufferingStatsdDataFactory $stats
setContentFormat( $contentFormat)
setContentModel( $contentModel)
setTextboxes( $yourtext, $storedversion)
incrementStatsByUserEdits( $userEdits, $keyPrefixBase)
string $submitLabel
Message key for submit button's label.
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.
Base interface for representing page content.
MediaWiki adaptation of StatsdDataFactory that provides buffering functionality.
getContentHandler(string $modelID)
Returns a ContentHandler instance for the given $modelID.