r98670 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r98669‎ | r98670 | r98671 >
Date:13:49, 2 October 2011
Author:robin
Status:ok (Comments)
Tags:
Comment:
* IncubatorTest::onGetUserPermissionsErrors(): do not disallow deleting pages belonging to existing wikis :)
* Call linker function statically (the extension is not compatible with 1.17 and lower anyway)
* Fix a link for protocol-relative URLs, and make the external links display nicely (without the '//')
Modified paths:
  • /trunk/extensions/WikimediaIncubator/IncubatorTest.php (modified) (history)
  • /trunk/extensions/WikimediaIncubator/InfoPage.php (modified) (history)

Diff [purge]

Index: trunk/extensions/WikimediaIncubator/IncubatorTest.php
@@ -322,8 +322,10 @@
323323 $link = self::getSubdomain( $prefixdata['lang'],
324324 $prefixdata['project'], ( $title->getNsText() ? $title->getNsText() . ':' : '' ) .
325325 str_replace( ' ', '_', $prefixdata['realtitle'] ) );
 326+ # faking external link to support prot-rel URLs
 327+ $link = "[$link ". self::makeExternalLinkText( $link ) . "]";
326328 $result[] = array( 'wminc-error-wiki-exists', $link );
327 - return false;
 329+ return $action == 'delete' ? true : false;
