-
Notifications
You must be signed in to change notification settings - Fork 8
/
islandora_porcus.module
163 lines (151 loc) · 5.68 KB
/
islandora_porcus.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
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
<?php
/**
* @file
* Pig latin demo module.
*
*/
/**
* Implements hook_menu().
* Drupal menus allow urls to be used as function calls, giving Drupal gets much
* of its power and flexibillty.
* See https://api.drupal.org/api/drupal/modules!system!system.api.php/function/hook_menu/7
*/
function islandora_porcus_menu() {
return array(
'admin/islandora/porcus' => array(
'title' => 'Pig Latin Module',
'description' => 'Configure the Pig Latin solution pack.',
'page callback' => 'drupal_get_form',
'access arguments' => array('administer site configuration'),
'page arguments' => array('islandora_porcus_admin'),
'file' => 'includes/islandora_porcus.admin.inc',
'type' => MENU_NORMAL_ITEM,
),
);
}
/**
* Implements hook_theme().
*
* We supply a pattern so we can overide templates at the theme level if needed.
* we can append a pid to a template and the new template file will be called
* (the pids colon should be replaced with a dash)
*/
function islandora_porcus_theme($existing, $type, $theme, $path) {
return array(
'islandora_porcus' => array(
'template' => 'theme/islandora-porcus',
'pattern' => 'islandora_porcus__',
'variables' => array('islandora_object' => NULL),
),
);
}
/**
* Implements hook_preprocess_theme().
* This is a Drupal hook, not supplied by islandora.
* Variables required for display are assembled here and passed to the template file
* defined in the theme function. The function defines islandora-porcus, which
* expands to islandora-porcus.tpl.php.
* The isandora object has been added to the $variables array by
* hook_CMODEL_PID_islandora_view_object(), whihc in this case is
* islandora_porcus_islandora_porcusCModel_islandora_view_object
*
*/
function islandora_porcus_preprocess_islandora_porcus(array &$variables) {
$islandora_object = $variables['islandora_object'];
// Thumbnail.
if (isset($islandora_object['TN'])) {
$thumbnail_size_url = url("islandora/object/{$islandora_object->id}/datastream/TN/view");
$params = array(
'title' => $islandora_object->label,
'path' => $thumbnail_size_url,
);
$variables['islandora_thumbnail_img'] = theme('image', $params);
}
}
/**
* Implements hook_CMODEL_PID_islandora_view_object().
* If an object's behavior is defined by the islandora_porcus_islandora_porcusCModel content model
* this hook takes the object being displayed and sends it to the theme function described by islandora_porcus_theme.
* A reference to the islandora object being displayed is added here as a member of
* the array whihc makes the seond argument to the theme function.
*/
function islandora_porcus_islandora_porcusCModel_islandora_view_object($object, $page_number, $page_size) {
$output = theme('islandora_porcus', array('islandora_object' => $object));
return array('' => $output);
}
/**
* Implements hook_islandora_ingest_steps().
* This hook adds a single ingest step, but more could be added as seperate entries.
*/
function islandora_porcus_islandora_porcusCModel_islandora_ingest_steps(array $configuration) {
return array(
'islandora_porcus_file_upload' => array(
'weight' => 10,
'type' => 'form',
'form_id' => 'islandora_porcus_upload_form',
'module' => 'islandora_porcus',
'file' => 'includes/islandora_porcus_upload.form.inc'
)
);
}
/**
* Implements hook_CMODEL_PID_islandora_object_ingested().
* This hook tells Islandora what to do with the object once it has been ingested.
* In this case the raw text has been uploaded so we'll be in a position to
* use that as input for our derived datastreams. The function
* islandora_porcus_create_all_derivatives will be called with a refrence to the
* as yet uningested object.
*/
function islandora_porcus_islandora_porcusCModel_islandora_object_ingested($object) {
module_load_include('inc', 'islandora_porcus', 'includes/derivatives');
islandora_porcus_create_all_derivatives($object);
}
/**
* Implements hook_islandora_xml_form_builder_forms().
* This hook makes a predefined ingest form for ingest.
*/
function islandora_porcus_islandora_xml_form_builder_forms() {
$module_path = drupal_get_path('module', 'islandora_porcus');
return array(
'Porcus MODS form' => array(
'form_file' => "$module_path/xml/islandora_porcus_form_mods.xml",
),
);
}
/**
* Implements hook_islandora_content_model_forms_form_associations().
* This hook associated our form with our content model. Any time we try to ingest
* an object with the islandora:porcusCModel content model, we will see this form
* allowing us to supply relevant metadata.
*/
function islandora_porcus_islandora_content_model_forms_form_associations() {
return array(
'islandora_porcus_mods_form' => array(
'content_model' => 'islandora:porcusCModel',
'form_name' => 'Porcus MODS form',
'dsid' => 'MODS',
'title_field' => array('titleInfo', 'title'),
'transform' => 'mods_to_dc.xsl',
'template' => FALSE,
),
);
}
/**
* Implements hook_islandora_required_objects().
* This hook ingests a very basic content model. It is run when the module is
* first installed.
*/
function islandora_porcus_islandora_required_objects(IslandoraTuque $connection) {
$islandora_porcus_content_model = $connection->repository->constructObject('islandora:porcusCModel');
$islandora_porcus_content_model->owner = 'fedoraAdmin';
$islandora_porcus_content_model->label = 'Islandora Pig Latin Model';
$islandora_porcus_content_model->models = 'fedora-system:ContentModel-3.0';
return array(
'islandora_porcus' => array(
'title' => 'Islandora Pig Latin',
'objects' => array(
$islandora_porcus_content_model,
),
),
);
}