function getExternalLinkAttributes( $link, $text, $class='' ) {
$link = htmlspecialchars( $link );
- $r = ($class != '') ? " class='$class'" : " class='external'";
+ $r = ($class != '') ? " class=\"$class\"" : " class=\"external\"";
$r .= " title=\"{$link}\"";
return $r;
$link = preg_replace( '/[\\x00-\\x1f]/', ' ', $link );
$link = htmlspecialchars( $link );
- $r = ($class != '') ? " class='$class'" : " class='external'";
+ $r = ($class != '') ? " class=\"$class\"" : " class=\"external\"";
$r .= " title=\"{$link}\"";
return $r;
# Fail gracefully
if ( ! is_object($nt) ) {
- # wfDebugDieBacktrace();
+ # throw new MWException();
wfProfileOut( $fname );
return "<!-- ERROR -->{$prefix}{$text}{$trail}";
}
function makeBrokenLinkObj( $nt, $text = '', $query = '', $trail = '', $prefix = '' ) {
# Fail gracefully
if ( ! isset($nt) ) {
- # wfDebugDieBacktrace();
+ # throw new MWException();
return "<!-- ERROR -->{$prefix}{$text}{$trail}";
}
/** @todo document */
function makeImageLinkObj( $nt, $label, $alt, $align = '', $width = false, $height = false, $framed = false,
- $thumb = false, $manual_thumb = '' )
+ $thumb = false, $manual_thumb = '', $page = null )
{
- global $wgContLang, $wgUser, $wgThumbLimits;
+ global $wgContLang, $wgUser, $wgThumbLimits, $wgGenerateThumbnailOnParse;
$img = new Image( $nt );
+
+ if ( ! is_null( $page ) ) {
+ $img->selectPage( $page );
+ }
+
if ( !$img->allowInlineDisplay() && $img->exists() ) {
return $this->makeKnownLinkObj( $nt );
}
$url = $img->getViewURL();
$error = $prefix = $postfix = '';
- wfDebug( "makeImageLinkObj: '$width'x'$height'\n" );
+ wfDebug( "makeImageLinkObj: '$width'x'$height', \"$label\"\n" );
if ( 'center' == $align )
{
if ( $height == false )
$height = -1;
if ( $manual_thumb == '') {
- $thumb = $img->getThumbnail( $width, $height );
+ $thumb = $img->getThumbnail( $width, $height, $wgGenerateThumbnailOnParse );
if ( $thumb ) {
// In most cases, $width = $thumb->width or $height = $thumb->height.
// If not, we're scaling the image larger than it can be scaled,
* $img is an Image object
*/
function makeThumbLinkObj( $img, $label = '', $alt, $align = 'right', $boxwidth = 180, $boxheight=false, $framed=false , $manual_thumb = "" ) {
- global $wgStylePath, $wgContLang;
- $url = $img->getViewURL();
+ global $wgStylePath, $wgContLang, $wgGenerateThumbnailOnParse;
$thumbUrl = '';
$error = '';
// Use image dimensions, don't scale
$boxwidth = $width;
$boxheight = $height;
- $thumbUrl = $url;
+ $thumbUrl = $img->getViewURL();
} else {
if ( $boxheight === false )
$boxheight = -1;
if ( '' == $manual_thumb ) {
- $thumb = $img->getThumbnail( $boxwidth, $boxheight );
+ $thumb = $img->getThumbnail( $boxwidth, $boxheight, $wgGenerateThumbnailOnParse );
if ( $thumb ) {
$thumbUrl = $thumb->getUrl();
$boxwidth = $thumb->width;
$s = "<div class=\"thumb t{$align}\"><div style=\"width:{$oboxwidth}px;\">";
if( $thumbUrl == '' ) {
// Couldn't generate thumbnail? Scale the image client-side.
- $thumbUrl = $url;
+ $thumbUrl = $img->getViewURL();
}
if ( $error ) {
$s .= htmlspecialchars( $error );
'width="15" height="11" alt="'.$more.'" /></a></div>';
}
}
- $s .= ' <div class="thumbcaption" '.$textalign.'>'.$zoomicon.$label."</div></div></div>";
+ $s .= ' <div class="thumbcaption"'.$textalign.'>'.$zoomicon.$label."</div></div></div>";
return str_replace("\n", ' ', $s);
}
function makeBrokenImageLinkObj( $nt, $text = '', $query = '', $trail = '', $prefix = '' ) {
# Fail gracefully
if ( ! isset($nt) ) {
- # wfDebugDieBacktrace();
+ # throw new MWException();
return "<!-- ERROR -->{$prefix}{$text}{$trail}";
}
$text = $alt;
}
$u = htmlspecialchars( $url );
- return "<a href=\"{$u}\" class='$class' title=\"{$alt}\">{$text}</a>";
+ return "<a href=\"{$u}\" class=\"$class\" title=\"{$alt}\">{$text}</a>";
}
}
* @return string HTML
*/
function revUserLink( $rev ) {
- if( $rev->userCan( Revision::MW_REV_DELETED_USER ) ) {
+ if( $rev->userCan( Revision::DELETED_USER ) ) {
$link = $this->userLink( $rev->getRawUser(), $rev->getRawUserText() );
} else {
$link = wfMsgHtml( 'rev-deleted-user' );
}
- if( $rev->isDeleted( Revision::MW_REV_DELETED_USER ) ) {
+ if( $rev->isDeleted( Revision::DELETED_USER ) ) {
return '<span class="history-deleted">' . $link . '</span>';
}
return $link;
* @return string HTML
*/
function revUserTools( $rev ) {
- if( $rev->userCan( Revision::MW_REV_DELETED_USER ) ) {
+ if( $rev->userCan( Revision::DELETED_USER ) ) {
$link = $this->userLink( $rev->getRawUser(), $rev->getRawUserText() ) .
' ' .
$this->userToolLinks( $rev->getRawUser(), $rev->getRawUserText() );
} else {
$link = wfMsgHtml( 'rev-deleted-user' );
}
- if( $rev->isDeleted( Revision::MW_REV_DELETED_USER ) ) {
+ if( $rev->isDeleted( Revision::DELETED_USER ) ) {
return '<span class="history-deleted">' . $link . '</span>';
}
return $link;
return '';
} else {
$formatted = $this->formatComment( $comment, $title );
- return " <span class='comment'>($formatted)</span>";
+ return " <span class=\"comment\">($formatted)</span>";
}
}
* @return string HTML
*/
function revComment( $rev ) {
- if( $rev->userCan( Revision::MW_REV_DELETED_COMMENT ) ) {
+ if( $rev->userCan( Revision::DELETED_COMMENT ) ) {
$block = $this->commentBlock( $rev->getRawComment(), $rev->getTitle() );
} else {
- $block = " <span class='comment'>" .
+ $block = " <span class=\"comment\">" .
wfMsgHtml( 'rev-deleted-comment' ) . "</span>";
}
- if( $rev->isDeleted( Revision::MW_REV_DELETED_COMMENT ) ) {
- return " <span class='history-deleted'>$block</span>";
+ if( $rev->isDeleted( Revision::DELETED_COMMENT ) ) {
+ return " <span class=\"history-deleted\">$block</span>";
}
return $block;
}
* parameter level defines if we are on an indentation level
*/
function tocLine( $anchor, $tocline, $tocnumber, $level ) {
- return "\n<li class='toclevel-$level'><a href=\"#" .
+ return "\n<li class=\"toclevel-$level\"><a href=\"#" .
$anchor . '"><span class="tocnumber">' .
$tocnumber . '</span> <span class="toctext">' .
$tocline . '</span></a>';
*
* @static
*/
- function splitTrail( $trail ) {
+ static function splitTrail( $trail ) {
static $regex = false;
if ( $regex === false ) {
global $wgContLang;