Support forums : File Manager

Embedded FM in Write Form

This forum is for anything and everything that helps us get a handle on what is wrong with and where we want to go with "file manager".

Moderator: Dracones

Re: Embedded FM in Write Form

Postby Kimberly » Mon Mar 12, 2012 1:21 am

leeturner wrote:
Overall it will be interesting to see where you go with this.

L


I thought if I could get all the bugs worked out, I would load it to a test bed for others to play with.

There is one feature I want to add to the file manager, and that is to the current form as well, and that is the ability to upload a zip archive of files and have the file manager take the name of the zip archive and create a folder on the server in the media folder and extract the files out to that folder. This is not that hard to do; what would needed to be done is to make sure the user has the permissions and such before running the operation.
Kimberly
Dracone
User avatar
 
Posts: 842
Joined: Mon Jul 19, 2010 4:44 pm

Re: Embedded FM in Write Form

Postby leeturner » Mon Mar 12, 2012 1:43 pm

Hi Kimberly

Unfortunately I have never used TinyMCE and as a result I have never touched the code for it. Out of the two of us you are definitely the expert.

Cheers
Lee
leeturner
Dracone
User avatar
 
Posts: 730
Joined: Fri Dec 11, 2009 11:55 am
Location: Brighton, UK

Re: Embedded FM in Write Form

Postby leeturner » Mon Mar 12, 2012 1:46 pm

Kimberly wrote:I thought if I could get all the bugs worked out, I would load it to a test bed for others to play with.

There is one feature I want to add to the file manager, and that is to the current form as well, and that is the ability to upload a zip archive of files and have the file manager take the name of the zip archive and create a folder on the server in the media folder and extract the files out to that folder. This is not that hard to do; what would needed to be done is to make sure the user has the permissions and such before running the operation.


A test bed would be good to look at.

If I were you I would recommend not implementing multiple different things at the same time. Do a branch for your embedded FM code and then submit that. Do the zip file uploading in a different branch. This way makes it easier to test as the changes are smaller and more desecrate. It is also easier to understand the dependancies between the changes.

L
leeturner
Dracone
User avatar
 
Posts: 730
Joined: Fri Dec 11, 2009 11:55 am
Location: Brighton, UK

Re: Embedded FM in Write Form

Postby Kimberly » Tue Mar 13, 2012 4:41 am

I am going to have to relearn how to do the branching thing. I need to get the proggies needed loaded to this hard drive. I had a hard drive problem and basically started over from scratch.
Kimberly
Dracone
User avatar
 
Posts: 842
Joined: Mon Jul 19, 2010 4:44 pm

Re: Embedded FM in Write Form

Postby EdB » Tue Mar 13, 2012 11:10 am

Just now getting ready for work, had a thought on this idea. Personally I'm not into adding FM to the write page because if you don't want immediate access to media when writing it's kinda pointless. I mean, it isn't actually required to write a blog post is what I mean.

Anyway a long time ago I kicked out the idea of a plugin hook that lets an author completely replace the write form. This idea, IMHO, is a great real-world example of when one might want to do that. A plugin that lets each user pick "original" or "with media" write page form :)

On the unzipping into a folder idea, sounds cool but I worry about security issues. Like, we would want to tell what extensions are inside the zip before creating the folder and adding new files else we've lost control over people uploading zips that contain malicious code. Dunno if we can do that though. See what is in it before actually unzipping it. If we can then this would be way cool. Verify that all the files have extensions in the allowed extension list, then do magic stuff.

work. bleh.
EdB
Dracone
User avatar
 
Posts: 2072
Joined: Sun Nov 22, 2009 7:20 am
Location: Maricopa Arizona

Re: Embedded FM in Write Form

Postby Kimberly » Wed Mar 14, 2012 2:28 am

Yes, this idea of embedded FM may not be for all. The way I work when writing this works for me. For others, it may not. My idea is for the FM to be hidden on load and it does not seem to impose much on being able to start writing. The biggest hit I see with the FM is loading the thumbnails. From what I am seeing, it is always loading the thumbnail from the server. I enabled "General Caching"; will that improve that load time of the thumbnails? Seems to help and on a fast connection the load time is really not very much.

One thing that I will often do is upload an image after I start writing an article, a post. The FM in a pop-up worked but I did not like the way the shifting focus from the pop-up, to the main window; losing sight of the FM and then sometimes even accidental clicking files again (no big deal as I could issue a "go back" to the pop-up window and retrieve the previous state of the FM in a pop-up, but could be a big deal for noobs).

This is a project mainly aimed at me since I have no idea how many users would like to have the FM ebedded in the right form, or prefers the current use of the FM in a pop-up when writing posts. If there are enough interested users that say, "hey, I like the idea of an embedded FM in the write form" I don't think it will be very difficult to simply have a switch for users to be able to choose. We would have to do checks in the four or five scripts that supports our use of the FM in a pop-up for the write form to see which to load but I don't think it will be a huge task to do so.

