Extension:SmbLinks
|
|
This extension stores its code inside a wiki page. Please be aware that MediaWiki developers do not review or keep track of extensions that put their code on the wiki.
|
|
SmbLinks Release status: beta |
|||
|---|---|---|---|
| Implementation | Hook, Link markup | ||
| Description | convert file:///// links to smb:// and vice versa | ||
| Author(s) | Daniel Schürmann (DaschuerTalk) | ||
| Last version | 0.1 (7.27.2010) | ||
| MediaWiki | 1.14.0+ | ||
| PHP | 5.2 | ||
| License | GPL | ||
| Download | No link | ||
|
|||
|
|||
|
Check usage (experimental) |
|||
Contents |
[edit] What can this extension do?
If you use intewikilinks 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.
[edit] Usage
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]]
[edit] Firefox setup
[edit] MS Windows
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]
[edit] Linux
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
[edit] MAC OS
... TODO ...
[edit] Installation
To install this extension, add the following to LocalSettings.php:
# Disable cache $wgEnableParserCache = false; $wgCachePages = false; require_once("$IP/extensions/SmbLinks.php" );
[edit] Code
<?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; }