From bf1df55887e8e32f63f7163860d45b280df97c76 Mon Sep 17 00:00:00 2001 From: Brian Wolff Date: Wed, 6 Jul 2011 00:38:40 +0000 Subject: [PATCH] (bug 29680, bug 22911) Add GetDeaultSortkey hook in order to override default sortkey used on pages (default is {{PAGENAME}}) Some people want it to default to subpage or to fullpagename this hook would let them do what they want :) --- RELEASE-NOTES-1.19 | 1 + docs/hooks.txt | 4 ++++ includes/Title.php | 6 ++++++ 3 files changed, 11 insertions(+) diff --git a/RELEASE-NOTES-1.19 b/RELEASE-NOTES-1.19 index b7397ec7f0..fcb8b39d5b 100644 --- a/RELEASE-NOTES-1.19 +++ b/RELEASE-NOTES-1.19 @@ -67,6 +67,7 @@ production. * (bug 5800) Added $formCallback as a parameter to the hook EditPage::showEditForm:initial * (bug 29723) mw.util.wikiGetlink() now defaults to wgPageName. +* (bug 29680) Add GetDefaultSortkey hook to override the default sortkey. === Bug fixes in 1.19 === * (bug 28868) Show total pages in the subtitle of an image on the diff --git a/docs/hooks.txt b/docs/hooks.txt index 004c7e7157..f2b5101095 100644 --- a/docs/hooks.txt +++ b/docs/hooks.txt @@ -862,6 +862,10 @@ $out: OutputPage object &$cookies: array of cookies name, add a value to it if you want to add a cookie that have to vary cache options +'GetDefaultSortkey': Override the default sortkey for a page. +$title: Title object that we need to get a sortkey for +&$sortkey: Sortkey to use. + 'GetFullURL': modify fully-qualified URLs used in redirects/export/offsite data $title: Title object of page $url: string value as output (out parameter, can modify) diff --git a/includes/Title.php b/includes/Title.php index f170213c7c..5f7c151950 100644 --- a/includes/Title.php +++ b/includes/Title.php @@ -4247,6 +4247,12 @@ class Title { */ public function getCategorySortkey( $prefix = '' ) { $unprefixed = $this->getText(); + + // Anything that uses this hook should only depend + // on the Title object passed in, and should probably + // tell the users to run updateCollations.php --force + // in order to re-sort existing category relations. + wfRunHooks( 'GetDefaultSortkey', array( $this, &$unprefixed ) ); if ( $prefix !== '' ) { # Separate with a line feed, so the unprefixed part is only used as # a tiebreaker when two pages have the exact same prefix. -- 2.20.1