README.txt 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. IMCE
  2. http://drupal.org/project/imce
  3. ====================================
  4. DESCRIPTION
  5. -----------
  6. IMCE is an image/file uploader and browser that supports personal directories and quota.
  7. IMCE can easily be integrated into any WYSIWYG editor or any web application that needs a file browser.
  8. See INTEGRATION METHODS for more information.
  9. FEATURES
  10. -----------
  11. - Basic file operations: upload, delete
  12. - Image(jpg, png, gif) operations: resize, create thumbnails, preview
  13. - Support for private file system
  14. - Configurable limits for user roles: file size per upload, directory quota, file extensions, and image dimensions
  15. - Personal or shared folders for users
  16. - Permissions per directory
  17. - Ftp-like directory navigation
  18. - File sorting by name, size, dimensions, date
  19. - Tabbed interface for file operations
  20. - Keyboard shortcuts(up, down, insert(or enter), delete, home, end, ctrl+A, R(esize), T(humbnails), U(pload)).
  21. - Built-in support for inline image/file insertion into textareas
  22. - Multiple file selection(using ctrl or shift)
  23. - Ajax file operations
  24. - Themable layout using tpl files
  25. INSTALLATION
  26. -----------
  27. 1) Copy imce directory to your modules directory
  28. 2) Enable the module at module administration page
  29. 3) Create configuration profiles and assign them to user roles at /admin/config/media/imce
  30. 4) Test it at /imce.
  31. 5) See imce-content.tpl.php for some configuration options such as inline previewing.
  32. 6) See INTEGRATION METHODS to make IMCE collaborate with your application if it's not already integrated.
  33. Notes:
  34. - When you configure IMCE for inline image/file insertion into textareas there should appear an IMCE link under each textarea you specified.
  35. - If you are uploading files containing unicode characters, it is strongly recommended to use the transliteration module that sanitizes filenames by converting characters from unicode to us-ascii. http://drupal.org/project/transliteration
  36. - If you are using CCK, you may want to check the File field sources module at http://drupal.org/project/filefield_sources
  37. FREQUENTLY FACED ISSUES
  38. -----------
  39. - Inaccessible/invalid directory or subdirectory:
  40. In some server configurations, manually(ftp or directly) created directories may not be writable by PHP(by IMCE). In this case, you have to set the chmod permissions of the directory to 0777 in order to make it writable by anyone.
  41. You should also make sure that in each configuration profile all of the defined directories are located under drupal's file system path which is usually "files".
  42. And also if "safe mode restriction" is active in your server, don't expect IMCE to run flawlessly.
  43. - Disappearing images after node submission:
  44. Having nothing to do with IMCE, it appeared many times in issue queues. This is an input filtering issue that can be resolved by adding <img> tag into the default input format. Using Full HTML is another solution. See admin/config/content/formats.
  45. - Upload does not work in Opera
  46. Jquery form plugin before version 2.09 has problems with Opera 9.2+. Replace Drupal's misc/jquery.form.js with the one at http://jquery.malsup.com/form/#download
  47. - IMCE may have problem working with Google Analytics and Secure pages modules. Just make sure to add *imce* path to the exceptions list of these modules.
  48. INTEGRATION METHODS
  49. -----------
  50. Here are the applications that already integrated IMCE.
  51. WYSIWYG:
  52. Install http://drupal.org/project/imce_wysiwyg bridge module and enable IMCE as a plug-in in WYSIWYG settings
  53. BUEditor:
  54. IMCE is integrated in image and link dialogs.
  55. (F)CKeditor(without WYSIWYG):
  56. (F)ckeditor profile->File browser settings->IMCE integration
  57. If your application is not one of the above, please keep reading in order to learn how to integrate IMCE.
  58. Let's create a CASE and embody the IMCE integration on it:
  59. - An application named myApp
  60. - Has an url field for file url:
  61. <input type="text" name="urlField" id="urlField">
  62. - Has a browse button with click event(inline or set by jQuery): (This can be a text link or anything that is clickable)
  63. <input type="button" value="Browse" onclick="openFileBrowser()">
  64. Now let's go through the integration methods and define the openFileBrowser function that opens IMCE and makes it fill our url field on file selection.
  65. INTEGRATION BY URL
  66. -----------
  67. When IMCE is opened using an url that contains &app=applicationName|fileProperty1@FieldId1|fileProperty2@FieldId2|...
  68. the specified fields are filled with the specified properties of the selected file.
  69. Available file properties are: url, name, size(formatted), width, height, date(formatted), bytes(integer size in bytes), time(integer date timestamp), id(file id for newly uploaded files, 0 or integer), relpath(rawurlencoded path relative to file directory path.)
  70. In our CASE, we should open IMCE using this URL: /imce?app=myApp|url@urlField which contains our application name and our url field id
  71. function openFileBrowser() {
  72. window.open('/imce?app=myApp|url@urlField', '', 'width=760,height=560,resizable=1');
  73. }
  74. That's all we need. Leave the rest to IMCE.
  75. It will automatically create an operation tab named "Send to myApp" that sends the file url to our url field.
  76. Clicking the files in preview do the same thing as well.
  77. - What if we had another field for another file property e.g, Size: <input type="text" id="file-size"> ?
  78. - We should have opened imce using this URL: /imce?app=myApp|url@urlField|size@file-size
  79. - USING imceload:
  80. You can point a predefined function to be executed when IMCE loads.
  81. When the URL is like "app=myApp|imceload@myOnloadFunc", IMCE looks for "myOnloadFunc" in the parent window and executes it with the window parameter referring to IMCE window.
  82. function myOnloadFunc (win) {//any method of imce is available through win.imce
  83. win.imce.setSendTo('Give it to myApplication baby', myFileHandler);//you should also define myFileHandler
  84. }
  85. - USING sendto:
  86. You can point a predefined function to which the selected files are sent.
  87. When the URL is like "app=myApp|sendto@myFileHandler", IMCE calls "myFileHandler" function of the parent window with file and window parameters.
  88. function myFileHandler (file, win) {
  89. $('#urlFieldId').val(file.url);//insert file url into the url field
  90. win.close();//close IMCE
  91. }
  92. Usually sendto method is easier to implement, on the other hand imceload method is more flexible as you manually add your sento operator and also can do any modification before IMCE shows up.
  93. ADVANCED INTEGRATION
  94. -----------
  95. In case:
  96. - Your application wants to go beyond the simple "give me that file property" interaction with IMCE.
  97. - Your application wants IMCE to send multiple files to it.(e.g., a gallery application)
  98. - Your application wants to gain total control over IMCE.
  99. Then you should consider applying advanced integration.
  100. The initial step of advanced integration is the same as imceload-integration above.
  101. We open IMCE and set its onload function:
  102. window.open('/imce?app=myApp|imceload@initiateMyApp', '', 'width=760,height=560,resizable=1'); //initiateMyApp(win) will run when imce loads
  103. Now we define our initiator function in which we do the necessary manipulations to IMCE interface:
  104. initiateMyApp = function (win) {
  105. var imce = win.imce;
  106. ...use imce methods to add/remove/change things...
  107. }
  108. - Allright, but what do we add/romeve/change in IMCE ?
  109. - Depends on our goal. Here are some properties and methods that can help us to achieve it:
  110. Hooks
  111. imce.hooks.load: an array of functions that run after imce loads. they are called with the window parameter.
  112. imce.hooks.list: an array of functions that run while processing the file list. each row of the file list is sent to these functions.
  113. imce.hooks.navigate: an array of functions that run after a directory is loaded. parameters sent are data(from ajax or cache), old_directory, cached(boolean that states the data is from the cache or not).
  114. imce.hooks.cache: an array of functions that run just before a new directory is loaded. parameters are cached_data and new_directory.
  115. Directory related properties
  116. imce.tree: stores the directory list where imce.tree['.'] is the root element.
  117. Directory related methods
  118. imce.dirAdd(directory_name, parent_element, clickable): adds directory_name under parent_element. ex: imce.dirAdd('foo', imce.dir['.'], true)
  119. imce.dirSubdirs(directory_name, subdirectories): adds each subdirectory in subdirectories array under directory_name. ex: imce.dirSubdirs('foo', ['bar', 'baz'])
  120. File related properties
  121. imce.findex: indexed array of files(table rows that contain file properties.)
  122. imce.fids: object containing file_id(file name)-file(row) pairs.
  123. imce.selected: object containing currently selected file_id(file name)-file(row) pairs.
  124. File related methods
  125. imce.fileAdd(file): adds the file object to the list. file object has the properties; name, size(bytes), width, height, date(timestamp), fsize(formatted), fdate(formatted)
  126. imce.fileRemove(fiile_id): removes the file having the file_id from the list.
  127. imce.fileGet(file_id). returns the file object having the file_id. file object contains name, url, size, bytes, width, height, date, time, id(file id for newly uploaded files, 0 or integer), relpath(rawurlencoded path relative to file directory path.)
  128. File operations
  129. imce.opAdd(op): adds an operation tab to the interface. op contains name, title, content(optional), func(optional onclick function)
  130. imce.opEnable(name), imce.opDisable(name): enable/disable operation tabs.
  131. Miscellaneous
  132. imce.setMessage(msg, type): logs a message of the type(status, warning, error)
  133. NOTES:
  134. - All URL strings in the examples start with "/" considering the base path is "/".
  135. In case your drupal is running on a sub directory e.g, http://localhost/drupal, these URLs should start with "/drupal/".
  136. There is a safer solution that does not require manual URL fixing: If the Drupal javascript object is available in your page you can use Drupal.settings.basePath at the beginning of URLs (Drupal.settings.basePath+'?q=imce....'). Note that, this won't work with multilingual paths with language prefixes.
  137. - file and directory ids(names) used in imce.js are url encoded forms of original names. They are decoded using imce.decode and displayed in the lists.