For now, I am just hacking at the code to make things work, like when TinyMCE is active. It would need to be smoothed out for prime time.
Kimberly
Dracone
User avatar
 
Posts: 842
Joined: Mon Jul 19, 2010 4:44 pm

Re: Embedded FM in Write Form

Postby Kimberly » Wed Mar 14, 2012 2:35 am

EdB wrote:
On the unzipping into a folder idea, sounds cool but I worry about security issues. Like, we would want to tell what extensions are inside the zip before creating the folder and adding new files else we've lost control over people uploading zips that contain malicious code. Dunno if we can do that though. See what is in it before actually unzipping it. If we can then this would be way cool. Verify that all the files have extensions in the allowed extension list, then do magic stuff.

work. bleh.


This is a very important aspect. I have just been doing some general reading on the zip features built into PHP and at some code where it has been implemented, the zip file to folder upload. Not sure what checks they did. It should be checked against the file types allowed settings that is already a part of QP. Zip files do contain an index of the files that are inside the archive, so that might be a check that can be made.

My idea on this is for people without FTP access; a good way to do a mass uploading of files. The other way is to do a combination of JQuery and PHP upload; which I have looked at but not understood very well, to have a mass uploader.
Kimberly
Dracone
User avatar
 
Posts: 842
Joined: Mon Jul 19, 2010 4:44 pm

Re: Embedded FM in Write Form

Postby Kimberly » Wed Mar 14, 2012 2:37 am

EdB wrote:
Anyway a long time ago I kicked out the idea of a plugin hook that lets an author completely replace the write form. This idea, IMHO, is a great real-world example of when one might want to do that. A plugin that lets each user pick "original" or "with media" write page form :)

work. bleh.


Yes, I remember that. Need to find the thread where you spoke of this and visit it again.

Edit Found it: viewtopic.php?f=11&t=881&p=5867&hilit=replace+write+form#p5867
Kimberly
Dracone
User avatar
 
Posts: 842
Joined: Mon Jul 19, 2010 4:44 pm

Re: Embedded FM in Write Form

Postby Kimberly » Wed Mar 14, 2012 2:42 am

I now have the embedded file manager (well, the browse part, not the upload part but that should follow soon) working with TinyMCE enabled. I edited the call back in the function.js.

Original code:
Code: Select all
   // First try, if a JavaScript callback is registered to handle this.
   // E.g. the tinymce_plugin uses registers "wrap_selection_for_itemform_post_content"
   //      to replace the (non-)selection
   if( b2evo_Callbacks.trigger_callback( "wrap_selection_for_"+myField.id, hook_params ) )
   {
      return;
   }
   if( window.opener
      && window.opener.b2evo_Callbacks
      && ( typeof window.opener.b2evo_Callbacks != "undefined" ) )
   { // callback in parent document (e.g. "Files" popup)
      if( window.opener.b2evo_Callbacks.trigger_callback( "wrap_selection_for_"+myField.id, hook_params ) )
      {
         return;
      }
   }



My changed code:
Code: Select all
   // First try, if a JavaScript callback is registered to handle this.
   // E.g. the tinymce_plugin uses registers "wrap_selection_for_itemform_post_content"
   //      to replace the (non-)selection
   if( b2evo_Callbacks.trigger_callback( "wrap_selection_for_"+myField.id, hook_params ) )
   {
      return;
   }
   if( parent.b2evo_Callbacks
      && ( typeof parent.b2evo_Callbacks != "undefined" ) )
   { // callback in parent document (e.g. "Files" popup)
      if( parent.b2evo_Callbacks.trigger_callback( "wrap_selection_for_"+myField.id, hook_params ) )
      {
         return;
      }
   }


Let me know if there are problems with what I did.

Edit No changes needed to be done to the upload control, the changes to the call back works for after uploading files as well. One more thing that needs to be done is to clear the selected files after inserting since one can forget to clear the selections and end up adding the same images again.


Edit To clear the selected files after inserting image(s) into the textarea/TinyMCE I wrote a clear function and call it after we call the textarea_wrap_selection()

Code: Select all
   function clear_selected_files()
   {
      elems = document.getElementsByName( 'fm_selected[]' );
      for( i = 0; i < elems.length; i++ )
      {
         elems[i].checked = false;
      }
   }


This just goes through the list, from the first to the last and clears the checkbox. Is there a better way?
Kimberly
Dracone
User avatar
 
Posts: 842
Joined: Mon Jul 19, 2010 4:44 pm

Re: Embedded FM in Write Form

Postby leeturner » Mon Jul 23, 2012 10:31 pm

Kimberly, are you still working on the embedded FM ?

L
leeturner
Dracone
User avatar
 
Posts: 730
Joined: Fri Dec 11, 2009 11:55 am
Location: Brighton, UK

PreviousNext

Return to File Manager

Who is online

Users browsing this forum: No registered users and 1 guest

cron