forked from Islandora/islandora_solution_pack_collection
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathadmin.form.inc
178 lines (169 loc) · 6.88 KB
/
admin.form.inc
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
<?php
/**
* @file
* Handles the display and submission of this modules admin form.
*/
/**
* Defines the admin settings form.
*
* @param array $form
* The Drupal form definition.
* @param array $form_state
* The Drupal form state.
*
* @return array
* The Drupal form definition.
*/
function islandora_basic_collection_admin(array $form, array &$form_state) {
$backend_options = module_invoke_all('islandora_basic_collection_query_backends');
$map_to_title = function ($backend) {
return $backend['title'];
};
$form = array(
// Display options.
'display_generation_fieldset' => array(
'#type' => 'fieldset',
'#title' => t('Display Generation'),
'#states' => array(
'invisible' => array(
':input[name="islandora_basic_collection_disable_display_generation"]' => array('checked' => TRUE),
),
),
'islandora_collection_display' => array(
'islandora_basic_collection_page_size' => array(
'#type' => 'textfield',
'#title' => t('Default collection objects per page'),
'#default_value' => variable_get('islandora_basic_collection_page_size', '12'),
'#description' => t('The default number of objects to show in a collection view.'),
),
'islandora_basic_collection_disable_count_object' => array(
'#type' => 'checkbox',
'#title' => t('Disable object count query in collection overview'),
'#default_value' => variable_get('islandora_basic_collection_disable_count_object', FALSE),
'#description' => t("Disabling the object count query can improve performance when loading the overview for large collections."),
),
'islandora_basic_collection_default_view' => array(
'#type' => 'select',
'#title' => t('Default collection view style.'),
'#default_value' => variable_get('islandora_basic_collection_default_view', 'grid'),
'#options' => array(
'list' => t('List'),
'grid' => t('Grid'),
),
),
'islandora_basic_collection_display_backend' => array(
'#type' => 'radios',
'#title' => t('Display Generation'),
'#options' => array_map($map_to_title, $backend_options),
'#default_value' => variable_get('islandora_basic_collection_display_backend', ISLANDORA_BASIC_COLLECTION_LEGACY_BACKEND),
),
),
),
'islandora_basic_collection_disable_display_generation' => array(
'#type' => 'checkbox',
'#title' => t('Completely disable default collection display generation.'),
'#default_value' => variable_get('islandora_basic_collection_disable_display_generation', FALSE),
'#description' => t("Disabling display generation allows for alternate collection displays to be used."),
),
'islandora_basic_collection_admin_page_size' => array(
'#type' => 'textfield',
'#title' => t('Objects per page during collection management'),
'#default_value' => variable_get('islandora_basic_collection_admin_page_size', '10'),
'#description' => t('The number of child objects to show per page in the migrate/share/delete interface.'),
'#element_validate' => array('element_validate_integer_positive'),
'#required' => TRUE,
),
'islandora_basic_collection_disable_collection_policy_delete' => array(
'#type' => 'checkbox',
'#title' => t('Disable deleting the collection policy'),
'#default_value' => variable_get('islandora_basic_collection_disable_collection_policy_delete', TRUE),
'#description' => t("Disables the 'delete' link for the COLLECTION_POLICY datastream."),
),
// Metadata display.
'metadata_display_fieldset' => array(
'#type' => 'fieldset',
'#title' => t('Metadata display'),
'islandora_collection_metadata_display' => array(
'#type' => 'checkbox',
'#title' => t('Display object metadata'),
'#description' => t('Display object metadata below the collection display.'),
'#default_value' => variable_get('islandora_collection_metadata_display', FALSE),
),
),
);
// Define the elements that appear on a collection objects display page.
// The key's match up with the form elements array keys.
$page_content = array(
'description' => array(
'name' => t("Description"),
'description' => t("An objects description field"),
),
'collections' => array(
'name' => t("In Collection"),
'description' => t("Indicates which collections this object belongs to"),
),
'wrapper' => array(
'name' => t("Fieldset Metadata"),
'description' => t("An objects metadata collection set"),
),
'islandora_basic_collection_display' => array(
'name' => t("Object Content"),
'description' => t("Main object page content, such as configured viewers"),
),
);
$form['metadata_display_fieldset']['islandora_basic_collection_metadata_info_table_drag_attributes'] = array(
'#theme_wrappers' => array('fieldset'),
'#tree' => TRUE,
'#title' => t("Page content placement"),
'#theme' => 'islandora_basic_collection_metadata_table_drag_components',
'#description' => t('Use the table below to determine the rendering order of page and metadata content.'),
'#states' => array(
'visible' => array(
':input[name="islandora_basic_collection_display_backend"]' => array('!value' => ISLANDORA_BASIC_COLLECTION_LEGACY_BACKEND),
':input[name="islandora_collection_metadata_display"]' => array('checked' => TRUE),
),
),
);
$config = variable_get('islandora_basic_collection_metadata_info_table_drag_attributes', array());
foreach ($page_content as $key => $data) {
$form['metadata_display_fieldset']['islandora_basic_collection_metadata_info_table_drag_attributes'][$key] = array();
$element =& $form['metadata_display_fieldset']['islandora_basic_collection_metadata_info_table_drag_attributes'][$key];
if (!isset($config[$key])) {
$config[$key] = array();
}
$config[$key] += array(
'weight' => 0,
'omit' => 0,
);
$element['#weight'] = $config[$key]['weight'];
$element['label'] = array(
'#type' => 'item',
'#markup' => $data['name'],
);
$element['textfield'] = array(
'#type' => 'item',
'#markup' => $data['description'],
);
$element['weight'] = array(
'#type' => 'textfield',
'#default_value' => $element['#weight'],
'#size' => 3,
'#attributes' => array(
'class' => array(
'item-row-weight',
),
),
);
$element['omit'] = array(
'#type' => 'checkbox',
'#default_value' => $config[$key]['omit'],
'#attributes' => array(
'class' => array(
'item-row-weight',
),
'title' => t('Hide the selected element from display, marking it as an invisible element in the DOM.'),
),
);
}
return system_settings_form($form);
}