Commit Graph

66 Commits

Author SHA1 Message Date
0ced2cff44 Do not re-link links inside curly braces. 2014-08-29 14:16:46 +02:00
cfeafc7751 Prevent linking inside multiline templates. 2014-08-29 12:13:38 +02:00
3c930eb90a Do not touch piped links in template parameters. 2014-08-29 07:57:30 +02:00
2915c6c798 Fix region exclusion with multiple lines.
Added the 's' modifier so that the regex that detects not-to-be-linked
regions that span several lines (e.g., multiline <pre></pre> section).
2014-08-28 16:07:36 +02:00
c800862990 Fix word detection with non-ASCII characters.
Use the unicode character property \pL together with look-behind and
look-ahead assertions rather than '\b' escape sequences (which do not work
with non-ASCII characters).
2014-08-28 15:57:49 +02:00
b722774f68 Fix return value if __NOAUTOLINKS__ is present. 2014-06-11 17:10:02 +02:00
dd34719f0d Fix page black list. 2014-06-11 16:55:25 +02:00
284b0695fe Implement InternalParseBeforeLinks hook.
This replaces the ArticleAfterFetchContent hook and enables the extension to
parse output produced by templates for links.
2014-06-11 12:00:06 +02:00
35d1b57f38 Change signature of parseContent function.
To be able to use the InternalParseBeforeLinks hook (to be implemented), a
different signature was needed. This entailed subsequent changes to calling
functions.
2014-06-11 08:02:50 +02:00
600b545477 Use typed parameters in functions. 2014-06-11 06:17:48 +02:00
d4923fb9f7 Change names of private static variables. 2014-06-10 19:06:37 +02:00
eef4e793e7 Use GetDoubleUnderscoreIDs hook to remove magic words.
Prevously, the magic words were removed by hooking onto ParserBeforeTidy.
Since the Parser class provides its own mechanism for removing magic words
that are surrounded by double underscores, we now use this (undocumented)
hook.
2014-06-10 19:04:27 +02:00
5fcf92861f Make compatible with PHP 5.3 again.
The anonymous callback functions that were handed over to
preg_replace_callback called private static methods of the LinkTitles class,
which worked fine with PHP 5.5.9, but not with PHP 5.3.3.

The functions were not turned (back) into static methods, and the callback
is given in the array form, as described in the PHP documentation.
2014-06-10 18:54:46 +02:00
1cafdc4b1a Use WikiPage::doQuickEditContent for speed up batch.
WikiPage::doEditContent was extremely slow, because it updated link tables
etc. For batch processing, we now use WikiPage::doQuickEditContent, which is
considerably faster.
2014-06-10 16:45:23 +02:00
d7571c4922 Use preg_replace_callback throughout; lazy checks.
The checks for whether a page is a potential link target or not (depending
on the absence of the __NOAUTOLINKTARGET__ magic word and if it is not a
redirect to the current page) have now been moved into the callback
functions, so that they are only performed if a page really is a candidate
for linking (i.e, its title occurs on the currently edited page).

The change resulted in a ~10-fold increase in speed.
2014-06-10 16:22:28 +02:00
4ca1225fd0 Fix saving of modified content.
A bug caused text to be saved only if links were added by smart mode
algorithm, not by normal algorithm.
2014-06-10 13:56:40 +02:00
34720765da Implement config for check-redirect and magic word.
Added two new configuration variables, $wgLinkTitlesCheckRedirect and
$wgLinkTitlesEnableNoTargetMagicWord, that can be used to increase
performance. If both are overridden to be false, the target page content
will not be fetched from the database to check for redirect or the
occurrence of a magic word, which saves a lot of time.
2014-06-10 13:41:35 +02:00
5842430021 Check if content was modified before committing. 2014-06-10 11:55:55 +02:00
e5008b9997 Use ArticleAfterFetchContentObject hook.
No longer use deprecated ArticleAfterFetchContent hook. The new hook
requires MediaWiki 1.21 or later.
2014-06-08 22:52:36 +02:00
adbc1ea5cd Use PageContentSave rather than ArticleSave hook.
This commit also contains some refactoring which should lend itself to
increased performance.
2014-06-08 19:21:41 +02:00
1542901551 Complete documentation of source code. 2014-06-05 22:41:09 +02:00
56dc484949 Remove entry point warning from body file. 2014-06-03 21:44:47 +02:00
3ea8d9509f Change bot message for batch processing, add user. 2014-06-03 19:16:23 +02:00
b32d48bdc9 Move the page processing function to LinkTitles class.
A public static function was created to DRY things up.
2014-06-03 18:52:04 +02:00
ffb8daa1ad Remove superfluous variable; comment code. 2014-06-03 18:28:25 +02:00
256f905c69 Prevent linking inside attributes etc.
Includes prevention of linking in class and style attributes of WikiTables.
2014-06-02 19:58:01 +02:00
cf792072dd Prevent creating indirect links to self.
Added code to check if a target page redirects to the current page, and
prevents linking to that target page. Note that this does not catch
situations where a page title exists twice, once with first capital letter
and once with first lowercase letter (should happen on test systems only).
2014-06-02 18:55:02 +02:00
821d6d6b34 Prevent parsing in pre, html, and script tags. 2014-06-02 18:26:39 +02:00
3d37b2d8ba Refactor smart mode code for increased performance.
The preg_replace_callback callback functions were removed as static
functions and declared inline; the callback function for $wgCapitalLinks ==
false was simplified to speed up the process.
2014-06-02 18:22:53 +02:00
7cb5b713ab Add __NOAUTOLINKTARGET__ magic word; refactor.
The magic word __NOAUTOLINKTARGET__ will prevent a page from being
automatically linked to.

