Page MenuHomePhabricator

4901.diff

Authored By
bzimport
Nov 21 2014, 9:04 PM
Size
2 KB
Referenced Files
None
Subscribers
None

4901.diff

Index: includes/Linker.php
===================================================================
--- includes/Linker.php (revision 88299)
+++ includes/Linker.php (working copy)
@@ -35,6 +35,8 @@
* @param $unused String: unused
* @param $class String: the contents of the class attribute; if an empty
* string is passed, which is the default value, defaults to 'external'.
+ *
+ * @todo this function seems to be unused now... deprecate?
*/
static function getInterwikiLinkAttributes( $title, $unused = null, $class = 'external' ) {
global $wgContLang;
@@ -45,7 +47,13 @@
$title = $wgContLang->checkTitleEncoding( $title );
$title = preg_replace( '/[\\x00-\\x1f]/', ' ', $title );
- return self::getLinkAttributesInternal( $title, $class );
+ $attrs = self::getLinkAttributesInternal( $title, $class );
+
+ if ( $wgContLang->getLanguageName( $iw ) ) {
+ $attrs .= ' hreflang="' . htmlspecialchars( strtolower( $iw ) ) . '"';
+ }
+
+ return $attrs;
}
/**
@@ -273,7 +281,15 @@
}
if ( $target->isExternal() ) {
+ global $wgContLang;
+
$classes[] = 'extiw';
+ $iw = strtolower( $target->getInterwiki() );
+ if ( $wgContLang->getLanguageName( $iw ) ) {
+ // Note that we cannot guess if the text of the link is in
+ // that language reliably, so we only set hreflang, not lang.
+ $defaults['hreflang'] = $iw;
+ }
}
if ( !in_array( 'broken', $options ) ) { # Avoid useless calls to LinkCache (see r50387)
Index: includes/SkinTemplate.php
===================================================================
--- includes/SkinTemplate.php (revision 88299)
+++ includes/SkinTemplate.php (working copy)
@@ -476,7 +476,9 @@
'text' => ( $wgContLang->getLanguageName( $nt->getInterwiki() ) != '' ?
$wgContLang->getLanguageName( $nt->getInterwiki() ) : $l ),
'title' => $nt->getText(),
- 'class' => $class
+ 'class' => $class,
+ 'lang' => $nt->getInterwiki(),
+ 'hreflang' => $nt->getInterwiki(),
);
}
}
@@ -1558,7 +1560,7 @@
}
$attrs = array();
- foreach ( array( 'href', 'id', 'class', 'rel', 'type' ) as $attr ) {
+ foreach ( array( 'href', 'id', 'class', 'rel', 'type', 'lang', 'hreflang' ) as $attr ) {
if ( isset( $item[$attr] ) ) {
$attrs[$attr] = $item[$attr];
}
@@ -1611,7 +1613,7 @@
}
} else {
$link = array();
- foreach ( array( 'text', 'msg', 'href', 'rel', 'type', 'tooltiponly' ) as $k ) {
+ foreach ( array( 'text', 'msg', 'href', 'rel', 'type', 'tooltiponly', 'lang', 'hreflang' ) as $k ) {
if ( isset( $item[$k] ) ) {
$link[$k] = $item[$k];
}

File Metadata

Mime Type
text/x-diff
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2184
Default Alt Text
4901.diff (2 KB)

Event Timeline