protected $mCanonicalUrl = false;
/**
- * @var string The contents of <h1> */
+ * @var string The contents of <h1>
+ */
private $mPageTitle = '';
/**
* @param string|null $action Action that was denied or null if unknown
*/
public function showPermissionsErrorPage( array $errors, $action = null ) {
+ $services = MediaWikiServices::getInstance();
+ $permissionManager = $services->getPermissionManager();
foreach ( $errors as $key => $error ) {
$errors[$key] = (array)$error;
}
// 1. the user is not logged in
// 2. the only error is insufficient permissions (i.e. no block or something else)
// 3. the error can be avoided simply by logging in
+
if ( in_array( $action, [ 'read', 'edit', 'createpage', 'createtalk', 'upload' ] )
&& $this->getUser()->isAnon() && count( $errors ) == 1 && isset( $errors[0][0] )
&& ( $errors[0][0] == 'badaccess-groups' || $errors[0][0] == 'badaccess-group0' )
- && ( User::groupHasPermission( 'user', $action )
- || User::groupHasPermission( 'autoconfirmed', $action ) )
+ && ( $permissionManager->groupHasPermission( 'user', $action )
+ || $permissionManager->groupHasPermission( 'autoconfirmed', $action ) )
) {
$displayReturnto = null;
}
}
- $services = MediaWikiServices::getInstance();
-
$title = SpecialPage::getTitleFor( 'Userlogin' );
$linkRenderer = $services->getLinkRenderer();
$loginUrl = $title->getLinkURL( $query, false, PROTO_RELATIVE );
$this->prepareErrorPage( $this->msg( 'loginreqtitle' ) );
$this->addHTML( $this->msg( $msg )->rawParams( $loginLink )->params( $loginUrl )->parse() );
- $permissionManager = $services->getPermissionManager();
-
# Don't return to a page the user can't read otherwise
# we'll end up in a pointless loop
if ( $displayReturnto && $permissionManager->userCan(
* @return string The doctype, opening "<html>", and head element.
*/
public function headElement( Skin $sk, $includeStyle = true ) {
+ $config = $this->getConfig();
$userdir = $this->getLanguage()->getDir();
$sitedir = MediaWikiServices::getInstance()->getContentLanguage()->getDir();
$this->setHTMLTitle( $this->msg( 'pagetitle', $this->getPageTitle() )->inContentLanguage() );
}
- if ( !Html::isXmlMimeType( $this->getConfig()->get( 'MimeType' ) ) ) {
+ if ( !Html::isXmlMimeType( $config->get( 'MimeType' ) ) ) {
// Add <meta charset="UTF-8">
// This should be before <title> since it defines the charset used by
// text including the text inside <title>.
$pieces = array_merge( $pieces, array_values( $this->getHeadLinksArray() ) );
$pieces = array_merge( $pieces, array_values( $this->mHeadItems ) );
+ // This library is intended to run on older browsers that MediaWiki no longer
+ // supports as Grade A. For these Grade C browsers, we provide an experience
+ // using only HTML and CSS. But, where standards-compliant browsers are able to
+ // style unknown HTML elements without issue, old IE ignores these styles.
+ // The html5shiv library fixes that.
// Use an IE conditional comment to serve the script only to old IE
+ $shivUrl = $config->get( 'ResourceBasePath' ) . '/resources/lib/html5shiv/html5shiv.js';
$pieces[] = '<!--[if lt IE 9]>' .
- ResourceLoaderClientHtml::makeLoad(
- new ResourceLoaderContext(
- $this->getResourceLoader(),
- new FauxRequest( [] )
- ),
- [ 'html5shiv' ],
- ResourceLoaderModule::TYPE_SCRIPTS,
- [ 'raw' => '1', 'sync' => '1' ],
- $this->getCSPNonce()
- ) .
+ Html::linkedScript( $shivUrl, $this->getCSPNonce() ) .
'<![endif]-->';
$pieces[] = Html::closeElement( 'head' );