You are here

function managed_file_element_widgets in Managed File 7

Get list of available file widgets.

Return value

array[] An array with "path" and "label" keys.

1 call to managed_file_element_widgets()
managed_file_element_process in includes/managed_file.common.inc
Process widget of managed file.

File

includes/managed_file.common.inc, line 14
Auxiliary functionality.

Code

function managed_file_element_widgets() {
  $widgets = [];
  foreach ([
    'imce' => [
      '#label' => t('IMCE'),
      '#module' => 'imce',
      // Function to determine the path of JS library.
      '#function' => [
        'drupal_get_path',
        [
          'module',
          'imce',
        ],
      ],
      '#subfolder' => 'js',
    ],
    'ckfinder' => [
      '#label' => t('CKFinder'),
      '#module' => 'ckeditor',
      '#function' => [
        'ckfinder_path',
        [],
      ],
      '#subfolder' => '',
    ],
  ] as $widget => $data) {
    if (module_exists($data['#module'])) {
      list($func, $arguments) = $data['#function'];
      $path = trim(call_user_func_array($func, $arguments), '/');

      // If empty, then module does not exists.
      if (!empty($path)) {
        $widgets[$widget] = [
          'label' => $data['#label'],
          'path' => $path . '/' . $data['#subfolder'],
        ];
      }
    }
  }
  return $widgets;
}