Merge "Add CollationFa"
[lhc/web/wiklou.git] / includes / skins / SkinTemplate.php
index 3efbd3b..69f2e49 100644 (file)
@@ -196,7 +196,6 @@ class SkinTemplate extends Skin {
        }
 
        protected function setupTemplateForOutput() {
-
                $request = $this->getRequest();
                $user = $this->getUser();
                $title = $this->getTitle();
@@ -257,7 +256,6 @@ class SkinTemplate extends Skin {
                if ( $oldContext ) {
                        $this->setContext( $oldContext );
                }
-
        }
 
        /**
@@ -921,19 +919,18 @@ class SkinTemplate extends Skin {
                                        $content_navigation['views']['view']['redundant'] = true;
                                }
 
-                               $isForeignFile = $title->inNamespace( NS_FILE ) && $this->canUseWikiPage() &&
-                                       $this->getWikiPage() instanceof WikiFilePage && !$this->getWikiPage()->isLocal();
+                               $page = $this->canUseWikiPage() ? $this->getWikiPage() : false;
+                               $isRemoteContent = $page && !$page->isLocal();
 
                                // If it is a non-local file, show a link to the file in its own repository
                                // @todo abstract this for remote content that isn't a file
-                               if ( $isForeignFile ) {
-                                       $file = $this->getWikiPage()->getFile();
+                               if ( $isRemoteContent ) {
                                        $content_navigation['views']['view-foreign'] = [
                                                'class' => '',
                                                'text' => wfMessageFallback( "$skname-view-foreign", 'view-foreign' )->
                                                        setContext( $this->getContext() )->
-                                                       params( $file->getRepo()->getDisplayName() )->text(),
-                                               'href' => $file->getDescriptionUrl(),
+                                                       params( $page->getWikiDisplayName() )->text(),
+                                               'href' => $page->getSourceURL(),
                                                'primary' => false,
                                        ];
                                }
@@ -957,9 +954,9 @@ class SkinTemplate extends Skin {
                                                        && $title->getDefaultMessageText() !== false
                                                )
                                        ) {
-                                               $msgKey = $isForeignFile ? 'edit-local' : 'edit';
+                                               $msgKey = $isRemoteContent ? 'edit-local' : 'edit';
                                        } else {
-                                               $msgKey = $isForeignFile ? 'create-local' : 'create';
+                                               $msgKey = $isRemoteContent ? 'create-local' : 'create';
                                        }
                                        $content_navigation['views']['edit'] = [
                                                'class' => ( $isEditing && ( $section !== 'new' || !$showNewSection )
@@ -969,7 +966,7 @@ class SkinTemplate extends Skin {
                                                'text' => wfMessageFallback( "$skname-view-$msgKey", $msgKey )
                                                        ->setContext( $this->getContext() )->text(),
                                                'href' => $title->getLocalURL( $this->editUrlOptions() ),
-                                               'primary' => !$isForeignFile, // don't collapse this in vector
+                                               'primary' => !$isRemoteContent, // don't collapse this in vector
                                        ];
 
                                        // section link
@@ -1171,7 +1168,6 @@ class SkinTemplate extends Skin {
         * @return array
         */
        private function buildContentActionUrls( $content_navigation ) {
-
                // content_actions has been replaced with content_navigation for backwards
                // compatibility and also for skins that just want simple tabs content_actions
                // is now built by flattening the content_navigation arrays into one
@@ -1312,12 +1308,14 @@ class SkinTemplate extends Skin {
                        if ( !$user->isAnon() ) {
                                $sur = new UserrightsPage;
                                $sur->setContext( $this->getContext() );
-                               if ( $sur->userCanExecute( $this->getUser() ) ) {
-                                       $nav_urls['userrights'] = [
-                                               'text' => $this->msg( 'tool-link-userrights', $this->getUser()->getName() )->text(),
-                                               'href' => self::makeSpecialUrlSubpage( 'Userrights', $rootUser )
-                                       ];
-                               }
+                               $canChange = $sur->userCanChangeRights( $this->getUser(), false );
+                               $nav_urls['userrights'] = [
+                                       'text' => $this->msg(
+                                               $canChange ? 'tool-link-userrights' : 'tool-link-userrights-readonly',
+                                               $this->getUser()->getName()
+                                       )->text(),
+                                       'href' => self::makeSpecialUrlSubpage( 'Userrights', $rootUser )
+                               ];
                        }
                }