Extension talk:FileProtocolLinks
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
editAnnotations
editHello Edmund, very nice extension! But I have 2 annotations:
- The LocalLink-Addon is a very good answer to the problems with firefox.
- 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
- >> It seems to be necessary to avoid an XSS vulnerability. --Edmund Mielach 14:28, 5 June 2008 (UTC)
Function for using MediaWiki-variables in the file-path
editI 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); }
Note that the above conversation may have been edited or added to since the transfer. If in doubt, check the edit history.
2008
editFeature request: Info button
editI'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)
- 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)
- Thanks. That's exactly the thing I wanted to know :) --Flominator 18:31, 19 June 2008 (UTC)
Need Help to Get it to Work, Please
editI'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)
- 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)
- 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)
Bug in MediaWiki variables
editHi,
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
editThe 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
editIf 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) gregor
test if file exists ?
editAny way to make it test if the file exists and display an alternative link if not ?
Thanks!
--Goulu 10:34, 15 February 2011 (UTC)
Missing Download link
editWhere 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
editIt would be nice to be able to link to network paths also.
unix
editDoes this extension also work with unix?
Thanks
2014
editFeature Requests
editOpen in New Tab (that actually works)
editGreetings 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)
2015 Extension to make it work on linux/mac
editHi 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
editHi - 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?