diff --git a/sites/all/modules/imce/README.txt b/sites/all/modules/imce/README.txt index 19bb9a96838d2930a3e8487a3c724eeef6fd72ba..76fbf2bbdfd01c0599eb532090df8d1bbfc32aae 100644 --- a/sites/all/modules/imce/README.txt +++ b/sites/all/modules/imce/README.txt @@ -1,4 +1,4 @@ -// $Id: README.txt,v 1.15 2010/04/10 12:36:20 ufku Exp $ +// $Id: README.txt,v 1.17 2010/06/19 15:12:34 ufku Exp $ IMCE http://drupal.org/project/imce @@ -30,10 +30,10 @@ FEATURES INSTALLATION ----------- 1) Copy imce directory to your modules directory -2) Enable the module at: /admin/build/modules +2) Enable the module at module administration page 3) Create configuration profiles and assign them to user roles at /admin/config/media/imce 4) Test it at /imce. -5) See imce-content.tpl.php for some configuration options such as absolute URLs ad inline previewing. +5) See imce-content.tpl.php for some configuration options such as inline previewing. 6) See INTEGRATION METHODS to make IMCE collaborate with your application if it's not already integrated. Notes: - When you configure IMCE for inline image/file insertion into textareas there should appear an IMCE link under each textarea you specified. diff --git a/sites/all/modules/imce/css/close.png b/sites/all/modules/imce/css/close.png index 1af29cac63261cd724d0ece69bf6dd497991e336..dde4617b16e415236b50e85dd7ef995e2899ac95 100644 Binary files a/sites/all/modules/imce/css/close.png and b/sites/all/modules/imce/css/close.png differ diff --git a/sites/all/modules/imce/css/sendto.png b/sites/all/modules/imce/css/sendto.png new file mode 100644 index 0000000000000000000000000000000000000000..64bc32753630dfb21e7961b695709b4d754e95f5 Binary files /dev/null and b/sites/all/modules/imce/css/sendto.png differ diff --git a/sites/all/modules/imce/imce.info b/sites/all/modules/imce/imce.info index 130f55610a8d3f15a16d793e1ec29a130fe297a3..b032cc4b3c4b13f5fbc190ece3cb93fd13e6d82e 100644 --- a/sites/all/modules/imce/imce.info +++ b/sites/all/modules/imce/imce.info @@ -9,9 +9,9 @@ files[] = "imce.module" files[] = "inc/imce.admin.inc" files[] = "inc/imce.page.inc" -; Information added by drupal.org packaging script on 2010-05-29 -version = "7.x-1.0-alpha2" +; Information added by drupal.org packaging script on 2010-06-21 +version = "7.x-1.0-alpha3" core = "7.x" project = "imce" -datestamp = "1275125108" +datestamp = "1277145015" diff --git a/sites/all/modules/imce/imce.install b/sites/all/modules/imce/imce.install index 3c3256e2a091e44bcc4c2fab3296e079f32ef7b4..3a0cfcc85e4635d958bd0675b42bfc59fdcfdf1c 100644 --- a/sites/all/modules/imce/imce.install +++ b/sites/all/modules/imce/imce.install @@ -1,5 +1,5 @@ <?php -// $Id: imce.install,v 1.6 2010/05/29 08:23:20 ufku Exp $ +// $Id: imce.install,v 1.7 2010/06/02 08:27:00 ufku Exp $ /** * @file @@ -42,10 +42,13 @@ function imce_schema() { 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0, - 'description' => 'The {files}.fid that belongs to IMCE.', + 'description' => 'The {file_managed}.fid that belongs to IMCE.', ), ), 'primary key' => array('fid'), + 'foreign keys' => array( + 'fid' => array('file_managed' => 'fid'), + ), ); return $schema; } diff --git a/sites/all/modules/imce/imce.module b/sites/all/modules/imce/imce.module index 680e69577693f9438f6699ada3181475ea3bdead..6b6cb01dfefc24c2db45212d5569897ccd7f06ff 100644 --- a/sites/all/modules/imce/imce.module +++ b/sites/all/modules/imce/imce.module @@ -1,5 +1,5 @@ <?php -// $Id: imce.module,v 1.32 2010/05/29 08:23:20 ufku Exp $ +// $Id: imce.module,v 1.34 2010/06/02 08:31:10 ufku Exp $ /** * @file @@ -95,7 +95,7 @@ function imce_theme() { * Support private downloads if not disabled. */ function imce_file_download($uri) { - $serve = file_uri_scheme($uri) == 'private' && !variable_get('imce_settings_disable_private', 1) && file_exists($uri); + $serve = file_uri_scheme($uri) == 'private' && !variable_get('imce_settings_disable_private', 1) && file_exists($uri) && strpos(basename($uri), '.'); if ($serve) { return array( 'Content-type' => file_get_mimetype($uri), @@ -247,7 +247,7 @@ function imce_user_page_access($account, $user = FALSE) { global $user; } - return $account->uid == $user->uid && ($profile = imce_user_profile($user)) && $profile['usertab']; + return ($user->uid == 1 || $account->uid == $user->uid) && ($profile = imce_user_profile($account)) && $profile['usertab']; } /** diff --git a/sites/all/modules/imce/inc/imce.admin.inc b/sites/all/modules/imce/inc/imce.admin.inc index a36a1f2952a56371071fe9d5bc3a3b04866487a9..7d1d4a30273f5ef3657af95a04b3166419972443 100644 --- a/sites/all/modules/imce/inc/imce.admin.inc +++ b/sites/all/modules/imce/inc/imce.admin.inc @@ -1,5 +1,5 @@ <?php -// $Id: imce.admin.inc,v 1.4 2010/05/29 02:09:05 ufku Exp $ +// $Id: imce.admin.inc,v 1.5 2010/06/02 08:31:10 ufku Exp $ /** * @file @@ -72,6 +72,12 @@ function imce_admin_form($form, &$form_state) { '#maxlength' => NULL, '#description' => t('If you don\'t use any WYSIWYG editor, this feature will allow you to add your images or files as <strong>html code into any plain textarea</strong>. Enter <strong>comma separated textarea IDs</strong> under which you want to enable a link to IMCE. The * character is a wildcard. Hint: ID of Body fields in most node types starts with edit-body.'), ); + $form['common']['absurls'] = array( + '#type' => 'checkbox', + '#title' => t('Absolute URLs'), + '#default_value' => variable_get('imce_settings_absurls', 0), + '#description' => t('Check if you want IMCE to return absolute file URLs.'), + ); $form['common']['replace'] = array( '#type' => 'radios', '#title' => t('Default behaviour for existing files during file uploads'), @@ -150,6 +156,7 @@ function imce_admin_submit($form, &$form_state) { } variable_set('imce_roles_profiles', $roles); variable_set('imce_settings_textarea', $form_state['values']['textarea']); + variable_set('imce_settings_absurls', $form_state['values']['absurls']); variable_set('imce_settings_replace', $form_state['values']['replace']); variable_set('imce_settings_thumb_method', $form_state['values']['thumb_method']); variable_set('imce_settings_disable_private', $form_state['values']['disable_private']); diff --git a/sites/all/modules/imce/inc/imce.page.inc b/sites/all/modules/imce/inc/imce.page.inc index b907ce30f372d4d320b878423253976e2015cbd8..c16ca5a6966fff8f325fce6c73d03718e004aa89 100644 --- a/sites/all/modules/imce/inc/imce.page.inc +++ b/sites/all/modules/imce/inc/imce.page.inc @@ -1,5 +1,5 @@ <?php -// $Id: imce.page.inc,v 1.5 2010/05/29 08:23:20 ufku Exp $ +// $Id: imce.page.inc,v 1.9 2010/06/19 15:13:35 ufku Exp $ /** * @file @@ -385,10 +385,21 @@ function imce_process_files($filenames, &$imce, $function, $args = array()) { } /** - * Delete a file in the file list. + * Deletes a file in the file list. */ function imce_delete_file($filename, &$imce) { $uri = imce_dir_uri($imce) . $filename; + if (!imce_delete_filepath($uri)) { + return FALSE; + } + imce_remove_file($filename, $imce); + return TRUE; +} + +/** + * Deletes a file by uri. + */ +function imce_delete_filepath($uri) { $file = file_load_multiple(array(), array('uri' => $uri)); $file = reset($file); @@ -412,7 +423,6 @@ function imce_delete_file($filename, &$imce) { return FALSE; } - imce_remove_file($filename, $imce); return TRUE; } @@ -688,9 +698,10 @@ function imce_initiate_profile($user, $scheme = NULL) { if ($imce = imce_user_profile($user, $scheme)) { imce_process_directories($imce, $user); if (!empty($imce['directories'])) { - $imce['uid'] = (int)$user->uid; + $imce['uid'] = (int) $user->uid; $imce['url'] = url($_GET['q']); $imce['clean'] = variable_get('clean_url', 0) == 1; + $imce['absurls'] = variable_get('imce_settings_absurls', 0) == 1; $imce['furl'] = file_create_url($imce['scheme'] . '://'); $imce['filesize'] *= 1048576;//convert from Mb to byte $imce['quota'] *= 1048576; @@ -1054,12 +1065,22 @@ function theme_imce_root_text($variables) { * Returns the html for user's file browser tab. */ function theme_imce_user_page($variables) { - return '<iframe src="' . url('imce') . '" frameborder="0" style="border: 1px solid #eee; width: 99%; height: 520px" class="imce-frame"></iframe>'; + global $user; + $account = $variables['account']; + $options = array(); + //switch to account's active folder + if ($user->uid == 1 && $account->uid != 1) { + $imce = imce_initiate_profile($account); + $options['query'] = array('dir' => $imce['dir']); + } + return '<iframe src="' . url('imce', $options) . '" frameborder="0" style="border: 1px solid #eee; width: 99%; height: 520px" class="imce-frame"></iframe>'; } /** * Registers the file as an IMCE file. */ function imce_file_register($file) { - return $file->fid && @db_insert('imce_files')->fields(array('fid' => $file->fid))->execute(); + if (!db_query('SELECT 1 FROM {imce_files} WHERE fid = :fid', array(':fid' => $file->fid))->fetchField()) { + return @db_insert('imce_files')->fields(array('fid' => $file->fid))->execute(); + } } \ No newline at end of file diff --git a/sites/all/modules/imce/js/imce.js b/sites/all/modules/imce/js/imce.js index c67866a214e7b76e79c13ba299a29ac7cf88bcd1..87211864218d24b4e170bfdd9002f30b1bc7baf3 100644 --- a/sites/all/modules/imce/js/imce.js +++ b/sites/all/modules/imce/js/imce.js @@ -1,4 +1,4 @@ -// $Id: imce.js,v 1.19 2010/05/29 08:24:01 ufku Exp $ +// $Id: imce.js,v 1.23 2010/06/19 15:14:20 ufku Exp $ (function($) { //Global container. @@ -323,7 +323,12 @@ opClick: function(name) { var $opcon = $('#op-contents').css({left: 0}); $(Op.div).slideDown('normal', function() { setTimeout(function() { - imce.vars.op && $('input:first', imce.ops[imce.vars.op].div).focus(); + if (imce.vars.op) { + var $inputs = $('input', imce.ops[imce.vars.op].div); + $inputs.eq(0).focus(); + //form inputs become invisible in IE. Solution is as stupid as the behavior. + $('html').is('.ie') && $inputs.addClass('dummyie').removeClass('dummyie'); + } }); }); var diff = left + $opcon.width() - $('#imce-content').width(); @@ -699,7 +704,7 @@ decode: function (str) { }, //global ajax error function ajaxError: function (e, response, settings, thrown) { - imce.setMessage(Drupal.ahahError(response, settings.url).replace('\n', '<br />'), 'error'); + imce.setMessage(Drupal.ajaxError(response, settings.url).replace(/\n/g, '<br />'), 'error'); }, //convert button elements to standard input buttons convertButtons: function(form) { @@ -731,11 +736,18 @@ syncScroll: function(scrlEl, fixEl, bottom) { updateUI: function() { //file urls. var furl = imce.conf.furl, isabs = furl.indexOf('://') > -1; - furl.charAt(furl.length - 1) != '/' && (furl += '/'); - imce.conf.modfix = imce.conf.clean && furl.indexOf(location.host + '/system/') > -1; - if (imce.vars.absurls && !isabs || !imce.vars.absurls && isabs) { - var baseurl = location.protocol + '//' + location.host + (location.port ? ':' + location.port : ''); - imce.conf.furl = isabs ? furl.substr(baseurl.length) : baseurl + furl; + var absurls = imce.conf.absurls = imce.vars.absurls || imce.conf.absurls; + var host = location.host; + var baseurl = location.protocol + '//' + host; + if (furl.charAt(furl.length - 1) != '/') { + furl += '/'; + } + imce.conf.modfix = imce.conf.clean && furl.indexOf(host + '/system/') > -1; + if (absurls && !isabs) { + imce.conf.furl = baseurl + furl; + } + else if (!absurls && isabs && furl.indexOf(baseurl) == 0) { + imce.conf.furl = furl.substr(baseurl.length); } //convert button elements to input elements. imce.convertButtons(imce.el('forms-wrapper')); diff --git a/sites/all/modules/imce/js/imce_extras.js b/sites/all/modules/imce/js/imce_extras.js index 8f7586e5ca9731614a511107c174848e88cc57ab..a06ad3426bc8203e847c44edcfd8d10a5c36df82 100644 --- a/sites/all/modules/imce/js/imce_extras.js +++ b/sites/all/modules/imce/js/imce_extras.js @@ -1,4 +1,4 @@ -// $Id: imce_extras.js,v 1.5 2010/05/15 13:31:16 ufku Exp $ +// $Id: imce_extras.js,v 1.6 2010/06/05 08:04:41 ufku Exp $ //This pack implemets: keyboard shortcuts, file sorting, resize bars, and inline thumbnail preview. (function($) { @@ -109,11 +109,10 @@ imce.initiateSorting = function() { imce.hooks.navigate.push(function (data, olddir, cached) { cached ? imce.updateSortState(data.cid, data.dsc) : imce.firstSort(); }); - imce.vars.cid = imce.cookie('icid')*1; - imce.vars.dsc = imce.cookie('idsc')*1; + imce.vars.cid = imce.cookie('imcecid') * 1; + imce.vars.dsc = imce.cookie('imcedsc') * 1; imce.cols = imce.el('file-header').rows[0].cells; $(imce.cols).click(function () {imce.columnSort(this.cellIndex, imce.hasC(this, 'asc'));}); - $(window).unload(function() {imce.cookie('icid', imce.vars.cid); imce.cookie('idsc', imce.vars.dsc ? 1 : 0);}); imce.firstSort(); }; @@ -145,8 +144,8 @@ imce.columnSort = function(cid, dsc) { imce.updateSortState = function(cid, dsc) { $(imce.cols[imce.vars.cid]).removeClass(imce.vars.dsc ? 'desc' : 'asc'); $(imce.cols[cid]).addClass(dsc ? 'desc' : 'asc'); - imce.vars.cid = cid; - imce.vars.dsc = dsc; + imce.vars.cid != cid && imce.cookie('imcecid', imce.vars.cid = cid); + imce.vars.dsc != dsc && imce.cookie('imcedsc', (imce.vars.dsc = dsc) ? 1 : 0); }; //sorters @@ -159,13 +158,13 @@ imce.sortNumDsc = function(a, b) {return b-a}; //set resizers for resizable areas and recall previous dimensions imce.initiateResizeBars = function () { - imce.setResizer('navigation-resizer', 'X', 'navigation-wrapper', null, 1); - imce.setResizer('browse-resizer', 'Y', 'browse-wrapper', 'preview-wrapper', 50); - imce.recallDimensions(); - $(window).unload(function() { - imce.cookie('imcebwh', $(imce.BW).height()); - imce.cookie('imcenww', Math.max($(imce.NW).width(), 1)); + imce.setResizer('navigation-resizer', 'X', 'navigation-wrapper', null, 1, function(p1, p2, m) { + p1 != p2 && imce.cookie('imcenww', p2); + }); + imce.setResizer('browse-resizer', 'Y', 'browse-wrapper', 'preview-wrapper', 50, function(p1, p2, m) { + p1 != p2 && imce.cookie('imcebwh', p2); }); + imce.recallDimensions(); }; //set a resize bar @@ -231,7 +230,7 @@ imce.cookie = function (name, value) { if (typeof(value) == 'undefined') {//get return unescape((document.cookie.match(new RegExp('(^|;) *'+ name +'=([^;]*)(;|$)')) || ['', '', ''])[2]); } - document.cookie = name +'='+ escape(value) +'; expires='+ (new Date(new Date()*1 + 30*86400000)).toGMTString() +'; path=/';//set + document.cookie = name +'='+ escape(value) +'; expires='+ (new Date(new Date() * 1 + 15 * 86400000)).toGMTString() +'; path=' + Drupal.settings.basePath + 'imce';//set }; //view thumbnails(smaller than tMaxW x tMaxH) inside the rows. diff --git a/sites/all/modules/imce/js/imce_set_app.js b/sites/all/modules/imce/js/imce_set_app.js index 38a317b9a398e9ca8dae71de32a7286ebd3f136a..f910cc57e9a74a9d96c630364781ceff2f80e97d 100644 --- a/sites/all/modules/imce/js/imce_set_app.js +++ b/sites/all/modules/imce/js/imce_set_app.js @@ -1,11 +1,11 @@ -// $Id: imce_set_app.js,v 1.5 2010/04/03 16:04:41 ufku Exp $ +// $Id: imce_set_app.js,v 1.6 2010/06/02 08:28:47 ufku Exp $ /* * IMCE Integration by URL * Ex-1: http://example.com/imce?app=XEditor|url@urlFieldId|width@widthFieldId|height@heightFieldId - * Creates "Send to XEditor" operation tab, which fills the specified fields with url, width, height properties + * Creates "Insert file" operation tab, which fills the specified fields with url, width, height properties * of the selected file in the parent window * Ex-2: http://example.com/imce?app=XEditor|sendto@functionName - * "Send to XEditor" operation calls parent window's functionName(file, imceWindow) + * "Insert file" operation calls parent window's functionName(file, imceWindow) * Ex-3: http://example.com/imce?app=nomatter|imceload@functionName * Parent window's functionName(imceWindow) is called as soon as IMCE UI is ready. Send to operation * needs to be set manually. See imce.setSendTo() method in imce.js diff --git a/sites/all/modules/imce/js/imce_set_inline.js b/sites/all/modules/imce/js/imce_set_inline.js index 107db732002cb2d062063b0ffa286fd5ee6c0d87..462efef1307dfd03fff4572420b17fe1dbfcdf7d 100644 --- a/sites/all/modules/imce/js/imce_set_inline.js +++ b/sites/all/modules/imce/js/imce_set_inline.js @@ -1,4 +1,4 @@ -// $Id: imce_set_inline.js,v 1.4 2010/03/17 20:55:38 ufku Exp $ +// $Id: imce_set_inline.js,v 1.5 2010/06/02 08:29:40 ufku Exp $ (function($) { @@ -21,7 +21,7 @@ ii.initiate = function() { //function to be executed when imce loads. ii.load = function(win) { - win.imce.setSendTo(Drupal.t('Send to @app', {'@app': Drupal.t('textarea')}), ii.insert); + win.imce.setSendTo(Drupal.t('Insert file'), ii.insert); $(window).unload(function() { if (ii.pop && !ii.pop.closed) ii.pop.close(); });