X-Git-Url: https://git.cyclocoop.org/%27.WWW_URL.%27admin/?a=blobdiff_plain;f=includes%2FLinker.php;h=6d264c37f1b5b58c8fd492bc6c7930627819bac0;hb=c23ccacba320473b6e1f333805f22c8681316429;hp=25f21e2f6594334cbae38eea05eec17eafcfa065;hpb=07c98fb98e7b38a6b15978beb0a9f0418ea20c6b;p=lhc%2Fweb%2Fwiklou.git
diff --git a/includes/Linker.php b/includes/Linker.php
index 25f21e2f65..6d264c37f1 100644
--- a/includes/Linker.php
+++ b/includes/Linker.php
@@ -12,6 +12,7 @@ class Linker {
* Flags for userToolLinks()
*/
const TOOL_LINKS_NOBLOCK = 1;
+ const TOOL_LINKS_EMAIL = 2;
/**
* Get the appropriate HTML attributes to add to the "a" element of an ex-
@@ -19,7 +20,7 @@ class Linker {
*
* @param $class String: the contents of the class attribute; if an empty
* string is passed, which is the default value, defaults to 'external'.
- * @deprecated Just pass the external class directly to something using Html::expandAttributes
+ * @deprecated since 1.18 Just pass the external class directly to something using Html::expandAttributes
*/
static function getExternalLinkAttributes( $class = 'external' ) {
wfDeprecated( __METHOD__ );
@@ -39,7 +40,7 @@ class Linker {
static function getInterwikiLinkAttributes( $title, $unused = null, $class = 'external' ) {
global $wgContLang;
- # FIXME: We have a whole bunch of handling here that doesn't happen in
+ # @todo FIXME: We have a whole bunch of handling here that doesn't happen in
# getExternalLinkAttributes, why?
$title = urldecode( $title );
$title = $wgContLang->checkTitleEncoding( $title );
@@ -82,6 +83,11 @@ class Linker {
/**
* Common code for getLinkAttributesX functions
+ *
+ * @param $title string
+ * @param $class string
+ *
+ * @return string
*/
private static function getLinkAttributesInternal( $title, $class ) {
$title = htmlspecialchars( $title );
@@ -103,7 +109,7 @@ class Linker {
* @param $threshold Integer: user defined threshold
* @return String: CSS class
*/
- static function getLinkColour( $t, $threshold ) {
+ public static function getLinkColour( $t, $threshold ) {
$colour = '';
if ( $t->isRedirect() ) {
# Page is a redirect
@@ -131,7 +137,7 @@ class Linker {
*
* @param $target Title Can currently only be a Title, but this may
* change to support Images, literal URLs, etc.
- * @param $text string The HTML contents of the element, i.e.,
+ * @param $html string The HTML contents of the element, i.e.,
* the link text. This is raw HTML and will not be escaped. If null,
* defaults to the prefixed text of the Title; or if the Title is just a
* fragment, the contents of the fragment.
@@ -143,7 +149,7 @@ class Linker {
* @param $query array The query string to append to the URL
* you're linking to, in key => value array form. Query keys and values
* will be URL-encoded.
- * @param $options mixed String or array of strings:
+ * @param $options string|array String or array of strings:
* 'known': Page is known to exist, so don't check if it does.
* 'broken': Page is known not to exist, so don't check if it does.
* 'noclasses': Don't add any classes automatically (includes "new",
@@ -155,19 +161,19 @@ class Linker {
* @return string HTML attribute
*/
public static function link(
- $target, $text = null, $customAttribs = array(), $query = array(), $options = array()
+ $target, $html = null, $customAttribs = array(), $query = array(), $options = array()
) {
wfProfileIn( __METHOD__ );
if ( !$target instanceof Title ) {
wfProfileOut( __METHOD__ );
- return "$text";
+ return "$html";
}
$options = (array)$options;
$dummy = new DummyLinker; // dummy linker instance for bc on the hooks
$ret = null;
- if ( !wfRunHooks( 'LinkBegin', array( $dummy, $target, &$text,
+ if ( !wfRunHooks( 'LinkBegin', array( $dummy, $target, &$html,
&$customAttribs, &$query, &$options, &$ret ) ) ) {
wfProfileOut( __METHOD__ );
return $ret;
@@ -201,15 +207,15 @@ class Linker {
$attribs = array_merge(
$attribs,
- self::linkAttribs( $target, $customAttribs, $options, $text )
+ self::linkAttribs( $target, $customAttribs, $options )
);
- if ( is_null( $text ) ) {
- $text = self::linkText( $target );
+ if ( is_null( $html ) ) {
+ $html = self::linkText( $target );
}
$ret = null;
- if ( wfRunHooks( 'LinkEnd', array( $dummy, $target, $options, &$text, &$attribs, &$ret ) ) ) {
- $ret = Html::rawElement( 'a', $attribs, $text );
+ if ( wfRunHooks( 'LinkEnd', array( $dummy, $target, $options, &$html, &$attribs, &$ret ) ) ) {
+ $ret = Html::rawElement( 'a', $attribs, $html );
}
wfProfileOut( __METHOD__ );
@@ -220,10 +226,10 @@ class Linker {
* Identical to link(), except $options defaults to 'known'.
*/
public static function linkKnown(
- $target, $text = null, $customAttribs = array(),
+ $target, $html = null, $customAttribs = array(),
$query = array(), $options = array( 'known', 'noclasses' ) )
{
- return self::link( $target, $text, $customAttribs, $query, $options );
+ return self::link( $target, $html, $customAttribs, $query, $options );
}
/**
@@ -257,8 +263,12 @@ class Linker {
* Returns the array of attributes used when linking to the Title $target
*
* @param $target Title
+ * @param $attribs
+ * @param $options
+ *
+ * @return array
*/
- private static function linkAttribs( $target, $attribs, $options, $linkText ) {
+ private static function linkAttribs( $target, $attribs, $options ) {
wfProfileIn( __METHOD__ );
global $wgUser;
$defaults = array();
@@ -289,16 +299,12 @@ class Linker {
}
# Get a default title attribute.
- global $wgLang;
- $known = in_array( 'known', $options );
if ( $target->getPrefixedText() == '' ) {
# A link like [[#Foo]]. This used to mean an empty title
# attribute, but that's silly. Just don't output a title.
- } elseif ( $known &&
- $wgLang->caseFold($linkText) !== $wgLang->caseFold($target->getPrefixedText() ) )
- {
+ } elseif ( in_array( 'known', $options ) ) {
$defaults['title'] = $target->getPrefixedText();
- } elseif ( !$known ) {
+ } else {
$defaults['title'] = wfMsg( 'red-link-title', $target->getPrefixedText() );
}
@@ -321,6 +327,8 @@ class Linker {
* Default text of the links to the Title $target
*
* @param $target Title
+ *
+ * @return string
*/
private static function linkText( $target ) {
# We might be passed a non-Title by make*LinkObj(). Fail gracefully.
@@ -355,7 +363,7 @@ class Linker {
$threshold = $wgUser->getStubThreshold();
$colour = ( $size < $threshold ) ? 'stub' : '';
- // FIXME: replace deprecated makeColouredLinkObj by link()
+ // @todo FIXME: Replace deprecated makeColouredLinkObj by link()
return self::makeColouredLinkObj( $nt, $colour, $text, $query, $trail, $prefix );
}
@@ -365,18 +373,24 @@ class Linker {
* despite $query not being used.
*
* @param $nt Title
+ *
+ * @return string
*/
- static function makeSelfLinkObj( $nt, $text = '', $query = '', $trail = '', $prefix = '' ) {
- if ( $text == '' ) {
- $text = htmlspecialchars( $nt->getPrefixedText() );
+ public static function makeSelfLinkObj( $nt, $html = '', $query = '', $trail = '', $prefix = '' ) {
+ if ( $html == '' ) {
+ $html = htmlspecialchars( $nt->getPrefixedText() );
}
list( $inside, $trail ) = self::splitTrail( $trail );
- return "{$prefix}{$text}{$inside}{$trail}";
+ return "{$prefix}{$html}{$inside}{$trail}";
}
+ /**
+ * @param $title Title
+ * @return Title
+ */
static function normaliseSpecialPage( Title $title ) {
if ( $title->getNamespace() == NS_SPECIAL ) {
- list( $name, $subpage ) = SpecialPage::resolveAliasWithSubpage( $title->getDBkey() );
+ list( $name, $subpage ) = SpecialPageFactory::resolveAlias( $title->getDBkey() );
if ( !$name ) {
return $title;
}
@@ -391,8 +405,12 @@ class Linker {
/**
* Returns the filename part of an url.
* Used as alternative text for external images.
+ *
+ * @param $url string
+ *
+ * @return string
*/
- static function fnamePart( $url ) {
+ private static function fnamePart( $url ) {
$basename = strrchr( $url, '/' );
if ( false === $basename ) {
$basename = $url;
@@ -405,8 +423,13 @@ class Linker {
/**
* Return the code for images which were added via external links,
* via Parser::maybeMakeExternalImage().
+ *
+ * @param $url
+ * @param $alt
+ *
+ * @return string
*/
- static function makeExternalImage( $url, $alt = '' ) {
+ public static function makeExternalImage( $url, $alt = '' ) {
if ( $alt == '' ) {
$alt = self::fnamePart( $url );
}
@@ -455,7 +478,7 @@ class Linker {
* @param $widthOption: Used by the parser to remember the user preference thumbnailsize
* @return String: HTML for an image, with links, wrappers, etc.
*/
- static function makeImageLink2( Title $title, $file, $frameParams = array(),
+ public static function makeImageLink2( Title $title, $file, $frameParams = array(),
$handlerParams = array(), $time = false, $query = "", $widthOption = null )
{
$res = null;
@@ -494,7 +517,14 @@ class Linker {
$fp['align'] = 'none';
}
if ( $file && !isset( $hp['width'] ) ) {
- $hp['width'] = $file->getWidth( $page );
+ if ( isset( $hp['height'] ) && $file->isVectorized() ) {
+ // If its a vector image, and user only specifies height
+ // we don't want it to be limited by its "normal" width.
+ global $wgSVGMaxSize;
+ $hp['width'] = $wgSVGMaxSize;
+ } else {
+ $hp['width'] = $file->getWidth( $page );
+ }
if ( isset( $fp['thumbnail'] ) || isset( $fp['framed'] ) || isset( $fp['frameless'] ) || !$hp['width'] ) {
global $wgThumbLimits, $wgThumbUpright;
@@ -575,7 +605,7 @@ class Linker {
* @param $frameParams The frame parameters
* @param $query An optional query string to add to description page links
*/
- static function getImageLinkMTOParams( $frameParams, $query = '' ) {
+ private static function getImageLinkMTOParams( $frameParams, $query = '' ) {
$mtoParams = array();
if ( isset( $frameParams['link-url'] ) && $frameParams['link-url'] !== '' ) {
$mtoParams['custom-url-link'] = $frameParams['link-url'];
@@ -604,7 +634,7 @@ class Linker {
* @param $framed Boolean
* @param $manualthumb String
*/
- static function makeThumbLinkObj( Title $title, $file, $label = '', $alt,
+ public static function makeThumbLinkObj( Title $title, $file, $label = '', $alt,
$align = 'right', $params = array(), $framed = false , $manualthumb = "" )
{
$frameParams = array(
@@ -630,10 +660,10 @@ class Linker {
* @param string $query
* @return mixed
*/
- static function makeThumbLink2( Title $title, $file, $frameParams = array(),
+ public static function makeThumbLink2( Title $title, $file, $frameParams = array(),
$handlerParams = array(), $time = false, $query = "" )
{
- global $wgStylePath;
+ global $wgStylePath, $wgContLang;
$exists = $file && $file->exists();
# Shortcuts
@@ -711,11 +741,16 @@ class Linker {
if ( isset( $fp['framed'] ) ) {
$zoomIcon = "";
} else {
- $zoomIcon = '";
}
/**
* Finish one or more sublevels on the Table of Contents
+ *
+ * @return string
*/
- static function tocUnindent( $level ) {
+ public static function tocUnindent( $level ) {
return "\n" . str_repeat( "
\n\n", $level > 0 ? $level : 0 );
}
/**
* parameter level defines if we are on an indentation level
+ *
+ * @return string
*/
- static function tocLine( $anchor, $tocline, $tocnumber, $level, $sectionIndex = false ) {
+ public static function tocLine( $anchor, $tocline, $tocnumber, $level, $sectionIndex = false ) {
$classes = "toclevel-$level";
- if ( $sectionIndex !== false )
+ if ( $sectionIndex !== false ) {
$classes .= " tocsection-$sectionIndex";
+ }
return "\n
'
@@ -1412,7 +1491,7 @@ class Linker {
foreach ( $tree as $section ) {
if ( $section['toclevel'] > $lastLevel )
$toc .= self::tocIndent();
- else if ( $section['toclevel'] < $lastLevel )
+ elseif ( $section['toclevel'] < $lastLevel )
$toc .= self::tocUnindent(
$lastLevel - $section['toclevel'] );
else
@@ -1435,17 +1514,17 @@ class Linker {
* a space and ending with '>'
* This *must* be at least '>' for no attribs
* @param $anchor String: the anchor to give the headline (the bit after the #)
- * @param $text String: the text of the header
+ * @param $html String: html for the text of the header
* @param $link String: HTML to add for the section edit link
* @param $legacyAnchor Mixed: a second, optional anchor to give for
* backward compatibility (false to omit)
*
* @return String: HTML headline
*/
- public static function makeHeadline( $level, $attribs, $anchor, $text, $link, $legacyAnchor = false ) {
+ public static function makeHeadline( $level, $attribs, $anchor, $html, $link, $legacyAnchor = false ) {
$ret = " ';
+ if ( $preview ) {
+ $outText .= wfMsgExt( 'distanttemplatesusedpreview', array( 'parse' ), count( $templates ) );
+ } elseif ( $section ) {
+ $outText .= wfMsgExt( 'distanttemplatesusedsection', array( 'parse' ), count( $templates ) );
+ } else {
+ $outText .= wfMsgExt( 'distanttemplatesused', array( 'parse' ), count( $templates ) );
+ }
+ $outText .= "
|