GithubHelp home page GithubHelp logo

gerhobbelt / mootools-filemanager Goto Github PK

View Code? Open in Web Editor NEW

This project forked from cpojer/mootools-filemanager

4.0 1.0 1.0 15.95 MB

A filemanager for the web based on MooTools that allows you to (pre)view, upload and modify files and folders via the browser.

Home Page: http://cpojer.net/blog/MooTools_based_FileManager

License: Other

PHP 67.27% JavaScript 32.73%

mootools-filemanager's Introduction

MooTools FileManager

A filemanager for the web based on MooTools that allows you to (pre)view, upload and modify files and folders via your browser.

Screenshot

Authors

Features

  • Browse through Files and Folders on your Server
  • Rename, Delete, Move (Drag&Drop), Copy (Drag + hold CTRL) and Download Files
  • View detailed Previews of Images, Text-Files, Compressed-Files or Audio Content
  • Nice User Interface ;)
  • Upload Files via FancyUpload (integrated Feature)
  • Option to automatically resize big Images when uploading
  • Use it to select a File anywhere you need to specify one inside your Application's Backend
  • Use as a FileManager in TinyMCE, Xinha or CKEditor
  • Provides your client with the most possible convenience
  • Create galleries using the Gallery-Plugin
  • History and state management
  • Backend PHP support for mod_alias/mod_vhost_alias/otherwise nonlinear mapped filesystems
  • Auto-adjusts directory views, balancing performance and the amount of data shown, ensuring optimum user experience

Issues

  • sometimes "illegal character (Error #2038) mootools-core-1.3.js (line 5015)" when uploading multiple files

How to use

Demos

  • Open the "Demos/" folder and have fun

Installation

  • First you need to include the follwing scripts

    • Source/FileManager.js
    • Source/Uploader/Fx.ProgressBar.js
    • Source/Uploader/Swiff.Uploader.js
    • Source/Uploader.js
    • Source/Gallery.js (if you want to create a gallery, see example in the Demos/index.html)
    • Language/Language.en.js (or the language(s) do you need)
  • Then you need to modify the "Demos/manager.php" or "Demos/selectImage.php" to set up your upload folder etc

  • See the "Demos/index.html" for examples, but basically you need to do the following:

    var myFileManager = new FileManager({
      url: 'path/to/the/manager.php',
      assetBasePath: '../Assets'
    });
    myFileManager.show();
    

Configurable Options

