Add option $wgLinkTitlesIgnoreCase to enable case-sensitive linking of page titles.

This commit is contained in:
Daniel Kraus
2013-01-22 16:09:51 +01:00
parent a269b906b0
commit 455f333c28
4 changed files with 10 additions and 3 deletions

View File

@ -79,9 +79,11 @@
global $wgLinkTitlesFirstOnly; global $wgLinkTitlesFirstOnly;
global $wgLinkTitlesWordStartOnly; global $wgLinkTitlesWordStartOnly;
global $wgLinkTitlesWordEndOnly; global $wgLinkTitlesWordEndOnly;
global $wgLinkTitlesIgnoreCase;
( $wgLinkTitlesWordStartOnly ) ? $wordStartDelim = '\b' : $wordStartDelim = ''; ( $wgLinkTitlesWordStartOnly ) ? $wordStartDelim = '\b' : $wordStartDelim = '';
( $wgLinkTitlesWordEndOnly ) ? $wordEndDelim = '\b' : $wordEndDelim = ''; ( $wgLinkTitlesWordEndOnly ) ? $wordEndDelim = '\b' : $wordEndDelim = '';
( $wgLinkTitlesIgnoreCase ) ? $regexModifier = 'i' : $regexModifier = '';
// To prevent adding self-references, we now // To prevent adding self-references, we now
// extract the current page's title. // extract the current page's title.
@ -148,7 +150,7 @@
// even indexes will point to text that is not enclosed by brackets // even indexes will point to text that is not enclosed by brackets
$arr[$i] = preg_replace( '/(?<![\:\.\@\/\?\&])' . $arr[$i] = preg_replace( '/(?<![\:\.\@\/\?\&])' .
$wordStartDelim . '(' . $safeTitle . ')' . $wordStartDelim . '(' . $safeTitle . ')' .
$wordEndDelim . '/i', '[[$1]]', $arr[$i], $limit, $count ); $wordEndDelim . '/' . $regexModifier , '[[$1]]', $arr[$i], $limit, $count );
if (( $limit >= 0 ) && ( $count > 0 )) { if (( $limit >= 0 ) && ( $count > 0 )) {
break; break;
}; };

View File

@ -42,13 +42,14 @@
$wgLinkTitlesFirstOnly = false; $wgLinkTitlesFirstOnly = false;
$wgLinkTitlesWordStartOnly = true; $wgLinkTitlesWordStartOnly = true;
$wgLinkTitlesWordEndOnly = true; $wgLinkTitlesWordEndOnly = true;
$wgLinkTitlesIgnoreCase = true;
$wgExtensionCredits['parserhook'][] = array( $wgExtensionCredits['parserhook'][] = array(
'path' => __FILE__, 'path' => __FILE__,
'name' => 'LinkTitles', 'name' => 'LinkTitles',
'author' => '[http://www.mediawiki.org/wiki/User:Bovender Daniel Kraus]', 'author' => '[http://www.mediawiki.org/wiki/User:Bovender Daniel Kraus]',
'url' => 'http://www.mediawiki.org/wiki/Extension:LinkTitles', 'url' => 'http://www.mediawiki.org/wiki/Extension:LinkTitles',
'version' => '1.6.1', 'version' => '1.7.0',
'descriptionmsg' => 'linktitles-desc' 'descriptionmsg' => 'linktitles-desc'
); );

6
NEWS
View File

@ -1,3 +1,7 @@
LinkTitles 1.7.0: 2013-01-22
* Added new option to do exact searches of page titles; the default is to
do __case-insensitive__ searches as before ($wgLinkTitlesIgnoreCase).
LinkTitles 1.6.1: 2012-12-31 LinkTitles 1.6.1: 2012-12-31
* Fixed a bug that caused linking to fail in certain situations when * Fixed a bug that caused linking to fail in certain situations when
$wgLinkTitlesFirstOnly was set to true. $wgLinkTitlesFirstOnly was set to true.
@ -13,7 +17,7 @@ LinkTitles 1.4.0: 2012-10-09
* Added new option to skip template variables. * Added new option to skip template variables.
LinkTitles 1.3.2: 2012-10-05 LinkTitles 1.3.2: 2012-10-05
* Fix incorrect handling of PreverShortTitles option. * Fix incorrect handling of PreferShortTitles option.
LinkTitles 1.3.1: 2012-10-05 LinkTitles 1.3.1: 2012-10-05
* Fix typo that prevented proper function of the extension. * Fix typo that prevented proper function of the extension.

Binary file not shown.