-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfield_validation_report.admin.inc
More file actions
70 lines (64 loc) · 3.11 KB
/
field_validation_report.admin.inc
File metadata and controls
70 lines (64 loc) · 3.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
<?php
/**
* @file
* Contains admin functionality for the field validation report module.
*/
/**
* Page callback for the field validation report configuration.
*/
function field_validation_report_config() {
$form = array();
$form['#attached'] = array(
'css' => array(
drupal_get_path('module', 'field_validation_report') . '/field_validation_report.admin.css',
),
);
$form['entities'] = array(
'#type' => 'fieldset',
'#title' => t('Master controls for all entities'),
'#description' => t("By enabling and disabling items here, it is possible to control which entities (e.g. nodes, taxonomy terms) and bundles (e.g. content types, vocabularies) will have the appear in the field validation report. If an entity type is disabled it also disables it for <em>all</em> of that entity type's bundles.<br />Technical note: Entity types must be fieldable and must not be configuration entities."),
'#collapsible' => TRUE,
'#collapsed' => FALSE,
);
foreach (entity_get_info() as $entity_type => $entity_info) {
// Only show entities that are capable of using field validation report.
if (field_validation_report_entity_type_is_suitable($entity_type, $entity_info)) {
$entity_enabled = field_validation_report_entities_enabled($entity_type);
$form['entities']['field_validation_report_enable_' . $entity_type] = array(
'#type' => 'checkbox',
'#title' => t($entity_info['label']),
'#default_value' => $entity_enabled,
);
// Some entities, e.g. User, (core) File, have a single bundle with the
// same name as the entity, so only show the bundles list if there is
// more than one of them and the bundle's name isn't the same as the
// entity type's.
if (!empty($entity_info['bundles'])) {
foreach ($entity_info['bundles'] as $bundle_name => $bundle_info) {
if (count($entity_info['bundles']) > 1 || $entity_type != $bundle_name) {
// If the entity type was disabled, automatically enable the bundle.
// This will have the effect that if the entity type is enabled in
// the form then all of the bundles will then also be enabled. This
// is safe to do because in the rest of the module the bundle will
// be ignored if the entity is disabled.
$form['entities']['field_validation_report_enable_' . $entity_type . '__' . $bundle_name] = array(
'#type' => 'checkbox',
'#title' => t($bundle_info['label']),
'#default_value' => !$entity_enabled || field_validation_report_entities_enabled($entity_type, $bundle_name),
'#attributes' => array(
// Add some theming that'll indent this bundle.
'class' => array('field-validation-report-bundle-checkbox'),
),
'#states' => array(
'visible' => array(
':input[name="field_validation_report_enable_' . $entity_type . '"]' => array('checked' => TRUE),
),
),
);
}
}
}
}
}
return system_settings_form($form);
}