-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathislandora_youtube.module
92 lines (87 loc) · 3.45 KB
/
islandora_youtube.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
<?php
/**
* Islandora YouTube
*
* Lets you "ingest" a YouTube video and display it.
*/
function islandora_youtube_islandora_required_objects(IslandoraTuque $connection) {
$module_path = drupal_get_path('module', 'islandora_youtube');
// Youtube Video Content Model.
$youtube_content_model = $connection->repository->constructObject('islandora:sp_youtubeCModel');
$youtube_content_model->owner = 'fedoraAdmin';
$youtube_content_model->label = 'Islandora YouTube Content Model';
$youtube_content_model->models = 'fedora-system:ContentModel-3.0';
// ISLANDORACM Datastream.
$datastream = $youtube_content_model->constructDatastream('ISLANDORACM', 'X');
$datastream->label = 'Islandora content model';
$datastream->mimetype = 'text/xml';
$datastream->setContentFromFile("$module_path/xml/islandora_youtube_cmodel.xml", FALSE);
$youtube_content_model->ingestDatastream($datastream);
// DS-COMPOSITE-MODEL Datastream.
$datastream = $youtube_content_model->constructDatastream('DS-COMPOSITE-MODEL', 'X');
$datastream->label = 'DS-COMPOSITE-MODEL';
$datastream->mimetype = 'text/xml';
$datastream->setContentFromFile("$module_path/xml/islandora_youtube_ds_composite_model.xml", FALSE);
$youtube_content_model->ingestDatastream($datastream);
// Youtube Collection.
$youtube_collection = $connection->repository->constructObject('islandora:youtube_collection');
$youtube_collection->owner = 'fedoraAdmin';
$youtube_collection->label = 'YouTube Video Collection';
$youtube_collection->models = 'islandora:collectionCModel';
$youtube_collection->relationships->add(FEDORA_RELS_EXT_URI, 'isMemberOfCollection', 'islandora:root');
// Collection Policy Datastream.
$datastream = $youtube_collection->constructDatastream('COLLECTION_POLICY', 'X');
$datastream->label = 'Collection policy';
$datastream->mimetype = 'text/xml';
$datastream->setContentFromFile("$module_path/xml/islandora_youtube_collection_policy.xml", FALSE);
$youtube_collection->ingestDatastream($datastream);
// TN Datastream.
$datastream = $youtube_collection->constructDatastream('TN', 'M');
$datastream->label = 'Thumbnail';
$datastream->mimetype = 'image/png';
$datastream->setContentFromFile("$module_path/images/folder.png", FALSE);
$youtube_collection->ingestDatastream($datastream);
return array(
'islandora_youtube' => array(
'title' => 'Islandora Youtube',
'objects' => array(
$youtube_content_model,
$youtube_collection,
),
),
);
}
/**
* Implements hook_islandora_ingest_steps().
*/
function islandora_youtube_islandora_sp_youtubeCModel_islandora_ingest_steps() {
return array(
'islandora_youtube_upload' => array(
'weight' => 5,
'type' => 'form',
'form_id' => 'islandora_youtube_upload_form',
'module' => 'islandora_youtube',
'file' => 'includes/youtube_upload.form.inc',
),
);
}
/**
* Implements hook_theme().
*/
function islandora_youtube_theme($existing, $type, $theme, $path) {
return array(
'islandora_youtube' => array(
'template' => 'theme/islandora-youtube',
'file' => 'theme/theme.inc',
'pattern' => 'islandora_youtube__',
'variables' => array('object' => NULL),
),
);
}
/**
* Implements hook_CMODEL_PID_islandora_view_object().
*/
function islandora_youtube_islandora_sp_youtubeCModel_islandora_view_object($object, $page_number, $page_size) {
$output = theme('islandora_youtube', array('object' => $object));
return array('' => $output);
}