forked from DBCDK/ting
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathting.theme.inc
More file actions
81 lines (69 loc) · 2.63 KB
/
ting.theme.inc
File metadata and controls
81 lines (69 loc) · 2.63 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
<?php
/**
* @file
* Theming functions for ting.
*/
/**
* Template preprocessor for ting objects.
*/
function template_preprocess_ting_object(&$variables) {
$variables['object'] = $variables['elements']['#object'];
// Set 'h1' title for collection page.
if ($variables['id'] == 1 && $variables['elements']['#view_mode'] == 'collection_primary') {
$variables['elements']['group_collection_object']['ting_title'][0]['#prefix'] = '<h1>';
$variables['elements']['group_collection_object']['ting_title'][0]['#sufix'] = '</h1>';
}
$variables['page'] = $variables['elements']['#view_mode'] == 'full';
// Helpful $content variable for templates.
foreach (element_children($variables['elements']) as $key) {
$variables['content'][$key] = $variables['elements'][$key];
}
if (isset($variables['content']['entities'])) {
foreach ($variables['content']['entities'] as $key => $val) {
$variables['content']['overview']['types'][] = $key;
}
}
// Set entity 'class'.
$class = 'ding-entity';
// Disable entity buttons for collection items.
if (is_object($variables['object']) && $variables['object'] instanceof TingCollection) {
// Set collection 'class'.
if (count($variables['object']->getEntities()) > 1) {
$class = 'ding-entity-collection';
unset($variables['content']['ting_primary_object'][0]['ding_entity_buttons']);
}
}
// Modify 'alt' attribute for list items.
if (!empty($variables['content']['ting_cover']) && !empty($variables['content']['group_collection_list'])) {
$variables['content']['ting_cover'][0]['#alt'] = implode(' ', array(
$variables['object']->title,
$variables['object']->type,
$variables['object']->date,
));
}
// Remove fieldset 'id' attribute.
if (!empty($variables['content']['group_collection_object']['#id'])) {
unset($variables['content']['group_collection_object']['#id']);
}
if (!empty($variables['content']['group_collection_list']['#id'])) {
unset($variables['content']['group_collection_list']['#id']);
}
if (!empty($variables['content']['group_content']['#id'])) {
unset($variables['content']['group_content']['#id']);
}
// Set additional classes.
$variables['classes_array'] = array_merge($variables['classes_array'], array(
'clearfix',
'type-' . $class,
drupal_html_class('view-mode-' . $variables['elements']['#view_mode']),
));
}
/**
* Helper function to format abstracts from ting.
*/
function ting_format_abstract($string) {
$string = str_replace('Indhold:', '', $string);
$string = str_replace(' ; ', '<br/>', $string);
$string = str_replace(' / ', '<br/>', $string);
return $string;
}