Extension:ExternalLinks

From MediaWiki.org
Jump to navigation Jump to search
MediaWiki extensions manual
Crystal Clear action run.svg
ExternalLinks
Release status: unmaintained
ExternalLinks - screenshot -2.png
Implementation Special page
Description Returns a list of all external links on the wiki
Author(s) Subfader
Latest version 1.1.3 (2016-09-08)
MediaWiki 1.27+ (check)
Database changes no (optional)
License GNU General Public License 2.0
Download See here
Example Screenshots: 1, 2
Translate the ExternalLinks extension if it is available at translatewiki.net
ExternalLinks - screenshot -2.png

The ExternalLinks extension adds [[Special:ExternalLinks]] which lists all external links used on the wiki including dynamic URLs by templates, i.e. all URLs stored in the externallinks table.

The special page lists the pages which use the URL (edit link with preview).

URLs can be filtered with a truncated text string.

URL validation[edit]

The extension also works as link checker by validating the reported URLs.

For each result page you can let PHP check the availability of each URL target by reporting its server response header (requires the $wgELvalidationMode setting, see below).

You could also use a browser plugin like Pinger for Firefox.

Although e-mail addresses cannot be validated too easily, they can be added to the report list.

Installation[edit]

  • Download, extract and place the file(s) in a directory called ExternalLinks in your extensions/ folder.
  • Add the following code at the bottom of your LocalSettings.php:
    require_once "$IP/extensions/ExternalLinks/ExternalLinks.php";
    
  • Configure as required.
  • Yes Done – Navigate to Special:Version on your wiki to verify that the extension is successfully installed.

Configuration[edit]

$wgELuserRight
Override the default user right "edit" which is required to view the page.
$wgELtableClass
Add class names to the result table.
$wgELpageLinkClass
Add class names to the page (article) links.
$wgELmaxPerPage
Overrides the default 200 results per page.
$wgELenableSessionStoring
Enables the options
  • Mark all URLs on result pages as "checked today"
  • Last validation older than: X days
Requires a new date row 'el_last_validated' in table 'externallinks' (see #Skip previously checked URLs).
$wgELvalidationMode
Define the validation mode, e.g. $wgELvalidationMode = 'cURL';.
If enabled, this setting will ignore your $wgMiserMode setting and can slow down your server.
Options:
  • "cURL" uses cURL as PHP extension. This validation mode is recommended.
    In phpinfo() "cURL support" should be "enabled".
  • "getHeaders" uses PHP's get_headers() and requires allow_url_fopen = on (security risk!) and only supports the http://-protocol.
    In phpinfo() "allow_url_fopen" should be "on".
$wgELvalidationMaxPerPage
Validating URLs with a $wgELvalidationMode can take very long. If $wgELvalidationMode is set, the default number of results (or $wgELmaxPerPage) is overwritten with a new maximum of 25. Override these 25 with $wgELvalidationMaxPerPage.
$wgELtoolboxLink
Adds a toolbox link in the sidebar to "validate external URLs" used on the current page. The link will appear on non-special pages to users allowed by $wgELuserRight.

Example configuration[edit]

require_once( "$IP/extensions/ExternalLinks/ExternalLinks.php" );
$wgELuserRight = 'delete'; // default: edit
$wgELtableClass = "wikitable sortable alternate"; // default: "wikitable sortable"
$wgELpageLinkClass = "targetBlank";
$wgELmaxPerPage = 100;  // default: 200
$wgELenableSessionStoring = true; // default: false (requires a new date row 'el_last_validated' in table 'externallinks')
$wgELvalidationMode = 'cURL'; // default: none (disabled)
$wgELvalidationMaxPerPage = '50'; // default: 25
$wgELtoolboxLink = true; // default: false

Skip previously checked URLs[edit]

Optional: When you validate URLs you can store the date and skip these URLs next time, e.g. by hiding all URLs which have been validated (and stored) in the past X days.

$wgELenableSessionStoring = true; will add the option Mark all URLs on result pages as "checked today".

To store the date you need to add a new row el_last_validated to the externallinks-table. Run this SQL command:

ALTER TABLE `externallinks` ADD `el_last_validated` DATE NOT NULL

With stored dates you can later use the option Last validation is older than: [___] days

Contribution[edit]

Translations[edit]

Translations can be posted here.

Coding[edit]

Please post if you have a working solution for

  • grouping results of different wiki pages with the same URL (same URLs should only be listed once with a list of the pages they're used on, should also work with $wgELtoolboxLink)
  • a page name filter that excludes pages with a given string (like URL string filter)
  • a namespace selector as on Special:Search
  • validating https-URLs
  • validating flash-URLs (*.swf?foo=bar)
  • removing the toolbox link if the page doesn't use external URLs
This can be tricky since a simple javascript check for a link is not enough. An URL could be used in a templare to produce some content without a link of that URL (varying link, flash content, etc.).

MW version tests[edit]

  • Not working on MW 1.29.1, Warning: Parameter 1 to efExternalLinksToolbox() expected to be a reference, value given in ...wiki\includes\Hooks.php on line 186 --Rob Kam (talk) 23:08, 11 September 2017 (UTC)
  • ExternalLinks 1.1.3 now working on MW 1.27.1 --Subfader (talk) 12:22, 8 September 2016 (UTC)
  • Not working on MW 1.27.1 --Rob Kam (talk) 09:48, 6 September 2016 (UTC)
  • Tested and working on MW 1.23.14 (only missing ExternalLinks-page in SpecialPages, but manually OK) --DikkieDick
  • Tested and working on MW 1.19.2 --Stefahn (talk) 16:32, 25 October 2012 (UTC)
  • Tested and working on MW 1.19.1 --Nrobbins (talk) 19:50, 9 October 2012 (UTC)
  • Tested and working on MW 1.18.1 --Subfader (talk) 21:11, 29 June 2012 (UTC)
  • Tested and working on MW 1.16alpha --Subfader (talk) 21:11, 29 June 2012 (UTC)

Versions[edit]

  • 1.1.2 (2012-11-16) bug fix ($wgELuserRight is now really optional and falls back to 'edit', thanks User:Stefahn)
  • 1.1.1 (2012-10-19) bug fix of 1.1 for MW 1.15 and below
  • 1.1 (2012-10-16) Postgres support (thanks User:Hbswn), $wgELtoolboxLink adds a new toolbox-link to validate all URLs on the current page, i18n improvements
  • 1.0 (2012-07-14) cURL support, $wgELvalidationMaxPerPage, URL exclude input, $wgELenableSessionStoring
  • 0.1 (2012-06-29) Extension added

See also[edit]