From: This, that and the other Date: Mon, 7 Apr 2014 10:00:11 +0000 (+1000) Subject: Add extra views (tabs) for files in a foreign repository X-Git-Tag: 1.31.0-rc.0~16330^2 X-Git-Url: https://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/comptes/ajouter.php?a=commitdiff_plain;h=fc613e6360b31933a2a027e81b7075f5cd867d8b;p=lhc%2Fweb%2Fwiklou.git Add extra views (tabs) for files in a foreign repository Previously, foreign files with no local page had only a [Create] tab, with no explanation that this created a local description page. There was not even a [Read] tab - from SkinTemplate's perspective, a foreign file page did not exist. This patch changes the following view tabs: * [Read] now always appears on foreign files - no change in functionality * New tab [View on ] always appears on foreign files * [Create] tab renamed to [Add local description] for foreign files without a local page * [Edit] tab renamed to [Edit local description] for foreign files with a local page This is related to bug 26525. I am hesitant to implement a [Edit on ] tab that goes straight to the edit screen, as I worry about users getting confused and thinking they are editing the file locally. Change-Id: I4a43b759b7a7e9ac2c8d437408847bf3b6c1f4a9 --- diff --git a/includes/SkinTemplate.php b/includes/SkinTemplate.php index 50739138b0..f359a1cc09 100644 --- a/includes/SkinTemplate.php +++ b/includes/SkinTemplate.php @@ -944,8 +944,11 @@ class SkinTemplate extends Skin { $content_navigation['namespaces'][$talkId]['context'] = 'talk'; if ( $userCanRead ) { + $isForeignFile = $title->inNamespace( NS_FILE ) && $this->canUseWikiPage() && + $this->getWikiPage() instanceof WikiFilePage && !$this->getWikiPage()->isLocal(); + // Adds view view link - if ( $title->exists() ) { + if ( $title->exists() || $isForeignFile ) { $content_navigation['views']['view'] = $this->tabAction( $isTalk ? $talkPage : $subjectPage, array( "$skname-view-view", 'view' ), @@ -955,6 +958,19 @@ class SkinTemplate extends Skin { $content_navigation['views']['view']['redundant'] = true; } + // If it is a non-local file, show a link to the file in its own repository + if ( $isForeignFile ) { + $file = $this->getWikiPage()->getFile(); + $content_navigation['views']['view-foreign'] = array( + 'class' => '', + 'text' => wfMessageFallback( "$skname-view-foreign", 'view-foreign' )-> + setContext( $this->getContext() )-> + params( $file->getRepo()->getDisplayName() )->text(), + 'href' => $file->getDescriptionUrl(), + 'primary' => false, + ); + } + wfProfileIn( __METHOD__ . '-edit' ); // Checks if user can edit the current page if it exists or create it otherwise @@ -969,13 +985,16 @@ class SkinTemplate extends Skin { && ( ( $isTalk && $this->isRevisionCurrent() ) || $out->showNewSectionLink() ); $section = $request->getVal( 'section' ); - $msgKey = $title->exists() || ( $title->getNamespace() == NS_MEDIAWIKI && $title->getDefaultMessageText() !== false ) ? - 'edit' : 'create'; + if ( $title->exists() || ( $title->getNamespace() == NS_MEDIAWIKI && $title->getDefaultMessageText() !== false ) ) { + $msgKey = $isForeignFile ? 'edit-local' : 'edit'; + } else { + $msgKey = $isForeignFile ? 'create-local' : 'create'; + } $content_navigation['views']['edit'] = array( 'class' => ( $isEditing && ( $section !== 'new' || !$showNewSection ) ? 'selected' : '' ) . $isTalkClass, 'text' => wfMessageFallback( "$skname-view-$msgKey", $msgKey )->setContext( $this->getContext() )->text(), 'href' => $title->getLocalURL( $this->editUrlOptions() ), - 'primary' => true, // don't collapse this in vector + 'primary' => !$isForeignFile, // don't collapse this in vector ); // section link diff --git a/languages/i18n/en.json b/languages/i18n/en.json index 9031b9678b..4ca6300aa4 100644 --- a/languages/i18n/en.json +++ b/languages/i18n/en.json @@ -181,8 +181,11 @@ "permalink": "Permanent link", "print": "Print", "view": "View", + "view-foreign": "View on $1", "edit": "Edit", + "edit-local": "Edit local description", "create": "Create", + "create-local": "Add local description", "editthispage": "Edit this page", "create-this-page": "Create this page", "delete": "Delete", diff --git a/languages/i18n/qqq.json b/languages/i18n/qqq.json index 5b3c939115..03fe5721d9 100644 --- a/languages/i18n/qqq.json +++ b/languages/i18n/qqq.json @@ -338,8 +338,11 @@ "permalink": "Display name for a permanent link to the current revision of a page. When the page is edited, permalink will still link to this revision. Example: Last menu link on [[{{MediaWiki:Mainpage}}]]\n\nSee also:\n* {{msg-mw|Permalink}}\n* {{msg-mw|Accesskey-t-permalink}}\n* {{msg-mw|Tooltip-t-permalink}}\n{{Identical|Permalink}}", "print": "{{Identical|Print}}", "view": "The default text of the \"View\" or \"Read\" (Vector) views tab which represents the basic view for the page. Should be in the infinitive mood.\n\n{{Identical|View}}", + "view-foreign": "The text on the tab that sends people to the \"master copy\" of the file at the foreign file\nrepository (e.g. Wikimedia Commons). Should be in the infinitive mood.\n\nParameters:\n* $1 - the name of the shared repository. On Wikimedia sites, $1 is {{msg-mw|Shared-repo-name-shared}}. On wikis using [[mw:InstantCommons|InstantCommons]], $1 is {{msg-mw|Shared-repo-name-wikimediacommons}}. The default value for $1 is {{msg-mw|Shared-repo}}.", "edit": "The text of the tab going to the edit form. When the page is protected, you will see {{msg-mw|Viewsource}}. Should be in the infinitive mood.\n\nSee also:\n* {{msg-mw|Edit}}\n* {{msg-mw|Accesskey-ca-edit}}\n* {{msg-mw|Tooltip-ca-edit}}\n{{Identical|Edit}}", - "create": "The text on the tab of the edit form on unexisting pages starts editing them.\n\n{{Identical|Create}}", + "edit-local": "The text on the tab going to the edit form for the local description page of a file from a foreign file repository (e.g. Wikimedia Commons). Should be in the infinitive mood.\n\nSee also:\n* {{msg-mw|Edit}}\n* {{msg-mw|Create-local}}", + "create": "The text on the tab of the edit form on unexisting pages starts editing them. Should be in the infinitive mood.\n\n{{Identical|Create}}", + "create-local": "The text on the tab going to the creation form for the (not yet existing) local description page of a file from a foreign file repository (e.g. Wikimedia Commons). Should be in the infinitive mood.\n\nSee also:\n* {{msg-mw|Create}}\n* {{msg-mw|Edit-local}}", "editthispage": "This is the \"edit\" link as used in the Cologne Blue skin, at the bottom of the page.\n\nSee {{msg-mw|Create-this-page}} for when the page does not exist.\n{{Identical|Edit this page}}", "create-this-page": "In the Cologne Blue skin this is the text for the link leading to the edit form on pages that have not yet been created, at the bottom of the page. See {{msg-mw|editthispage}} for when the page already exists.\n{{Identical|Createpage}}", "delete": "Name of the Delete tab shown for admins. Should be in the infinitive mood.\n\nSee also:\n* {{msg-mw|Delete}}\n* {{msg-mw|Accesskey-ca-delete}}\n* {{msg-mw|Tooltip-ca-delete}}\n{{Identical|Delete}}",