Extension:SmbLinks
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 . |
This extension is currently not actively maintained! Although it may still work, any bug reports or feature requests will more than likely be ignored. |
SmbLinks Release status: unmaintained |
|
---|---|
Implementation | Hook , Link markup |
Description | convert file:///// links to smb:// and vice versa |
Author(s) | Daniel Schürmann (Daschuertalk) |
Latest version | 0.1 (2010-07-27) |
MediaWiki | 1.14.0+ |
PHP | 5.2 |
License | GPL |
Download | No link |
require_once( "extensions/SmbLinks.php" ); $wgEnableParserCache = false; $wgCachePages = false; |
|
What can this extension do?Edit
If you use interwikilinks to local Windows shares with this format "file://///windows_share", Linux and Mac users are not able to follow them.
This extension changes the link according to the client OS to "smb://windows_share"
This extension also allowes links to Windows shares with spaces in Path. Spaces must be replaces with %_ in the link. It is a workaround for the %20 problem.
UsageEdit
For Links to your local Windows share you have to add a link to the interwiki Table. e.g.: (windows_share, file://///windows_share/$1, 0, 0
Please refer interwiki.
I have installed the Extension:SpecialInterwiki for that purpose.
A link to your windows shares in Wiki \\windows_share\file.txt will look like:
[[windows_share:file.txt|File]]
Firefox setupEdit
MS WindowsEdit
On MS Windows machines, Firefox need to enable local file links:
- manual: http://kb.mozillazine.org/Links_to_local_pages_do_not_work
- Addon: [1]
LinuxEdit
On Linux macines we have to register smb: protocol handler.
Open "about:config" and add the following settings:
network.protocol-handler.expose.smb = false (Typ: boolean)
network.protocol-handler.external.smb = true (Typ: boolean)
Next time you click an smb: Link firefox ask you for an application.
- For Gnome:
select "/usr/bin/gnome-open". gnome-open does not mount the location. So ensure sat you have opened the window share with nautilus before.
- For KDE:
we have to make a workaround with a script because firefox does not allow do add additional parameters
##!/bin/sh
kfmclient exec $1
Testet with:
- Firefox 3.6.8 on Ubuntu 9.10
- Firefox 3.5.10 on OpenSuse 11.0
MAC OSEdit
... TODO ...
InstallationEdit
To install this extension, add the following to LocalSettings.php :
# Disable cache
$wgEnableParserCache = false;
$wgCachePages = false;
require_once("$IP/extensions/SmbLinks.php" );
CodeEdit
<?php
/**
* Extension:Smblinks - convert file:///// links to smb:// links and vice versa
*
* 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 Daniel Schürmann <daschue@gmx.de>
* @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later
*/
$wgExtensionCredits['other'][] = array(
'path' => __FILE__,
'name' => 'SmbLinks',
'url' => 'http://mediawiki.org/wiki/Extension:SmbLinks',
'description' => 'convert file:///// links to smb:// links and vice versa',
'author' => '[mailto:daschuer@gmx.de Daniel Schürmann]',
);
// Restrict link removal to anons only
$wgRRAnonOnly = false;
// Hook Registering
$wgHooks['LinkEnd'][] = 'fnSmbLinks';
// And the function
function fnSmbLinks( $skin, $target, $options, &$text, &$attribs, &$ret ) {
// Auslesen der Betriebssysteme
$user_agent = $_SERVER['HTTP_USER_AGENT'];
if( strstr($user_agent, "Windows 95")
|| strstr($user_agent, "Windows 98")
|| strstr($user_agent, "NT 4.0")
|| strstr($user_agent, "NT 5.0")
|| strstr($user_agent, "NT 5.1")
|| strstr($user_agent, "Win")
){
$attribs = str_replace("smb://", "file://///", $attribs);
}
elseif( strstr($user_agent, "Linux")
|| strstr($user_agent, "Mac")
){
$attribs = str_replace("file://///", "smb://", $attribs);
}
// elseif( strstr($user_agent, "FreeBSD")
// || strstr($user_agent, "SunOS")
// || strstr($user_agent, "IRIX")
// || strstr($user_agent, "BeOS")
// || strstr($user_agent, "OS/2")
// || strstr($user_agent, "AIX")
// || strstr($user_agent, "Unix")
// ){
// Todo ...
//
// }
// Workaround for locations with spaces (%20)
// Spaces must be replaces with %_
$attribs = str_replace("%25_", "%20", $attribs);
return true;
}