Options

  • url: (string) The base url to a file with an instance of the FileManager php class (FileManager.php), without QueryString
  • assetBasePath: (string) The path to all images and swf files used by the filemanager
  • directory: (string, relative to the directory set in to the filemanager php class) Can be used to load a subfolder instead of the base folder
  • language: (string, defaults to en) The language used for the FileManager
  • selectable: (boolean, defaults to false) If true, provides a button to select a file
  • destroy: (boolean, defaults to false) Whether to allow deletion of files or not
  • rename: (boolean, defaults to false) Whether to allow renaming of files or not
  • move_or_copy: (boolean, defaults to false) Whether to allow moving or copying files to other directories (parent directory or subdirectories)
  • download: (boolean, defaults to false) Whether to allow downloading of files or not
  • createFolders: (boolean, defaults to false) Whether to allow creation of folders or not
  • filter: (string) If specified, it reduces the shown and upload-able filetypes to these mimetypes. possible options are
    • image: *.jpg; *.jpeg; *.bmp; *.gif; *.png
    • video: *.avi; *.flv; *.fli; *.movie; *.mpe; *.qt; *.viv; *.mkv; *.vivo; *.mov; *.mpeg; *.mpg; *.wmv; *.mp4
    • audio: *.aif; *.aifc; *.aiff; *.aif; *.au; *.mka; *.kar; *.mid; *.midi; *.mp2; *.mp3; *.mpga; *.ra; *.ram; *.rm; *.rpm; *.snd; *.wav; *.tsi
    • text: *.txt; *.rtf; *.rtx; *.html; *.htm; *.css; *.as; *.xml; *.tpl
    • application: *.ai; *.bin; *.ccad; *.class; *.cpt; *.dir; *.dms; *.drw; *.doc; *.dvi; *.dwg; *.eps; *.exe; *.gtar; *.gz; *.js; *.latex; *.lnk; *.lnk; *.oda; *.odt; *.ods; *.odp; *.odg; *.odc; *.odf; *.odb; *.odi; *.odm; *.ott; *.ots; *.otp; *.otg; *.pdf; *.php; *.pot; *.pps; *.ppt; *.ppz; *.pre; *.ps; *.rar; *.set; *.sh; *.skd; *.skm; *.smi; *.smil; *.spl; *.src; *.stl; *.swf; *.tar; *.tex; *.texi; *.texinfo; *.tsp; *.unv; *.vcd; *.vda; *.xlc; *.xll; *.xlm; *.xls; *.xlw; *.zip;
  • hideClose: (boolean, defaults to false) Whether to hide the close button in the right corner
  • hideOnClick: (boolean, defaults to false) When true, hides the FileManager when the area outside of it is clicked
  • hideOnSelect: (boolean, defaults to true) If set to false, it leavers the FM open after you've clicked the select button, allowing for faster interaction when selecting multiple images.
  • hideOverlay: (boolean, defaults to false) When true, hides the background overlay
  • hideQonDelete: (boolean, defaults to false) When true, hides the Dialog asking 'are you sure' when you have clicked on any 'delete file/directory' button
  • zIndex: (integer, defaults to 1000) The z-index at which the file manager will be placed (CSS attribute). The overlay will be placed at (zIndex - 1), the highest used z-index offset is (zIndex + 3000)
  • styles: (object, defaults to {}) Extra styles which will be assigned to the file manager
  • listPaginationSize: (integer, defaults to 100) When non-zero, add pagination, i.e. split the view of huge directories into pages of N items each (this speeds up rendering and interaction)
  • listPaginationAvgWaitTime: (integer, defaults to 2000) When non-zero, enable adaptive pagination: strive to, on average, not to spend more than this number of milliseconds on rendering a directory view. This is a great help to adapt the view to match the power of your clients' machines.
  • propagateData: (object, defaults to empty) Specify extra elements, all of which will be sent with every request to the backend
  • verbose: (boolean, defaults to false) Whether the MTFM script should log developer info to the console
  • standalone: (boolean, defaults to true) If set to false, returns the Filemanager without enclosing window / overlay.
  • parentContainer: (string, defaults to null) ID of the parent container. If not set, FM will consider its first container parent for fitSizes()
  • thumbSize4DirGallery: (integer, defaults to 120) The thumbnail image size in pixels of any thumbnails shown in the directory gallery view (detail pane, i.e. right panel); you can reduce network traffic quite a bit by picking '48' as the thumbnail size as the file manager will pick the small (48) or large (250) thumbnails produced by the backend, depending on this configured size.
  • mkServerRequestURL: (function, defaults to null) specify your own alternative URL/POST data constructor when you use a framework/system which requires such. function(object: fm_obj, string: request_code, assoc.array: post_data)

Options if Uploader is included

  • upload: (boolean, defaults to true)
  • uploadAuthData: DEPRECATED: anything you'd place here goes into 'propagateData' now! (object, defaults to empty) Extra data to be send with the GET-Request of an Upload as Flash ignores authenticated clients
  • resizeImages: (boolean, defaults to true) Whether to show the option to resize big images or not
  • uploadTimeLimit: (integer, defaults to 260) The maximum number of seconds any single upload may take. This is forwarded to the Swiff.Uploader as the 'timeLimit' setting.
  • uploadFileSizeMax: (integer, defaults to 2600 * 2600 * 25) The maximum number of bytes any single upload can be. This is forwarded to the Swiff.Uploader as the 'fileSizeMax' setting. Note that the backend option 'maxUploadSize' is the decisive factor; this is merely a user assist value.

Events

  • onComplete(path, file, fm_obj): fired when a file gets selected via the "Select file" button. Note that 'path' is already HTML encoded for direct use in tags, etc., while the file object contains all available metadata including references to and sizes of both thumbnail sizes produced by the backend.
  • onModify(file, json, mode, fm_obj): fired when a file gets renamed/deleted or modified in another way. 'mode' tells you which of these fired the event: mode = 'destroy', 'rename', 'move' or 'copy'.
  • onShow(fm_obj): fired when the FileManager opens
  • onHide(fm_obj): event fired when FileManager closes
  • onPreview(src, fm_obj, img_el): event fired when the user clicks an image in the preview
  • onHidePreview(fm_obj): event fired before a displayed detail view ('preview') is erased, to be replaced by another one
  • onDetails(json, fm_obj): event fired when an item is picked form the files list, supplies object (e.g. {width: 123, height:456} )
  • onHidePreview(): event fired when the preview is hidden (e.g. when uploading)
  • onScroll(e, fm_obj): event fired before the file manager is resized/repositioned following a mouse scroll or viewport resize event

