Index: trunk/phase3/includes/Linker.php |
— | — | @@ -627,34 +627,38 @@ |
628 | 628 | } |
629 | 629 | |
630 | 630 | /** |
631 | | - * Pass a title object, not a title string |
| 631 | + * Make a "broken" link to an image |
| 632 | + * |
| 633 | + * @param Title $title Image title |
| 634 | + * @param string $text Link label |
| 635 | + * @param string $query Query string |
| 636 | + * @param string $trail Link trail |
| 637 | + * @param string $prefix Link prefix |
| 638 | + * @return string |
632 | 639 | */ |
633 | | - function makeBrokenImageLinkObj( $nt, $text = '', $query = '', $trail = '', $prefix = '' ) { |
634 | | - # Fail gracefully |
635 | | - if ( ! isset($nt) ) { |
636 | | - # throw new MWException(); |
| 640 | + public function makeBrokenImageLinkObj( $title, $text = '', $query = '', $trail = '', $prefix = '' ) { |
| 641 | + global $wgEnableUploads; |
| 642 | + if( $title instanceof Title ) { |
| 643 | + wfProfileIn( __METHOD__ ); |
| 644 | + if( $wgEnableUploads ) { |
| 645 | + $upload = SpecialPage::getTitleFor( 'Upload' ); |
| 646 | + if( $text == '' ) |
| 647 | + $text = htmlspecialchars( $title->getPrefixedText() ); |
| 648 | + $q = 'wpDestFile=' . $title->getPrefixedUrl(); |
| 649 | + if( $query != '' ) |
| 650 | + $q .= '&' . $query; |
| 651 | + list( $inside, $trail ) = self::splitTrail( $trail ); |
| 652 | + $style = $this->getInternalLinkAttributesObj( $title, $text, 'yes' ); |
| 653 | + wfProfileOut( __METHOD__ ); |
| 654 | + return '<a href="' . $upload->escapeLocalUrl( $q ) . '"' |
| 655 | + . $style . '>' . $prefix . $text . $inside . '</a>' . $trail; |
| 656 | + } else { |
| 657 | + wfProfileOut( __METHOD__ ); |
| 658 | + return $this->makeKnownLinkObj( $title, $text, $query, $trail, $prefix ); |
| 659 | + } |
| 660 | + } else { |
637 | 661 | return "<!-- ERROR -->{$prefix}{$text}{$trail}"; |
638 | 662 | } |
639 | | - |
640 | | - $fname = 'Linker::makeBrokenImageLinkObj'; |
641 | | - wfProfileIn( $fname ); |
642 | | - |
643 | | - $q = 'wpDestFile=' . urlencode( $nt->getDBkey() ); |
644 | | - if ( '' != $query ) { |
645 | | - $q .= "&$query"; |
646 | | - } |
647 | | - $uploadTitle = SpecialPage::getTitleFor( 'Upload' ); |
648 | | - $url = $uploadTitle->escapeLocalURL( $q ); |
649 | | - |
650 | | - if ( '' == $text ) { |
651 | | - $text = htmlspecialchars( $nt->getPrefixedText() ); |
652 | | - } |
653 | | - $style = $this->getInternalLinkAttributesObj( $nt, $text, "yes" ); |
654 | | - list( $inside, $trail ) = Linker::splitTrail( $trail ); |
655 | | - $s = "<a href=\"{$url}\"{$style}>{$prefix}{$text}{$inside}</a>{$trail}"; |
656 | | - |
657 | | - wfProfileOut( $fname ); |
658 | | - return $s; |
659 | 663 | } |
660 | 664 | |
661 | 665 | /** @deprecated use Linker::makeMediaLinkObj() */ |
Index: trunk/phase3/RELEASE-NOTES |
— | — | @@ -150,7 +150,9 @@ |
151 | 151 | files are found, and make the list of extensions an option (defaults to |
152 | 152 | $wgFileExtensions) |
153 | 153 | * (bug 9909) Ensure access to binary fields in the math table use encodeBlob() |
154 | | - and decodeBlob. |
| 154 | + and decodeBlob() |
| 155 | +* (bug 6743) Don't link broken image links to the upload form when uploads |
| 156 | + are disabled |
155 | 157 | |
156 | 158 | == MediaWiki API changes since 1.10 == |
157 | 159 | |