1
|
<?php
|
2
|
|
3
|
/**
|
4
|
* @file
|
5
|
* Administration page callbacks and forms.
|
6
|
*/
|
7
|
|
8
|
/**
|
9
|
* General configuration form for controlling the diff behaviour.
|
10
|
*/
|
11
|
function diff_admin_settings($form, $form_state) {
|
12
|
$form['diff_theme'] = array(
|
13
|
'#type' => 'select',
|
14
|
'#title' => t('CSS options'),
|
15
|
'#default_value' => variable_get('diff_theme', 'default'),
|
16
|
'#options' => array(
|
17
|
'default' => t('Classic'),
|
18
|
'boxes' => t('Boxes'),
|
19
|
),
|
20
|
'#empty_option' => t('- None -'),
|
21
|
'#description' => t('Alter the CSS used when displaying diff results.'),
|
22
|
);
|
23
|
$form['diff_default_state_node'] = array(
|
24
|
'#type' => 'select',
|
25
|
'#title' => t('Diff default state'),
|
26
|
'#default_value' => variable_get('diff_default_state_node', 'raw'),
|
27
|
'#options' => array(
|
28
|
'raw' => t('HTML view'),
|
29
|
'raw_plain' => t('Plain view'),
|
30
|
),
|
31
|
'#empty_option' => t('- None -'),
|
32
|
'#description' => t('Default display to show when viewing a diff, html tags in diffed result or as plain text.'),
|
33
|
);
|
34
|
$form['diff_radio_behavior'] = array(
|
35
|
'#type' => 'select',
|
36
|
'#title' => t('Diff radio behavior'),
|
37
|
'#default_value' => variable_get('diff_radio_behavior', 'simple'),
|
38
|
'#options' => array(
|
39
|
'simple' => t('Simple exclusion'),
|
40
|
'linear' => t('Linear restrictions'),
|
41
|
),
|
42
|
'#empty_option' => t('- None -'),
|
43
|
'#description' => t('<em>Simple exclusion</em> means that users will not be able to select the same revision, <em>Linear restrictions</em> means that users can only select older or newer revisions of the current selections.'),
|
44
|
);
|
45
|
|
46
|
$options = drupal_map_assoc(array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10));
|
47
|
$form['diff_context_lines_leading'] = array(
|
48
|
'#type' => 'select',
|
49
|
'#title' => t('Leading context lines'),
|
50
|
'#description' => t('This governs the number of unchanged leading context "lines" to preserve.'),
|
51
|
'#default_value' => variable_get('diff_context_lines_leading', 2),
|
52
|
'#options' => $options,
|
53
|
);
|
54
|
$form['diff_context_lines_trailing'] = array(
|
55
|
'#type' => 'select',
|
56
|
'#title' => t('Trailing context lines'),
|
57
|
'#description' => t('This governs the number of unchanged trailing context "lines" to preserve.'),
|
58
|
'#default_value' => variable_get('diff_context_lines_trailing', 2),
|
59
|
'#options' => $options,
|
60
|
);
|
61
|
|
62
|
return system_settings_form($form);
|
63
|
}
|
64
|
|
65
|
/**
|
66
|
* Global entity settings.
|
67
|
*/
|
68
|
function diff_admin_global_entity_settings($form, $form_state, $entity_type) {
|
69
|
$entity_info = entity_get_info($entity_type);
|
70
|
drupal_set_title(t('Diff settings for %entity_label entities', array('%entity_label' => $entity_info['label'])), PASS_THROUGH);
|
71
|
$form['diff_show_header_' . $entity_type] = array(
|
72
|
'#type' => 'checkbox',
|
73
|
'#title' => t('Show entity label header'),
|
74
|
'#default_value' => variable_get('diff_show_header_' . $entity_type, 1),
|
75
|
);
|
76
|
$form['diff_admin_path_' . $entity_type] = array(
|
77
|
'#type' => 'checkbox',
|
78
|
'#title' => t('Treat diff pages as administrative'),
|
79
|
'#description' => t('Diff pages are treated as administrative pages by default, although it is up to each module to enforce this and to implement this optional setting.'),
|
80
|
'#default_value' => variable_get('diff_admin_path_' . $entity_type, 1),
|
81
|
);
|
82
|
return system_settings_form($form);
|
83
|
}
|
84
|
|
85
|
/**
|
86
|
* Menu callback - provides an overview of Diff support and global settings.
|
87
|
*/
|
88
|
function diff_admin_field_overview() {
|
89
|
$build['info'] = array(
|
90
|
'#markup' => '<p>' . t('This table provides a summary of the field type support found on the system. It is recommended that you use global settings whenever possible to configure field comparison settings.') . '</p>',
|
91
|
);
|
92
|
|
93
|
$header = array(t('Type'), t('Module'), t('Operations'));
|
94
|
$rows = array();
|
95
|
|
96
|
// Skip field types which have no widget types.
|
97
|
$field_types = field_info_field_types();
|
98
|
$widgets = array();
|
99
|
foreach (field_info_widget_types() as $name => $widget_type) {
|
100
|
foreach ($widget_type['field types'] as $widget_field_type) {
|
101
|
if (isset($field_types[$widget_field_type])) {
|
102
|
$widgets[$widget_field_type][$name] = $widget_type['label'];
|
103
|
}
|
104
|
}
|
105
|
}
|
106
|
|
107
|
foreach ($field_types as $field_name => $field_type) {
|
108
|
if (!empty($widgets[$field_name])) {
|
109
|
$row = array();
|
110
|
$row[] = t('@field_label (%field_type)', array(
|
111
|
'@field_label' => $field_type['label'],
|
112
|
'%field_type' => $field_name,
|
113
|
));
|
114
|
$row[] = $field_type['module'];
|
115
|
$row[] = l(t('Global settings'), 'admin/config/content/diff/fields/' . $field_name);
|
116
|
$rows[] = $row;
|
117
|
}
|
118
|
}
|
119
|
|
120
|
$build['category_table'] = array(
|
121
|
'#theme' => 'table',
|
122
|
'#header' => $header,
|
123
|
'#rows' => $rows,
|
124
|
'#empty' => t('The system has no configurable fields.'),
|
125
|
);
|
126
|
return $build;
|
127
|
}
|
128
|
|
129
|
/**
|
130
|
* Menu form callback for the field settings.
|
131
|
*/
|
132
|
function diff_admin_global_field_settings($form, $form_state, $type) {
|
133
|
module_load_include('diff.inc', 'diff');
|
134
|
|
135
|
$field_types = field_info_field_types();
|
136
|
if (!isset($field_types[$type])) {
|
137
|
drupal_set_message(t('Invalid field type.'), 'error');
|
138
|
drupal_goto('admin/config/content/diff/fields');
|
139
|
}
|
140
|
$field_type = $field_types[$type];
|
141
|
|
142
|
// Set the title to give more context to this page.
|
143
|
drupal_set_title(t('Global settings for %label fields', array(
|
144
|
'%label' => $field_type['label'],
|
145
|
)), PASS_THROUGH);
|
146
|
|
147
|
$variable_name = "diff_{$field_type['module']}_field_{$type}_default_options";
|
148
|
$settings = variable_get($variable_name, array());
|
149
|
$settings = _diff_field_default_settings($field_type['module'], $type, $settings);
|
150
|
$func = $field_type['module'] . '_field_diff_options_form';
|
151
|
if (function_exists($func) && ($options_form = $func($type, $settings))) {
|
152
|
$form[$variable_name] = $options_form;
|
153
|
}
|
154
|
$form[$variable_name]['#tree'] = TRUE;
|
155
|
|
156
|
diff_global_settings_form($form[$variable_name], $form_state, $type, $settings);
|
157
|
return system_settings_form($form);
|
158
|
}
|