Change $text to $html. This has been bothering me for awhile. It's stupid, counterint...
[lhc/web/wiklou.git] / includes / Linker.php
index 61d8b83..fd0b48a 100644 (file)
@@ -19,7 +19,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__ );
@@ -155,19 +155,19 @@ class Linker {
         * @return string HTML <a> 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 "<!-- ERROR -->$text";
+                       return "<!-- ERROR -->$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;
@@ -203,13 +203,13 @@ class Linker {
                        $attribs,
                        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__ );
@@ -317,6 +317,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.
@@ -361,6 +363,8 @@ class Linker {
         * despite $query not being used.
         *
         * @param $nt Title
+        *
+        * @return string
         */
        static function makeSelfLinkObj( $nt, $text = '', $query = '', $trail = '', $prefix = '' ) {
                if ( $text == '' ) {
@@ -370,6 +374,10 @@ class Linker {
                return "<strong class=\"selflink\">{$prefix}{$text}{$inside}</strong>{$trail}";
        }
 
+       /**
+        * @param $title Title
+        * @return Title
+        */
        static function normaliseSpecialPage( Title $title ) {
                if ( $title->getNamespace() == NS_SPECIAL ) {
                        list( $name, $subpage ) = SpecialPageFactory::resolveAlias( $title->getDBkey() );
@@ -387,6 +395,10 @@ 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 ) {
                $basename = strrchr( $url, '/' );
@@ -401,6 +413,11 @@ 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 = '' ) {
                if ( $alt == '' ) {
@@ -1737,60 +1754,6 @@ class Linker {
 
        /* Deprecated methods */
 
-       /**
-        * @deprecated since 1.16 Use link()
-        *
-        * This function is a shortcut to makeLinkObj(Title::newFromText($title),...). Do not call
-        * it if you already have a title object handy. See makeLinkObj for further documentation.
-        *
-        * @param $title String: the text of the title
-        * @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.
-        */
-       static function makeLink( $title, $text = '', $query = '', $trail = '' ) {
-               wfProfileIn( __METHOD__ );
-               $nt = Title::newFromText( $title );
-               if ( $nt instanceof Title ) {
-                       $result = self::makeLinkObj( $nt, $text, $query, $trail );
-               } else {
-                       wfDebug( 'Invalid title passed to self::makeLink(): "' . $title . "\"\n" );
-                       $result = $text == "" ? $title : $text;
-               }
-
-               wfProfileOut( __METHOD__ );
-               return $result;
-       }
-
-       /**
-        * @deprecated since 1.16 Use link()
-        *
-        * This function is a shortcut to makeKnownLinkObj(Title::newFromText($title),...). Do not call
-        * it if you already have a title object handy. See makeKnownLinkObj for further documentation.
-        *
-        * @param $title String: the text of the title
-        * @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 $prefix String: Optional prefix
-        * @param $aprops String: extra attributes to the a-element
-        */
-       static function makeKnownLink(
-               $title, $text = '', $query = '', $trail = '', $prefix = '', $aprops = ''
-       ) {
-               $nt = Title::newFromText( $title );
-               if ( $nt instanceof Title ) {
-                       return self::makeKnownLinkObj( $nt, $text, $query, $trail, $prefix , $aprops );
-               } else {
-                       wfDebug( 'Invalid title passed to self::makeKnownLink(): "' . $title . "\"\n" );
-                       return $text == '' ? $title : $text;
-               }
-       }
-
        /**
         * @deprecated since 1.16 Use link()
         *
@@ -1814,30 +1777,6 @@ class Linker {
                }
        }
 
-       /**
-        * @deprecated since 1.16 Use link()
-        *
-        * This function is a shortcut to makeStubLinkObj(Title::newFromText($title),...). Do not call
-        * it if you already have a title object handy. See makeStubLinkObj for further documentation.
-        *
-        * @param $title String: the text of the title
-        * @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.
-        */
-       static function makeStubLink( $title, $text = '', $query = '', $trail = '' ) {
-               wfDeprecated( __METHOD__ );
-               $nt = Title::newFromText( $title );
-               if ( $nt instanceof Title ) {
-                       return self::makeStubLinkObj( $nt, $text, $query, $trail );
-               } else {
-                       wfDebug( 'Invalid title passed to self::makeStubLink(): "' . $title . "\"\n" );
-                       return $text == '' ? $title : $text;
-               }
-       }
-
        /**
         * @deprecated since 1.16 Use link()
         *
@@ -1934,23 +1873,6 @@ class Linker {
                return $ret;
        }
 
-       /**
-        * @deprecated since 1.16 Use link()
-        *
-        * Make a brown link to a short article.
-        *
-        * @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
-        *                      be included in the link text. Other characters will be appended after
-        *                      the end of the link.
-        * @param $prefix String: Optional prefix
-        */
-       static function makeStubLinkObj( $nt, $text = '', $query = '', $trail = '', $prefix = '' ) {
-               return self::makeColouredLinkObj( $nt, 'stub', $text, $query, $trail, $prefix );
-       }
-
        /**
         * @deprecated since 1.16 Use link()
         *
@@ -1974,57 +1896,6 @@ class Linker {
                return self::makeKnownLinkObj( $nt, $text, $query, $trail, $prefix, '', $style );
        }
 
-       /** Obsolete alias */
-       static function makeImage( $url, $alt = '' ) {
-               wfDeprecated( __METHOD__ );
-               return self::makeExternalImage( $url, $alt );
-       }
-
-       /**
-        * Creates the HTML source for images
-        * @deprecated since 1.16 use makeImageLink2
-        *
-        * @param $title Title object
-        * @param $label String: label text
-        * @param $alt String: alt text
-        * @param $align String: horizontal alignment: none, left, center, right)
-        * @param $handlerParams Array: parameters to be passed to the media handler
-        * @param $framed Boolean: shows image in original size in a frame
-        * @param $thumb Boolean: shows image as thumbnail in a frame
-        * @param $manualthumb String: image name for the manual thumbnail
-        * @param $valign String: vertical alignment: baseline, sub, super, top, text-top, middle, bottom, text-bottom
-        * @param $time String: timestamp of the file, set as false for current
-        * @return String
-        */
-       static function makeImageLinkObj( $title, $label, $alt, $align = '', $handlerParams = array(),
-               $framed = false, $thumb = false, $manualthumb = '', $valign = '', $time = false )
-       {
-               $frameParams = array( 'alt' => $alt, 'caption' => $label );
-               if ( $align ) {
-                       $frameParams['align'] = $align;
-               }
-               if ( $framed ) {
-                       $frameParams['framed'] = true;
-               }
-               if ( $thumb ) {
-                       $frameParams['thumbnail'] = true;
-               }
-               if ( $manualthumb ) {
-                       $frameParams['manualthumb'] = $manualthumb;
-               }
-               if ( $valign ) {
-                       $frameParams['valign'] = $valign;
-               }
-               $file = wfFindFile( $title, array( 'time' => $time ) );
-               return self::makeImageLink2( $title, $file, $frameParams, $handlerParams, $time );
-       }
-
-       /** @deprecated use Linker::makeMediaLinkObj() */
-       static function makeMediaLink( $name, $unused = '', $text = '', $time = false ) {
-               $nt = Title::makeTitleSafe( NS_FILE, $name );
-               return self::makeMediaLinkObj( $nt, $text, $time );
-       }
-
        /**
         * Returns the attributes for the tooltip and access key.
         */
@@ -2048,14 +1919,6 @@ class Linker {
                return $attribs;
        }
 
-       /**
-        * @deprecated since 1.14
-        * Returns raw bits of HTML, use titleAttrib() and accesskey()
-        */
-       public static function tooltipAndAccesskey( $name ) {
-               return Xml::expandAttributes( self::tooltipAndAccesskeyAttribs( $name ) );
-       }
-
        /**
         * @deprecated since 1.14
         * Returns raw bits of HTML, use titleAttrib()
@@ -2072,7 +1935,7 @@ class Linker {
                        return '';
                }
                return Xml::expandAttributes( array(
-                       'title' => self::titleAttrib( $name, $options )
+                       'title' => $tooltip
                ) );
        }
 }