Extension talk:RemoveRedlinks

From MediaWiki.org
Jump to: navigation, search

anyone wanna hack this so it only does it to mainspace articles? :) Wikademia

$wgExtensionCredits['other'][] = array(
        'path'                  => __FILE__,
        'name'                  => 'RemoveRedlinks',
        'url'                   => 'http://mediawiki.org/wiki/Extension:RemoveRedlinks',
        'description'   => 'Removes all redlinks from page output',
        'author'                => '[mailto:innocentkiller@gmail.com Chad Horohoe]',
);

// Restrict link removal to anons only
$wgRRAnonOnly = true;

// Hook Registering
$wgHooks['LinkBegin'][] = 'efRemoveRedlinks';

// And the function
function efRemoveRedlinks( $skin, $target, &$text, &$customAttribs, &$query, &$options, &$ret ) {
        global $wgRRAnonOnly, $wgUser;

        // return possibly if we're not an anon
        if( $wgRRAnonOnly && $wgUser->isLoggedIn() ) {
                return true;
        }
        // return immediately if we know it's real
        if ( in_array( 'known', $options ) ) {
                return true;
        }
        // or if we know it's broken
        if ( in_array( 'broken', $options ) ) {

      $ret = $text;
      if ($target->mNamespace == 10)
      $ret = "";
      //         $text = "";
      return false;

        }
        // hopefully we don't have to do this, but here we'll check for existence.
        // dupes a bit of the logic in Linker::link(), but we have to know here
        if( $target->isKnown() ) {
                return true;
        } else {
                $ret = $text;
                return false;
        }
}

MediaWiki version 1.16. For anonymous users template red links not shows, other links - shows only link text. For registered users all red links will displayed. --Netsu 10:28, 7 December 2011 (UTC)

Personal tools
Namespaces
Variants
Actions
Site
Support
Download
Development
Communication
Print/export
Toolbox