Some minor refactoring was performed.
2014-06-02 16:25:03 +02:00
2930916ce6 Adjust copyright year. 2014-06-01 18:10:31 +02:00
33a2169301 Fix regular expression.
The regular expression used to split the page content had a few pipe
characters in the wrong places, due to the previous 'cleaning-up' of the
convoluted expression for version 2.3.0.
2013-08-29 19:54:57 +02:00
8257471d89 Prevent linking inside preformatted text and code.
Ignore lines that start with a space as well as text enclosed in <nowiki> or
<code> tags.
2013-08-28 19:40:04 +02:00
ad700ca7f4 Do not mess up page content with leading slashes.
If a page title started with a slash, the algorithm to deal with leading
capitals would produce a faulty regexp by accessing $escapedTitle[0] and
substr($escapedTitle, 1), which would only capture the slash that escapes
the slash.

Also fix small bug in template detection (make expression non-greedy).
2013-08-27 20:55:06 +02:00
9d414d0e5e Prevent crashes due to regexp compilation errors
Page titles are now properly escaped using preg_quote() to prevent regexp
compilation errors if the title contains characters with special meanings in
regular expressions.
2013-08-09 17:36:32 +02:00
3bf0ddfe17 Make the SQL query work with sqlite databases.
The fallback query does not use the CHAR_LENGTH function, but uses LENGTH.
2013-07-22 22:00:40 +02:00
53ad020f1d Fix case-sensitive linking when $wgCapitalLinks is false. 2013-04-16 21:48:30 +02:00
aaa89cb536 Fix invalid callback error due to non-static declaration of LinkTitles::removeMagicWord. 2013-03-06 19:02:50 +01:00
ae1f72aefd Do not remove magic word when saving page. 2013-02-23 14:09:33 +01:00
6d38db71af Use MagicWord class to handle the magic word; update copyright year. 2013-02-23 12:38:39 +01:00
a6544b37d9 Add preliminary support for __NOAUTOLINKS__ magic word. 2013-02-20 21:47:23 +01:00
05d77684c2 Introduce smart mode ($wgLinkTitlesSmartmode).
Smart mode generates aliases for page titles if a case mismatch is
detected.
2013-01-29 21:17:21 +01:00
a448b8632b Generate aliases for case-mismatched page titles.
If a page title does has a different case than an occurrence of the same
word(s) on the page that is being edited, the extension will now
automatically generate 'piped' links such as [[Linking titles|Linking
Titles]].
2013-01-26 18:44:45 +01:00
455f333c28 Add option $wgLinkTitlesIgnoreCase to enable case-sensitive linking of page titles. 2013-01-22 16:11:25 +01:00
77c5840199 Fix bug that could prevent linking when $wgLinkTitlesFirstOnly was set to true. 2012-12-31 12:54:15 +01:00
5f82daad6a Added two options to restrict linking to whole words. 2012-12-22 17:15:29 +01:00
a2850bb318 Introduce new option to link only the first occurrence of a title on a page. 2012-12-11 16:37:06 +01:00
55e6f01b5f Add new option to skip parsing of templates. 2012-10-09 19:40:33 +02:00
b704c3187e Fix incorrect handling of PreferShortTitles option. 2012-10-05 18:31:35 +02:00
487b91b016 Fix typo in regexp that prevented proper functioning. 2012-10-05 18:02:16 +02:00