328330 }
329331
330332 if( !self::shouldWeShowUnprefixedError( $title ) || $action != 'create' ) {
@@ -467,7 +469,6 @@
468470 if( $prefix['error'] ) { # We are not on info pages
469471 global $wmincSisterProjects;
470472 $prefix2 = self::analyzePrefix( $title->getText(), false, true );
471 - $linker = class_exists( 'DummyLinker' ) ? new DummyLinker : new Linker;
472473 $p = isset( $prefix2['project' ] ) ? $prefix2['project'] : '';
473474 if( self::getDBState( $prefix2 ) == 'existing' ) {
474475 $link = self::getSubdomain( $prefix2['lang'], $p,
@@ -478,7 +479,7 @@
479480 return true;
480481 } else {
481482 # Show a link to the existing wiki
482 - $showLink = $linker->makeExternalLink( $link, $link );
 483+ $showLink = self::makeExternalLinkText( $link, true );
483484 $wgOut->addHtml( '<div class="wminc-wiki-exists">' .
484485 wfMsgHtml( 'wminc-error-wiki-exists', $showLink ) .
485486 '</div>' );
@@ -487,7 +488,7 @@
488489 # A sister project is not hosted here, so direct the user to the relevant wiki
489490 $link = self::getSubdomain( $prefix2['lang'], $p,
490491 ( $title->getNsText() ? $title->getNsText() . ':' : '' ) . $prefix2['realtitle'] );
491 - $showLink = $linker->makeExternalLink( $link, $link );
 492+ $showLink = self::makeExternalLinkText( $link, true );
492493 $wgOut->addHtml( '<div class="wminc-wiki-sister">' .
493494 wfMsgHtml( 'wminc-error-wiki-sister', $showLink ) .
494495 '</div>' );
@@ -754,4 +755,15 @@
755756 private static function preg_quote_slash( $str ) {
756757 return preg_quote( $str, '/' );
757758 }
 759+
 760+ /**
 761+ * @param $url String
 762+ * @param $callLinker Boolean Whether to call makeExternalLink()
 763+ */
 764+ public static function makeExternalLinkText( $url, $callLinker = false ) {
 765+ # when displaying a URL, if it contains 'http://' or 'https://' it's ok to leave it,
 766+ # but for protocol-relative URLs, it's nicer to remove the '//'
 767+ $linktext = ltrim( $url, '/' );
 768+ return $callLinker ? Linker::makeExternalLink( $url, $linktext ) : $linktext;
 769+ }
758770 }
Index: trunk/extensions/WikimediaIncubator/InfoPage.php
@@ -49,7 +49,6 @@
5050 * @return String
5151 */
5252 public function makeLogo( $project, $clickable = true, $width = 25, $height = '', $url = '', $args = array() ) {
53 - global $wgUser;
5453 $projectForFile = preg_replace('/ /', '-', strtolower( $project ) );
5554 $imageobj = wfFindFile( wfMsg( 'wminc-logo-' . $projectForFile ) );
5655 $useUrl = $url ? $url : IncubatorTest::getSubdomain( 'www', IncubatorTest::getProject( $project, false, true ) );
@@ -57,7 +56,7 @@
5857 if( !$clickable ) {
5958 return $logo;
6059 }
61 - return $wgUser->getSkin()->makeExternalLink( $useUrl, $project, false );
 60+ return Linker::makeExternalLink( $useUrl, $project, false );
6261 }
6362 if( $clickable ) {
6463 $args['link-url'] = $useUrl;
@@ -68,7 +67,7 @@
6968 if( $height ) {
7069 $handlerParams['height'] = $height;
7170 }
72 - return $wgUser->getSkin()->makeImageLink2( $this->mTitle, $imageobj,
 71+ return Linker::makeImageLink2( $this->mTitle, $imageobj,
7372 array( 'alt' => $project, 'caption' => $project ) + $args, $handlerParams
7473 );
7574 }
@@ -159,14 +158,14 @@
160159 * @return String
161160 */
162161 public function showIncubatingWiki() {
163 - global $wgUser, $wgLang;
 162+ global $wgLang;
164163 $substatus = $this->mSubStatus;
165164 if( $substatus == 'imported' && $this->mIsSister ) {
166165 $substatus = 'closedsister';
167166 }
168 - $portalLink = $wgUser->getSkin()->makeExternalLink( $this->mPortal, $this->mProjectName );
 167+ $portalLink = Linker::makeExternalLink( $this->mPortal, $this->mProjectName );
169168 if( $this->mThisLangData['type'] != 'invalid' ) {
170 - $gotoLink = $wgUser->getSkin()->link(
 169+ $gotoLink = Linker::link(
171170 Title::newFromText( IncubatorTest::getMainPage( $this->mLangCode, $this->mPrefix ) ),
172171 wfMsgNoTrans( 'wminc-infopage-enter' ) );
173172 $gotoMainPage = Html::rawElement( 'span',
@@ -174,7 +173,7 @@
175174 $wgLang->getArrow() . ' ' . ( $this->mIsSister ? $portalLink : $gotoLink ) );
176175 }
177176 $subdomain = IncubatorTest::getSubdomain( $this->mLangCode, $this->mProjectCode );
178 - $subdomainLink = $wgUser->getSkin()->makeExternalLink( $subdomain, $subdomain );
 177+ $subdomainLink = IncubatorTest::makeExternalLinkText( $subdomain, true );
179178 $content = Html::rawElement( 'div', array( 'class' => 'wminc-infopage-status' ),
180179 wfMsgWikiHtml( 'wminc-infopage-status-' . $substatus, $subdomainLink, $portalLink ) );
181180 if( $this->mSubStatus != 'approved' && $this->mThisLangData['type'] != 'invalid' ) {
@@ -189,11 +188,11 @@
190189 * @return String
191190 */
192191 public function showExistingWiki() {
193 - global $wgLang, $wgUser;
 192+ global $wgLang;
194193 $created = isset( $this->mCreated ) ? $this->mCreated : ''; # for future use
195194 $bug = isset( $this->mBug ) ? $this->mBug : ''; # for future use
196195 $subdomain = IncubatorTest::getSubdomain( $this->mLangCode, $this->mProjectCode );
197 - $subdomainLink = $wgUser->getSkin()->makeExternalLink( $subdomain, $subdomain );
 196+ $subdomainLink = IncubatorTest::makeExternalLinkText( $subdomain, true );
198197 if( $this->mThisLangData['type'] != 'invalid' ) {
199198 $gotoSubdomain = Html::rawElement( 'span',
200199 array( 'class' => 'wminc-infopage-entertest' ),

Follow-up revisions

RevisionCommit summaryAuthorDate
r105776MFT for WikimediaIncubator: r95582, r96122, r96138, r96141, r97175, r98670, r...siebrand00:32, 11 December 2011

Comments

#Comment by Nikerabbit (talk | contribs)   14:53, 21 November 2011
 -return $action == 'delete' ? true : false;
 +return $action === 'delete';

Latter is sufficient.

#Comment by SPQRobin (talk | contribs)   16:58, 21 November 2011

Changed meanwhile in e.g. r103822

Status & tagging log