You are here

function imce_js in IMCE 7

Same name and namespace in other branches
  1. 6.2 inc/imce.page.inc \imce_js()
  2. 6 inc/page.inc \imce_js()

Ajax operations. q=imce&jsop={op}.

1 call to imce_js()
imce_content in inc/imce.page.inc
Returns the content of the file browser.

File

inc/imce.page.inc, line 101
Implements the file browser.

Code

function imce_js($user, $scheme, $jsop = '') {
  $response = array();

  // Data.
  if ($imce = imce_initiate_profile($user, $scheme)) {
    imce_process_profile($imce);
    if (!$imce['error']) {
      module_load_include('inc', 'imce', 'inc/imce.js');
      if (function_exists($func = 'imce_js_' . $jsop)) {
        $response['data'] = $func($imce);
      }

      // Allow alteration of response.
      foreach (variable_get('imce_custom_response', array()) as $func => $state) {
        if ($state && function_exists($func)) {
          $func($jsop, $response, $imce, $user);
        }
      }
    }
  }

  // Messages.
  $response['messages'] = drupal_get_messages();

  // Disable devel log.
  $GLOBALS['devel_shutdown'] = FALSE;

  // For upload we must return plain text header.
  drupal_add_http_header('Content-Type', (!empty($_POST['html_response']) ? 'text/html' : 'application/json') . '; charset=utf-8');
  print drupal_json_encode($response);
  exit;
}