mirror of
https://github.com/diocloid/LinkTitles.git
synced 2025-07-13 09:49:31 +02:00
Implement PreferShortTitles option
This commit is contained in:
@ -45,6 +45,8 @@
|
|||||||
// extract the current page's title.
|
// extract the current page's title.
|
||||||
$my_title = $article->getTitle()->getText();
|
$my_title = $article->getTitle()->getText();
|
||||||
|
|
||||||
|
( $wgLinkTitlesPreferShortTitles ) ? $sort_order = 'DESC' : $sort_order = '';
|
||||||
|
|
||||||
// Build an SQL query and fetch all page titles ordered
|
// Build an SQL query and fetch all page titles ordered
|
||||||
// by length from shortest to longest.
|
// by length from shortest to longest.
|
||||||
// Only titles from 'normal' pages (namespace uid = 0)
|
// Only titles from 'normal' pages (namespace uid = 0)
|
||||||
@ -55,7 +57,7 @@
|
|||||||
'page_title',
|
'page_title',
|
||||||
'page_namespace = 0',
|
'page_namespace = 0',
|
||||||
__METHOD__,
|
__METHOD__,
|
||||||
array( 'ORDER BY' => 'length(page_title) DESC' ));
|
array( 'ORDER BY' => 'length(page_title) ' . $sort_order ));
|
||||||
|
|
||||||
// Iterate through the page titles
|
// Iterate through the page titles
|
||||||
$new_text = $text;
|
$new_text = $text;
|
||||||
|
@ -46,5 +46,8 @@
|
|||||||
// Hook up our custom function to the ArticleSave event.
|
// Hook up our custom function to the ArticleSave event.
|
||||||
$wgHooks['ArticleSave'][] = 'LinkTitles::onArticleSave';
|
$wgHooks['ArticleSave'][] = 'LinkTitles::onArticleSave';
|
||||||
|
|
||||||
|
// Configuration variables
|
||||||
|
$wgLinkTitlesPreferShortTitles = false;
|
||||||
|
|
||||||
// vim: ts=2:sw=2:noet
|
// vim: ts=2:sw=2:noet
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user