-
Notifications
You must be signed in to change notification settings - Fork 0
/
template.php
147 lines (123 loc) · 3.63 KB
/
template.php
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
<?php
/**
* Helper functions for MIS
*
* @author Hilmar Kári Hallbjörnsson <hilmar@kosmosogkaos.is>
*/
function mis_theme_preprocess_user_login(&$vars) {
$vars['intro_text'] = t('MIS login form');
}
function mis_theme_theme() {
return array(
'user_login' => array(
'render element' => 'form',
'path' => drupal_get_path('theme', 'mis_theme') . '/templates',
'template' => 'user-login',
'preprocess functions' => array(
'mis_theme_preprocess_user_login'
),
)
);
}
function mis_theme_js_alter(&$js) {
// Sort JS items, so that they appear in the correct order.
uasort($js, 'drupal_sort_css_js');
$weight = 0;
foreach ($js as $name => $javascript) {
$js[$name]['group'] = -100;
$js[$name]['weight'] = ++$weight;
$js[$name]['every_page'] = 1;
}
}
function mis_theme_css_alter(&$css) {
// Sort CSS items, so that they appear in the correct order.
uasort($css, 'drupal_sort_css_js');
$weight = 0;
foreach ($css as $name => $javascript) {
$css[$name]['group'] = -100;
$css[$name]['weight'] = ++$weight;
$css[$name]['every_page'] = 1;
}
}
function mis_theme_get_frontpage_content($language)
{
$frontpageQuery = new EntityFieldQuery;
$result = $frontpageQuery
->entityCondition('entity_type', 'node')
->propertyCondition('type', 'forsida')
->propertyCondition('status', 1, '=')
->propertyCondition('language', $language, '=')
->propertyOrderBy('created', 'DESC')
->execute();
if (!empty($result['node'])) {
$frontpage = entity_load('node', array_keys($result['node']));
$frontpage = array_values($frontpage);
$frontpage = $frontpage[0];
}
foreach ($frontpage->field_fs_slider['und'] as $key => &$value)
{
$c = field_collection_field_get_entity($value);
$value = array(
'field_image' => (isset($c->field_image["und"])) ? scald_atom_load( $c->field_image["und"][0]["sid"] ) : null,
'field_fyrirsogn' => (isset($c->field_fyrirsogn["und"])) ? $c->field_fyrirsogn : null,
'field_fyrirsogn_a_ensku' => (isset($c->field_fyrirsogn_a_ensku["und"])) ? $c->field_fyrirsogn_a_ensku : null
);
}
return $frontpage;
}
function mis_theme_get_one_testimonial( $language )
{
$testimonialQuery = new EntityFieldQuery;
$result = $testimonialQuery
->entityCondition('entity_type', 'node')
->propertyCondition('type', 'umsogn')
->propertyCondition('status', 1, '=')
->propertyCondition('language', $language, '=')
->propertyOrderBy('created', 'DESC')
->execute();
if (!empty($result['node'])) {
$testimonial = entity_load('node', array_keys($result['node']));
$testimonial = array_values($testimonial);
$size = sizeof( $testimonial );
$testimonial = $testimonial[rand(0, $size - 1)];
}
return $testimonial;
}
function mis_theme_get_all_categories_array()
{
$categories = taxonomy_get_tree(5);
$catArray = null;
foreach( $categories as $cat )
{
$catArray[] = taxonomy_term_load($cat->tid);
}
return $catArray;
}
function mis_theme_get_all_exercises( $category, $language )
{
$misQuery = new EntityFieldQuery;
$result = $misQuery
->entityCondition('entity_type', 'node')
->propertyCondition('type', 'aefing')
->propertyCondition('status', 1, '=')
->propertyCondition('language', $language, '=')
->propertyOrderBy('title', 'ASC')
->fieldCondition('field_aldursflokkun', 'tid', $category )
->execute();
if (!empty($result['node'])) {
$mis = entity_load('node', array_keys($result['node']));
}
foreach( $mis as $tmp )
{
if( isset( $tmp->field_ahold['und'] ) )
{
foreach( $tmp->field_ahold['und'] as $key => &$ahald )
{
$tax = taxonomy_term_load( $ahald['tid'] );
$ahald['name'] = $tax->name;
}
}
}
return $mis;
}
?>