Add option

This commit is contained in:
Daniel Kraus
2012-05-20 17:19:15 +02:00
parent 4e3d31981c
commit be1a02678d
4 changed files with 13 additions and 3 deletions

View File

@ -1,5 +1,11 @@
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
* Only look for page titles from 'normal' pages (namespace = 0).

View File

@ -36,6 +36,10 @@
public static function onArticleSave( &$article, &$user, &$text, &$summary,
$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
// it is edited and saved, we only parse it if the flag
// 'minor edits' is not set.
@ -55,9 +59,9 @@
$res = $dbr->select(
'page',
'page_title',
'page_namespace = 0',
array( 'page_namespace = 0', 'CHAR_LENGTH(page_title) > ' . $wgLinkTitlesMinimumTitleLength ),
__METHOD__,
array( 'ORDER BY' => 'length(page_title) ' . $sort_order ));
array( 'ORDER BY' => 'CHAR_LENGTH(page_title) ' . $sort_order ));
// Iterate through the page titles
$new_text = $text;
@ -75,7 +79,6 @@
// even indexes will text that is not enclosed by brackets
$arr[$i] = preg_replace( '/\b(' . $safe_title . ')\b/i', '[[$1]]', $arr[$i] );
};
dump( $arr );
$new_text = implode( '', $arr );
}; // if $title != $my_title
}; // foreach $res as $row

View File

@ -48,6 +48,7 @@
// Configuration variables
$wgLinkTitlesPreferShortTitles = false;
$wgLinkTitlesMinimumTitleLength = 3;
// vim: ts=2:sw=2:noet

Binary file not shown.