You are here

function imce_uploader_get_uploaders in IMCE Uploader 7

Get the list of uploaders.

Each item may have the following properties

  • title: The name of uploader.
  • description: The description of uploader.
  • callback: Process function of uploader when imce's called.
  • weight: The weight of this uploader in the list.

Return value

array A list of registered uploaders.

2 calls to imce_uploader_get_uploaders()
imce_uploader_form_imce_profile_form_alter in ./imce_uploader.module
Implements hook_form_FORM_ID_alter().
imce_uploader_form_imce_upload_form_alter in ./imce_uploader.module
Implements hook_form_FORM_ID_alter().

File

./imce_uploader.module, line 73
IMCE Uploader

Code

function imce_uploader_get_uploaders() {
  static $drupal_static_fast;
  if (!isset($drupal_static_fast)) {
    $drupal_static_fast['uploaders'] =& drupal_static(__FUNCTION__);
  }
  $uploaders =& $drupal_static_fast['uploaders'];
  if (empty($uploaders)) {
    $cid = 'imce:' . $GLOBALS['language']->language . ':uploaders';
    $cache = cache_get($cid);
    if (empty($cache)) {
      $modules = module_implements('imce_uploader');
      $uploaders = array();
      foreach ($modules as $module) {
        $items = call_user_func($module . '_imce_uploader');
        if (isset($items) && is_array($items)) {
          $uploaders = array_merge($uploaders, $items);
        }
      }
      drupal_alter('imce_uploader', $uploaders);
      foreach ($uploaders as $uploader_id => $uploader) {
        $uploaders[$uploader_id] = $uploader + array(
          'title' => $uploader_id,
          'description' => '',
          'callback' => NULL,
          'weight' => 0,
        );
      }
      $default['default'] = array(
        'title' => t('Default'),
        'callback' => NULL,
        'weight' => -100,
      );
      $uploaders = $default + $uploaders;
      uasort($uploaders, 'drupal_sort_weight');
      cache_set($cid, $uploaders);
    }
    else {
      $uploaders = $cache->data;
    }
  }
  return $uploaders;
}