You are here

function lingotek_node_settings_row_profiles in Lingotek Translation 7.7

Same name and namespace in other branches
  1. 7.6 lingotek.admin.inc \lingotek_node_settings_row_profiles()
1 call to lingotek_node_settings_row_profiles()
lingotek_admin_entity_bundle_profiles_form in ./lingotek.admin.inc
Content translation form

File

./lingotek.admin.inc, line 274

Code

function lingotek_node_settings_row_profiles($bundle_name, $entity_profiles, $entity_type, $profiles_options, $setup_complete, $config_handled) {
  $default_profile = $setup_complete ? LingotekSync::PROFILE_DISABLED : 0;
  $inherit_profile = LingotekSync::PROFILE_INHERIT;

  // Disable automatic profile as the default for comments during setup
  if ($entity_type == 'comment') {
    $default_profile = LingotekSync::PROFILE_DISABLED;
  }
  $languages = lingotek_get_target_locales(FALSE);
  $profiles = array();
  if ($config_handled) {
    $profiles['profile_' . $bundle_name] = array(
      '#type' => 'select',
      '#options' => array(
        'DISABLED' => 'See config tab',
      ),
      '#value' => 'DISABLED',
      '#attributes' => array(
        'id' => array(
          'edit-form-item-profile-' . $bundle_name,
        ),
        'name' => 'profile_' . $bundle_name,
        'class' => array(
          'field',
        ),
        'disabled' => TRUE,
      ),
    );
  }
  else {
    $profiles['profile_' . $bundle_name] = array(
      '#type' => 'select',
      '#options' => $profiles_options,
      '#value' => isset($entity_profiles[$entity_type][$bundle_name]) ? $entity_profiles[$entity_type][$bundle_name] : $default_profile,
      '#attributes' => array(
        'id' => array(
          'edit-form-item-profile-' . $bundle_name,
        ),
        'name' => 'profile_' . $bundle_name,
        'class' => array(
          'field',
        ),
      ),
    );
    if (variable_get('lingotek_enable_language_specific_profiles', FALSE)) {

      // add a title to the main profile for the bundle
      $profiles['profile_' . $bundle_name]['#title'] = 'Default Profile';

      // fieldset wrapper to indent the language overrides
      $profiles['profile_overrides'] = array(
        '#type' => 'fieldset',
        '#id' => 'profile_override__' . $bundle_name,
        '#states' => array(
          'invisible' => array(
            ':input[name="' . $entity_type . '_language"]' => array(
              'visible' => FALSE,
            ),
          ),
        ),
        '#attributes' => array(
          'style' => 'border: none; padding: 0 0 0 0; background-color: inherit;',
        ),
      );

      // add the 'inherit' option after writing the main profile box
      $profiles_options[LingotekSync::PROFILE_INHERIT] = '(use default profile for ' . $bundle_name . ')';
      foreach ($languages as $language) {
        $profiles['profile_overrides'][$bundle_name . '_' . $language->lingotek_locale] = array(
          '#title' => 'Content created in ' . $language->name,
          '#type' => 'select',
          '#options' => $profiles_options,
          '#value' => isset($entity_profiles[$entity_type][$bundle_name . '__' . $language->lingotek_locale]) ? $entity_profiles[$entity_type][$bundle_name . '__' . $language->lingotek_locale] : LingotekSync::PROFILE_INHERIT,
          '#attributes' => array(
            'id' => array(
              'edit-form-item-profile-' . $bundle_name . '__' . $language->lingotek_locale,
            ),
            'name' => 'profile_' . $bundle_name . '__' . $language->lingotek_locale,
            'class' => array(
              'field',
            ),
          ),
        );
      }
    }
  }
  return $profiles;
}