* Only show upload links on file description if $wgEnableUploads = true and user *can* upload
* Don't say "You need to log in to upload", because it's possible that uploading is disabled for registered users as well and e.g. only sysops can upload (same for moving pages)
* And a small tweak: less code in SkinTemplate.php with same result
.inc
* Deprecated methods Title::getInterwikiLink, Title::userCanCreate(),
Title::userCanEdit() and Title::userCanMove() have been removed
+* Only show upload links on file description if $wgEnableUploads = true
+ and user can upload
+* Don't say "You need to log in to upload/move", because it's possible that
+ uploading/moving is disabled for registered users as well (e.g. only sysops)
== API changes in 1.16 ==
}
protected function openShowImage() {
- global $wgOut, $wgUser, $wgImageLimits, $wgRequest, $wgLang, $wgContLang;
+ global $wgOut, $wgUser, $wgImageLimits, $wgRequest,
+ $wgLang, $wgContLang, $wgEnableUploads;
$this->loadFile();
}
} else {
# Image does not exist
-
- $title = SpecialPage::getTitleFor( 'Upload' );
- $link = $sk->makeKnownLinkObj($title, wfMsgHtml('noimage-linktext'),
- 'wpDestFile=' . urlencode( $this->displayImg->getName() ) );
+ $nofile = wfMsgHtml( 'filepage-nofile' );
+ if ( $wgEnableUploads && $wgUser->isAllowed( 'upload' ) ) {
+ // Only show an upload link if the user can upload
+ $nofile .= ' '.$sk->makeKnownLinkObj(
+ SpecialPage::getTitleFor( 'Upload' ),
+ wfMsgHtml('filepage-nofile-link'),
+ 'wpDestFile=' . urlencode( $this->displayImg->getName() )
+ );
+ }
$wgOut->setRobotPolicy( 'noindex,nofollow' );
- $wgOut->addHTML( wfMsgWikiHtml( 'noimage', $link ) );
+ $wgOut->addHTML( '<div id="mw-imagepage-nofile">' . $nofile . '</div>' );
}
}
* external editing (and instructions link) etc.
*/
protected function uploadLinksBox() {
- global $wgUser, $wgOut;
+ global $wgUser, $wgOut, $wgEnableUploads;
+
+ if( !$wgEnableUploads ) { return; }
$this->loadFile();
if( !$this->img->isLocal() )
$nav_urls = array();
$nav_urls['mainpage'] = array( 'href' => self::makeMainPageUrl() );
- if( $wgEnableUploads && $wgUser->isAllowed( 'upload' ) ) {
- if( $wgUploadNavigationUrl ) {
- $nav_urls['upload'] = array( 'href' => $wgUploadNavigationUrl );
- } else {
- $nav_urls['upload'] = array( 'href' => self::makeSpecialUrl( 'Upload' ) );
- }
+ if( $wgUploadNavigationUrl ) {
+ $nav_urls['upload'] = array( 'href' => $wgUploadNavigationUrl );
+ } elseif( $wgEnableUploads && $wgUser->isAllowed( 'upload' ) ) {
+ $nav_urls['upload'] = array( 'href' => self::makeSpecialUrl( 'Upload' ) );
} else {
- if( $wgUploadNavigationUrl )
- $nav_urls['upload'] = array( 'href' => $wgUploadNavigationUrl );
- else
- $nav_urls['upload'] = false;
+ $nav_urls['upload'] = false;
}
$nav_urls['specialpages'] = array( 'href' => self::makeSpecialUrl( 'Specialpages' ) );
if( !$user->isAllowed( 'move' ) ) {
// User can't move anything
- $errors[] = $user->isAnon() ? array ( 'movenologintext' ) : array ('movenotallowed');
+ $errors[] = array ('movenotallowed');
}
} elseif ( $action == 'create' ) {
if( ( $this->isTalkPage() && !$user->isAllowed( 'createtalk' ) ) ||
} elseif( $action == 'move-target' ) {
if( !$user->isAllowed( 'move' ) ) {
// User can't move anything
- $errors[] = $user->isAnon() ? array ( 'movenologintext' ) : array ('movenotallowed');
+ $errors[] = array ('movenotallowed');
} elseif( !$user->isAllowed( 'move-rootuserpages' )
&& $this->getNamespace() == NS_USER && !$this->isSubpage() )
{
# Check permissions
if( !$wgUser->isAllowed( 'upload' ) ) {
- if( !$wgUser->isLoggedIn() ) {
- $wgOut->showErrorPage( 'uploadnologin', 'uploadnologintext' );
- } else {
- $wgOut->permissionRequired( 'upload' );
- }
+ $wgOut->permissionRequired( 'upload' );
return;
}
'sharedupload-desc-here' => 'This file is from $1 and may be used by other projects.
The description on its [$2 file description page] there is shown below.',
'shareddescriptionfollows' => '-', # do not translate or duplicate this message to other languages
-'noimage' => 'No file by this name exists, but you can $1.',
-'noimage-linktext' => 'upload one',
+'filepage-nofile' => 'No file by this name exists.',
+'filepage-nofile-link' => 'Click here to upload it.',
'uploadnewversion-linktext' => 'Upload a new version of this file',
'shared-repo-from' => 'from $1',
'shared-repo' => 'a shared repository',
In those cases, you will have to move or merge the page manually if desired.",
'movearticle' => 'Move page:',
-'movenologin' => 'Not logged in',
-'movenologintext' => 'You must be a registered user and [[Special:UserLogin|logged in]] to move a page.',
'movenotallowed' => 'You do not have permission to move pages.',
'movenotallowedfile' => 'You do not have permission to move files.',
'cant-move-user-page' => 'You do not have permission to move user pages (apart from subpages).',
'version-hook-name' => 'Hook name',
'version-hook-subscribedby' => 'Subscribed by',
'version-version' => '(Version $1)',
-'version-svn-revision' => '(r$2)', # only translate this message to other languages if you have to change it
+'version-svn-revision' => 'r$2', # only translate this message to other languages if you have to change it
'version-license' => 'License',
'version-software' => 'Installed software',
'version-software-product' => 'Product',
'sharedupload-desc-there',
'sharedupload-desc-here',
'shareddescriptionfollows',
- 'noimage',
- 'noimage-linktext',
+ 'filepage-nofile',
+ 'filepage-nofile-link',
'uploadnewversion-linktext',
'shared-repo-from',
'shared-repo',
'movepagetext',
'movepagetalktext',
'movearticle',
- 'movenologin',
- 'movenologintext',
'movenotallowed',
'movenotallowedfile',
'cant-move-user-page',