r89314 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r89313‎ | r89314 | r89315 >
Date:01:46, 2 June 2011
Author:jeroendedauw
Status:deferred
Tags:
Comment:
fix more getSkin compat issues
Modified paths:
  • /trunk/extensions/SemanticMediaWiki/specials/SearchTriple/SMW_SpecialBrowse.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/specials/SearchTriple/SMW_SpecialPageProperty.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticMediaWiki/specials/SearchTriple/SMW_SpecialBrowse.php
@@ -120,8 +120,7 @@
121121 * @return A string containing the HTML with the factbox
122122 */
123123 private function displayData( SMWSemanticData $data, $left = true, $incoming = false ) {
124 - global $wgUser;
125 - $skin = $wgUser->getSkin();
 124+ $skin = $this->getSkin();
126125 // Some of the CSS classes are different for the left or the right side.
127126 // In this case, there is an "i" after the "smwb-". This is set here.
128127 $ccsPrefix = $left ? 'smwb-' : 'smwb-i';
@@ -202,9 +201,10 @@
203202 * @return string HTML with the link to the article, browse, and search pages
204203 */
205204 private function displayValue( SMWPropertyValue $property, SMWDataValue $dataValue, $incoming ) {
206 - global $wgUser;
207 - $skin = $wgUser->getSkin();
 205+ $skin = $this->getSkin();
 206+
208207 $html = $dataValue->getLongHTMLText( $skin );
 208+
209209 if ( $dataValue->getTypeID() == '_wpg' ) {
210210 $html .= " " . SMWInfolink::newBrowsingLink( '+', $dataValue->getLongWikiText() )->getHTML( $skin );
211211 } elseif ( $incoming && $property->isVisible() ) {
@@ -212,6 +212,7 @@
213213 } else {
214214 $html .= $dataValue->getInfolinkText( SMW_OUTPUT_HTML, $skin );
215215 }
 216+
216217 return $html;
217218 }
218219
@@ -221,14 +222,17 @@
222223 * @return A string containing the HTML with the subject line
223224 */
224225 private function displayHead() {
225 - global $wgUser, $wgOut;
226 - $skin = $wgUser->getSkin();
 226+ global $wgOut;
 227+
 228+ $skin = $this->getSkin();
 229+
227230 $wgOut->setHTMLTitle( $this->subject->getTitle() );
228231 $html = "<table class=\"smwb-factbox\" cellpadding=\"0\" cellspacing=\"0\">\n";
229232 $html .= "<tr class=\"smwb-title\"><td colspan=\"2\">\n";
230233 $html .= $skin->makeLinkObj( $this->subject->getTitle() ) . "\n"; // @todo Replace makeLinkObj with link as soon as we drop MW1.12 compatibility
231234 $html .= "</td></tr>\n";
232235 $html .= "</table>\n";
 236+
233237 return $html;
234238 }
235239
@@ -282,11 +286,9 @@
283287 * @return string HTML with the link to this page
284288 */
285289 private function linkhere( $text, $out, $in, $offset ) {
286 - global $wgUser;
287 - $skin = $wgUser->getSkin();
288290 $dir = $out ? ( $in ? 'both':'out' ):'in';
289291 $frag = ( $text == wfMsg( 'smw_browse_show_incoming' ) ) ? '#smw_browse_incoming':'';
290 - return '<a href="' . htmlspecialchars( $skin->makeSpecialUrl( 'Browse',
 292+ return '<a href="' . htmlspecialchars( $this->getSkin()->makeSpecialUrl( 'Browse',
291293 "offset={$offset}&dir={$dir}&article=" . urlencode( $this->subject->getLongWikiText() ) ) ) . "$frag\">$text</a>";
292294 }
293295
@@ -373,4 +375,22 @@
374376 $text = preg_replace( '/[\s]/u', $nonBreakingSpace, $text, - 1, $count );
375377 return $count > 2 ? preg_replace( '/($nonBreakingSpace)/u', ' ', $text, max( 0, $count - 2 ) ):$text;
376378 }
 379+
 380+ /**
 381+ * Compatibility method to get the skin; MW 1.18 introduces a getSkin method in SpecialPage.
 382+ *
 383+ * @since 1.6
 384+ *
 385+ * @return Skin
 386+ */
 387+ public function getSkin() {
 388+ if ( method_exists( 'SpecialPage', 'getSkin' ) ) {
 389+ return parent::getSkin();
 390+ }
 391+ else {
 392+ global $wgUser;
 393+ return $wgUser->getSkin();
 394+ }
 395+ }
 396+
377397 }
Index: trunk/extensions/SemanticMediaWiki/specials/SearchTriple/SMW_SpecialPageProperty.php
@@ -20,6 +20,7 @@
2121 * @ingroup SpecialPage
2222 */
2323 class SMWPageProperty extends SpecialPage {
 24+
2425 /**
2526 * Constructor
2627 */
@@ -29,10 +30,10 @@
3031 }
3132
3233 public function execute( $query ) {
33 - global $wgRequest, $wgOut, $wgUser;
34 - $skin = $wgUser->getSkin();
 34+ global $wgRequest, $wgOut;
 35+ $skin = $this->getSkin();
3536 $this->setHeaders();
36 -
 37+
3738 // Get parameters
3839 $pagename = $wgRequest->getVal( 'from' );
3940 $propname = $wgRequest->getVal( 'type' );
@@ -121,4 +122,22 @@
122123 $wgOut->addHTML( $html );
123124 SMWOutputs::commitToOutputPage( $wgOut ); // make sure locally collected output data is pushed to the output!
124125 }
 126+
 127+ /**
 128+ * Compatibility method to get the skin; MW 1.18 introduces a getSkin method in SpecialPage.
 129+ *
 130+ * @since 1.6
 131+ *
 132+ * @return Skin
 133+ */
 134+ public function getSkin() {
 135+ if ( method_exists( 'SpecialPage', 'getSkin' ) ) {
 136+ return parent::getSkin();
 137+ }
 138+ else {
 139+ global $wgUser;
 140+ return $wgUser->getSkin();
 141+ }
 142+ }
 143+
125144 }

Status & tagging log