*/
public function link( $target, $text = null, $customAttribs = array(), $query = array(), $options = array() ) {
wfProfileIn( __METHOD__ );
+ if( !$target instanceof Title ) {
+ return "<!-- ERROR -->$text";
+ }
+ $options = (array)$options;
+
$ret = null;
if( !wfRunHooks( 'LinkBegin', array( $this, $target, &$text,
&$customAttribs, &$query, &$options, &$ret ) ) ) {
return $ret;
}
- if( !$target instanceof Title ) {
- throw new MWException( 'Linker::link passed invalid target' );
- }
- $options = (array)$options;
-
# Normalize the Title if it's a special page
$target = $this->normaliseSpecialPage( $target );
}
private function linkText( $target ) {
+ # We might be passed a non-Title by make*LinkObj(). Fail gracefully.
+ if( !$target instanceof Title ) {
+ return '';
+ }
+
# If the target is just a fragment, with no title, we return the frag-
# ment text. Otherwise, we return the title text itself.
if( $target->getPrefixedText() === '' and $target->getFragment() !== '' ) {
* the end of the link.
* @param $prefix String: optional prefix. As trail, only before instead of after.
*/
- function makeLinkObj( Title $nt, $text= '', $query = '', $trail = '', $prefix = '' ) {
+ function makeLinkObj( $nt, $text= '', $query = '', $trail = '', $prefix = '' ) {
global $wgUser;
wfProfileIn( __METHOD__ );
* @param $style String: style to apply - if empty, use getInternalLinkAttributesObj instead
* @return the a-element
*/
- function makeKnownLinkObj( Title $title, $text = '', $query = '', $trail = '', $prefix = '' , $aprops = '', $style = '' ) {
+ function makeKnownLinkObj( $title, $text = '', $query = '', $trail = '', $prefix = '' , $aprops = '', $style = '' ) {
wfProfileIn( __METHOD__ );
if ( $text == '' ) {
* be included in the link text. Other characters will be appended after
* the end of the link.
*/
- function makeBrokenLinkObj( Title $title, $text = '', $query = '', $trail = '', $prefix = '' ) {
+ function makeBrokenLinkObj( $title, $text = '', $query = '', $trail = '', $prefix = '' ) {
wfProfileIn( __METHOD__ );
list( $inside, $trail ) = Linker::splitTrail( $trail );
if( $rev->isDeleted( Revision::DELETED_USER ) && $isPublic ) {
$link = wfMsgHtml( 'rev-deleted-user' );
} else if( $rev->userCan( Revision::DELETED_USER ) ) {
- $link = $this->userLink( $rev->getRawUser(), $rev->getRawUserText() );
+ $link = $this->userLink( $rev->getUser( Revision::FOR_THIS_USER ),
+ $rev->getUserText( Revision::FOR_THIS_USER ) );
} else {
$link = wfMsgHtml( 'rev-deleted-user' );
}
if( $rev->isDeleted( Revision::DELETED_USER ) && $isPublic ) {
$link = wfMsgHtml( 'rev-deleted-user' );
} else if( $rev->userCan( Revision::DELETED_USER ) ) {
- $link = $this->userLink( $rev->getRawUser(), $rev->getRawUserText() ) .
- ' ' . $this->userToolLinks( $rev->getRawUser(), $rev->getRawUserText() );
+ $userId = $rev->getUser( Revision::FOR_THIS_USER );
+ $userText = $rev->getUserText( Revision::FOR_THIS_USER );
+ $link = $this->userLink( $userId, $userText ) .
+ ' ' . $this->userToolLinks( $userId, $userText );
} else {
$link = wfMsgHtml( 'rev-deleted-user' );
}
if ( $local ) {
$sectionTitle = Title::newFromText( '#' . $section );
} else {
- $sectionTitle = clone( $title );
- $sectionTitle->mFragment = $section;
+ $sectionTitle = Title::makeTitleSafe( $title->getNamespace(),
+ $title->getDBkey(), $section );
}
- # FIXME: $sectionTitle should probably always be valid at this
- # point, but in some scenarios it's not (bug 15351). Is this cor-
- # rect?
- if( $title instanceof Title ) {
+ if ( $sectionTitle ) {
$link = $this->link( $sectionTitle,
wfMsgForContent( 'sectionlink' ), array(), array(),
'noclasses' );
if( $rev->isDeleted( Revision::DELETED_COMMENT ) && $isPublic ) {
$block = " <span class=\"comment\">" . wfMsgHtml( 'rev-deleted-comment' ) . "</span>";
} else if( $rev->userCan( Revision::DELETED_COMMENT ) ) {
- $block = $this->commentBlock( $rev->getRawComment(), $rev->getTitle(), $local );
+ $block = $this->commentBlock( $rev->getComment( Revision::FOR_THIS_USER ),
+ $rev->getTitle(), $local );
} else {
$block = " <span class=\"comment\">" . wfMsgHtml( 'rev-deleted-comment' ) . "</span>";
}
if( !is_null( $tooltip ) ) {
$attribs['title'] = wfMsg( 'editsectionhint', $tooltip );
}
- $url = $this->link( $nt, wfMsg('editsection'),
+ $link = $this->link( $nt, wfMsg('editsection'),
$attribs,
array( 'action' => 'edit', 'section' => $section ),
array( 'noclasses', 'known' )
$attribs = " title=\"$attribs\"";
}
$result = null;
- wfRunHooks( 'EditSectionLink', array( &$this, $nt, $section, $attribs, $url, &$result ) );
+ wfRunHooks( 'EditSectionLink', array( &$this, $nt, $section, $attribs, $link, &$result ) );
if( !is_null( $result ) ) {
# For reverse compatibility, add the brackets *after* the hook is
# run, and even add them to hook-provided text. (This is the main
# reason that the EditSectionLink hook is deprecated in favor of
# DoEditSectionLink: it can't change the brackets or the span.)
- $result = wfMsgHtml( 'editsection-brackets', $url );
+ $result = wfMsgHtml( 'editsection-brackets', $result );
return "<span class=\"editsection\">$result</span>";
}
# Add the brackets and the span, and *then* run the nice new hook, with
# clean and non-redundant arguments.
- $result = wfMsgHtml( 'editsection-brackets', $url );
+ $result = wfMsgHtml( 'editsection-brackets', $link );
$result = "<span class=\"editsection\">$result</span>";
wfRunHooks( 'DoEditSectionLink', array( $this, $nt, $section, $tooltip, &$result ) );