From: WMDE-Fisch Date: Thu, 27 Oct 2016 12:27:15 +0000 (+0200) Subject: Even more out-factoring to methods in the header X-Git-Tag: 1.31.0-rc.0~4914^2 X-Git-Url: http://git.cyclocoop.org/%24image?a=commitdiff_plain;h=bcc28e8b772066c56a339448b86cb549c772d259;p=lhc%2Fweb%2Fwiklou.git Even more out-factoring to methods in the header Change-Id: If5909f7a16c98504e78388a5ea6c26196f82cd12 --- diff --git a/includes/EditPage.php b/includes/EditPage.php index 7d1cf1d66e..cd6fb562bb 100644 --- a/includes/EditPage.php +++ b/includes/EditPage.php @@ -2890,7 +2890,6 @@ ERROR; } protected function showHeader() { - global $wgOut, $wgUser, $wgMaxArticleSize, $wgLang; global $wgAllowUserCss, $wgAllowUserJs; if ( $this->isConflict ) { @@ -3022,65 +3021,10 @@ ERROR; } } - if ( $this->mTitle->isProtected( 'edit' ) && - MWNamespace::getRestrictionLevels( $this->mTitle->getNamespace() ) !== [ '' ] - ) { - # Is the title semi-protected? - if ( $this->mTitle->isSemiProtected() ) { - $noticeMsg = 'semiprotectedpagewarning'; - } else { - # Then it must be protected based on static groups (regular) - $noticeMsg = 'protectedpagewarning'; - } - LogEventsList::showLogExtract( $wgOut, 'protect', $this->mTitle, '', - [ 'lim' => 1, 'msgKey' => [ $noticeMsg ] ] ); - } - if ( $this->mTitle->isCascadeProtected() ) { - # Is this page under cascading protection from some source pages? - /** @var Title[] $cascadeSources */ - list( $cascadeSources, /* $restrictions */ ) = $this->mTitle->getCascadeProtectionSources(); - $notice = "
\n$1\n"; - $cascadeSourcesCount = count( $cascadeSources ); - if ( $cascadeSourcesCount > 0 ) { - # Explain, and list the titles responsible - foreach ( $cascadeSources as $page ) { - $notice .= '* [[:' . $page->getPrefixedText() . "]]\n"; - } - } - $notice .= '
'; - $wgOut->wrapWikiMsg( $notice, [ 'cascadeprotectedwarning', $cascadeSourcesCount ] ); - } - if ( !$this->mTitle->exists() && $this->mTitle->getRestrictions( 'create' ) ) { - LogEventsList::showLogExtract( $wgOut, 'protect', $this->mTitle, '', - [ 'lim' => 1, - 'showIfEmpty' => false, - 'msgKey' => [ 'titleprotectedwarning' ], - 'wrap' => "
\n$1
" ] ); - } + $this->addPageProtectionWarningHeaders(); - if ( $this->contentLength === false ) { - $this->contentLength = strlen( $this->textbox1 ); - } + $this->addLongPageWarningHeader(); - if ( $this->tooBig || $this->contentLength > $wgMaxArticleSize * 1024 ) { - $wgOut->wrapWikiMsg( "
\n$1\n
", - [ - 'longpageerror', - $wgLang->formatNum( round( $this->contentLength / 1024, 3 ) ), - $wgLang->formatNum( $wgMaxArticleSize ) - ] - ); - } else { - if ( !$this->context->msg( 'longpage-hint' )->isDisabled() ) { - $wgOut->wrapWikiMsg( "
\n$1\n
", - [ - 'longpage-hint', - $wgLang->formatSize( strlen( $this->textbox1 ) ), - strlen( $this->textbox1 ) - ] - ); - } - } # Add header copyright warning $this->showHeaderCopyrightWarning(); } @@ -4440,4 +4384,78 @@ HTML $wgOut->addWikiMsg( 'talkpagetext' ); } } + + /** + * @since 1.29 + */ + protected function addLongPageWarningHeader() { + global $wgMaxArticleSize, $wgOut, $wgLang; + + if ( $this->contentLength === false ) { + $this->contentLength = strlen( $this->textbox1 ); + } + + if ( $this->tooBig || $this->contentLength > $wgMaxArticleSize * 1024 ) { + $wgOut->wrapWikiMsg( "
\n$1\n
", + [ + 'longpageerror', + $wgLang->formatNum( round( $this->contentLength / 1024, 3 ) ), + $wgLang->formatNum( $wgMaxArticleSize ) + ] + ); + } else { + if ( !$this->context->msg( 'longpage-hint' )->isDisabled() ) { + $wgOut->wrapWikiMsg( "
\n$1\n
", + [ + 'longpage-hint', + $wgLang->formatSize( strlen( $this->textbox1 ) ), + strlen( $this->textbox1 ) + ] + ); + } + } + } + + /** + * @since 1.29 + */ + protected function addPageProtectionWarningHeaders() { + global $wgOut; + + if ( $this->mTitle->isProtected( 'edit' ) && + MWNamespace::getRestrictionLevels( $this->mTitle->getNamespace() ) !== [ '' ] + ) { + # Is the title semi-protected? + if ( $this->mTitle->isSemiProtected() ) { + $noticeMsg = 'semiprotectedpagewarning'; + } else { + # Then it must be protected based on static groups (regular) + $noticeMsg = 'protectedpagewarning'; + } + LogEventsList::showLogExtract( $wgOut, 'protect', $this->mTitle, '', + [ 'lim' => 1, 'msgKey' => [ $noticeMsg ] ] ); + } + if ( $this->mTitle->isCascadeProtected() ) { + # Is this page under cascading protection from some source pages? + /** @var Title[] $cascadeSources */ + list( $cascadeSources, /* $restrictions */ ) = $this->mTitle->getCascadeProtectionSources(); + $notice = "
\n$1\n"; + $cascadeSourcesCount = count( $cascadeSources ); + if ( $cascadeSourcesCount > 0 ) { + # Explain, and list the titles responsible + foreach ( $cascadeSources as $page ) { + $notice .= '* [[:' . $page->getPrefixedText() . "]]\n"; + } + } + $notice .= '
'; + $wgOut->wrapWikiMsg( $notice, [ 'cascadeprotectedwarning', $cascadeSourcesCount ] ); + } + if ( !$this->mTitle->exists() && $this->mTitle->getRestrictions( 'create' ) ) { + LogEventsList::showLogExtract( $wgOut, 'protect', $this->mTitle, '', + [ 'lim' => 1, + 'showIfEmpty' => false, + 'msgKey' => [ 'titleprotectedwarning' ], + 'wrap' => "
\n$1
" ] ); + } + } }