Extension talk:FileProtocolLinks

From mediawiki.org
Latest comment: 9 years ago by Theschles in topic Feature Requests
The following discussion has been transferred from Meta-Wiki.
Any user names refer to users of that site, who are not necessarily users of MediaWiki.org (even if they share the same username).

2007[edit]

Annotations[edit]

Hello Edmund, very nice extension! But I have 2 annotations:

  1. The LocalLink-Addon is a very good answer to the problems with firefox.
  2. Is it really necessary to use the "htmlentities"-Command? I don't have any problems yet without the command. Maybe it is really necessary for $uri. I don't know. But $linktext is only normal text for the wiki. I can't find any reason why this must be converted.

--FreddyRincon 4 July 2007

Function for using MediaWiki-variables in the file-path[edit]

I wrote a function that gives you the possibility to use MediaWiki-variables in the file-path of this extension.

For example you can do something like this:

  • <file>{{SERVERPATH}}/subdirname/{{OTHERVAR}}/filename|nice name</file>

You only have to put the function at the end of FileProtocolLinks-extension and replace the line

  • $uri = htmlentities($exploded[0]);

with

  • $uri = getUriWithVarContent(htmlentities($exploded[0]));

(Annotation: Like I said above, I think the "htmlentities"-command isn't necessary ;-))

And this is the function:

// Change varnames with their content
function getUriWithVarContent($originalUri)
{
	// split into varname with '}}' and other stuff
	// ************************************
	//	example:
	//	$originalUri = '{{myNamespace:MyVar1}}Folder/{{myVar2}}.doc'
	// 	$vars[0]= ''
	//	$vars[1] = 'myNamespace:MyVar1}}Folder/'
	//	$vars[2] = 'myVar2}}.doc'
	$parts = explode('{{', $originalUri);
	
	// extract varnames
	// ***************
	foreach ($parts as $part)
	{
		$innerParts = explode('}}', $part);
		if ($innerParts[0] != '')
		{
			$vars[] = $innerParts[0];
		}
	}
	
	// extract namespaces and titles
	// *************************
	foreach ($vars as $var)
	{
		$varParts = explode(':', $var);
		if (count($varParts) > 1)
		{
			$namespace[] = $varParts[0];
			$title[] = $varParts[1];
		}
		else
		{
			$namespace[] = NS_TEMPLATE;
			$title[] = $varParts[0];
		}
	}
	
	// get the var-content and build newUri
	// *******************************
	$newUri = $originalUri;
	$counter = 0;
	foreach ($vars as $var)
	{
		$article = new Article(Title::newFromText($title[$counter], $namespace[$counter]));
		$content = $article->getContent();
		$newUri = str_replace('{{'.$var.'}}', $content, $newUri);
		$counter++;
		print $uri;
	}
	
	return ($newUri);
}

--FreddyRincon 16:09, 6 July 2007 (UTC)Reply

2008[edit]

Feature request: Info button[edit]

I'd love to have a little symbol at the end of the link that allows me to inform users, what they have to do, in ordner to be able to open them. Is this doable? Regards, --Flominator 13:45, 5 June 2008 (UTC)Reply

Yes, it is. But not by me at this time. Sorry! You are free to do it yourself. Simply change the following html-code according to your needs: '<a style="color:green" href="file:///%s">%s</a>' --Edmund Mielach 14:39, 5 June 2008 (UTC)Reply
Thanks. That's exactly the thing I wanted to know :) --Flominator 18:31, 19 June 2008 (UTC)Reply

Need Help to Get it to Work, Please[edit]

I've installed XAMPP and MediaWiki on my work laptop to try to organize information and files. I have installed this Extension and I cannot get it to work. I don't why. I added the line to LocalSettings, and added the file to the extensions directory. The <file>...</file> link shows up in green, but when I click it nothing happens. No click sound or anything. I've tried opening it in another tab and another window, and I've used both IE 7 and Firefox 3. I would really REALLY appreciate any help you all can provide. I think this is the panacea I've been looking for so I'm very excited to get it working. As you can probably tell from this comment I'm quite the Wiki Newbie.  :) Thanks for your help! -Matt 28 July 2008

see Extension:FileProtocolLinks#Limitations --Flominator 07:44, 28 July 2008 (UTC)Reply
Flominator, your heart is in the right place, but those limitations have to do with Mozilla products not IE 7. I understand that Firefox adds an extra "/" for some reason. However, the reason it doesn't work with IE is unclear. --42.3.7.254 09:09, 9 May 2012 (UTC)Reply
I've got the same configuration. For FF I installed the IETab extension. Open local wiki, switch the rendering engine to IE and it works fine.--TotalBalance 00:35, 25 September 2008 (UTC)Reply

Bug in MediaWiki variables[edit]

Hi,

if a MedaWiki variable includes a space, the link breaks. Can easily be tested with {{PAGENAME}} Instead of the page name, this is included in the link:

<div class='noarticletext'><p>(Diese Seite enthält momentan noch keinen Text)</p></div>

Can anyone fix this? -Bernhard

Template Example Does Not Work[edit]

The suggested template code

link to local file from C:/Directory1/Directory2: <file>C:/Directory1/Directory2/{{{file}}}|{{{txt}}</file>

does not work in MediaWiki latest 1.13. The reason can be found in the MediaWiki Manual:Tag extensions.

A partly working code would be:

link to local file from C:/Directory1/Directory2: {{#tag:file|C:/Directory1/Directory2/{{{file}}} }}

But actually, the alternative text will never be displayed... --Uwe Mönks 14:07, 10 February 2009 (CET)

Problem if I use it with FCK editor[edit]

If I make the link in the wiki language context, he is deleting out the file out of <file> --90.152.168.13 18:26, 1 April 2009 (UTC) gregorReply

test if file exists ?[edit]

Any way to make it test if the file exists and display an alternative link if not ?

Thanks!

--Goulu 10:34, 15 February 2011 (UTC)Reply

Missing Download link[edit]

Where from can I get this extension? There is no link at [[1]]

Thanks!

Anyone???

-- SourceCode is inside of the article itself. 5. Sourcecode

Feature request: Link to paths[edit]

It would be nice to be able to link to network paths also.

unix[edit]

Does this extension also work with unix?

Thanks

2014[edit]

Feature Requests[edit]

Open in New Tab (that actually works)[edit]

Greetings Edmund,

We just installed the FileProtocolLinks extension in our MediaWiki installation. It’s quite useful.

Would you have a moment to add in one feature? I’d like to be able to right-click on a file link and open it in a new tab. If I do that now in Chrome in Windows 7 -- with the Chrome LocalLinks extension activated -- the opened tab just shows “about:blank”.

Thanks for your help! --Theschles (talk) 20:34, 2 October 2014 (UTC)Reply

2015 Extension to make it work on linux/mac[edit]

Hi and nice work! I wrote an extension that works as a complement to this one and make it works on linux/mac. it's more or less a rewriting of Extension:FileProtocolLinksSMB and Extension:SmbLinks. I was wondering if we couldn't merge my extension into yours? Have look here Extension:FileProtocolLinksLinux

Security Risks[edit]

Hi - could you please highlight potential security risks on running this on an internal intranet. I am concerned about particular file types - is it possible to limit this by file type?