Backend

  • See Assets/Connector/FileManager.php and Assets/Connector/FileManagerWithAliasSupport.php for all available server-side options

  • Note that you can configure these items by changing the related PHP define:

    • MTFM_THUMBNAIL_JPEG_QUALITY (default: 80) the jpeg quality for the largest thumbnails (smaller ones are automatically done at increasingly higher quality to ensure they look good)

    • MTFM_NUMBER_OF_DIRLEVELS_FOR_CACHE (default: 1) the number of directory levels in the thumbnail cache; set to 2 when you expect to handle huge image collections. Note that each directory level distributes the files evenly across 256 directories; hence, you may set this level count to 2 when you expect to handle more than 32K images in total -- as each image will have two thumbnails: a 48px small one and a 250px large one.

Custom Authentication and Authorization

  • As Flash and therefore the Uploader ignores authenticated clients[*] you need to specify your own authentication / session initialization. This is taken care of by FileManager itself, so you don't need to bother, except provide a tiny bit of custom code in the "UploadIsAuthorized_cb" callback function on the serverside, manually initializing and starting your session-based authentication.

    [*] More specifically: Flash does not pass along any cookies of itself, hence the FileManager will place the cookies in the GET URI query section for extraction by the server.

  • You may pass along additional (key, value) elements to the server during upload by adding those items in the 'uploadAuthData' options' section. These will all be passed along in the GET URL query section.

  • Any (key, value) elements included in the "propagateData" options' section are sent to the server as part of every request URI (action) and will show up in the $_GET[] array, where you can extract them.

  • FM now provides a server-side callback hook for each request so you can apply your own business logic to determine if a given (file or directory, user context) mix is indeed permitted to be viewed / detailed / thumbnailed / uploaded / created / deleted / moved / renamed / copied / downloaded.

    These hooks can be configured as part of the server-side options for the Backend/FileManager instance. For more info and a sample see the Demos/manager.php and Demos/selectImage.php files.

    Server-side authorization hooks:

    • UploadIsAuthorized_cb
    • DownloadIsAuthorized_cb
    • CreateIsAuthorized_cb
    • DestroyIsAuthorized_cb
    • MoveIsAuthorized_cb
    • ViewIsAuthorized_cb
    • DetailIsAuthorized_cb

    You can also tweak/edit the already decoded request parameters in these callbacks: the backend will pick up on those changes and act accordingly. (This is for advanced usage needs.)

Credits

Loosely based on a Script by Yannick Croissant

mootools-filemanager's People

Contributors

alxrocha avatar cpojer avatar frozeman avatar gerhobbelt avatar partikule avatar sleemanj avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

ionize

mootools-filemanager's Issues

reopen gallery after 'save gallery' b0rks

in two ways:

the absolute paths produced by the latest MTFM are NOT correctly parsed by populate()

and

populate() seems to APPEND the loaded set as the original set is NOT discarded from the gallery pane (doubling the gallery set in there)

Keyboard Event on FF 4 Mac

In FF 4 (macOS X), pressing Shift+; (to get a point on a french keyboard) gives : keyboardInput key press: delete

With use of FMgr4Alias, $this->options['directory'] is allways null

Use of FMgr4Alias gives this error :

There was no file specified or the file does not exist. (path = /)

My config :

The error is throwed by _onView().

After a check :

  • The $dir value returned by $dir = $this->legal_url_path2file_path($legal_url) is always false,
  • When creating a new FileManagerWithAliasSupport() with the directory option set, this option is never takken in account,
  • Sending the directory option through JS with new Filemanager works not better,

I tried with :

My config :

The onThumbnail() method should receive data as POST or through URL, but like this :

I maintain that MTFM shouldn't act like a controller :-)

Since MTFM is calculating URLs, it becames an URLs builder machine :-D
Where is the simple FM, easy to install ???? come back please ! :-)

