imce.js.inc 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <?php
  2. /**
  3. * @file
  4. * Handles ajax file operations.
  5. */
  6. /**
  7. * Ajax operation: navigate
  8. */
  9. function imce_js_navigate(&$imce) {
  10. return array(
  11. 'files' => theme('imce_file_list', array('imce_ref' => array('imce' => &$imce))),
  12. 'dirsize' => format_size($imce['dirsize']),
  13. 'subdirectories' => array_map('rawurlencode', array_values($imce['subdirectories'])),
  14. 'perm' => $imce['perm']
  15. );
  16. }
  17. /**
  18. * Ajax operation: upload
  19. */
  20. function imce_js_upload(&$imce) {
  21. if ($imce['perm']['upload']) {
  22. $_POST['op'] = t('Upload');
  23. drupal_get_form('imce_upload_form', array('imce' => &$imce));
  24. return array('added' => isset($imce['added']) ? $imce['added'] : NULL, 'dirsize' => format_size($imce['dirsize']));
  25. }
  26. }
  27. /**
  28. * Ajax operation: thumbnails
  29. */
  30. function imce_js_thumb(&$imce) {
  31. if ($imce['perm']['thumb']) {
  32. $_POST['op'] = t('Create thumbnails');
  33. return imce_process_fileop($imce);
  34. }
  35. }
  36. /**
  37. * Ajax operation: delete
  38. */
  39. function imce_js_delete(&$imce) {
  40. if ($imce['perm']['delete']) {
  41. $_POST['op'] = t('Delete');
  42. return imce_process_fileop($imce);
  43. }
  44. }
  45. /**
  46. * Ajax operation: resize
  47. */
  48. function imce_js_resize(&$imce) {
  49. if ($imce['perm']['resize']) {
  50. $_POST['op'] = t('Resize');
  51. return imce_process_fileop($imce);
  52. }
  53. }
  54. /**
  55. * Process file operations form
  56. */
  57. function imce_process_fileop(&$imce) {
  58. drupal_get_form('imce_fileop_form', array('imce' => &$imce));
  59. return array('added' => isset($imce['added']) ? $imce['added'] : NULL, 'removed' => isset($imce['removed']) ? $imce['removed'] : NULL, 'dirsize' => format_size($imce['dirsize']));
  60. }