function getInterwikiLinkAttributes( $link, $text, $class='' ) {
global $wgContLang;
- $same = ($link == $text);
$link = urldecode( $link );
$link = $wgContLang->checkTitleEncoding( $link );
$link = preg_replace( '/[\\x00-\\x1f]/', ' ', $link );
return "<!-- ERROR -->{$prefix}{$text}{$trail}";
}
- $ns = $nt->getNamespace();
- $dbkey = $nt->getDBkey();
if ( $nt->isExternal() ) {
$u = $nt->getFullURL();
$link = $nt->getPrefixedURL();
$inside = '';
if ( '' != $trail ) {
+ $m = array();
if ( preg_match( '/^([a-z]+)(.*)$$/sD', $trail, $m ) ) {
$inside = $m[1];
$trail = $m[2];
* the end of the link.
*/
function makeStubLinkObj( $nt, $text = '', $query = '', $trail = '', $prefix = '' ) {
- $link = $nt->getPrefixedURL();
-
$u = $nt->escapeLocalURL( $query );
if ( '' == $text ) {
### HOTFIX. Instead of breaking, return empty string.
return $text;
} else {
- $name = $title->getDBKey();
$img = new Image( $title );
if( $img->exists() ) {
$url = $img->getURL();
function userLink( $userId, $userText ) {
$encName = htmlspecialchars( $userText );
if( $userId == 0 ) {
- $contribsPage = SpecialPage::getTitleFor( 'Contributions' );
+ $contribsPage = SpecialPage::getTitleFor( 'Contributions', $userText );
return $this->makeKnownLinkObj( $contribsPage,
- $encName, 'target=' . urlencode( $userText ) );
+ $encName);
} else {
$userPage = Title::makeTitle( NS_USER, $userText );
return $this->makeLinkObj( $userPage, $encName );
$items[] = $this->userTalkLink( $userId, $userText );
}
if( $userId ) {
- $contribsPage = SpecialPage::getTitleFor( 'Contributions' );
- $items[] = $this->makeKnownLinkObj( $contribsPage,
- wfMsgHtml( 'contribslink' ), 'target=' . urlencode( $userText ) );
+ $contribsPage = SpecialPage::getTitleFor( 'Contributions', $userText );
+ $items[] = $this->makeKnownLinkObj( $contribsPage ,
+ wfMsgHtml( 'contribslink' ) );
}
if( $blockable && $wgUser->isAllowed( 'block' ) ) {
$items[] = $this->blockLink( $userId, $userText );
* @private
*/
function blockLink( $userId, $userText ) {
- $blockPage = SpecialPage::getTitleFor( 'Blockip' );
+ $blockPage = SpecialPage::getTitleFor( 'Blockip', $userText );
$blockLink = $this->makeKnownLinkObj( $blockPage,
- wfMsgHtml( 'blocklink' ), 'ip=' . urlencode( $userText ) );
+ wfMsgHtml( 'blocklink' ) );
return $blockLink;
}
* temporarily to a value pass. Should be adjusted further. --brion
*
* $param string $comment
- * @param Title $title (to generate link to the section in autocomment)
+ * @param mixed $title Title object (to generate link to the section in autocomment) or null
* @param bool $local Whether section links should refer to local page
*/
- function formatComment($comment, Title $title = NULL, $local = false) {
+ function formatComment($comment, $title = NULL, $local = false) {
wfProfileIn( __METHOD__ );
global $wgContLang;
# some nasty regex.
# We look for all comments, match any text before and after the comment,
# add a separator where needed and format the comment itself with CSS
+ $match = array();
while (preg_match('/(.*)\/\*\s*(.*?)\s*\*\/(.*)/', $comment,$match)) {
$pre=$match[1];
$auto=$match[2];
# format regular and media links - all other wiki formatting
# is ignored
- $medians = $wgContLang->getNsText( NS_MEDIA ) . ':';
+ $medians = '(?:' . preg_quote( Namespace::getCanonicalName( NS_MEDIA ), '/' ) . '|';
+ $medians .= preg_quote( $wgContLang->getNsText( NS_MEDIA ), '/' ) . '):';
while(preg_match('/\[\[(.*?)(\|(.*?))*\]\](.*)$/',$comment,$match)) {
# Handle link renaming [[foo|text]] will show link as "text"
if( "" != $match[3] ) {
} else {
$text = $match[1];
}
+ $submatch = array();
if( preg_match( '/^' . $medians . '(.*)$/i', $match[1], $submatch ) ) {
# Media link; trail not supported.
$linkRegexp = '/\[\[(.*?)\]\]/';
$match[1] = substr($match[1], 1);
$thelink = $this->makeLink( $match[1], $text, "", $trail );
}
- $comment = preg_replace( $linkRegexp, wfRegexReplacement( $thelink ), $comment, 1 );
+ $comment = preg_replace( $linkRegexp, StringUtils::escapeRegexReplacement( $thelink ), $comment, 1 );
}
wfProfileOut( __METHOD__ );
return $comment;
* it's non-empty, otherwise return empty string.
*
* @param string $comment
- * @param Title $title
+ * @param mixed $title Title object (to generate link to section in autocomment) or null
* @param bool $local Whether section links should refer to local page
*
* @return string
*/
- function commentBlock( $comment, Title $title = NULL, $local = false ) {
+ function commentBlock( $comment, $title = NULL, $local = false ) {
// '*' used to be the comment inserted by the software way back
// in antiquity in case none was provided, here for backwards
// compatability, acc. to brion -ævar
}
$inside = '';
if ( '' != $trail ) {
+ $m = array();
if ( preg_match( $regex, $trail, $m ) ) {
$inside = $m[1];
$trail = $m[2];