-
Notifications
You must be signed in to change notification settings - Fork 1
/
islandora_thumbnail_selector.module
83 lines (78 loc) · 2.54 KB
/
islandora_thumbnail_selector.module
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
<?php
/**
* Implements islandora_basic_collection_build_manage_object().
*
* @param array $form_state
* The current Form State being processed.
* @param AbstractObject $object
* The Islandora Object being processed.
*
* @return array
* The current Form State with a form element appended.
*/
function islandora_thumbnail_selector_islandora_basic_collection_build_manage_object(array $form_state, AbstractObject $object) {
$form_state['manage_collection_object']['set-thumbnail'] = array(
'#id' => 'select-thumbnail',
'#group' => 'thumbnail',
'#access' => true,
'#type' => 'fieldset',
'#title' => t('Select thumbnail'),
'form' => drupal_get_form('islandora_thumbnail_selector_form', $object),
);
$form_state['manage_collection_object']['set-thumbnail']['form']['#submit'][] = 'islandora_thumbnail_selector_form_submit';
return $form_state;
}
/**
* Define the xacml management form.
*
* @param array $form
* The Drupal form definition.
* @param array $form_state
* The Drupal form state.
* @param AbstractObject $object
* The collection to move child objects from.
*
* @return array
* The Drupal form definition.
*/
function islandora_thumbnail_selector_form(array $form, array &$form_state, AbstractObject $object) {
if (module_exists('islandora_basic_collection')) {
module_load_include('inc', 'islandora', 'includes/utilities');
module_load_include('inc', 'islandora_thumbnail_selector', 'includes/utilities');
$form_state['collection'] = $object;
return array(
'#action' => request_uri() . '#select-thumbnail',
'child' => islandora_thumbnail_selector_get_thumbnail_select_form_element($object, array(
'element' => 4,
'fragment' => '#select-thumbnail',
)),
'description' => array(
'#type' => 'item',
'#markup' => t('Choose a child object to use its thumbnail.'),
),
'submit' => array(
'#type' => 'submit',
'#value' => t('Update Thumbnail'),
),
);
}
else {
return array();
}
}
/**
* Submit handler for the manage XACML form.
*
* @param array $form
* The Drupal form definition.
* @param array $form_state
* The Drupal form state.
*/
function islandora_thumbnail_selector_form_submit(array $form, array &$form_state) {
$collection = $form_state['collection'];
$child = $form_state['values']['child'];
if($child != null)
islandora_thumbnail_selector_replace_thumbnail($collection, islandora_object_load($child));
else
drupal_set_message(t('Can not update thumbnail. No object has been specified.'),'error');
}