-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathding_export_to_ris.module
More file actions
102 lines (91 loc) · 2.4 KB
/
ding_export_to_ris.module
File metadata and controls
102 lines (91 loc) · 2.4 KB
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
<?php
/**
* @file
* Interface module for talking with the materials backend.
*/
define('BUTTON_URL', 'https://bibliotek.dk/da/export/cart/ris/');
/**
* Implements hook_block_info().
*/
function ding_export_to_ris_block_info() {
$blocks['export_to_ris'] = array(
'info' => t('Export in RIS-format'),
);
return $blocks;
}
/**
* Implements hook_block_view().
*/
function ding_export_to_ris_block_view($delta = '') {
$block = array();
switch ($delta) {
case 'export_to_ris':
$module_path = drupal_get_path('module', 'ding_export_to_ris');
// Export bookmarts settings to Drupal js settings.
drupal_add_js(array('exportToRisUrl' => BUTTON_URL), 'setting');
// Enabling ding popup for error messaging.
drupal_add_js(drupal_get_path('module', 'ding_popup') . '/ding_popup.js');
drupal_add_js($module_path . '/js/ding_export_to_ris.js', array(
'scope' => 'footer',
'weight' => 99,
));
// Block markup.
$block['subject'] = t('Export in RIS-format');
$block['content'] = l(
t('Export in RIS-format'), '#',
array(
'attributes' =>
array(
'class' => array('export-to-ris')
)
)
);
break;
}
return $block;
}
/**
* Implements hook_ding_entity_buttons().
*/
function ding_export_to_ris_ding_entity_buttons($type, $entity, $widget = 'default') {
$id = $entity->ding_entity_id;
if (!empty($entity->data)) {
$object = $entity->data;
$id = $object->getObjectId();
}
return array(
array(
'#theme' => 'link',
'#text' => '<i class="icon-white icon-download-alt"></i>',
'#path' => '#',
'#weight' => 104,
'#options' => array(
'attributes' => array(
'class' => array(
'btn',
'btn-artesis-turquoise',
'export-to-ris-btn',
),
'data-tid' => $id,
'title' => t('Export in RIS-format'),
),
'html' => TRUE,
'absolute' => TRUE,
),
'#attached' => array(
'js' => array(
array(
'data' => drupal_get_path('module', 'ding_export_to_ris') . '/js/ding_export_to_ris.js',
'type' => 'file',
),
array(
'data' => array(
'exportToRisUrl' => BUTTON_URL
),
'type' => 'setting',
),
),
),
)
);
}