-
Notifications
You must be signed in to change notification settings - Fork 4
/
islandora_gsearch_index.module
75 lines (65 loc) · 2.32 KB
/
islandora_gsearch_index.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
<?php
/**
* Implements hook_menu().
*/
function islandora_gsearch_index_menu() {
$items = array();
$items['admin/islandora/islandora-gsearch-index'] = array(
'title' => 'Islandora GSearch Index',
'description' => 'Islandora GSearch Index Settings',
'page callback' => 'drupal_get_form',
'page arguments' => array('islandora_gsearch_index_configuration'),
'access arguments' => array('administer site configuration'),
'file' => 'includes/admin.form.inc',
'type' => MENU_NORMAL_ITEM,
);
return $items;
}
/**
* Implements hook_islandora_object_ingested().
*/
function islandora_gsearch_index_islandora_object_ingested(AbstractObject $object) {
if (variable_get('islandora_gsearch_index_fedoragsearch_uri', '')) {
if (drupal_strtolower($object->state) == 'a') {
$uri = variable_get('islandora_gsearch_index_fedoragsearch_uri', '');
$uri .= "/rest?operation=updateIndex&action=fromPid&value={$object->id}";
file_get_contents($uri);
} else {
islandora_gsearch_index_islandora_object_purged($object->id);
}
}
}
/**
* Implements hook_islandora_object_purged().
*/
function islandora_gsearch_index_islandora_object_purged($pid) {
if (variable_get('islandora_gsearch_index_fedoragsearch_uri', '')) {
$uri = variable_get('islandora_gsearch_index_fedoragsearch_uri', '');
$uri .= "/rest?operation=updateIndex&action=deletePid&value={$pid}";
file_get_contents($uri);
}
}
/**
* Implements hook_islandora_object_modified().
*/
function islandora_gsearch_index_islandora_object_modified(AbstractObject $object) {
islandora_gsearch_index_islandora_object_ingested($object);
}
/**
* Implements hook_islandora_datastream_ingested().
*/
function islandora_gsearch_index_islandora_datastream_ingested(AbstractObject $object, AbstractDatastream $datastream) {
islandora_gsearch_index_islandora_object_ingested($object);
}
/**
* Implements hook_islandora_datastream_modified().
*/
function islandora_gsearch_index_islandora_datastream_modified(AbstractObject $object, AbstractDatastream $datastream) {
islandora_gsearch_index_islandora_object_ingested($object);
}
/**
* Implements hook_islandora_datastream_purged().
*/
function islandora_gsearch_index_islandora_datastream_purged(AbstractObject $object, $dsid) {
islandora_gsearch_index_islandora_object_ingested($object);
}