r22867 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r22866‎ | r22867 | r22868 >
Date:16:19, 9 June 2007
Author:robchurch
Status:old
Tags:
Comment:
* Clean up and document Linker::makeBrokenImageLinkObj()
* (bug 6743) Don't link broken image links to the upload form when uploads are disabled
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/Linker.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/Linker.php
@@ -627,34 +627,38 @@
628628 }
629629
630630 /**
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
632639 */
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 {
637661 return "<!-- ERROR -->{$prefix}{$text}{$trail}";
638662 }
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;
659663 }
660664
661665 /** @deprecated use Linker::makeMediaLinkObj() */
Index: trunk/phase3/RELEASE-NOTES
@@ -150,7 +150,9 @@
151151 files are found, and make the list of extensions an option (defaults to
152152 $wgFileExtensions)
153153 * (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
155157
156158 == MediaWiki API changes since 1.10 ==
157159

Follow-up revisions

RevisionCommit summaryAuthorDate
r22878Merged revisions 22856-22877 via svnmerge from...david00:10, 10 June 2007
r22939Fix regression from r22867robchurch23:10, 12 June 2007
r22967Merged revisions 22935-22966 via svnmerge from...david18:35, 13 June 2007

Status & tagging log