mirror of
https://github.com/diocloid/LinkTitles.git
synced 2025-07-13 09:49:31 +02:00
Add option
This commit is contained in:
6
HISTORY
6
HISTORY
@ -1,5 +1,11 @@
|
|||||||
Extension:LinkTitles
|
Extension:LinkTitles
|
||||||
|
|
||||||
|
0.0.5: 2012-05-20
|
||||||
|
* Add $wgLinkTitlesMinimumTitleLength configuration variable.
|
||||||
|
|
||||||
|
0.0.4: 2012-05-20
|
||||||
|
* Add $wgLinkTitlesPreferShortTitles configuration variable.
|
||||||
|
|
||||||
0.0.3: 2012-05-20
|
0.0.3: 2012-05-20
|
||||||
* Only look for page titles from 'normal' pages (namespace = 0).
|
* Only look for page titles from 'normal' pages (namespace = 0).
|
||||||
|
|
||||||
|
@ -36,6 +36,10 @@
|
|||||||
public static function onArticleSave( &$article, &$user, &$text, &$summary,
|
public static function onArticleSave( &$article, &$user, &$text, &$summary,
|
||||||
$minor, $watchthis, $sectionanchor, &$flags, &$status ) {
|
$minor, $watchthis, $sectionanchor, &$flags, &$status ) {
|
||||||
|
|
||||||
|
// Configuration variables need to be defined here as globals.
|
||||||
|
global $wgLinkTitlesPreferShortTitles;
|
||||||
|
global $wgLinkTitlesMinimumTitleLength;
|
||||||
|
|
||||||
// To prevent time-consuming parsing of the page whenever
|
// To prevent time-consuming parsing of the page whenever
|
||||||
// it is edited and saved, we only parse it if the flag
|
// it is edited and saved, we only parse it if the flag
|
||||||
// 'minor edits' is not set.
|
// 'minor edits' is not set.
|
||||||
@ -55,9 +59,9 @@
|
|||||||
$res = $dbr->select(
|
$res = $dbr->select(
|
||||||
'page',
|
'page',
|
||||||
'page_title',
|
'page_title',
|
||||||
'page_namespace = 0',
|
array( 'page_namespace = 0', 'CHAR_LENGTH(page_title) > ' . $wgLinkTitlesMinimumTitleLength ),
|
||||||
__METHOD__,
|
__METHOD__,
|
||||||
array( 'ORDER BY' => 'length(page_title) ' . $sort_order ));
|
array( 'ORDER BY' => 'CHAR_LENGTH(page_title) ' . $sort_order ));
|
||||||
|
|
||||||
// Iterate through the page titles
|
// Iterate through the page titles
|
||||||
$new_text = $text;
|
$new_text = $text;
|
||||||
@ -75,7 +79,6 @@
|
|||||||
// even indexes will text that is not enclosed by brackets
|
// even indexes will text that is not enclosed by brackets
|
||||||
$arr[$i] = preg_replace( '/\b(' . $safe_title . ')\b/i', '[[$1]]', $arr[$i] );
|
$arr[$i] = preg_replace( '/\b(' . $safe_title . ')\b/i', '[[$1]]', $arr[$i] );
|
||||||
};
|
};
|
||||||
dump( $arr );
|
|
||||||
$new_text = implode( '', $arr );
|
$new_text = implode( '', $arr );
|
||||||
}; // if $title != $my_title
|
}; // if $title != $my_title
|
||||||
}; // foreach $res as $row
|
}; // foreach $res as $row
|
||||||
|
@ -48,6 +48,7 @@
|
|||||||
|
|
||||||
// Configuration variables
|
// Configuration variables
|
||||||
$wgLinkTitlesPreferShortTitles = false;
|
$wgLinkTitlesPreferShortTitles = false;
|
||||||
|
$wgLinkTitlesMinimumTitleLength = 3;
|
||||||
|
|
||||||
// vim: ts=2:sw=2:noet
|
// vim: ts=2:sw=2:noet
|
||||||
|
|
||||||
|
BIN
release/LinkTitles-0.0.4.tar.gz
Normal file
BIN
release/LinkTitles-0.0.4.tar.gz
Normal file
Binary file not shown.
Reference in New Issue
Block a user