Extension:RedLinks
From MediaWiki.org
| This extension stores its source code on a wiki page. Please be aware that this code may be unreviewed or maliciously altered. They may contain security holes, outdated interfaces that are no longer compatible etc. Note: No localisation updates are provided for this extension by translatewiki.net. |
|
RedLinks Release status: unknown |
|
|---|---|
| Implementation | Tag |
| Description | Display a list of red links (links that are not related to an existing page) |
| Author(s) | Luc Brunet (Lcnritalk) |
| License | No license specified |
| Download | No link |
| Check usage and version matrix | |
Contents |
What can this extension do? [edit]
Display a list of red links (links that are not related to an existing page). This is a beta version but seems to work on small wikis.
Usage [edit]
<redlinks v="my legend:" />
Download instructions [edit]
Copy the code below and place it in $IP/extensions/RedLinks/redlinks.php. Note: $IP stands for the root directory of your MediaWiki installation, the same directory that holds LocalSettings.php.
Installation [edit]
To install this extension, add the following to LocalSettings.php:
#add configuration parameters here #setup user rights here require_once("$IP/extensions/RedLinks/redlinks.php");
you must change these values according to your sql server configuration
$wgDBserver = "myserver"; $wgDBname = "my base"; $wgDBuser = "username"; $wgDBpassword = "password";
Code [edit]
Make this code into a redlinks.php file and save the file in $IP/extensions/Redlinks, where $IP is the installation path of MediaWiki.
<?php # Confirm MW environment if (defined('MEDIAWIKI')) { # Credits $wgExtensionCredits['parserhook'][] = array( 'name'=>'RedLinks', 'author'=>'Luc Brunet(luc.brunet at cnri.fr)', 'url'=>'none', 'description'=>'list all the red links', 'version'=>'0.1' ); # Register Extension initializer $wgExtensionFunctions[] = "wfRedLinks"; # Extension initializer function wfRedLinks() { global $wgParser; $wgParser->setHook( "redlinks", "renderRedLinks" ); } /** * Callback function for embedding video. * @param String $input Text between open and close tags - should always be empty or null. * @param Array $params Array of tag attributes. * @param Parser $parser Instance of Parser performing the parse. */ function renderRedLinks( $input, $params, &$parser ) { $v = htmlspecialchars($params['v']); $wgDBserver = "myserver"; $wgDBname = "my base"; $wgDBuser = "username"; $wgDBpassword = "password"; $chandle = mysql_connect($wgDBserver, $wgDBuser, $wgDBpassword) ; mysql_select_db($wgDBname, $chandle); $query1="SELECT pl_title FROM risk_pagelinks WHERE pl_title NOT IN ( SELECT page_title FROM risk_page )"; $result = mysql_query($query1); $rl=""; while ($row = mysql_fetch_array($result, MYSQL_NUM)) { $itm=$row[0]; $rl.= "<a href=index.php?title=$itm target=_blank>$itm</a> "; } mysql_free_result($result); $url = "$v$rl"; return $url; } } # Closing MW Environment wrapper