1

Topic: Insert Link with File Manager

I am trying to insert a link into highlighted text by clicking the insert link button, and then the integrated browse button in the pop-up.  Because I am using filemanager, I expected the link to be inserted with the filemanager_insert_template setting I created. Instead the link just inserts normally.

The whole point of the template is to insert links that direct to a php stream file that downloads the selected document, instead of linking directly to the document.  For example http://www.mysite.com/username/dl.php?f … stfile.pdf vs http://www.mysite.com/username/docs/testfile.pdf.  That way I can implement security on the document downloads and deny direct access.  Also please note that the username portion of the url changes based on what user is being edited, so the template needs to be set on the fly when the page is loaded.

If the insert template is not the way to go about this, then what is?  Its a big confusing issue for me and one I need to resolve asap!

Thank you

Last edited by justin916 (2009-10-30 01:43:17)

2

Re: Insert Link with File Manager

The link dialogs can't use the templates since it makes little sense. The template can consist of anything so if there isn't even a anchor element inside it there is nothing to add the link options to. The same goes for the imagemanager template since the template might be a link not a image.

Use the insertimage/insertfile buttons instead to directly insert things using the template.

In your case I would instead use the preview.urlprefix or rewrite the links server side using a simple regexp.

Best regards,
Spocke - Main developer of TinyMCE

3

Re: Insert Link with File Manager

That does make sense on the link button, but what about when you highlight text and select the file manager button? It still doesn't use the template then.  Its very frustrating when you want to prevent direct linking.

I'll try using the preview.urlprefix option (I've found it confusing so far).

Thank you for the quick response!

4

Re: Insert Link with File Manager

I think you need to look at the preview.urlprefix option if you want to force a specific prefix for all link locations. The template feature is not built to force a specific format but rather give the user the ability to use the template format if they like to. It will never work on selections since it can't just grab the HTML and wrap that since it would produce invalid results. For selections your would have to have another type of template format with just attribute values.

Best regards,
Spocke - Main developer of TinyMCE

5

Re: Insert Link with File Manager

I need something similar to this for restricting access to files. I've set 'filesystem.rootpath' to '../../../content' and all works great, but the paths are real and I need to control access thru a script like Justin. FileManager doesn't like using the script in 'filesystem.rootpath'.

Using 'preview.urlsuffix' gets close, but won't work because it appends to the end of the file name, after the root path. It should come in somewhere in the middle of the {host} bit? Also, it seems to me that 'preview.urlsuffix/prefix' only applies to the preview in the file manager functionality and not to the paths that are written to the code?

What's needed is a way to alter the path when the 'insert' link is pressed so that the code that's 'inserted' is changed to a tweaked path i.e. <img src="image.jpg" /> instead of <img src="../content/image.jpg" /> - likewise with links to docs - <a href="doc.pdf">doc.pdf</a> instead of <a href="../content/doc.pdf">doc.pdf</a>. Surely one of those many sexy $mcFileManagerConfig options does this? I haven't been able to find it.

Of course, using a string function on the server to replace '../content/' at the point of saving the content will do this, but it's an ugly option compared MC FileManager's beauty.

6

Re: Insert Link with File Manager

I actually ended up using what I think is a more elegant solution that still allows MC FileManager to work properly.  I used an .htaccess file with Mod_Redirect (apache) to automatically and invisibly rewrite any requests to my documents directory.  So http://www.domain.com/documents/test.doc actually loads http://www.domain.com/dl.php?f=documents/test.doc. 

That allows the dl.php to insure the user is logged in and has permissions to access the file while also allowing MC FileManager to read the links correctly from the admin area.

If you want to use this solution, let me know and I'll send you a copy of my htaccess file (setting it up correctly it was trickier than I expected)

7

Re: Insert Link with File Manager

Check the TinyMCE FAQ for details on how to produce relative urls from a specific point or the MCFileManager documentation it also provides this feature with examples and all.

Best regards,
Spocke - Main developer of TinyMCE

8

Re: Insert Link with File Manager

Hello,

I'm interested in getting a copy of the .htaccess file you described.

Thanks in advance.

Regards,
Martial.

justin916 wrote:

I actually ended up using what I think is a more elegant solution that still allows MC FileManager to work properly.  I used an .htaccess file with Mod_Redirect (apache) to automatically and invisibly rewrite any requests to my documents directory.  ...
That allows the dl.php to insure the user is logged in and has permissions to access the file while also allowing MC FileManager to read the links correctly from the admin area.

If you want to use this solution, let me know and I'll send you a copy of my htaccess file (setting it up correctly it was trickier than I expected)