-
Notifications
You must be signed in to change notification settings - Fork 15
/
islandora_xmlsitemap.module
124 lines (110 loc) · 3.71 KB
/
islandora_xmlsitemap.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
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
<?php
/**
* @file
* Main file for the islandora_xmlsitemap module.
*/
define('ISLANDORA_XMLSITEMAP_PATH_PREFIX', 'islandora/object/');
/**
* Implements hook_cron().
*/
function islandora_xmlsitemap_cron() {
module_load_include('inc', 'islandora_xmlsitemap', 'includes/batch');
xmlsitemap_run_unprogressive_batch('islandora_xmlsitemap_get_batch');
}
/**
* Implements hook_islandora_object_purged().
*
* When an islandora object is purged we will attempt to remove it from the
* xmlsitemap database.
*/
function islandora_xmlsitemap_islandora_object_purged($pid) {
module_load_include('inc', 'islandora_xmlsitemap', 'includes/utilities');
module_load_include('inc', 'islandora_xmlsitemap', 'includes/db');
$q = <<<EOQ
SELECT id
FROM {xmlsitemap}
WHERE type = 'custom' AND (
subtype = :sub_type OR loc = :loc
)
EOQ;
$ids = db_query($q, array(
':sub_type' => islandora_xmlsitemap_get_subtype_id($pid),
':loc' => islandora_xmlsitemap_get_link_url($pid),
))->fetchCol();
foreach ($ids as $id) {
$link = xmlsitemap_custom_load($id);
$value = xmlsitemap_link_delete('custom', array('id' => $id));
if ($value > 0) {
watchdog('islandora_xmlsitemap', 'Removed link %id with a path of %path from the xmlsitemap', array(
'%id' => $id,
'%path' => $link['loc'],
));
}
}
islandora_xmlsitemap_delete_increment_record($pid);
}
/**
* Implements hook_islandora_object_ingested().
*
* When an islandora object is ingested we will attempt to add a link to the
* xmlsitemap database.
*/
function islandora_xmlsitemap_islandora_object_ingested($object) {
module_load_include('inc', 'islandora_xmlsitemap', 'includes/utilities');
islandora_xmlsitemap_add_or_update_link($object->id);
}
/**
* Implements hook_islandora_object_modified().
*
* When an Islandora object is modified we will attempt to add a link to the
* xmlsitemap database.
*/
function islandora_xmlsitemap_islandora_object_modified($object) {
module_load_include('inc', 'islandora_xmlsitemap', 'includes/utilities');
drupal_static_reset('islandora_object_access');
islandora_xmlsitemap_add_or_update_link($object->id);
}
/**
* Implements hook_islandora_datastream_purged().
*/
function islandora_xmlsitemap_islandora_datastream_purged($object, $dsid) {
module_load_include('inc', 'islandora_xmlsitemap', 'includes/utilities');
drupal_static_reset('islandora_object_access');
islandora_xmlsitemap_add_or_update_link($object->id);
}
/**
* Implements hook_islandora_datastream_ingested().
*
* When an Islandora datastream is ingested we will attempt to add a link to the
* xmlsitemap database (to update).
*/
function islandora_xmlsitemap_islandora_datastream_ingested($object, $datastrean) {
module_load_include('inc', 'islandora_xmlsitemap', 'includes/utilities');
drupal_static_reset('islandora_object_access');
islandora_xmlsitemap_add_or_update_link($object->id);
}
/**
* Implements hook_islandora_datastream_modified().
*
* When an Islandora datastream is modified we will attempt to add a link to the
* xmlsitemap database.
*/
function islandora_xmlsitemap_islandora_datastream_modified($object, $datastream) {
module_load_include('inc', 'islandora_xmlsitemap', 'includes/utilities');
drupal_static_reset('islandora_object_access');
islandora_xmlsitemap_add_or_update_link($object->id);
}
/**
* Implements hook_menu().
*/
function islandora_xmlsitemap_menu() {
$items = array();
$items['admin/islandora/xmlsitemap'] = array(
'title' => 'XML Sitemap Integration',
'page callback' => 'drupal_get_form',
'page arguments' => array('islandora_xmlsitemap_admin_form'),
'access arguments' => array('administer site configuration'),
'file' => 'includes/admin.form.inc',
);
return $items;
}