From 2d71cb30802e5cb78a423a1699ad87e23bfe9f4e Mon Sep 17 00:00:00 2001 From: Tom Gilder Date: Sat, 15 Jan 2005 23:56:26 +0000 Subject: [PATCH] Generate expanded URLs for printing on the client, not server (using CSS, or JS for IE/win) (bug 642) --- includes/Linker.php | 11 ++------- includes/Parser.php | 22 ++++++------------ skins/amethyst/main.css | 2 +- skins/chick/main.css | 2 +- skins/common/IEFixes.js | 41 ++++++++++++++++++++++++++++++++++ skins/common/common.css | 2 +- skins/common/commonPrint.css | 15 +++++-------- skins/common/wikiprintable.css | 5 ----- skins/disabled/Chick.php | 1 - skins/monobook/main.css | 2 +- 10 files changed, 59 insertions(+), 44 deletions(-) diff --git a/includes/Linker.php b/includes/Linker.php index 7a725c496b..59766bc269 100644 --- a/includes/Linker.php +++ b/includes/Linker.php @@ -647,8 +647,8 @@ class Linker { wfMsg( $key ) ); } - function makeExternalLink( $url, $text, $escape = true ) { - $style = $this->getExternalLinkAttributes( $url, $text ); + function makeExternalLink( $url, $text, $escape = true, $linktype = '' ) { + $style = $this->getExternalLinkAttributes( $url, $text, 'external ' . $linktype ); $url = htmlspecialchars( $url ); if( $escape ) { $text = htmlspecialchars( $text ); @@ -833,13 +833,6 @@ class Linker { } - /** - * @access public - */ - function suppressUrlExpansion() { - return false; - } - } ?> \ No newline at end of file diff --git a/includes/Parser.php b/includes/Parser.php index e2407e7d33..375f988013 100644 --- a/includes/Parser.php +++ b/includes/Parser.php @@ -992,14 +992,19 @@ class Parser $dtrail = ''; + # Set linktype for CSS - if URL==text, link is essentially free + $linktype = ($text == $url) ? 'free' : 'text'; + # No link text, e.g. [http://domain.tld/some.link] if ( $text == '' ) { # Autonumber if allowed if ( strpos( HTTP_PROTOCOLS, $protocol ) !== false ) { $text = '[' . ++$this->mAutonumber . ']'; + $linktype = 'autonumber'; } else { # Otherwise just use the URL $text = htmlspecialchars( $url ); + $linktype = 'free'; } } else { # Have link text, e.g. [http://domain.tld/some.link text]s @@ -1010,19 +1015,6 @@ class Parser } } - $encUrl = htmlspecialchars( $url ); - # Bit in parentheses showing the URL for the printable version - if( $url == $text || preg_match( "!$protocol://" . preg_quote( $text, '/' ) . "/?$!", $url ) ) { - $paren = ''; - } else { - # Expand the URL for printable version - if ( ! $sk->suppressUrlExpansion() ) { - $paren = " (" . htmlspecialchars ( $encUrl ) . ")"; - } else { - $paren = ''; - } - } - # Process the trail (i.e. everything after this link up until start of the next link), # replacing any non-bracketed links $trail = $this->replaceFreeExternalLinks( $trail ); @@ -1031,7 +1023,7 @@ class Parser # This means that users can paste URLs directly into the text # Funny characters like ö aren't valid in URLs anyway # This was changed in August 2004 - $s .= $sk->makeExternalLink( $url, $text, false ) . $dtrail. $paren . $trail; + $s .= $sk->makeExternalLink( $url, $text, false, $linktype ) . $dtrail . $trail; } wfProfileOut( $fname ); @@ -1091,7 +1083,7 @@ class Parser $text = $this->maybeMakeImageLink( $url ); if ( $text === false ) { # Not an image, make a link - $text = $sk->makeExternalLink( $url, $url ); + $text = $sk->makeExternalLink( $url, $url, true, 'free' ); } $s .= $text . $trail; } else { diff --git a/skins/amethyst/main.css b/skins/amethyst/main.css index 898910c782..a48ab4e890 100644 --- a/skins/amethyst/main.css +++ b/skins/amethyst/main.css @@ -438,7 +438,7 @@ div.tleft { margin-right:0.5em; border-width: 0.5em 1.4em 0.8em 0; } -.urlexpansion, + .hiddenStructure { display: none; } diff --git a/skins/chick/main.css b/skins/chick/main.css index a7191b17ab..a07ee60a07 100755 --- a/skins/chick/main.css +++ b/skins/chick/main.css @@ -309,7 +309,7 @@ div.tleft { margin-right:0.5em; border-width: 0.5em 1.4em 0.8em 0; } -.urlexpansion, + .hiddenStructure { display: none; } diff --git a/skins/common/IEFixes.js b/skins/common/IEFixes.js index 2d2ba672bd..ec10f1b410 100644 --- a/skins/common/IEFixes.js +++ b/skins/common/IEFixes.js @@ -74,3 +74,44 @@ function setrelative (nodes) { i++; } } + + +// Expand links for printing + +String.prototype.hasClass = function(classWanted) +{ + var classArr = this.split(/\s/); + for (var i=0; iskinname = 'chick'; $this->template = 'Chick'; } - function suppressUrlExpansion() { return true; } function printSource() { return ''; } } diff --git a/skins/monobook/main.css b/skins/monobook/main.css index e3e4645b9e..e14117deac 100644 --- a/skins/monobook/main.css +++ b/skins/monobook/main.css @@ -408,7 +408,7 @@ div.tleft { margin-right:0.5em; border-width: 0.5em 1.4em 0.8em 0; } -.urlexpansion, + .hiddenStructure { display: none; } -- 2.20.1