diff --git a/core/modules/field_ui/field_ui.admin.inc b/core/modules/field_ui/field_ui.admin.inc index bb99234..01b8132 100644 --- a/core/modules/field_ui/field_ui.admin.inc +++ b/core/modules/field_ui/field_ui.admin.inc @@ -130,7 +130,7 @@ function field_ui_display_overview_row_region($row) { * This function is assigned as a #pre_render callback in * field_ui_element_info(). * - * @see drupal_render(). + * @see drupal_render() */ function field_ui_table_pre_render($elements) { $js_settings = array(); @@ -247,7 +247,11 @@ function theme_field_ui_table($variables) { if (isset($region['message'])) { $class = (empty($region['rows_order']) ? 'region-empty' : 'region-populated'); $table['rows'][] = array( - 'class' => array('region-message', 'region-' . $region_name_class . '-message', $class), + 'class' => array( + 'region-message', + 'region-' . $region_name_class . '-message', + $class, + ), 'no_striping' => TRUE, 'data' => array( array('data' => $region['message'], 'colspan' => $columns_count), @@ -359,7 +363,7 @@ function field_ui_field_overview_form($form, &$form_state, $entity_type, $bundle '#default_value' => $instance['widget']['weight'], '#size' => 3, '#attributes' => array('class' => array('field-weight')), - ), + ), 'parent_wrapper' => array( 'parent' => array( '#type' => 'select', @@ -468,7 +472,8 @@ function field_ui_field_overview_form($form, &$form_state, $entity_type, $bundle if ($field_type_options && $widget_type_options) { $name = '_add_new_field'; $table[$name] = array( - '#attributes' => array('class' => array('draggable', 'tabledrag-leaf', 'add-new')), + '#attributes' => array( + 'class' => array('draggable', 'tabledrag-leaf', 'add-new')), '#row_type' => 'add_new_field', '#region_callback' => 'field_ui_field_overview_row_region', 'label' => array( @@ -477,7 +482,7 @@ function field_ui_field_overview_form($form, &$form_state, $entity_type, $bundle '#title_display' => 'invisible', '#size' => 15, '#description' => t('Label'), - '#prefix' => '
' . t('Add new field') .'
', + '#prefix' => '
' . t('Add new field') . '
', '#suffix' => '
', ), 'weight' => array( @@ -572,7 +577,12 @@ function field_ui_field_overview_form($form, &$form_state, $entity_type, $bundle asort($existing_field_options); $name = '_add_existing_field'; $table[$name] = array( - '#attributes' => array('class' => array('draggable', 'tabledrag-leaf', 'add-new')), + '#attributes' => array( + 'class' => array( + 'draggable', + 'tabledrag-leaf', + 'add-new', + )), '#row_type' => 'add_new_field', '#region_callback' => 'field_ui_field_overview_row_region', 'label' => array( @@ -582,7 +592,7 @@ function field_ui_field_overview_form($form, &$form_state, $entity_type, $bundle '#size' => 15, '#description' => t('Label'), '#attributes' => array('class' => array('label-textfield')), - '#prefix' => '
' . t('Re-use existing field') .'
', + '#prefix' => '
' . t('Re-use existing field') . '
', '#suffix' => '
', ), 'weight' => array( @@ -645,7 +655,11 @@ function field_ui_field_overview_form($form, &$form_state, $entity_type, $bundle // Add settings for the update selects behavior. $js_fields = array(); foreach ($existing_fields as $field_name => $info) { - $js_fields[$field_name] = array('label' => $info['label'], 'type' => $info['type'], 'widget' => $info['widget_type']); + $js_fields[$field_name] = array( + 'label' => $info['label'], + 'type' => $info['type'], + 'widget' => $info['widget_type'], + ); } $form['#attached']['js'][] = array( @@ -654,8 +668,20 @@ function field_ui_field_overview_form($form, &$form_state, $entity_type, $bundle ); // Add tabledrag behavior. - $form['#attached']['drupal_add_tabledrag'][] = array('field-overview', 'order', 'sibling', 'field-weight'); - $form['#attached']['drupal_add_tabledrag'][] = array('field-overview', 'match', 'parent', 'field-parent', 'field-parent', 'field-name'); + $form['#attached']['drupal_add_tabledrag'][] = array( + 'field-overview', + 'order', + 'sibling', + 'field-weight', + ); + $form['#attached']['drupal_add_tabledrag'][] = array( + 'field-overview', + 'match', + 'parent', + 'field-parent', + 'field-parent', + 'field-name', + ); return $form; } @@ -679,7 +705,12 @@ function _field_ui_field_overview_form_validate_add_new($form, &$form_state) { $field = $form_state['values']['fields']['_add_new_field']; // Validate if any information was provided in the 'add new field' row. - if (array_filter(array($field['label'], $field['field_name'], $field['type'], $field['widget_type']))) { + if (array_filter(array( + $field['label'], + $field['field_name'], + $field['type'], + $field['widget_type'], + ))) { // Missing label. if (!$field['label']) { form_set_error('fields][_add_new_field][label', t('Add new field: you need to provide a label.')); @@ -746,8 +777,12 @@ function _field_ui_field_overview_form_validate_add_existing($form, &$form_state if (isset($form_state['values']['fields']['_add_existing_field'])) { $field = $form_state['values']['fields']['_add_existing_field']; - // Validate if any information was provided in the 're-use existing field' row. - if (array_filter(array($field['label'], $field['field_name'], $field['widget_type']))) { + // Check if any information was provided in the 're-use existing field' row. + if (array_filter(array( + $field['label'], + $field['field_name'], + $field['widget_type'], + ))) { // Missing label. if (!$field['label']) { form_set_error('fields][_add_existing_field][label', t('Re-use existing field: you need to provide a label.')); @@ -1015,7 +1050,6 @@ function field_ui_display_overview_form($form, &$form_state, $entity_type, $bund ); // Formatter settings. - // Check the currently selected formatter, and merge persisted values for // formatter settings. if (isset($form_state['values']['fields'][$name]['type'])) { @@ -1084,7 +1118,13 @@ function field_ui_display_overview_form($form, &$form_state, $entity_type, $bund '#op' => 'cancel', // Do not check errors for the 'Cancel' button, but make sure we // get the value of the 'formatter type' select. - '#limit_validation_errors' => array(array('fields', $name, 'type')), + '#limit_validation_errors' => array( + array( + 'fields', + $name, + 'type', + ), + ), ), ), ); @@ -1233,8 +1273,20 @@ function field_ui_display_overview_form($form, &$form_state, $entity_type, $bund $form['#attached']['library'][] = array('field_ui', 'drupal.field_ui'); // Add tabledrag behavior. - $form['#attached']['drupal_add_tabledrag'][] = array('field-display-overview', 'order', 'sibling', 'field-weight'); - $form['#attached']['drupal_add_tabledrag'][] = array('field-display-overview', 'match', 'parent', 'field-parent', 'field-parent', 'field-name'); + $form['#attached']['drupal_add_tabledrag'][] = array( + 'field-display-overview', + 'order', + 'sibling', + 'field-weight', + ); + $form['#attached']['drupal_add_tabledrag'][] = array( + 'field-display-overview', + 'match', + 'parent', + 'field-parent', + 'field-parent', + 'field-name', + ); return $form; } @@ -1416,7 +1468,7 @@ function field_ui_display_overview_form_submit($form, &$form_state) { * An associative array of bundle settings, as expected by * field_bundle_settings(). * - * @see field_ui_display_overview_form_submit(). + * @see field_ui_display_overview_form_submit() * @see field_bundle_settings() */ function _field_ui_add_default_view_mode_settings($entity_type, $bundle, $view_mode, &$settings) { @@ -1545,7 +1597,6 @@ function field_ui_existing_field_options($entity_type, $bundle) { // - fields already in the current bundle, // - fields that cannot be added to the entity type, // - fields that that shoud not be added via user interface. - if (empty($field['locked']) && !field_info_instance($entity_type, $field['field_name'], $bundle) && (empty($field['entity_types']) || in_array($entity_type, $field['entity_types'])) @@ -1960,7 +2011,7 @@ function field_ui_field_edit_form($form, &$form_state, $instance) { $form['actions'] = array('#type' => 'actions'); $form['actions']['submit'] = array( '#type' => 'submit', - '#value' => t('Save settings') + '#value' => t('Save settings'), ); $form['actions']['delete'] = array( '#type' => 'submit', @@ -2045,7 +2096,7 @@ function field_ui_default_value_widget($field, $instance, &$form, &$form_state) /** * Form validation handler for field_ui_field_edit_form(). * - * @see field_ui_field_edit_form_submit(). + * @see field_ui_field_edit_form_submit() */ function field_ui_field_edit_form_validate($form, &$form_state) { // Take the incoming values as the $instance definition, so that the 'default @@ -2082,7 +2133,7 @@ function field_ui_field_edit_form_validate($form, &$form_state) { /** * Form submission handler for field_ui_field_edit_form(). * - * @see field_ui_field_edit_form_validate(). + * @see field_ui_field_edit_form_validate() */ function field_ui_field_edit_form_submit($form, &$form_state) { $instance = $form_state['values']['instance']; diff --git a/core/modules/field_ui/field_ui.api.php b/core/modules/field_ui/field_ui.api.php index 80cbe78..6b013d2 100644 --- a/core/modules/field_ui/field_ui.api.php +++ b/core/modules/field_ui/field_ui.api.php @@ -83,7 +83,7 @@ function hook_field_instance_settings_form($field, $instance) { t('Yes'), ), '#description' => t('Display the summary to allow the user to input a summary value. Hide the summary to automatically fill it with a trimmed portion from the main post.'), - '#default_value' => !empty($settings['display_summary']) ? $settings['display_summary'] : 0, + '#default_value' => !empty($settings['display_summary']) ? $settings['display_summary'] : 0, ); } diff --git a/core/modules/field_ui/field_ui.module b/core/modules/field_ui/field_ui.module index bde3f35..cb5c67b 100644 --- a/core/modules/field_ui/field_ui.module +++ b/core/modules/field_ui/field_ui.module @@ -104,13 +104,20 @@ function field_ui_menu() { $items["$path/fields"] = array( 'title' => 'Manage fields', 'page callback' => 'drupal_get_form', - 'page arguments' => array('field_ui_field_overview_form', $entity_type, $bundle_arg), + 'page arguments' => array( + 'field_ui_field_overview_form', + $entity_type, + $bundle_arg), 'type' => MENU_LOCAL_TASK, 'weight' => 1, 'file' => 'field_ui.admin.inc', ) + $access; $items["$path/fields/%field_ui_menu"] = array( - 'load arguments' => array($entity_type, $bundle_arg, $bundle_pos, '%map'), + 'load arguments' => array( + $entity_type, + $bundle_arg, + $bundle_pos, + '%map'), 'title callback' => 'field_ui_menu_title', 'title arguments' => array($field_position), 'page callback' => 'drupal_get_form', @@ -118,7 +125,11 @@ function field_ui_menu() { 'file' => 'field_ui.admin.inc', ) + $access; $items["$path/fields/%field_ui_menu/edit"] = array( - 'load arguments' => array($entity_type, $bundle_arg, $bundle_pos, '%map'), + 'load arguments' => array( + $entity_type, + $bundle_arg, + $bundle_pos, + '%map'), 'title' => 'Edit', 'page callback' => 'drupal_get_form', 'page arguments' => array('field_ui_field_edit_form', $field_position), @@ -126,7 +137,11 @@ function field_ui_menu() { 'file' => 'field_ui.admin.inc', ) + $access; $items["$path/fields/%field_ui_menu/field-settings"] = array( - 'load arguments' => array($entity_type, $bundle_arg, $bundle_pos, '%map'), + 'load arguments' => array( + $entity_type, + $bundle_arg, + $bundle_pos, + '%map'), 'title' => 'Field settings', 'page callback' => 'drupal_get_form', 'page arguments' => array('field_ui_field_settings_form', $field_position), @@ -134,7 +149,11 @@ function field_ui_menu() { 'file' => 'field_ui.admin.inc', ) + $access; $items["$path/fields/%field_ui_menu/widget-type"] = array( - 'load arguments' => array($entity_type, $bundle_arg, $bundle_pos, '%map'), + 'load arguments' => array( + $entity_type, + $bundle_arg, + $bundle_pos, + '%map'), 'title' => 'Widget type', 'page callback' => 'drupal_get_form', 'page arguments' => array('field_ui_widget_type_form', $field_position), @@ -142,7 +161,11 @@ function field_ui_menu() { 'file' => 'field_ui.admin.inc', ) + $access; $items["$path/fields/%field_ui_menu/delete"] = array( - 'load arguments' => array($entity_type, $bundle_arg, $bundle_pos, '%map'), + 'load arguments' => array( + $entity_type, + $bundle_arg, + $bundle_pos, + '%map'), 'title' => 'Delete', 'page callback' => 'drupal_get_form', 'page arguments' => array('field_ui_field_delete_form', $field_position), @@ -155,7 +178,11 @@ function field_ui_menu() { $items["$path/display"] = array( 'title' => 'Manage display', 'page callback' => 'drupal_get_form', - 'page arguments' => array('field_ui_display_overview_form', $entity_type, $bundle_arg, 'default'), + 'page arguments' => array( + 'field_ui_display_overview_form', + $entity_type, + $bundle_arg, + 'default'), 'type' => MENU_LOCAL_TASK, 'weight' => 2, 'file' => 'field_ui.admin.inc', @@ -173,14 +200,23 @@ function field_ui_menu() { foreach ($view_modes as $view_mode => $view_mode_info) { $items["$path/display/$view_mode"] = array( 'title' => $view_mode_info['label'], - 'page arguments' => array('field_ui_display_overview_form', $entity_type, $bundle_arg, $view_mode), + 'page arguments' => array( + 'field_ui_display_overview_form', + $entity_type, + $bundle_arg, + $view_mode), // The access callback needs to check both the current 'custom // display' setting for the view mode, and the overall access // rules for the bundle admin pages. 'access callback' => '_field_ui_view_mode_menu_access', - 'access arguments' => array_merge(array($entity_type, $bundle_arg, $view_mode, $access['access callback']), $access['access arguments']), + 'access arguments' => array_merge(array( + $entity_type, + $bundle_arg, + $view_mode, + $access['access callback']), + $access['access arguments']), 'type' => ($view_mode == 'default' ? MENU_DEFAULT_LOCAL_TASK : MENU_LOCAL_TASK), - 'weight' => ($view_mode == 'default' ? -10 : $weight++), + 'weight' => ($view_mode == 'default' ? '-10' : $weight++), 'file' => 'field_ui.admin.inc', ); } @@ -377,7 +413,7 @@ function field_ui_form_node_type_form_alter(&$form, $form_state) { */ function field_ui_form_node_type_form_submit($form, &$form_state) { if ($form_state['triggering_element']['#parents'][0] === 'save_continue') { - $form_state['redirect'] = _field_ui_bundle_admin_path('node', $form_state['values']['type']) .'/fields'; + $form_state['redirect'] = _field_ui_bundle_admin_path('node', $form_state['values']['type']) . '/fields'; } } diff --git a/core/modules/field_ui/lib/Drupal/field_ui/Tests/AlterTest.php b/core/modules/field_ui/lib/Drupal/field_ui/Tests/AlterTest.php index 687aa2e..606d7b5 100644 --- a/core/modules/field_ui/lib/Drupal/field_ui/Tests/AlterTest.php +++ b/core/modules/field_ui/lib/Drupal/field_ui/Tests/AlterTest.php @@ -37,7 +37,11 @@ class AlterTest extends WebTestBase { $this->drupalCreateContentType(array('type' => 'article', 'name' => 'Article')); // Create test user. - $admin_user = $this->drupalCreateUser(array('access content', 'administer content types', 'administer users')); + $admin_user = $this->drupalCreateUser(array( + 'access content', + 'administer content types', + 'administer users', + )); $this->drupalLogin($admin_user); } @@ -78,7 +82,7 @@ class AlterTest extends WebTestBase { // Create the alter_test_options field. field_create_field(array( 'field_name' => 'alter_test_options', - 'type' => 'list_text' + 'type' => 'list_text', )); // Create instances on users and page nodes. field_create_instance(array( @@ -87,7 +91,7 @@ class AlterTest extends WebTestBase { 'bundle' => 'user', 'widget' => array( 'type' => 'options_select', - ) + ), )); field_create_instance(array( 'field_name' => 'alter_test_options', @@ -95,7 +99,7 @@ class AlterTest extends WebTestBase { 'bundle' => 'page', 'widget' => array( 'type' => 'options_select', - ) + ), )); // Test that field_test_field_widget_properties_user_alter() replaces diff --git a/core/modules/field_ui/lib/Drupal/field_ui/Tests/FieldUiTestBase.php b/core/modules/field_ui/lib/Drupal/field_ui/Tests/FieldUiTestBase.php index 06e8dc6..b515f84 100644 --- a/core/modules/field_ui/lib/Drupal/field_ui/Tests/FieldUiTestBase.php +++ b/core/modules/field_ui/lib/Drupal/field_ui/Tests/FieldUiTestBase.php @@ -25,7 +25,11 @@ abstract class FieldUiTestBase extends WebTestBase { parent::setUp(); // Create test user. - $admin_user = $this->drupalCreateUser(array('access content', 'administer content types', 'administer taxonomy')); + $admin_user = $this->drupalCreateUser(array( + 'access content', + 'administer content types', + 'administer taxonomy', + )); $this->drupalLogin($admin_user); // Create content type, with underscores. @@ -59,7 +63,7 @@ abstract class FieldUiTestBase extends WebTestBase { $field_name = $initial_edit['fields[_add_new_field][field_name]']; // First step : 'Add new field' on the 'Manage fields' page. - $this->drupalPost("$bundle_path/fields", $initial_edit, t('Save')); + $this->drupalPost("$bundle_path/fields", $initial_edit, t('Save')); $this->assertRaw(t('These settings apply to the %label field everywhere it is used.', array('%label' => $label)), t('Field settings page was displayed.')); // Second step : 'Field settings' form. diff --git a/core/modules/field_ui/lib/Drupal/field_ui/Tests/ManageDisplayTest.php b/core/modules/field_ui/lib/Drupal/field_ui/Tests/ManageDisplayTest.php index 40edfa5..5fe4c1a 100644 --- a/core/modules/field_ui/lib/Drupal/field_ui/Tests/ManageDisplayTest.php +++ b/core/modules/field_ui/lib/Drupal/field_ui/Tests/ManageDisplayTest.php @@ -51,8 +51,8 @@ class ManageDisplayTest extends FieldUiTestBase { $setting_name = key($default_settings); $setting_value = $instance['display']['default']['settings'][$setting_name]; - // Display the "Manage display" screen and check that the expected formatter is - // selected. + // Display the "Manage display" screen and check that the expected formatter + // is selected. $this->drupalGet($manage_display); $this->assertFieldByName('fields[field_test][type]', $format, t('The expected formatter is selected.')); $this->assertText("$setting_name: $setting_value", t('The expected summary is displayed.')); @@ -101,11 +101,12 @@ class ManageDisplayTest extends FieldUiTestBase { $formatters = field_info_formatter_types(); $output = array( 'field_test_default' => $formatters['field_test_default']['settings']['test_formatter_setting'] . '|' . $value, - 'field_test_with_prepare_view' => $formatters['field_test_with_prepare_view']['settings']['test_formatter_setting_additional'] . '|' . $value. '|' . ($value + 1), + 'field_test_with_prepare_view' => $formatters['field_test_with_prepare_view']['settings']['test_formatter_setting_additional'] . '|' . $value . '|' . ($value + 1), ); // Check that the field is displayed with the default formatter in 'rss' - // mode (uses 'default'), and hidden in 'teaser' mode (uses custom settings). + // mode (uses 'default'), and hidden in 'teaser' mode + // (uses custom settings). $this->assertNodeViewText($node, 'rss', $output['field_test_default'], t("The field is displayed as expected in view modes that use 'default' settings.")); $this->assertNodeViewNoText($node, 'teaser', $value, t("The field is hidden in view modes that use custom settings.")); @@ -179,6 +180,7 @@ class ManageDisplayTest extends FieldUiTestBase { * Plain text to look for. * @param $message * Message to display. + * * @return * TRUE on pass, FALSE on fail. */ @@ -218,7 +220,7 @@ class ManageDisplayTest extends FieldUiTestBase { $clone = clone $node; $element = node_view($clone, $view_mode); $output = drupal_render($element); - $this->verbose(t('Rendered node - view mode: @view_mode', array('@view_mode' => $view_mode)) . '
'. $output); + $this->verbose(t('Rendered node - view mode: @view_mode', array('@view_mode' => $view_mode)) . '
' . $output); // Assign content so that WebTestBase functions can be used. $this->drupalSetContent($output); diff --git a/core/modules/field_ui/lib/Drupal/field_ui/Tests/ManageFieldsTest.php b/core/modules/field_ui/lib/Drupal/field_ui/Tests/ManageFieldsTest.php index 4aa0dd6..39dbf28 100644 --- a/core/modules/field_ui/lib/Drupal/field_ui/Tests/ManageFieldsTest.php +++ b/core/modules/field_ui/lib/Drupal/field_ui/Tests/ManageFieldsTest.php @@ -24,8 +24,8 @@ class ManageFieldsTest extends FieldUiTestBase { // Create random field name. $this->field_label = $this->randomName(8); - $this->field_name_input = strtolower($this->randomName(8)); - $this->field_name = 'field_'. $this->field_name_input; + $this->field_name_input = strtolower($this->randomName(8)); + $this->field_name = 'field_' . $this->field_name_input; // Create Basic page and Article node types. $this->drupalCreateContentType(array('type' => 'page', 'name' => 'Basic page')); @@ -85,8 +85,8 @@ class ManageFieldsTest extends FieldUiTestBase { $this->assertRaw($table_header . '', t('%table_header table header was found.', array('%table_header' => $table_header))); } - // "Add new field" and "Re-use existing field" aren't a table heading so just - // test the text. + // "Add new field" and "Re-use existing field" aren't a table heading so + // just test the text. foreach (array('Add new field', 'Re-use existing field') as $element) { $this->assertText($element, t('"@element" was found.', array('@element' => $element))); } @@ -191,7 +191,7 @@ class ManageFieldsTest extends FieldUiTestBase { $field_name = 'test'; $field = array( 'field_name' => $field_name, - 'type' => 'test_field' + 'type' => 'test_field', ); field_create_field($field); $instance = array( @@ -220,7 +220,7 @@ class ManageFieldsTest extends FieldUiTestBase { $instance = field_info_instance('node', $field_name, $this->type); $this->assertEqual($instance['default_value'], array(array('value' => 1)), t('The default value was correctly saved.')); - // Check that the default value shows up in the form + // Check that the default value shows up in the form. $this->drupalGet($admin_path); $this->assertFieldById($element_id, '1', t('The default value widget was displayed with the correct value.')); @@ -265,7 +265,7 @@ class ManageFieldsTest extends FieldUiTestBase { _field_info_collate_fields_reset(); // Check that the field instance was deleted. $this->assertNull(field_info_instance('node', $this->field_name, $this->type), t('Field instance was deleted.')); - // Check that the field was not deleted + // Check that the field was not deleted. $this->assertNotNull(field_info_field($this->field_name), t('Field was not deleted.')); // Delete the second instance. @@ -307,8 +307,8 @@ class ManageFieldsTest extends FieldUiTestBase { $this->drupalGet($bundle_path); $this->assertFieldByXPath('//table[@id="field-overview"]//td[1]', $instance['label'], t('Field was created and appears in the overview page.')); - // Check that the instance does not appear in the 're-use existing field' row - // on other bundles. + // Check that the instance does not appear in the 're-use existing field' + // row on other bundles. $bundle_path = 'admin/structure/types/manage/article/fields/'; $this->drupalGet($bundle_path); $this->assertFalse($this->xpath('//select[@id="edit-add-existing-field-field-name"]//option[@value=:field_name]', array(':field_name' => $field_name)), t("The 're-use existing field' select respects field types 'no_ui' property."));