* @param $text String: FIXME
* @param $class String: CSS class of the link, default ''.
*/
- function getInternalLinkAttributesObj( &$nt, $text, $class='' ) {
+ function getInternalLinkAttributesObj( &$nt, $text, $class = '', $titleAttr = false ) {
$r = ($class != '') ? ' class="' . htmlspecialchars( $class ) . '"' : '';
- $r .= ' title="' . $nt->getEscapedText() . '"';
+ if ( $titleAttr === false ) {
+ $r .= ' title="' . $nt->getEscapedText() . '"';
+ } else {
+ $r .= ' title="' . htmlspecialchars( $titleAttr ) . '"';
+ }
return $r;
}
* Return the CSS colour of a known link
*
* @param mixed $s
- * @param integer $id
- * @param integer $threshold
+ * @param integer $threshold user defined threshold
+ * @return string CSS class
*/
function getLinkColour( $s, $threshold ) {
- if( $threshold > 0 && $s!=false ) {
- $colour = ( $s->page_len >= $threshold ||
- $s->page_is_redirect ||
- !Namespace::isContent( $s->page_namespace )
- ? '' : 'stub' );
+ if( $s === false ) {
+ return '';
}
- else {
- $colour = '';
+
+ $colour = '';
+ if ( !empty( $s->page_is_redirect ) ) {
+ # Page is a redirect
+ $colour = 'mw-redirect';
+ } elseif ( $threshold > 0 && $s->page_len < $threshold && Namespace::isContent( $s->page_namespace ) ) {
+ # Page is a stub
+ $colour = 'stub';
}
return $colour;
}
} else {
wfProfileIn( __METHOD__.'-immediate' );
- # Handles links to special pages wich do not exist in the database:
+ # Handles links to special pages which do not exist in the database:
if( $nt->getNamespace() == NS_SPECIAL ) {
- if( SpecialPage::exists( $nt->getDbKey() ) ) {
+ if( SpecialPage::exists( $nt->getDBkey() ) ) {
$retVal = $this->makeKnownLinkObj( $nt, $text, $query, $trail, $prefix );
} else {
$retVal = $this->makeBrokenLinkObj( $nt, $text, $query, $trail, $prefix );
} else {
$colour = '';
if ( $nt->isContentPage() ) {
+ # FIXME: This is stupid, we should combine this query with
+ # the Title::getArticleID() query above.
$threshold = $wgUser->getOption('stubthreshold');
- if ( $threshold > 0 ) {
- $dbr = wfGetDB( DB_SLAVE );
- $s = $dbr->selectRow(
- array( 'page' ),
- array( 'page_len', 'page_is_redirect', 'page_namespace' ),
- array( 'page_id' => $aid ), __METHOD__ ) ;
- $colour = $this->getLinkColour( $s, $threshold );
- }
+ $dbr = wfGetDB( DB_SLAVE );
+ $s = $dbr->selectRow(
+ array( 'page' ),
+ array( 'page_len', 'page_is_redirect', 'page_namespace' ),
+ array( 'page_id' => $aid ), __METHOD__ ) ;
+ $colour = $this->getLinkColour( $s, $threshold );
}
$retVal = $this->makeColouredLinkObj( $nt, $colour, $text, $query, $trail, $prefix );
}
/**
* Make a red link to the edit page of a given title.
*
- * @param $title String: The text of the title
+ * @param $nt Title object of the target page
* @param $text String: Link text
* @param $query String: Optional query part
* @param $trail String: Optional trail. Alphabetic characters at the start of this string will
if( $nt->getNamespace() == NS_SPECIAL ) {
$q = $query;
} else if ( '' == $query ) {
- $q = 'action=edit';
+ $q = 'action=edit&redlink=1';
} else {
- $q = 'action=edit&'.$query;
+ $q = 'action=edit&redlink=1&'.$query;
}
$u = $nt->escapeLocalURL( $q );
+ $titleText = $nt->getPrefixedText();
if ( '' == $text ) {
- $text = htmlspecialchars( $nt->getPrefixedText() );
+ $text = htmlspecialchars( $titleText );
}
- $style = $this->getInternalLinkAttributesObj( $nt, $text, 'new' );
-
+ $titleAttr = wfMsg( 'red-link-title', $titleText );
+ $style = $this->getInternalLinkAttributesObj( $nt, $text, 'new', $titleAttr );
list( $inside, $trail ) = Linker::splitTrail( $trail );
+
+ wfRunHooks( 'BrokenLink', array( &$this, $nt, $query, &$u, &$style, &$prefix, &$text, &$inside, &$trail ) );
$s = "<a href=\"{$u}\"{$style}>{$prefix}{$text}{$inside}</a>{$trail}";
wfProfileOut( __METHOD__ );
*
* Make a brown link to a short article.
*
- * @param $title String: the text of the title
+ * @param $nt Title object of the target page
* @param $text String: link text
* @param $query String: optional query part
* @param $trail String: optional trail. Alphabetic characters at the start of this string will
/**
* Make a coloured link.
*
- * @param $title String: the text of the title
+ * @param $nt Title object of the target page
* @param $colour Integer: colour of the link
* @param $text String: link text
* @param $query String: optional query part
* @param boolean $thumb shows image as thumbnail in a frame
* @param string $manualthumb image name for the manual thumbnail
* @param string $valign vertical alignment: baseline, sub, super, top, text-top, middle, bottom, text-bottom
+ * @param string $time, timestamp of the file, set as false for current
* @return string
*/
function makeImageLinkObj( $title, $label, $alt, $align = '', $handlerParams = array(), $framed = false,
$frameParams['valign'] = $valign;
}
$file = wfFindFile( $title, $time );
- return $this->makeImageLink2( $title, $file, $frameParams, $handlerParams );
+ return $this->makeImageLink2( $title, $file, $frameParams, $handlerParams, $time );
}
/**
- * Make an image link
+ * Given parameters derived from [[Image:Foo|options...]], generate the
+ * HTML that that syntax inserts in the page.
+ *
* @param Title $title Title object
* @param File $file File object, or false if it doesn't exist
*
- * @param array $frameParams Associative array of parameters external to the media handler.
- * Boolean parameters are indicated by presence or absence, the value is arbitrary and
- * will often be false.
- * thumbnail If present, downscale and frame
- * manualthumb Image name to use as a thumbnail, instead of automatic scaling
- * framed Shows image in original size in a frame
- * frameless Downscale but don't frame
- * upright If present, tweak default sizes for portrait orientation
- * upright_factor Fudge factor for "upright" tweak (default 0.75)
- * border If present, show a border around the image
- * align Horizontal alignment (left, right, center, none)
- * valign Vertical alignment (baseline, sub, super, top, text-top, middle,
- * bottom, text-bottom)
- * alt Alternate text for image (i.e. alt attribute). Plain text.
- * caption HTML for image caption.
+ * @param array $frameParams Associative array of parameters external to the media handler.
+ * Boolean parameters are indicated by presence or absence, the value is arbitrary and
+ * will often be false.
+ * thumbnail If present, downscale and frame
+ * manualthumb Image name to use as a thumbnail, instead of automatic scaling
+ * framed Shows image in original size in a frame
+ * frameless Downscale but don't frame
+ * upright If present, tweak default sizes for portrait orientation
+ * upright_factor Fudge factor for "upright" tweak (default 0.75)
+ * border If present, show a border around the image
+ * align Horizontal alignment (left, right, center, none)
+ * valign Vertical alignment (baseline, sub, super, top, text-top, middle,
+ * bottom, text-bottom)
+ * alt Alternate text for image (i.e. alt attribute). Plain text.
+ * caption HTML for image caption.
*
- * @param array $handlerParams Associative array of media handler parameters, to be passed
- * to transform(). Typical keys are "width" and "page".
+ * @param array $handlerParams Associative array of media handler parameters, to be passed
+ * to transform(). Typical keys are "width" and "page".
+ * @param string $time, timestamp of the file, set as false for current
+ * @return string HTML for an image, with links, wrappers, etc.
*/
- function makeImageLink2( Title $title, $file, $frameParams = array(), $handlerParams = array() ) {
+ function makeImageLink2( Title $title, $file, $frameParams = array(), $handlerParams = array(), $time = false ) {
+ $res = null;
+ if( !wfRunHooks( 'ImageBeforeProduceHTML', array( &$this, &$title,
+ &$file, &$frameParams, &$handlerParams, &$time, &$res ) ) ) {
+ return $res;
+ }
+
global $wgContLang, $wgUser, $wgThumbLimits, $wgThumbUpright;
if ( $file && !$file->allowInlineDisplay() ) {
wfDebug( __METHOD__.': '.$title->getPrefixedDBkey()." does not allow inline display\n" );
if ( $fp['align'] == '' ) {
$fp['align'] = $wgContLang->isRTL() ? 'left' : 'right';
}
- return $prefix.$this->makeThumbLink2( $title, $file, $fp, $hp ).$postfix;
+ return $prefix.$this->makeThumbLink2( $title, $file, $fp, $hp, $time ).$postfix;
}
if ( $file && isset( $fp['frameless'] ) ) {
}
if ( !$thumb ) {
- $s = $this->makeBrokenImageLinkObj( $title );
+ $s = $this->makeBrokenImageLinkObj( $title, '', '', '', '', $time==true );
} else {
$s = $thumb->toHtml( array(
'desc-link' => true,
return $this->makeThumbLink2( $title, $file, $frameParams, $params );
}
- function makeThumbLink2( Title $title, $file, $frameParams = array(), $handlerParams = array() ) {
+ function makeThumbLink2( Title $title, $file, $frameParams = array(), $handlerParams = array(), $time = false ) {
global $wgStylePath, $wgContLang;
$exists = $file && $file->exists();
$url = $title->getLocalURL( $query );
$more = htmlspecialchars( wfMsg( 'thumbnail-more' ) );
- $magnifyalign = $wgContLang->isRTL() ? 'left' : 'right';
- $textalign = $wgContLang->isRTL() ? ' style="text-align:right"' : '';
$s = "<div class=\"thumb t{$fp['align']}\"><div class=\"thumbinner\" style=\"width:{$outerWidth}px;\">";
if( !$exists ) {
- $s .= $this->makeBrokenImageLinkObj( $title );
+ $s .= $this->makeBrokenImageLinkObj( $title, '', '', '', '', $time==true );
$zoomicon = '';
} elseif ( !$thumb ) {
$s .= htmlspecialchars( wfMsg( 'thumbnail_error', '' ) );
if ( isset( $fp['framed'] ) ) {
$zoomicon="";
} else {
- $zoomicon = '<div class="magnify" style="float:'.$magnifyalign.'">'.
+ $zoomicon = '<div class="magnify">'.
'<a href="'.$url.'" class="internal" title="'.$more.'">'.
'<img src="'.$wgStylePath.'/common/images/magnify-clip.png" ' .
'width="15" height="11" alt="" /></a></div>';
}
}
- $s .= ' <div class="thumbcaption"'.$textalign.'>'.$zoomicon.$fp['caption']."</div></div></div>";
+ $s .= ' <div class="thumbcaption">'.$zoomicon.$fp['caption']."</div></div></div>";
return str_replace("\n", ' ', $s);
}
* @param string $query Query string
* @param string $trail Link trail
* @param string $prefix Link prefix
+ * @param bool $time, a file of a certain timestamp was requested
* @return string
*/
- public function makeBrokenImageLinkObj( $title, $text = '', $query = '', $trail = '', $prefix = '' ) {
+ public function makeBrokenImageLinkObj( $title, $text = '', $query = '', $trail = '', $prefix = '', $time = false ) {
global $wgEnableUploads;
if( $title instanceof Title ) {
wfProfileIn( __METHOD__ );
- if( $wgEnableUploads ) {
+ $currentExists = $time ? ( wfFindFile( $title ) != false ) : false;
+ if( $wgEnableUploads && !$currentExists ) {
$upload = SpecialPage::getTitleFor( 'Upload' );
if( $text == '' )
$text = htmlspecialchars( $title->getPrefixedText() );
+ $redir = RepoGroup::singleton()->getLocalRepo()->checkRedirect( $title );
+ if( $redir ) {
+ return $this->makeKnownLinkObj( $title, $text, $query, $trail, $prefix );
+ }
$q = 'wpDestFile=' . $title->getPartialUrl();
if( $query != '' )
$q .= '&' . $query;
$class = 'internal';
} else {
$upload = SpecialPage::getTitleFor( 'Upload' );
- $url = $upload->getLocalUrl( 'wpDestFile=' . urlencode( $title->getDbKey() ) );
+ $url = $upload->getLocalUrl( 'wpDestFile=' . urlencode( $title->getDBkey() ) );
$class = 'new';
}
$alt = htmlspecialchars( $title->getText() );
/**
* Generate a user link if the current user is allowed to view it
* @param $rev Revision object.
+ * @param $isPublic, bool, show only if all users can see it
* @return string HTML
*/
- function revUserLink( $rev ) {
- if( $rev->userCan( Revision::DELETED_USER ) ) {
+ function revUserLink( $rev, $isPublic = false ) {
+ 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() );
} else {
$link = wfMsgHtml( 'rev-deleted-user' );
/**
* Generate a user tool link cluster if the current user is allowed to view it
* @param $rev Revision object.
+ * @param $isPublic, bool, show only if all users can see it
* @return string HTML
*/
- function revUserTools( $rev ) {
- if( $rev->userCan( Revision::DELETED_USER ) ) {
+ function revUserTools( $rev, $isPublic = false ) {
+ 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() );
+ ' ' . $this->userToolLinks( $rev->getRawUser(), $rev->getRawUserText() );
} else {
$link = wfMsgHtml( 'rev-deleted-user' );
}
if( $rev->isDeleted( Revision::DELETED_USER ) ) {
- return '<span class="history-deleted">' . $link . '</span>';
+ return ' <span class="history-deleted">' . $link . '</span>';
}
return $link;
}
* add a separator where needed and format the comment itself with CSS
* Called by Linker::formatComment.
*
- * @param $comment Comment text
- * @param $title An optional title object used to links to sections
+ * @param string $comment Comment text
+ * @param object $title An optional title object used to links to sections
+ * @return string $comment formatted comment
*
* @todo Document the $local parameter.
*/
$sectionTitle = wfClone( $title );
$sectionTitle->mFragment = $section;
}
- $link = $this->makeKnownLinkObj( $sectionTitle, wfMsg( 'sectionlink' ) );
+ $link = $this->makeKnownLinkObj( $sectionTitle, wfMsgForContent( 'sectionlink' ) );
}
- $sep='-';
- $auto=$link.$auto;
- if($pre) { $auto = $sep.' '.$auto; }
- if($post) { $auto .= ' '.$sep; }
- $auto='<span class="autocomment">'.$auto.'</span>';
- $comment=$pre.$auto.$post;
+ $auto = $link . $auto;
+ if( $pre ) {
+ $auto = '- ' . $auto; # written summary $presep autocomment (summary /* section */)
+ }
+ if( $post ) {
+ $auto .= ': '; # autocomment $postsep written summary (/* section */ summary)
+ }
+ $auto = '<span class="autocomment">' . $auto . '</span>';
+ $comment = $pre . $auto . $post;
}
return $comment;
*
* @param Revision $rev
* @param bool $local Whether section links should refer to local page
+ * @param $isPublic, show only if all users can see it
* @return string HTML
*/
- function revComment( Revision $rev, $local = false ) {
- if( $rev->userCan( Revision::DELETED_COMMENT ) ) {
+ function revComment( Revision $rev, $local = false, $isPublic = false ) {
+ 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 );
} else {
- $block = " <span class=\"comment\">" .
- wfMsgHtml( 'rev-deleted-comment' ) . "</span>";
+ $block = " <span class=\"comment\">" . wfMsgHtml( 'rev-deleted-comment' ) . "</span>";
}
if( $rev->isDeleted( Revision::DELETED_COMMENT ) ) {
return " <span class=\"history-deleted\">$block</span>";
wfProfileOut( __METHOD__ );
return $outText;
}
-
+
+ /**
+ * Returns HTML for the "hidden categories on this page" list.
+ *
+ * @param array $hiddencats Array of hidden categories from Article::getHiddenCategories
+ * or similar
+ * @return string HTML output
+ */
+ public function formatHiddenCategories( $hiddencats) {
+ global $wgUser, $wgLang;
+ wfProfileIn( __METHOD__ );
+
+ $sk = $wgUser->getSkin();
+
+ $outText = '';
+ if ( count( $hiddencats ) > 0 ) {
+ # Construct the HTML
+ $outText = '<div class="mw-hiddenCategoriesExplanation">';
+ $outText .= wfMsgExt( 'hiddencategories', array( 'parse' ), $wgLang->formatnum( count( $hiddencats ) ) );
+ $outText .= '</div><ul>';
+
+ foreach ( $hiddencats as $titleObj ) {
+ $outText .= '<li>' . $sk->makeKnownLinkObj( $titleObj ) . '</li>'; # If it's hidden, it must exist - no need to check with a LinkBatch
+ }
+ $outText .= '</ul>';
+ }
+ wfProfileOut( __METHOD__ );
+ return $outText;
+ }
+
/**
* Format a size in bytes for output, using an appropriate
* unit (B, KB, MB or GB) according to the magnitude in question