You are here

function imce_content in IMCE 7

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

Returns the content of the file browser.

1 call to imce_content()
imce_page in inc/imce.page.inc
Returns the imce page for the specified user and the file scheme.

File

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

Code

function imce_content($user, $scheme = NULL, $jsop = NULL) {

  // Execute ajax calls.
  if ($jsop) {
    return imce_js($user, $scheme, $jsop);
  }

  // Initiate configuration profile.
  if (!($imce = imce_initiate_profile($user, $scheme))) {
    return '';
  }

  // Get active directory content.
  imce_process_profile($imce);

  // Before creating the content let's add main files
  // required for imce to function properly.
  $path = drupal_get_path('module', 'imce');
  drupal_add_js($path . '/js/jquery.form.js');
  drupal_add_js($path . '/js/imce.js');
  drupal_add_js($path . '/js/imce_extras.js');
  drupal_add_css($path . '/css/imce-content.css');

  // Process forms.
  $imce_ref = array(
    'imce' => &$imce,
  );
  $forms = array();
  if (!$imce['error']) {

    // Process file upload.
    if (imce_perm_exists($imce, 'upload')) {
      $forms[] = drupal_get_form('imce_upload_form', $imce_ref);
    }

    // Process file operations.
    $forms[] = drupal_get_form('imce_fileop_form', $imce_ref);
  }
  $forms = drupal_render($forms);

  // Run custom content functions. possible to insert
  // extra forms. content is invisible when js is enabled.
  foreach (variable_get('imce_custom_content', array()) as $func => $state) {
    if ($state && function_exists($func) && ($output = $func($imce))) {
      $forms .= $output;
    }
  }
  $content = theme('imce_content', array(
    'tree' => imce_create_tree($imce),
    'forms' => $forms,
    'imce_ref' => $imce_ref,
  ));

  // Make necessary changes for js conversion.
  $imce['dir'] = str_replace('%2F', '/', rawurlencode($imce['dir']));
  unset($imce['files'], $imce['name'], $imce['directories'], $imce['subdirectories'], $imce['filesize'], $imce['quota'], $imce['tuquota'], $imce['thumbnails'], $imce['uid'], $imce['usertab']);

  //add the default sort variable
  $imce_ref['imce']['sort'] = variable_get('imce_settings_sort', 'default');
  drupal_add_js($imce_ref, 'setting');
  return $content;
}