Extension:FileLink

From MediaWiki.org
Jump to: navigation, search
MediaWiki extensions manual - list
Crystal Clear action run.png
FileLink

Release status: unknown

Implementation Link markup
Description Automates the creation of file:// links prompting user to select a file using a dialog.
Author(s) Assela
Last version 0.2
License GPL
Download [1]

Check usage (experimental)


Automates the creation of file:// links prompting user to select a file using a dialog.

IMPORTANT
This extension is useful only in the context of mediawiki sites within controlled network environments. (e.g. Personal wikis, Intranet wikis, etc.) Even in such cases care should be taken to safeguard the integrity of the wiki.
IMPORTANT
To use with Firefox 3.0, several additional steps are required and a patch is needed. The patch will be uploaded here soon.
PLEASE VISIT
http://assela.pathirana.net/FileLinkExtension FOR UP TO DATE INFORMATION ABOUT THIS EXTENSION (the following has been duplicated from that site on 22/07/07

Contents

[edit] Context and Purpose

When MediaWiki is used as an internal collaborating platform or a Personal Information Management tool, its access is mostly limited to a single computer or a single subnet (shared network environment). In such situations, it is sometimes useful to have the "file://" protocol enabled, so that links to files that can be normally accessed can be made in the documents. MediaWiki FAQ explains how to do this. (Needs to enable the functionality in MediaWiki AND all the client browsers. Once both those changes are made, it is possible to make links like

[[file://data6/manual.pdf]]

in wikitext and clicking on them will open (or download) the respective link. One of the issues in this approach is that the users need to make the

file://

link themselves. This can sometimes be a tedious and error-prone process (particularly in Windows environments). This extensions adds an editor toolbar button that will trigger a file open dialog so that the user can simply select the file to be linked. The extension places the correctly formatted file:// protocol link in the current position of the edit box.

[edit] Warning

Using fileprotocol links, even in a intranet environment can kill the integrity wiki, unless it is very carefully controlled. For example, one should never link files that will be later moved to some other place, or the are not shared (with the same path) among all the client computers.

[edit] How to use

#settings for fileLinkExtension
$wgFilelinkExtensionPath = "extensions/FileLinkExtension";
include("$IP/$wgFilelinkExtensionPath/FileLinkExtension.php");
#end settings for fileLinkExtension

[edit] To be done

  • Consider this as an alpha version. Not tested for many OS/browser environments yet.
  • Conversion of filenames to urls (e.g. escaping the spaces, converting \ to / in windows, etc.) are done in an ad-hoc fashion. Have to find a better way to do this.

[edit] Update

Sometimes the edit button of the extension appear several times on the toolbar. In order to avoid this problem. the following changes were done: Change

 
function addbuttonDo (&$parser, &$text){ 
  global $wgRequest;
  global $wgAddButtonExtensionPath;

to

 
function addbuttonDo (&$parser, &$text){ 
#########new part###########
  static $done=0;
  if ( $done ) { 
    return;
  }
  $done=1;
############################
  global $wgRequest;
  global $wgAddButtonExtensionPath;

Thanks to all who pointed this out by mail (and on the discussion page.)!

[edit] To make buttons appear in 'preview' mode

If you need to have the Filelink extension button in preview mode as well, just do the following mod.

Replace

 
 if(strtolower($action) == "edit" && $wgUser->isAllowed('edit')){

with

 
 if((strtolower($action) == "submit" || strtolower($action) == "edit" )
                                 && $wgUser->isAllowed('edit')){

This is the source I use :

 
$action_preview =  $wgRequest->getVal( 'wpPreview', false );
  //Are we in a edit page AND are we allowed to edit
  if( ((strtolower($action) == "submit" && $action_preview!="")
        || strtolower($action) == "edit" )
      && $wgUser->isAllowed('edit')){

This corrected the fact that when the page is saved, the javascript part of adding the button to the toolbar was added to the page.

[edit] See also

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