-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathartesis_netarchive.module
More file actions
70 lines (59 loc) · 1.91 KB
/
artesis_netarchive.module
File metadata and controls
70 lines (59 loc) · 1.91 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
<?php
/**
* @file
* Add link to archived pdf articles of Ting objects.
*/
// Load Field module hooks.
module_load_include('inc', 'artesis_netarchive', 'artesis_netarchive.field');
/**
* Implements hook_menu().
*/
function artesis_netarchive_menu() {
$items = array();
$items['ting/netarchive'] = array(
'title' => 'Retreives netarchive for Ting objects',
'page callback' => 'artesis_netarchive_objects',
'access arguments' => array('access content'),
'type' => MENU_CALLBACK,
'file' => 'artesis_netarchive.pages.inc',
);
return $items;
}
/**
* Implements hook_theme().
*/
function artesis_netarchive_theme() {
return array(
'artesis_netarchive_link_theme' => array(
'render element' => 'elements',
'file' => 'artesis_netarchive.theme.inc',
),
);
}
/**
* Implements hook_preprocess_ting_object().
*
* Force the field to appear above the ding_entity_buttons.
*/
function artesis_netarchive_preprocess_ting_object(&$variables) {
// Dive in only for 'search_result' view mode.
if ('search_result' !== $variables['elements']['#view_mode']) {
return;
}
$elements = &$variables['elements'];
if (!array_key_exists('group_content', $elements['#groups'])) {
return;
}
$content = &$variables['content'];
if (!array_key_exists('ding_entity_buttons', $content) || !array_key_exists('netarchive_link', $content)) {
return;
}
$content['netarchive_link']['#weight'] = $content['ding_entity_buttons']['#weight'] - 1;
// There are two keys, which are references to same object: #groups and #fieldgroups.
// Populating #groups will populate #fieldgroups as well.
if (!in_array('netarchive_link', $elements['#groups']['group_content']->children)) {
$elements['#groups']['group_content']->children[] = 'netarchive_link';
}
// Enforce specific group regardless what's there already.
$elements['#group_children']['netarchive_link'] = 'group_content';
}