You are here

function swftools_admin_cck_form in SWF Tools 6.2

Same name and namespace in other branches
  1. 6.3 includes/swftools.admin.inc \swftools_admin_cck_form()

Menu callback: Settings form for configuring CCK playlist fallbacks.

1 string reference to 'swftools_admin_cck_form'
swftools_menu in ./swftools.module
Implementation of hook_menu().

File

./swftools.admin.inc, line 451

Code

function swftools_admin_cck_form() {

  // Get a list of all content types in use
  $content_types = content_types();

  // Get a list of all the CCK fields that are in use
  $fields = content_fields();

  // If filefield isn't in the list of fields then stop now
  if (!isset($field_types['filefield'])) {
    $form['description'] = array(
      '#value' => '<p>' . t('No filefields have been created.') . '</p>',
    );
  }

  // Get a list of all field types (this contains the list of formatters
  $field_types = _content_field_types();

  // Put a description on the page
  $form['description'] = array(
    '#value' => '<p>' . t('For content that is being formatted as an SWF Tools playlist you can specify an alternate format that should be used if a
                           single file is passed to the playlist function. For example, display a single image as a regular image instead of placing
                           it in a slideshow.') . '</p><p>' . t('Content types that contain fields that have been configured to be formatted as an
                           SWF Tools playlist are listed below.') . '</p>',
  );

  // Get the filefield formatters as a list of options
  $options = array();
  foreach ($field_types['filefield']['formatters'] as $formatter_name => $formatter_info) {
    $options[$formatter_name] = $formatter_info['label'];
  }
  $options['hidden'] = t('<Hidden>');

  // Cycle through each content type
  foreach ($content_types as $type => $type_info) {

    // See if fields are in use on this type
    if (isset($type_info['fields'])) {

      // If fields are in use then cycle through them
      foreach ($type_info['fields'] as $field => $field_info) {

        // If field is a filefield type then we might be interested in it
        if ($field_info['type'] == 'filefield') {

          // Check if something is trying to use a playlist
          // At the moment not sure we can distinguish between teaser and full view since we only make this check during the theming stage
          //          if ($field_info['display_settings']['teaser']['format'] == 'swftools_playlist') {
          //
          //            $form['swftools_' . $type . '_' . $field . '_teaser'] = array(
          //              '#title' => check_plain($type_info['name'] . ' - ' . $field_info['widget']['label']) . ' - ' . t('teaser'),
          //              '#type' => 'select',
          //              '#options' => $options,
          //              '#default_value' => variable_get('swftools_' . $type . '_' . $field . '_teaser' ,'swftools_playlist'),
          //            );
          //          }
          //
          //          // Check full view next
          //          if ($field_info['display_settings']['full']['format'] == 'swftools_playlist') {
          //            $form['swftools_' . $type . '_' . $field . '_full'] = array(
          //              '#title' => check_plain($type_info['name'] . ' - ' . $field_info['widget']['label']) . ' - ' . t('full node'),
          //              '#type' => 'select',
          //              '#options' => $options,
          //              '#default_value' => variable_get('swftools_' . $type . '_' . $field . '_full' ,'swftools_playlist'),
          //            );
          //          }
          // See if either of the teaser or body are set to be a playlist
          if ($field_info['display_settings']['teaser']['format'] == 'swftools_playlist' || $field_info['display_settings']['full']['format'] == 'swftools_playlist') {

            // If they are then create a form entry in the form swftools_{type}_{field}
            $form['swftools_' . $type . '_' . $field] = array(
              '#title' => check_plain($type_info['name'] . ' - ' . $field_info['widget']['label']),
              '#type' => 'select',
              '#options' => $options,
              '#default_value' => variable_get('swftools_' . $type . '_' . $field, 'swftools_playlist'),
            );
          }
        }
      }
    }
  }

  // Return a system settings form
  return system_settings_form($form);
}