From 6c79b2309bb4a446e39f9ebcb9219db8b07d17cb Mon Sep 17 00:00:00 2001 From: Rob Church Date: Sat, 7 Jul 2007 04:54:43 +0000 Subject: [PATCH] Clean up OutputPage::readOnlyPage() -- most of these specific reasons should probably be moved to callers --- includes/OutputPage.php | 41 +++++++++++++++++++---------------------- 1 file changed, 19 insertions(+), 22 deletions(-) diff --git a/includes/OutputPage.php b/includes/OutputPage.php index 0ca713b69b..a181d6d681 100644 --- a/includes/OutputPage.php +++ b/includes/OutputPage.php @@ -962,33 +962,30 @@ class OutputPage { if( $protected ) { $this->setPageTitle( wfMsg( 'viewsource' ) ); $this->setSubtitle( wfMsg( 'viewsourcefor', $skin->makeKnownLinkObj( $wgTitle ) ) ); - list( $cascadeSources, /* $restrictions */ ) = $wgTitle->getCascadeProtectionSources(); - # Determine if protection is due to the page being a system message - # and show an appropriate explanation + // Show an appropriate explanation depending upon the reason + // for the protection...all of these should be moved to the + // callers if( $wgTitle->getNamespace() == NS_MEDIAWIKI ) { + // User isn't allowed to edit the interface $this->addWikiText( wfMsg( 'protectedinterface' ) ); - } if ( $cascadeSources && count($cascadeSources) > 0 ) { - $titles = ''; - - foreach ( $cascadeSources as $title ) { - $titles .= '* [[:' . $title->getPrefixedText() . "]]\n"; - } - - $notice = wfMsgExt( 'cascadeprotected', array('parsemag'), count($cascadeSources) ) . "\n$titles"; - - $this->addWikiText( $notice ); - } else if ( $wgTitle->isNamespaceProtected() ) { + } elseif( $cascadeSources && ( $count = count( $cascadeSources ) ) > 0 ) { + // Cascading protection + $titles = ''; + foreach( $cascadeSources as $title ) + $titles .= "* [[:" . $title->getPrefixedText() . "]]\n"; + $this->addWikiText( wfMsgExt( 'cascadeprotected', 'parsemag', $count ) . "\n{$titles}" ); + } elseif( $wgTitle->isNamespaceProtected() ) { + // Namespace protection global $wgNamespaceProtection; - - $ns = ($wgTitle->getNamespace() == NS_MAIN) - ?wfMsg('nstab-main') - :$wgTitle->getNsText(); - + $ns = $wgTitle->getNamespace() == NS_MAIN + ? wfMsg( 'nstab-main' ) + : $wgTitle->getNsText(); $this->addWikiText( wfMsg( 'namespaceprotectedtext', $ns, - implode( ',', $wgNamespaceProtection[$wgTitle->getNamespace()] ) ) ); + implode( ', ', $wgNamespaceProtection[ $wgTitle->getNamespace() ] ) ) ); } else { + // Standard protection $this->addWikiText( wfMsg( 'protectedpagetext' ) ); } } else { @@ -1009,8 +1006,8 @@ class OutputPage { htmlspecialchars( $source ) . "\n"; $this->addHTML( $text ); } - $article = new Article($wgTitle); - $this->addHTML( $skin->formatTemplates($article->getUsedTemplates()) ); + $article = new Article( $wgTitle ); + $this->addHTML( $skin->formatTemplates( $article->getUsedTemplates() ) ); $this->returnToMain( false ); } -- 2.20.1