Siebrand has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/106931


Change subject: Call Linker methods statically
......................................................................

Call Linker methods statically

Change-Id: Ib06feb6e6adb9d41b45b32af55edd84e963a22bd
---
M includes/SPM_Utils.php
M specials/WidgetAssembler/SPM_UploadWindow.php
M specials/WidgetAssembler/SPM_UploadWindow2.php
3 files changed, 14 insertions(+), 24 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/SemanticPageMaker 
refs/changes/31/106931/1

diff --git a/includes/SPM_Utils.php b/includes/SPM_Utils.php
index db4be65..1b2189a 100644
--- a/includes/SPM_Utils.php
+++ b/includes/SPM_Utils.php
@@ -18,11 +18,11 @@
        }
 
        static function showCleanWikiOutput() {
-               global $wgOut, $wgUser;
+               global $wgOut;
 
+               $sk = $wgOut->getSkin();
                $wgOut->disable();
 
-               $sk = $wgUser->getSkin();
                $sk->initPage( $wgOut ); // need to call this to set skin name 
correctly
 
 //             global $wgJsMimeType, $wgStylePath, $wgStyleVersion,
diff --git a/specials/WidgetAssembler/SPM_UploadWindow.php 
b/specials/WidgetAssembler/SPM_UploadWindow.php
index e3fd5c6..3ba30e8 100644
--- a/specials/WidgetAssembler/SPM_UploadWindow.php
+++ b/specials/WidgetAssembler/SPM_UploadWindow.php
@@ -300,7 +300,7 @@
         * @access private
         */
        function processUpload() {
-               global $wgUser, $wgOut;
+               global $wgOut;
 
                if ( !wfRunHooks( 'UploadForm:BeforeProcessing', array( &$this 
) ) )
                {
@@ -444,9 +444,8 @@
 
                        global $wgUploadSizeWarning;
                        if ( $wgUploadSizeWarning && ( $this->mFileSize > 
$wgUploadSizeWarning ) ) {
-                               $skin = $wgUser->getSkin();
-                               $wsize = $skin->formatSize( 
$wgUploadSizeWarning );
-                               $asize = $skin->formatSize( $this->mFileSize );
+                               $wsize =Linker::formatSize( 
$wgUploadSizeWarning );
+                               $asize = Linker::formatSize( $this->mFileSize );
                                $warning .= '<li>' . wfMsgHtml( 'large-file', 
$wsize, $asize ) . '</li>';
                        }
                        if ( $this->mFileSize == 0 ) {
@@ -560,9 +559,9 @@
                }
 
                if ( $file->exists() ) {
-                       $dlink = $sk->makeKnownLinkObj( $file->getTitle() );
+                       $dlink = Linker::makeKnownLinkObj( $file->getTitle() );
                        if ( $file->allowInlineDisplay() ) {
-                               $dlink2 = $sk->makeImageLinkObj( 
$file->getTitle(), wfMsgExt( 'fileexists-thumb', 'parseinline', $dlink ),
+                               $dlink2 = Linker::makeImageLinkObj( 
$file->getTitle(), wfMsgExt( 'fileexists-thumb', 'parseinline', $dlink ),
                                        $file->getName(), 'right', array(), 
false, true );
                        } elseif ( !$file->allowInlineDisplay() && 
$file->isSafeFile() ) {
                                $icon = $file->iconThumb();
@@ -577,9 +576,9 @@
                } elseif ( $file_lc && $file_lc->exists() ) {
                        # Check if image with lowercase extension exists.
                        # It's not forbidden but in 99% it makes no sense to 
upload the same filename with uppercase extension
-                       $dlink = $sk->makeKnownLinkObj( $nt_lc );
+                       $dlink = Linker::makeKnownLinkObj( $nt_lc );
                        if ( $file_lc->allowInlineDisplay() ) {
-                               $dlink2 = $sk->makeImageLinkObj( $nt_lc, 
wfMsgExt( 'fileexists-thumb', 'parseinline', $dlink ),
+                               $dlink2 = Linker::makeImageLinkObj( $nt_lc, 
wfMsgExt( 'fileexists-thumb', 'parseinline', $dlink ),
                                        $nt_lc->getText(), 'right', array(), 
false, true );
                        } elseif ( !$file_lc->allowInlineDisplay() && 
$file_lc->isSafeFile() ) {
                                $icon = $file_lc->iconThumb();
@@ -599,7 +598,7 @@
                        $file_thb = wfLocalFile( $nt_thb );
                        if ( $file_thb->exists() ) {
                                # Check if an image without leading '180px-' 
(or similiar) exists
-                               $dlink = $sk->makeKnownLinkObj( $nt_thb );
+                               $dlink = Linker::makeKnownLinkObj( $nt_thb );
                                if ( $file_thb->allowInlineDisplay() ) {
                                        $dlink2 = $sk->makeImageLinkObj( 
$nt_thb,
                                                wfMsgExt( 'fileexists-thumb', 
'parseinline', $dlink ),
@@ -828,7 +827,7 @@
        function mainUploadWindowForm( $msg = '' ) {
                global $wgOut, $wgUser, $wgContLang;
                global $wgUseCopyrightUpload, $wgUseAjax, 
$wgAjaxUploadDestCheck, $wgAjaxLicensePreview;
-               global $wgRequest, $wgAllowCopyUploads;
+               global $wgAllowCopyUploads;
                global $wgStylePath, $wgStyleVersion;
 
                $useAjaxDestCheck = $wgUseAjax && $wgAjaxUploadDestCheck;
@@ -856,7 +855,7 @@
                                $link = wfMsgExt(
                                        $wgUser->isAllowed( 'delete' ) ? 
'thisisdeleted' : 'viewdeleted',
                                        array( 'parse', 'replaceafter' ),
-                                       $wgUser->getSkin()->makeKnownLinkObj(
+                                       Linker::makeKnownLinkObj(
                                                SpecialPage::getTitleFor( 
'Undelete', SPMWidgetUtils::getTitlePrefixedText( $title ) ),
                                                wfMsgHtml( 'restorelink', 
$count )
                                        )
diff --git a/specials/WidgetAssembler/SPM_UploadWindow2.php 
b/specials/WidgetAssembler/SPM_UploadWindow2.php
index 7a3ccfe..a010e40 100644
--- a/specials/WidgetAssembler/SPM_UploadWindow2.php
+++ b/specials/WidgetAssembler/SPM_UploadWindow2.php
@@ -243,7 +243,7 @@
                        $link = wfMsgExt(
                                $wgUser->isAllowed( 'delete' ) ? 
'thisisdeleted' : 'viewdeleted',
                                array( 'parse', 'replaceafter' ),
-                               $wgUser->getSkin()->linkKnown(
+                               Linker::linkKnown(
                                        SpecialPage::getTitleFor( 'Undelete', 
SPMWidgetUtils::getTitlePrefixedText( $title ) ),
                                        wfMsgExt( 'restorelink', array( 
'parsemag', 'escape' ), $count )
                                )
@@ -283,16 +283,11 @@
         * @param array $warnings
         */
        protected function uploadWarning( $warnings ) {
-               global $wgUser;
-
                $sessionKey = $this->mUpload->stashSession();
-
-               $sk = $wgUser->getSkin();
 
                $warningHtml = '<h2>' . wfMsgHtml( 'uploadwarning' ) . "</h2>\n"
                        . '<ul class="warning">';
                foreach ( $warnings as $warning => $args ) {
-                               $msg = '';
                                if ( $warning == 'exists' ) {
                                        $msg = self::getExistsWarning( $args );
                                } elseif ( $warning == 'duplicate' ) {
@@ -566,16 +561,12 @@
         * consisting of one or more <li> elements if there is a warning.
         */
        public static function getExistsWarning( $exists ) {
-               global $wgUser, $wgContLang;
-
                if ( !$exists )
                        return '';
 
                $file = $exists['file'];
                $filename = SPMWidgetUtils::getTitlePrefixedText( 
$file->getTitle() );
                $warning = array();
-
-               $sk = $wgUser->getSkin();
 
                if ( $exists['warning'] == 'exists' ) {
                        // Exact match
@@ -600,7 +591,7 @@
                } elseif ( $exists['warning'] == 'was-deleted' ) {
                        # If the file existed before and was deleted, warn the 
user of this
                        $ltitle = SpecialPage::getTitleFor( 'Log' );
-                       $llink = $sk->linkKnown(
+                       $llink = Linker::linkKnown(
                                $ltitle,
                                wfMsgHtml( 'deletionlog' ),
                                array(),

-- 
To view, visit https://gerrit.wikimedia.org/r/106931
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ib06feb6e6adb9d41b45b32af55edd84e963a22bd
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/SemanticPageMaker
Gerrit-Branch: master
Gerrit-Owner: Siebrand <siebr...@wikimedia.org>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to