mirror of
https://github.com/diocloid/LinkTitles.git
synced 2025-07-13 01:39:30 +02:00
Implement black list option.
This commit is contained in:
@ -74,6 +74,7 @@
|
||||
global $wgLinkTitlesPreferShortTitles;
|
||||
global $wgLinkTitlesMinimumTitleLength;
|
||||
global $wgLinkTitlesParseHeadings;
|
||||
global $wgLinkTitlesBlackList;
|
||||
|
||||
// To prevent adding self-references, we now
|
||||
// extract the current page's title.
|
||||
@ -93,6 +94,10 @@
|
||||
$delimiter = '/(' . $delimiter . '\[\[.*?\]\]|\[' .
|
||||
$urlPattern . '\s.+?\]|'. $urlPattern . '(?=\s|$)|(?<=\b)\S+\@(?:\S+\.)+\S+(?=\b))/i';
|
||||
|
||||
$black_list = str_replace( '_', ' ',
|
||||
'("' . implode( '", "',$wgLinkTitlesBlackList ) . '")' );
|
||||
dump( $black_list );
|
||||
|
||||
// Build an SQL query and fetch all page titles ordered
|
||||
// by length from shortest to longest.
|
||||
// Only titles from 'normal' pages (namespace uid = 0)
|
||||
@ -101,9 +106,14 @@
|
||||
$res = $dbr->select(
|
||||
'page',
|
||||
'page_title',
|
||||
array( 'page_namespace = 0', 'CHAR_LENGTH(page_title) >= ' . $wgLinkTitlesMinimumTitleLength ),
|
||||
array(
|
||||
'page_namespace = 0',
|
||||
'CHAR_LENGTH(page_title) >= ' . $wgLinkTitlesMinimumTitleLength,
|
||||
'page_title NOT IN ' . $black_list,
|
||||
),
|
||||
__METHOD__,
|
||||
array( 'ORDER BY' => 'CHAR_LENGTH(page_title) ' . $sort_order ));
|
||||
array( 'ORDER BY' => 'CHAR_LENGTH(page_title) ' . $sort_order )
|
||||
);
|
||||
|
||||
// Iterate through the page titles
|
||||
foreach( $res as $row ) {
|
||||
|
@ -23,13 +23,11 @@
|
||||
die( 'Not an entry point.' );
|
||||
}
|
||||
|
||||
/*
|
||||
error_reporting(E_ALL);
|
||||
ini_set('display_errors', 'Off');
|
||||
ini_set('error_log', 'php://stderr');
|
||||
$wgMainCacheType = CACHE_NONE;
|
||||
$wgCacheDirectory = false;
|
||||
*/
|
||||
error_reporting(E_ALL);
|
||||
ini_set('display_errors', 'Off');
|
||||
ini_set('error_log', 'php://stderr');
|
||||
$wgMainCacheType = CACHE_NONE;
|
||||
$wgCacheDirectory = false;
|
||||
|
||||
// Configuration variables
|
||||
$wgLinkTitlesPreferShortTitles = false;
|
||||
@ -37,13 +35,14 @@
|
||||
$wgLinkTitlesParseHeadings = false;
|
||||
$wgLinkTitlesParseOnEdit = true;
|
||||
$wgLinkTitlesParseOnRender = false;
|
||||
$wgLinkTitlesBlackList = array();
|
||||
|
||||
$wgExtensionCredits['parserhook'][] = array(
|
||||
'path' => __FILE__,
|
||||
'name' => 'LinkTitles',
|
||||
'author' => '[http://www.mediawiki.org/wiki/User:Bovender Daniel Kraus]',
|
||||
'url' => 'http://www.mediawiki.org/wiki/Extension:LinkTitles',
|
||||
'version' => '1.1.0',
|
||||
'version' => '1.2.0',
|
||||
'descriptionmsg' => 'linktitles-desc'
|
||||
);
|
||||
|
||||
|
5
NEWS
5
NEWS
@ -1,3 +1,7 @@
|
||||
LinkTitles 1.2.0: 2012-07-19
|
||||
* Added a black list option to prevent certain page titles from being
|
||||
automatically linked.
|
||||
|
||||
LinkTitles 1.1.0: 2012-05-24
|
||||
* No longer parses urls and email addresses.
|
||||
|
||||
@ -30,3 +34,4 @@ LinkTitles 0.0.2: 2012-05-20
|
||||
LinkTitles 0.0.1: 2012-05-20
|
||||
* Initial release.
|
||||
|
||||
# vim: flp=\*\s
|
||||
|
Reference in New Issue
Block a user