Add CASCADINGSOURCES parser function
[lhc/web/wiklou.git] / includes / Linker.php
index 895f0f2..27f8ab4 100644 (file)
@@ -264,8 +264,8 @@ class Linker {
         */
        public static function linkKnown(
                $target, $html = null, $customAttribs = array(),
-               $query = array(), $options = array( 'known', 'noclasses' ) )
-       {
+               $query = array(), $options = array( 'known', 'noclasses' )
+       {
                return self::link( $target, $html, $customAttribs, $query, $options );
        }
 
@@ -393,29 +393,6 @@ class Linker {
                return htmlspecialchars( $target->getPrefixedText() );
        }
 
-       /**
-        * Generate either a normal exists-style link or a stub link, depending
-        * on the given page size.
-        *
-        * @param $size Integer
-        * @param $nt Title object.
-        * @param $text String
-        * @param $query String
-        * @param $trail String
-        * @param $prefix String
-        * @return string HTML of link
-        * @deprecated since 1.17
-        */
-       static function makeSizeLinkObj( $size, $nt, $text = '', $query = '', $trail = '', $prefix = '' ) {
-               global $wgUser;
-               wfDeprecated( __METHOD__, '1.17' );
-
-               $threshold = $wgUser->getStubThreshold();
-               $colour = ( $size < $threshold ) ? 'stub' : '';
-               // @todo FIXME: Replace deprecated makeColouredLinkObj by link()
-               return self::makeColouredLinkObj( $nt, $colour, $text, $query, $trail, $prefix );
-       }
-
        /**
         * Make appropriate markup for a link to the current article. This is currently rendered
         * as the bold link text. The calling sequence is the same as the other make*LinkObj static functions,
@@ -562,8 +539,8 @@ class Linker {
         * @return String: HTML for an image, with links, wrappers, etc.
         */
        public static function makeImageLink( /*Parser*/ $parser, Title $title, $file, $frameParams = array(),
-               $handlerParams = array(), $time = false, $query = "", $widthOption = null )
-       {
+               $handlerParams = array(), $time = false, $query = "", $widthOption = null
+       {
                $res = null;
                $dummy = new DummyLinker;
                if ( !wfRunHooks( 'ImageBeforeProduceHTML', array( &$dummy, &$title,
@@ -681,8 +658,7 @@ class Linker {
                                'valign' => isset( $fp['valign'] ) ? $fp['valign'] : false,
                                'img-class' => $fp['class'] );
                        if ( isset( $fp['border'] ) ) {
-                               // TODO: BUG? Both values are identical
-                               $params['img-class'] .= ( $params['img-class'] !== '' ) ? ' thumbborder' : 'thumbborder';
+                               $params['img-class'] .= ( $params['img-class'] !== '' ? ' ' : '' ) . 'thumbborder';
                        }
                        $params = self::getImageLinkMTOParams( $fp, $query, $parser ) + $params;
 
@@ -750,8 +726,8 @@ class Linker {
         * @return mixed
         */
        public static function makeThumbLinkObj( Title $title, $file, $label = '', $alt,
-               $align = 'right', $params = array(), $framed = false, $manualthumb = "" )
-       {
+               $align = 'right', $params = array(), $framed = false, $manualthumb = ""
+       {
                $frameParams = array(
                        'alt' => $alt,
                        'caption' => $label,
@@ -776,8 +752,8 @@ class Linker {
         * @return mixed
         */
        public static function makeThumbLink2( Title $title, $file, $frameParams = array(),
-               $handlerParams = array(), $time = false, $query = "" )
-       {
+               $handlerParams = array(), $time = false, $query = ""
+       {
                global $wgStylePath, $wgContLang;
                $exists = $file && $file->exists();
 
@@ -850,10 +826,10 @@ class Linker {
                if ( $page ) {
                        $url = wfAppendQuery( $url, array( 'page' => $page ) );
                }
-               if ( $manualthumb &&
-                    !isset( $fp['link-title'] ) &&
-                    !isset( $fp['link-url'] ) &&
-                    !isset( $fp['no-link'] ) ) {
+               if ( $manualthumb
+                       && !isset( $fp['link-title'] )
+                       && !isset( $fp['link-url'] )
+                       && !isset( $fp['no-link'] ) ) {
                        $fp['link-url'] = $url;
                }
 
@@ -871,7 +847,7 @@ class Linker {
                        $params = array(
                                'alt' => $fp['alt'],
                                'title' => $fp['title'],
-                               'img-class' => ( isset( $fp['class'] ) && $fp['class'] !== '' ) ? $fp['class'] . ' thumbimage' : 'thumbimage'
+                               'img-class' => ( isset( $fp['class'] ) && $fp['class'] !== '' ? $fp['class'] . ' ' : '' ) . 'thumbimage'
                        );
                        $params = self::getImageLinkMTOParams( $fp, $query ) + $params;
                        $s .= $thumb->toHtml( $params );
@@ -899,7 +875,7 @@ class Linker {
         * applicable.
         *
         * @param File $file
-        * @param MediaOutput $thumb
+        * @param MediaTransformOutput $thumb
         * @param array $hp image parameters
         */
        public static function processResponsiveImages( $file, $thumb, $hp ) {
@@ -916,11 +892,11 @@ class Linker {
 
                        $thumb15 = $file->transform( $hp15 );
                        $thumb20 = $file->transform( $hp20 );
-                       if ( $thumb15->url !== $thumb->url ) {
-                               $thumb->responsiveUrls['1.5'] = $thumb15->url;
+                       if ( $thumb15 && $thumb15->getUrl() !== $thumb->getUrl() ) {
+                               $thumb->responsiveUrls['1.5'] = $thumb15->getUrl();
                        }
-                       if ( $thumb20->url !== $thumb->url ) {
-                               $thumb->responsiveUrls['2'] = $thumb20->url;
+                       if ( $thumb20 && $thumb20->getUrl() !== $thumb->getUrl() ) {
+                               $thumb->responsiveUrls['2'] = $thumb20->getUrl();
                        }
                }
        }
@@ -1471,8 +1447,8 @@ class Linker {
                        $target = Title::newFromText( $linkTarget );
                        if ( $target ) {
                                if ( $target->getText() == '' && $target->getInterwiki() === ''
-                                       && !self::$commentLocal && self::$commentContextTitle )
-                               {
+                                       && !self::$commentLocal && self::$commentContextTitle
+                               {
                                        $newTarget = clone ( self::$commentContextTitle );
                                        $newTarget->setFragment( '#' . $target->getFragment() );
                                        $target = $newTarget;
@@ -2244,32 +2220,6 @@ class Linker {
 
        /* Deprecated methods */
 
-       /**
-        * @deprecated since 1.16 Use link()
-        *
-        * This function is a shortcut to makeBrokenLinkObj(Title::newFromText($title),...). Do not call
-        * it if you already have a title object handy. See makeBrokenLinkObj for further documentation.
-        *
-        * @param string $title The text of the title
-        * @param string $text Link text
-        * @param string $query Optional query part
-        * @param string $trail Optional trail. Alphabetic characters at the start of this string will
-        *               be included in the link text. Other characters will be appended after
-        *               the end of the link.
-        * @return string
-        */
-       static function makeBrokenLink( $title, $text = '', $query = '', $trail = '' ) {
-               wfDeprecated( __METHOD__, '1.16' );
-
-               $nt = Title::newFromText( $title );
-               if ( $nt instanceof Title ) {
-                       return self::makeBrokenLinkObj( $nt, $text, $query, $trail );
-               } else {
-                       wfDebug( 'Invalid title passed to self::makeBrokenLink(): "' . $title . "\"\n" );
-                       return $text == '' ? $title : $text;
-               }
-       }
-
        /**
         * @deprecated since 1.16 Use link(); warnings since 1.21
         *
@@ -2343,63 +2293,6 @@ class Linker {
                return $ret;
        }
 
-       /**
-        * @deprecated since 1.16 Use link()
-        *
-        * Make a red link to the edit page of a given title.
-        *
-        * @param $title Title object of the target page
-        * @param $text  String: Link text
-        * @param string $query Optional query part
-        * @param string $trail Optional trail. Alphabetic characters at the start of this string will
-        *                      be included in the link text. Other characters will be appended after
-        *                      the end of the link.
-        * @param string $prefix Optional prefix
-        * @return string
-        */
-       static function makeBrokenLinkObj( $title, $text = '', $query = '', $trail = '', $prefix = '' ) {
-               wfDeprecated( __METHOD__, '1.16' );
-
-               wfProfileIn( __METHOD__ );
-
-               list( $inside, $trail ) = self::splitTrail( $trail );
-               if ( $text === '' ) {
-                       $text = self::linkText( $title );
-               }
-
-               $ret = self::link( $title, "$prefix$text$inside", array(),
-                       wfCgiToArray( $query ), 'broken' ) . $trail;
-
-               wfProfileOut( __METHOD__ );
-               return $ret;
-       }
-
-       /**
-        * @deprecated since 1.16 Use link()
-        *
-        * Make a coloured link.
-        *
-        * @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 $trail  String:  optional trail. Alphabetic characters at the start of this string will
-        *                      be included in the link text. Other characters will be appended after
-        *                      the end of the link.
-        * @param string $prefix Optional prefix
-        * @return string
-        */
-       static function makeColouredLinkObj( $nt, $colour, $text = '', $query = '', $trail = '', $prefix = '' ) {
-               wfDeprecated( __METHOD__, '1.16' );
-
-               if ( $colour != '' ) {
-                       $style = self::getInternalLinkAttributesObj( $nt, $text, $colour );
-               } else {
-                       $style = '';
-               }
-               return self::makeKnownLinkObj( $nt, $text, $query, $trail, $prefix, '', $style );
-       }
-
        /**
         * Returns the attributes for the tooltip and access key.
         * @return array