function Linker() {}
/**
- * OBSOLETE
+ * @deprecated
*/
function postParseLinkColour( $s = NULL ) {
return NULL;
return $s;
}
+ /**
+ * Generate either a normal exists-style link or a stub link, depending
+ * on the given page size.
+ *
+ * @param int $size
+ * @param Title $nt
+ * @param string $text
+ * @param string $query
+ * @param string $trail
+ * @param string $prefix
+ * @return string HTML of link
+ */
+ function makeSizeLinkObj( $size, $nt, $text = '', $query = '', $trail = '', $prefix = '' ) {
+ global $wgUser;
+ $threshold = IntVal( $wgUser->getOption( 'stubthreshold' ) );
+ if( $size < $threshold ) {
+ return $this->makeStubLinkObj( $nt, $text, $query, $trail, $prefix );
+ } else {
+ return $this->makeKnownLinkObj( $nt, $text, $query, $trail, $prefix );
+ }
+ }
+
/** @todo document */
function makeSelfLinkObj( $nt, $text = '', $query = '', $trail = '', $prefix = '' ) {
$u = $nt->escapeLocalURL( $query );
$url = $img->getViewURL();
$prefix = $postfix = '';
+ wfDebug( "makeImageLinkObj: '$width'x'$height'\n" );
+
if ( 'center' == $align )
{
$prefix = '<div class="center">';
if ( $height !== false && ( $img->getHeight() * $width / $img->getWidth() > $height ) ) {
$width = $img->getWidth() * $height / $img->getHeight();
}
- if ( '' == $manual_thumb ) {
- $url = $img->createThumb( $width );
+ if ( $manual_thumb == '') {
+ $thumb = $img->getThumbnail( $width );
+ if ( $thumb ) {
+ if( $width > $thumb->width ) {
+ // Requested a display size larger than the actual image;
+ // fake it up!
+ $height = floor($thumb->height * $width / $thumb->width);
+ wfDebug( "makeImageLinkObj: client-size height set to '$height'\n" );
+ } else {
+ $height = $thumb->height;
+ wfDebug( "makeImageLinkObj: thumb height set to '$height'\n" );
+ }
+ $url = $thumb->getUrl();
+ }
}
+ } else {
+ $width = $img->width;
+ $height = $img->height;
}
+ wfDebug( "makeImageLinkObj2: '$width'x'$height'\n" );
$u = $nt->escapeLocalURL();
if ( $url == '' ) {
$s = $this->makeBrokenImageLinkObj( $img->getTitle() );
//$s .= "<br />{$alt}<br />{$url}<br />\n";
} else {
$s = '<a href="'.$u.'" class="image" title="'.$alt.'">' .
- '<img src="'.$url.'" alt="'.$alt.'" longdesc="'.$u.'" /></a>';
+ '<img src="'.$url.'" alt="'.$alt.'" ' .
+ ( $width
+ ? ( 'width="'.$width.'" height="'.$height.'" ' )
+ : '' ) .
+ 'longdesc="'.$u.'" /></a>';
}
if ( '' != $align ) {
$s = "<div class=\"float{$align}\"><span>{$s}</span></div>";
$boxheight = $height;
$thumbUrl = $url;
} else {
- $h = intval( $height/($width/$boxwidth) );
+ $h = round( $height/($width/$boxwidth) );
$oboxwidth = $boxwidth + 2;
if ( ( ! $boxheight === false ) && ( $h > $boxheight ) )
{
} else {
$name = $title->getDBKey();
$img = new Image( $title );
- $url = $img->getURL();
- if( $nourl ) {
- $url = str_replace( "http://", "http-noparse://", $url );
+ if( $img->exists() ) {
+ $url = $img->getURL();
+ if( $nourl ) {
+ $url = str_replace( "http://", "http-noparse://", $url );
+ }
+ $class = 'internal';
+ } else {
+ $upload = Title::makeTitle( NS_SPECIAL, 'Upload' );
+ $url = $upload->getLocalUrl( 'wpDestFile=' . urlencode( $img->getName() ) );
+ $class = 'new';
}
$alt = htmlspecialchars( $title->getText() );
if( $text == '' ) {
$text = $alt;
}
$u = htmlspecialchars( $url );
- return "<a href=\"{$u}\" class='internal' title=\"{$alt}\">{$text}</a>";
+ return "<a href=\"{$u}\" class='$class' title=\"{$alt}\">{$text}</a>";
}
}
/** @todo document */
function editSectionLink( $nt, $section ) {
- global $wgRequest;
global $wgContLang;
- if( $wgRequest->getInt( 'oldid' ) && ( $wgRequest->getVal( 'diff' ) != '0' ) ) {
- # Section edit links would be out of sync on an old page.
- # But, if we're diffing to the current page, they'll be
- # correct.
- return '';
- }
-
$editurl = '§ion='.$section;
$url = $this->makeKnownLink($nt->getPrefixedText(),wfMsg('editsection'),'action=edit'.$editurl);