You are here

function media_wysiwyg_form_media_admin_config_browser_alter in D7 Media 7.2

Same name and namespace in other branches
  1. 7.4 modules/media_wysiwyg/media_wysiwyg.module \media_wysiwyg_form_media_admin_config_browser_alter()
  2. 7.3 modules/media_wysiwyg/media_wysiwyg.module \media_wysiwyg_form_media_admin_config_browser_alter()

Implements hook_form_FORM_ID_alter().

File

modules/media_wysiwyg/media_wysiwyg.module, line 227
Primarily Drupal hooks.

Code

function media_wysiwyg_form_media_admin_config_browser_alter(&$form, &$form_state) {
  $form['wysiwyg'] = array(
    '#type' => 'fieldset',
    '#title' => t('WYSIWYG configuration'),
    '#collapsible' => TRUE,
    '#collapsed' => FALSE,
  );
  $form['wysiwyg']['media_wysiwyg_wysiwyg_browser_plugins'] = array(
    '#type' => 'checkboxes',
    '#title' => t('Enabled browser plugins'),
    '#options' => array(),
    '#required' => FALSE,
    '#default_value' => variable_get('media_wysiwyg_wysiwyg_browser_plugins', array()),
    '#description' => t('If no plugins are selected, they will all be available.'),
  );
  $plugins = media_get_browser_plugin_info();
  foreach ($plugins as $key => $plugin) {
    $form['wysiwyg']['media_wysiwyg_wysiwyg_browser_plugins']['#options'][$key] = !empty($plugin['title']) ? $plugin['title'] : $key;
  }
  $form['wysiwyg']['media_wysiwyg_wysiwyg_upload_directory'] = array(
    '#type' => 'textfield',
    '#title' => t("File directory for uploaded media"),
    '#default_value' => variable_get('media_wysiwyg_wysiwyg_upload_directory', ''),
    '#description' => t('Optional subdirectory within the upload destination where files will be stored. Do not include preceding or trailing slashes.'),
  );
  if (module_exists('token')) {
    $form['wysiwyg']['media_wysiwyg_wysiwyg_upload_directory']['#description'] .= t('This field supports tokens.');
    $form['wysiwyg']['tokens'] = array(
      '#theme' => 'token_tree',
      '#dialog' => TRUE,
    );
  }
  $form['wysiwyg']['media_wysiwyg_default_render'] = array(
    '#type' => 'radios',
    '#title' => t('How should file entities be rendered within a text field?'),
    '#description' => t("Full file entity rendering is the best choice for most sites. It respects the file entity's display settings specified at admin/structure/file-types. If your site already uses the legacy method, note that changing this option will affect your site's markup. Testing it on a non-production site is recommended."),
    '#options' => array(
      'file_entity' => 'Full file entity rendering',
      'field_attach' => 'Legacy rendering (using field attach)',
    ),
    '#default_value' => variable_get('media_wysiwyg_default_render', 'file_entity'),
  );
  $form['wysiwyg']['media_wysiwyg_wysiwyg_allowed_types'] = array(
    '#type' => 'checkboxes',
    '#title' => t('Allowed types in WYSIWYG'),
    '#options' => file_entity_type_get_names(),
    '#default_value' => variable_get('media_wysiwyg_wysiwyg_allowed_types', array(
      'audio',
      'image',
      'video',
      'document',
    )),
  );
  $options = array();
  foreach (field_info_field_types() as $key => $type) {
    $options[$key] = !empty($type['label']) ? $type['label'] : ucfirst(str_replace("_", " ", $key));
  }
  asort($options);
  $form['wysiwyg']['media_wysiwyg_wysiwyg_override_field_types'] = array(
    '#type' => 'checkboxes',
    '#title' => t('Override field types in WYSIWYG'),
    '#options' => $options,
    '#default_value' => variable_get('media_wysiwyg_wysiwyg_override_field_types', array(
      'text',
      'text_long',
    )),
    '#description' => t('If checked, then the field type may be overridden in the WYSIWYG editor. Not all field types/widgets (e.g. Term reference autocomplete) currently support being overridden so the desired result might not be achieved.'),
  );
  $form['wysiwyg']['media_wysiwyg_wysiwyg_override_multivalue'] = array(
    '#type' => 'checkbox',
    '#title' => t('Override multi-value fields in WYSIWYG'),
    '#description' => t('If checked, then multi-value fields may be overridden in the WYSIWYG editor. Not all field types/widgets (e.g. Term reference autocomplete) currently support being overridden so the desired result might not be achieved.'),
    '#default_value' => variable_get('media_wysiwyg_wysiwyg_override_multivalue', FALSE),
  );
  $form['wysiwyg']['media_wysiwyg_use_link_text_for_filename'] = array(
    '#type' => 'checkbox',
    '#title' => t("Use link text for filename"),
    '#default_value' => variable_get('media_wysiwyg_use_link_text_for_filename', 1),
    '#description' => t('When formatting inserted media, allow editable link text to be used in place of the filename. Turn this off if your file view modes handle link formatting.'),
  );
  $form['wysiwyg']['media_wysiwyg_alignment'] = array(
    '#type' => 'checkbox',
    '#title' => t('Provide alignment option when embedding media'),
    '#default_value' => variable_get('media_wysiwyg_alignment', FALSE),
    '#description' => t('If checked, there will be an alignment (left/right/center) option when embedding media in a WYSIWYG.'),
  );
  $form['wysiwyg']['media_wysiwyg_external_link'] = array(
    '#type' => 'checkbox',
    '#title' => t('Provide the ability to link media to pages'),
    '#default_value' => variable_get('media_wysiwyg_external_link', FALSE),
    '#description' => t('If checked there will be a new field when embedding that will allow users to link to the media to urls'),
  );
  $form['wysiwyg']['media_wysiwyg_remove_media_class'] = array(
    '#type' => 'checkbox',
    '#title' => t('Remove the ".media" class from embedded media'),
    '#description' => t('If checked, the ".media" class will be removed from embedded media. Particularlly for sites using Bootstrap, the ".media" class can cause CSS to be unexpectedly applied to embedded media.'),
    '#default_value' => variable_get('media_wysiwyg_remove_media_class', FALSE),
  );
  $form['#submit'][] = 'media_wysiwyg_admin_config_browser_pre_submit';
}