Extension:Imagetabs

From MediaWiki.org

Jump to: navigation, search
Manual on MediaWiki Extensions
List of MediaWiki Extensions
Imagetabs

Release status: beta

Implementation User interface
Description An extension that shows interwiki tabs above Image: pages
Author(s) Joe Beaudoin Jr. and Roan Kattouw
Version 1.0 (August 31, 2007)
MediaWiki 1.10 and higher
Download imagetabs.php
README
CHANGELOG
Parameters $wgEnableInterwikiImageTabs, $wgInterwikiImageTabs
Hooks used

SkinTemplateContentActions

Contents

[edit] What can this extension do?

When you use one wiki as an image repository for multiple wikis (through shared uploads), it's hard to find out where a specific image is used, as you have to check it at all wikis. Imagetabs is an extension that makes this easier by adding interwiki tabs above Image: pages.

[edit] Installation

Just download imagetabs.php through the download link in the infobox on the right and move it to the /extensions/imagetabs/ directory. See also the README file.

[edit] Parameters

  • $wgEnableInterwikiImageTabs: if set to true, Imagetabs is enabled, if set to false, it's disabled.
  • $wgInterwikiImageTabs: An associative array with the keys representing interwiki prefixes, and the values being the tabs' captions. For a more detailed explanation, see the README.

[edit] Changes to LocalSettings.php

require_once("$IP/extensions/Imagetabs/imagetabs.php");
$wgEnableInterwikiImageTabs = true;
$wgInterwikiImageTabs = array(
        'prefix1' => 'caption1',
        'prefix2' => 'caption2',
        'prefix3' => 'caption3'
);

[edit] Code

[edit] imagetabs.php

<?php
/**
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * @author Roan Kattouw <roan.kattouw@home.nl>
 * @copyright Copyright (C) 2007 Roan Kattouw 
 * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License
 *
 * An extension that shows interwiki tabs above Image: pages
 * Original code by Joe Beaudoin Jr. from www.battlestarwiki.org (joe(AT)frakmedia(DOT)net)
 * Modified for more generic usage by Roan Kattouw (AKA Catrope) (roan(DOT)kattouw(AT)home(DOT)nl)
 * For information how to install and use this extension, see the README file.
 *
 */
 
$wgExtensionFunctions[] = 'createImageTabs_setup';
$wgExtensionCredits['other'][] = array(
        'name' => 'Imagetabs',
        'author' => 'Joe Beaudoin Jr. and Roan Kattouw',
        'description' => 'Adds tabs with interwiki links above Image: pages',
        'version' => '1.0',
        'url' => 'http://www.mediawiki.org/wiki/Extension:Imagetabs'
);
 
function createImageTabs_setup()
{
        global $wgHooks;
        $wgHooks['SkinTemplateContentActions'][] = 'createImageTabs_hook';
}
 
function createImageTabs_hook(&$content_actions)
{
        global $wgEnableInterwikiImageTabs, $wgInterwikiImageTabs, $wgTitle, $wgLocalInterwiki;
        if($wgEnableInterwikiImageTabs && $wgTitle->getNamespace() == NS_IMAGE)
        {
                $i = 0;
                foreach($wgInterwikiImageTabs as $prefix => $caption)
                {
                        // Go to prefix:Image:title. Image: is automatically translated if necessary.
                        $titleObj = Title::newFromText($prefix . ":Image:" . $wgTitle->getText());
                        // Check that we don't link to ourselves
                        if($titleObj->getInterwiki() != $wgLocalInterwiki && $titleObj->getFullURL() != $wgTitle->getFullURL())
                                $content_actions['interwikitab-'.$i++] = array(
                                        'class' => false,
                                        'text' => $caption,
                                        'href' => $titleObj->getFullURL()
                                );
                }
        }
        return true;
}
Personal tools