Page MenuHomePhabricator

bug6467.patch

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

bug6467.patch

Index: includes/Linker.php
===================================================================
--- includes/Linker.php (revision 16616)
+++ includes/Linker.php (working copy)
@@ -1038,6 +1038,21 @@
. "</script>\n";
}
+ /**
+ * Add "return to top" links to section headers
+ *
+ * @param $show bool True: show return to top link, False: do not show unless $wgShowTopLink is true
+ */
+ function topLink( $show=false ) {
+ global $wgShowTopLink;
+
+ if ( $wgShowTopLink || $show ) {
+ return "&nbsp;<a href=\"#\" class=\"internal\" title=\"" . wfMsgHtml( 'tophint' ) . "\">&uarr;</a>";
+ } else {
+ return "";
+ }
+ }
+
/** @todo document */
function editSectionLinkForOther( $title, $section ) {
global $wgContLang;
@@ -1045,6 +1060,7 @@
$title = Title::newFromText( $title );
$editurl = '&section='.$section;
$url = $this->makeKnownLinkObj( $title, wfMsg('editsection'), 'action=edit'.$editurl );
+ $topurl = $this->topLink();
if( $wgContLang->isRTL() ) {
$farside = 'left';
@@ -1053,7 +1069,7 @@
$farside = 'right';
$nearside = 'left';
}
- return "<div class=\"editsection\" style=\"float:$farside;margin-$nearside:5px;\">[".$url."]</div>";
+ return "<div class=\"editsection\" style=\"float:$farside;margin-$nearside:5px;\">[".$url."]$topurl</div>";
}
@@ -1068,6 +1084,7 @@
$editurl = '&section='.$section;
$hint = ( $hint=='' ) ? '' : ' title="' . wfMsgHtml( 'editsectionhint', htmlspecialchars( $hint ) ) . '"';
$url = $this->makeKnownLinkObj( $nt, wfMsg('editsection'), 'action=edit'.$editurl, '', '', '', $hint );
+ $topurl = $this->topLink();
if( $wgContLang->isRTL() ) {
$farside = 'left';
@@ -1076,10 +1093,29 @@
$farside = 'right';
$nearside = 'left';
}
- return "<div class=\"editsection\" style=\"float:$farside;margin-$nearside:5px;\">[".$url."]</div>";
+ return "<div class=\"editsection\" style=\"float:$farside;margin-$nearside:5px;\">[".$url."]$topurl</div>";
}
/**
+ * Add "return to top" links to section headers when editsection is not shown
+ */
+ function topSectionLink() {
+ global $wgContLang;
+
+ $topurl = $this->topLink( true );
+
+ if( $wgContLang->isRTL() ) {
+ $farside = 'left';
+ $nearside = 'right';
+ } else {
+ $farside = 'right';
+ $nearside = 'left';
+ }
+
+ return "<div class=\"editsection\" style=\"float:$farside;margin-$nearside:5px;\">$topurl</div>";
+ }
+
+ /**
* Split a link trail, return the "inside" portion and the remainder of the trail
* as a two-element array
*
Index: includes/Parser.php
===================================================================
--- includes/Parser.php (revision 16616)
+++ includes/Parser.php (working copy)
@@ -3317,6 +3317,7 @@
* 2) Add an [edit] link to sections for logged in users who have enabled the option
* 3) Add a Table of contents on the top for users who have enabled the option
* 4) Auto-anchor headings
+ * 5) Add a return to top link headings if that option is enabled
*
* It loops through all headlines, collects the necessary data, then splits up the
* string and re-inserts the newly formatted headlines.
@@ -3326,7 +3327,7 @@
* @private
*/
function formatHeadings( $text, $isMain=true ) {
- global $wgMaxTocLevel, $wgContLang;
+ global $wgMaxTocLevel, $wgContLang, $wgShowTopLink;
$doNumberHeadings = $this->mOptions->getNumberHeadings();
if( !$this->mTitle->userCanEdit() ) {
@@ -3516,6 +3517,12 @@
else
$head[$headlineCount] .= $sk->editSectionLink($this->mTitle, $sectionCount+1, $headline_hint);
}
+ if( !$showEditLink && $wgShowTopLink ) {
+ if ( empty( $head[$headlineCount] ) ) {
+ $head[$headlineCount] = '';
+ }
+ $head[$headlineCount] .= $sk->topSectionLink();
+ }
# give headline the correct <h#> tag
@$head[$headlineCount] .= "<a name=\"$anchor\"></a><h".$level.$matches[2][$headlineCount] .$headline.'</h'.$level.'>';
Index: includes/DefaultSettings.php
===================================================================
--- includes/DefaultSettings.php (revision 16616)
+++ includes/DefaultSettings.php (working copy)
@@ -2223,4 +2223,10 @@
*/
$wgDjvuPostProcessor = 'ppmtojpeg';
+/**
+ * To hide the "return to top" link in section headers of articles set to false.
+ * $wgShowTopLink = false;
+ */
+$wgShowTopLink = true;
+
?>
Index: languages/MessagesEn.php
===================================================================
--- languages/MessagesEn.php (revision 16616)
+++ languages/MessagesEn.php (working copy)
@@ -555,6 +555,7 @@
'editsection'=>'edit',
'editold'=>'edit',
'editsectionhint' => 'Edit section: $1',
+'tophint' => 'return to top',
'toc' => 'Contents',
'showtoc' => 'show',
'hidetoc' => 'hide',
Index: languages/MessagesDe.php
===================================================================
--- languages/MessagesDe.php (revision 16616)
+++ languages/MessagesDe.php (working copy)
@@ -282,6 +282,7 @@
"editsection" => "bearbeiten",
"editold" => "bearbeiten",
'editsectionhint' => 'Abschnitt bearbeiten: $1',
+'tophint' => 'nach oben',
"toc" => "Inhaltsverzeichnis",
"showtoc" => "Anzeigen",
"hidetoc" => "Verbergen",

File Metadata

Mime Type
text/x-diff
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2616
Default Alt Text
bug6467.patch (5 KB)

Event Timeline