mirror of
https://github.com/diocloid/LinkTitles.git
synced 2025-07-13 09:49:31 +02:00
Implement black list option.
This commit is contained in:
@ -74,6 +74,7 @@
|
|||||||
global $wgLinkTitlesPreferShortTitles;
|
global $wgLinkTitlesPreferShortTitles;
|
||||||
global $wgLinkTitlesMinimumTitleLength;
|
global $wgLinkTitlesMinimumTitleLength;
|
||||||
global $wgLinkTitlesParseHeadings;
|
global $wgLinkTitlesParseHeadings;
|
||||||
|
global $wgLinkTitlesBlackList;
|
||||||
|
|
||||||
// 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.
|
||||||
@ -93,6 +94,10 @@
|
|||||||
$delimiter = '/(' . $delimiter . '\[\[.*?\]\]|\[' .
|
$delimiter = '/(' . $delimiter . '\[\[.*?\]\]|\[' .
|
||||||
$urlPattern . '\s.+?\]|'. $urlPattern . '(?=\s|$)|(?<=\b)\S+\@(?:\S+\.)+\S+(?=\b))/i';
|
$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
|
// Build an SQL query and fetch all page titles ordered
|
||||||
// by length from shortest to longest.
|
// by length from shortest to longest.
|
||||||
// Only titles from 'normal' pages (namespace uid = 0)
|
// Only titles from 'normal' pages (namespace uid = 0)
|
||||||
@ -101,9 +106,14 @@
|
|||||||
$res = $dbr->select(
|
$res = $dbr->select(
|
||||||
'page',
|
'page',
|
||||||
'page_title',
|
'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__,
|
__METHOD__,
|
||||||
array( 'ORDER BY' => 'CHAR_LENGTH(page_title) ' . $sort_order ));
|
array( 'ORDER BY' => 'CHAR_LENGTH(page_title) ' . $sort_order )
|
||||||
|
);
|
||||||
|
|
||||||
// Iterate through the page titles
|
// Iterate through the page titles
|
||||||
foreach( $res as $row ) {
|
foreach( $res as $row ) {
|
||||||
|
@ -23,13 +23,11 @@
|
|||||||
die( 'Not an entry point.' );
|
die( 'Not an entry point.' );
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
error_reporting(E_ALL);
|
||||||
error_reporting(E_ALL);
|
ini_set('display_errors', 'Off');
|
||||||
ini_set('display_errors', 'Off');
|
ini_set('error_log', 'php://stderr');
|
||||||
ini_set('error_log', 'php://stderr');
|
$wgMainCacheType = CACHE_NONE;
|
||||||
$wgMainCacheType = CACHE_NONE;
|
$wgCacheDirectory = false;
|
||||||
$wgCacheDirectory = false;
|
|
||||||
*/
|
|
||||||
|
|
||||||
// Configuration variables
|
// Configuration variables
|
||||||
$wgLinkTitlesPreferShortTitles = false;
|
$wgLinkTitlesPreferShortTitles = false;
|
||||||
@ -37,13 +35,14 @@
|
|||||||
$wgLinkTitlesParseHeadings = false;
|
$wgLinkTitlesParseHeadings = false;
|
||||||
$wgLinkTitlesParseOnEdit = true;
|
$wgLinkTitlesParseOnEdit = true;
|
||||||
$wgLinkTitlesParseOnRender = false;
|
$wgLinkTitlesParseOnRender = false;
|
||||||
|
$wgLinkTitlesBlackList = array();
|
||||||
|
|
||||||
$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.1.0',
|
'version' => '1.2.0',
|
||||||
'descriptionmsg' => 'linktitles-desc'
|
'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
|
LinkTitles 1.1.0: 2012-05-24
|
||||||
* No longer parses urls and email addresses.
|
* 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
|
LinkTitles 0.0.1: 2012-05-20
|
||||||
* Initial release.
|
* Initial release.
|
||||||
|
|
||||||
|
# vim: flp=\*\s
|
||||||
|
Reference in New Issue
Block a user