http://www.mediawiki.org/wiki/Special:Code/MediaWiki/89314

Revision: 89314
Author:   jeroendedauw
Date:     2011-06-02 01:46:27 +0000 (Thu, 02 Jun 2011)
Log Message:
-----------
fix more getSkin compat issues

Modified Paths:
--------------
    
trunk/extensions/SemanticMediaWiki/specials/SearchTriple/SMW_SpecialBrowse.php
    
trunk/extensions/SemanticMediaWiki/specials/SearchTriple/SMW_SpecialPageProperty.php

Modified: 
trunk/extensions/SemanticMediaWiki/specials/SearchTriple/SMW_SpecialBrowse.php
===================================================================
--- 
trunk/extensions/SemanticMediaWiki/specials/SearchTriple/SMW_SpecialBrowse.php  
    2011-06-02 01:38:43 UTC (rev 89313)
+++ 
trunk/extensions/SemanticMediaWiki/specials/SearchTriple/SMW_SpecialBrowse.php  
    2011-06-02 01:46:27 UTC (rev 89314)
@@ -120,8 +120,7 @@
         * @return A string containing the HTML with the factbox
         */
        private function displayData( SMWSemanticData $data, $left = true, 
$incoming = false ) {
-               global $wgUser;
-               $skin = $wgUser->getSkin();
+               $skin = $this->getSkin();
                // Some of the CSS classes are different for the left or the 
right side.
                // In this case, there is an "i" after the "smwb-". This is set 
here.
                $ccsPrefix = $left ? 'smwb-' : 'smwb-i';
@@ -202,9 +201,10 @@
         * @return string  HTML with the link to the article, browse, and 
search pages
         */
        private function displayValue( SMWPropertyValue $property, SMWDataValue 
$dataValue, $incoming ) {
-               global $wgUser;
-               $skin = $wgUser->getSkin();
+               $skin = $this->getSkin();
+               
                $html = $dataValue->getLongHTMLText( $skin );
+               
                if ( $dataValue->getTypeID() == '_wpg' ) {
                        $html .= " " . SMWInfolink::newBrowsingLink( '+', 
$dataValue->getLongWikiText() )->getHTML( $skin );
                } elseif ( $incoming && $property->isVisible() ) {
@@ -212,6 +212,7 @@
                } else {
                        $html .= $dataValue->getInfolinkText( SMW_OUTPUT_HTML, 
$skin );
                }
+               
                return $html;
        }
 
@@ -221,14 +222,17 @@
         * @return A string containing the HTML with the subject line
         */
         private function displayHead() {
-               global $wgUser, $wgOut;
-               $skin = $wgUser->getSkin();
+               global $wgOut;
+               
+               $skin = $this->getSkin();
+               
                $wgOut->setHTMLTitle( $this->subject->getTitle() );
                $html  = "<table class=\"smwb-factbox\" cellpadding=\"0\" 
cellspacing=\"0\">\n";
                $html .= "<tr class=\"smwb-title\"><td colspan=\"2\">\n";
                $html .= $skin->makeLinkObj( $this->subject->getTitle() ) . 
"\n"; // @todo Replace makeLinkObj with link as soon as we drop MW1.12 
compatibility
                $html .= "</td></tr>\n";
                $html .= "</table>\n";
+               
                return $html;
         }
 
@@ -282,11 +286,9 @@
         * @return string  HTML with the link to this page
         */
        private function linkhere( $text, $out, $in, $offset ) {
-               global $wgUser;
-               $skin = $wgUser->getSkin();
                $dir = $out ? ( $in ? 'both':'out' ):'in';
                $frag = ( $text == wfMsg( 'smw_browse_show_incoming' ) ) ? 
'#smw_browse_incoming':'';
-               return '<a href="' . htmlspecialchars( $skin->makeSpecialUrl( 
'Browse',
+               return '<a href="' . htmlspecialchars( 
$this->getSkin()->makeSpecialUrl( 'Browse',
                         "offset={$offset}&dir={$dir}&article=" . urlencode( 
$this->subject->getLongWikiText() ) ) ) . "$frag\">$text</a>";
        }
 
@@ -373,4 +375,22 @@
                $text = preg_replace( '/[\s]/u', $nonBreakingSpace, $text, - 1, 
$count );
                return $count > 2 ? preg_replace( '/($nonBreakingSpace)/u', ' 
', $text, max( 0, $count - 2 ) ):$text;
        }
+       
+    /**
+     * Compatibility method to get the skin; MW 1.18 introduces a getSkin 
method in SpecialPage.
+     *
+     * @since 1.6
+     *
+     * @return Skin
+     */
+    public function getSkin() {
+        if ( method_exists( 'SpecialPage', 'getSkin' ) ) {
+            return parent::getSkin();
+        }
+        else {
+            global $wgUser;
+            return $wgUser->getSkin();
+        }
+    }
+    
 }

Modified: 
trunk/extensions/SemanticMediaWiki/specials/SearchTriple/SMW_SpecialPageProperty.php
===================================================================
--- 
trunk/extensions/SemanticMediaWiki/specials/SearchTriple/SMW_SpecialPageProperty.php
        2011-06-02 01:38:43 UTC (rev 89313)
+++ 
trunk/extensions/SemanticMediaWiki/specials/SearchTriple/SMW_SpecialPageProperty.php
        2011-06-02 01:46:27 UTC (rev 89314)
@@ -20,6 +20,7 @@
  * @ingroup SpecialPage
  */
 class SMWPageProperty extends SpecialPage {
+       
        /**
         * Constructor
         */
@@ -29,10 +30,10 @@
        }
 
        public function execute( $query ) {
-               global $wgRequest, $wgOut, $wgUser;
-               $skin = $wgUser->getSkin();
+               global $wgRequest, $wgOut;
+               $skin = $this->getSkin();
                $this->setHeaders();
-
+               
                // Get parameters
                $pagename = $wgRequest->getVal( 'from' );
                $propname = $wgRequest->getVal( 'type' );
@@ -121,4 +122,22 @@
                $wgOut->addHTML( $html );
                SMWOutputs::commitToOutputPage( $wgOut ); // make sure locally 
collected output data is pushed to the output!
        }
+       
+    /**
+     * Compatibility method to get the skin; MW 1.18 introduces a getSkin 
method in SpecialPage.
+     *
+     * @since 1.6
+     *
+     * @return Skin
+     */
+    public function getSkin() {
+        if ( method_exists( 'SpecialPage', 'getSkin' ) ) {
+            return parent::getSkin();
+        }
+        else {
+            global $wgUser;
+            return $wgUser->getSkin();
+        }
+    }
+    
 }


_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to