diff --git a/includes/media.admin.inc b/includes/media.admin.inc index 7cf574e..6cb3402 100644 --- a/includes/media.admin.inc +++ b/includes/media.admin.inc @@ -635,3 +635,45 @@ function media_admin_rebuild_types_batch_complete($success, $results, $operation } drupal_set_message($message); } + +/** + * Provide a UI for enabling media types in the WYSIWYG. + */ +function media_admin_wysiwyg_types($form, &$form_state) { + $types = array(); + + foreach(media_type_get_types() as $type) { + $types[$type->name] = $type->label; + } + + $form['types'] = array( + '#title' => t('Select the media types available in the WYSIWYG'), + '#type' => 'checkboxes', + '#options' => $types, + '#default_value' => media_variable_get('wysiwyg_allowed_types'), + ); + + $form['submit'] = array( + '#type' => 'submit', + '#value' => t('Save'), + ); + + return $form; +} + +/** + * Submit handler for media_admin_wysiwyg_types() + */ +function media_admin_wysiwyg_types_submit($form, &$form_state) { + $types = array(); + + foreach($form_state['values']['types'] as $key => $value) { + if ($value != '0') { + $types[] = $key; + } + } + + drupal_set_message('WYSIWYG media types updated'); + + media_variable_set('wysiwyg_allowed_types', $types); +} diff --git a/media.module b/media.module index a74653e..4cd7edd 100644 --- a/media.module +++ b/media.module @@ -86,6 +86,15 @@ function media_menu() { 'access arguments' => array('administer media'), 'file' => 'includes/media.admin.inc', ); + + $items['admin/config/media/wysiwyg_types'] = array( + 'title' => 'WYSIWYG media types', + 'description' => 'Configure media types available for the WYSIWYG', + 'page callback' => 'drupal_get_form', + 'page arguments' => array('media_admin_wysiwyg_types'), + 'access arguments' => array('administer media'), + 'file' => 'includes/media.admin.inc', + ); // Settings used for determining the type of media a file is. // @todo Find a new home for this that integrates with the file_entity module.