85 private $contentHandlerFactory;
105 $this->contentHandlerFactory = $contentHandlerFactory;
107 $this->contentFormat = $this->contentHandlerFactory
109 ->getDefaultFormat();
142 $statsdMetrics = [
'edit.failures.conflict' ];
146 $this->title->getNamespace() >=
NS_MAIN &&
150 $namespace = $this->title->getNsText() ?:
'Main';
151 $statsdMetrics[] =
'edit.failures.conflict.byNamespaceId.' . $this->title->getNamespace();
155 $statsdMetrics[] =
'edit.failures.conflict.byUserEdits.' . $userBucket;
158 $this->stats->getCounter(
'edit_failure_total' )
159 ->setLabel(
'cause',
'conflict' )
160 ->setLabel(
'namespace', $namespace )
161 ->setLabel(
'user_bucket', $userBucket )
162 ->copyToStatsdAt( $statsdMetrics )
167 foreach ( $statsdMetrics as $metric ) {
168 $this->stats->increment( $metric );
180 $statsdMetrics = [
'edit.failures.conflict.resolved' ];
184 $this->title->getNamespace() >=
NS_MAIN &&
188 $namespace = $this->title->getNsText() ?:
'Main';
189 $statsdMetrics[] =
'edit.failures.conflict.resolved.byNamespaceId.' . $this->title->getNamespace();
194 $statsdMetrics[] =
'edit.failures.conflict.resolved.byUserEdits.' . $userBucket;
198 $this->stats->getCounter(
'edit_failure_resolved_total' )
199 ->setLabel(
'cause',
'conflict' )
200 ->setLabel(
'namespace', $namespace )
201 ->setLabel(
'user_bucket', $userBucket )
202 ->copyToStatsdAt( $statsdMetrics )
207 foreach ( $statsdMetrics as $metric ) {
208 $this->stats->increment( $metric );
224 $this->stats->increment( $keyPrefixBase .
'.byUserEdits.' . $this->
getUserBucket( $userEdits ) );
233 if ( $userEdits === null ) {
235 } elseif ( $userEdits > 200 ) {
237 } elseif ( $userEdits > 100 ) {
239 } elseif ( $userEdits > 10 ) {
250 return Html::rawElement(
252 [
'class' =>
'mw-explainconflict' ],
253 $this->out->msg(
'explainconflict', $this->out->msg( $this->submitLabel )->text() )->parse()
265 $classes = $builder->getTextboxProtectionCSSClasses( $this->title );
268 'aria-label' => $this->out->msg(
'edit-textarea-aria-label' )->text(),
271 $attribs += $customAttribs;
273 $attribs = $builder->mergeClassesIntoAttributes( $classes, $attribs );
275 $attribs = $builder->buildTextboxAttribs(
278 $this->out->getUser(),
282 return Html::textarea(
284 $builder->addNewLineAtEnd( $this->storedversion ),
314 $this->out->wrapWikiMsg(
'<h2>$1</h2>',
"yourdiff" );
316 $yourContent = $this->toEditContent( $this->yourtext );
317 $storedContent = $this->toEditContent( $this->storedversion );
318 $handler = $this->contentHandlerFactory->getContentHandler( $this->contentModel );
319 $diffEngine = $handler->createDifferenceEngine( $this->out );
321 $diffEngine->setContent( $yourContent, $storedContent );
322 $diffEngine->showDiff(
323 $this->out->msg(
'yourtext' )->parse(),
324 $this->out->msg(
'storedversion' )->text()
327 $this->out->wrapWikiMsg(
'<h2>$1</h2>',
"yourtext" );
330 $attribs = $builder->buildTextboxAttribs(
332 [
'tabindex' => 6,
'readonly' ],
333 $this->out->getUser(),
338 Html::textarea(
'wpTextbox2', $builder->addNewLineAtEnd( $this->yourtext ), $attribs )
346 private function toEditContent( $text ) {
347 return ContentHandler::makeContent(
if(!defined('MW_SETUP_CALLBACK'))
Exception thrown when an unregistered content model is requested.
A content handler knows how do deal with a specific type of content on a wiki page.
Helper for displaying edit conflicts in text content models to users.
incrementResolvedStats(User $user=null)
Record when a user has resolved an edit conflict.
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,...
incrementConflictStats(User $user=null)
Record a user encountering an edit conflict.
null string $contentFormat
__construct(Title $title, OutputPage $out, $stats, $submitLabel, IContentHandlerFactory $contentHandlerFactory)
IBufferingStatsdDataFactory StatsFactory $stats
setContentFormat( $contentFormat)
setContentModel( $contentModel)
setTextboxes( $yourtext, $storedversion)
incrementStatsByUserEdits( $userEdits, $keyPrefixBase)
Retained temporarily for backwards-compatibility.
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.
MediaWiki adaptation of StatsdDataFactory that provides buffering functionality.
Base interface for representing page content.
getContentHandler(string $modelID)
Returns a ContentHandler instance for the given $modelID.