demo:gallery: make sure the dragged images are thumbnails and proper ratio!

now all images are resized, using the full image and neglecting the WxH ratio as well, producing some truly odd looking results.

Note that the gallery zooms the image smoothly when entering a caption to W=200,H=150, so the thumbnail should accommodate that; probably best to use the 250px thumb for this (a little scaling doesn't hurt and the 250px images are way smaller than the originals so load times stay really low)

thumbnails are not resized and shown

the thumbnails are not shown for me. is there anything wrong? or must it now be activated?

also when i use you modified Image.class.php, i sometimes cant resize images, but with my old one it worked.

it throws n exception, that the file is not an image ?

fabian

the chmod option is not applied to the thumbnails folder and subfolders?

the chmod option should be applied to all folders and files created by the fm, otherwiese you have the problem the manually remove folders which are created by the fm, when having permission restrictions and no fm anymore (spercially the thumbnails folder is then imporssible to remove, beacuse the fm will create always a new one when you open it :-)

Suggestion about documentRootPath & directory ...

Let's take concreet example to illustrate the problem :

Case 1 :
Web site's URL : http://www.mydomain.com
Web site's root dir : /Users/mydomain/
MTFM File's root dir : /Users/mydomain/files/

Filemanager option array :
'documentRootPath' => null,
'directory' => 'files'

Result : Everything's fine : documentRootPath and directory is well calculated by the Filemanager

Case 2 :
Web site's URL : http://mysubdomain.mydomain.com
Web site's root dir : /Users/mydomain/mysubdomain/
MTFM File's root dir : /Users/mydomain/mysubdomain/files/

Filemanager option array :
'documentRootPath' => null,
'directory' => 'files'

Result Not good : documentRootPath : /Users/mydomain/files/

Case 3 (should be the default behavior) :
Web site's URL : http://www.mydomain.com
Web site's root dir : /Users/mydomain/
MTFM File's root dir : /Users/mydomain/files/

Filemanager option array :
'documentRootPath' => '/Users/mydomain/',
'directory' => 'files'

Result Not good : documentRootPath : /Users/mydomain/Users/mydomain/files/

Suggestion :
In the current behavior, the Filemanager lib calculates too much the root path and the base URL of files.
Only 1 base URL and 1 basepath should be send to the FM at initialization, so the FM work with them and doesn't need to try to found the base URL / PATH :

Example :
$param = array(
basePath => '/Users/mydomain/',
baseURL => 'http://www.mydomain.com/',
directory => 'files/'
);

Simple and efficient.

Meta data cache issues...

Issue 1 : Upload
After upload, meta data showed for one file are the original picture's one, even the picture was resized.

Issue 2 : Delete
After delete, the thumb stay visible in the preview thumb list until we change folder and come back.

jsGET issue? walk around dirtree with lots of spaces, etc. in dir & filenames and # will carry cruft

After browsing through a image collection with directories and filenames which have spaces in them, and a few other non-alpha ASCII characters (not sure this is purely due to the WS in there), the #fm.... bookmark-based storage (jsGET?) gets crufty: it still works well, but among the 'correct' entries, there's a lot of garbage gathering, making the #.... section HUGE after a while and no way to clean up.

The suspect here is jsGET, but that's a hunch. It DOES have real trouble with filenames which carry a # themselves, as the filenames, etc. are stored unencoded and a browser will (FF3 at least) will strip anything beyond the second #, or so it seems.

get diagnostics error in subfolders

still get the diagnostic error in subfolders

Diagnostics

Could not open "D:\Creative\Server\htdocs_feindura_upload\test." (does not exist, or is not a file)
error.0 Could not open "D:\Creative\Server\htdocs_feindura_upload\test." (does not exist, or is not a file)
mime type text/directory
cache hash 353354520e4a0c2ae722390a0e9dc46c
cache file D:/Creative/Server/htdocs/_feindura/_upload/thumbnails/a8/3688_36885a663a16c2b5c62e10ab23f6de-info.nfo
cache dir D:/Creative/Server/htdocs/_feindura/_upload/thumbnails/a8/

IE6 is completely buggered

overflow FAIL:
filenames are not clipped at right edge
filenames wrap to the next line --> filenames may overlap if short one follows a long one
view list is not clipped at top and bottom

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.