diff --git a/HISTORY b/HISTORY index 7790740..2e97b6b 100644 --- a/HISTORY +++ b/HISTORY @@ -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). diff --git a/LinkTitles.body.php b/LinkTitles.body.php index 755f5f1..0b916df 100755 --- a/LinkTitles.body.php +++ b/LinkTitles.body.php @@ -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 diff --git a/LinkTitles.php b/LinkTitles.php index 3dbca2c..3cbd9da 100755 --- a/LinkTitles.php +++ b/LinkTitles.php @@ -48,6 +48,7 @@ // Configuration variables $wgLinkTitlesPreferShortTitles = false; + $wgLinkTitlesMinimumTitleLength = 3; // vim: ts=2:sw=2:noet diff --git a/release/LinkTitles-0.0.4.tar.gz b/release/LinkTitles-0.0.4.tar.gz new file mode 100644 index 0000000..a4618ee Binary files /dev/null and b/release/LinkTitles-0.0.4.tar.gz differ