-
Notifications
You must be signed in to change notification settings - Fork 0
/
template.php
151 lines (144 loc) · 5.36 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
148
149
150
151
<?php
// hook_html_head_alter()
function html5_boilerplate_html_head_alter(&$head_elements) {
$head_elements['system_meta_content_type']['#attributes'] = array(
'charset' => 'utf-8',
);
}
// Preprocess variables for node.tpl.php.
function html5_boilerplate_preprocess_node(&$vars) {
$vars['datetime'] = format_date($vars['created'], 'custom', 'c');
if (variable_get('node_submitted_' . $vars['node']->type, TRUE)) {
$vars['submitted'] = t('Submitted by !username on !datetime',
array(
'!username' => $vars['name'],
'!datetime' => '<time datetime="' . $vars['datetime'] . '" pubdate="pubdate">' . $vars['date'] . '</time>',
)
);
}
else {
$vars['submitted'] = '';
}
$vars['unpublished'] = '';
if (!$vars['status']) {
$vars['unpublished'] = '<div class="unpublished">' . t('Unpublished') . '</div>';
}
}
// Preprocess variables for comment.tpl.php.
function html5_boilerplate_preprocess_comment(&$vars) {
$uri = entity_uri('comment', $vars['comment']);
$uri['options'] += array('attributes' => array('rel' => 'bookmark'));
$vars['title'] = l($vars['comment']->subject, $uri['path'], $uri['options']);
$vars['permalink'] = l(t('Permalink'), $uri['path'], $uri['options']);
$vars['created'] = '<span class="date-time permalink">' . l($vars['created'], $uri['path'], $uri['options']) . '</span>';
$vars['datetime'] = format_date($vars['comment']->created, 'custom', 'c');
$vars['unpublished'] = '';
if ($vars['status'] == 'comment-unpublished') {
$vars['unpublished'] = '<div class="unpublished">' . t('Unpublished') . '</div>';
}
}
// Preprocess variables for comment_wrapper.tpl.php
function html5_boilerplate_preprocess_comment_wrapper(&$vars) {
if ($vars['node']->type == 'forum') {
$vars['title_attributes_array']['class'][] = 'element-invisible';
}
}
// Preprocess variables for block.tpl.php.
function html5_boilerplate_preprocess_block(&$vars) {
if ($vars['block']->region == 'menu_bar') {
$vars['title_attributes_array']['class'][] = 'element-invisible';
}
$nav_blocks = array('navigation', 'main-menu', 'management', 'user-menu');
if (in_array($vars['block']->delta, $nav_blocks)) {
$vars['theme_hook_suggestions'][] = 'block__menu';
}
}
// Process variables for aggregator-item.tpl.php.
function html5_boilerplate_preprocess_aggregator_item(&$vars) {
$item = $vars['item'];
$vars['datetime'] = format_date($item->timestamp, 'custom', 'c');
}
// Changes the search form to use the "search" input element of HTML5
function html5_boilerplate_preprocess_search_block_form(&$vars) {
$vars['search_form'] = str_replace('type="text"', 'type="search"', $vars['search_form']);
}
// Improve the accessibility of the advanced search form by wrapping everything in fieldsets
function html5_boilerplate_form_search_form_alter(&$form, $form_state) {
if (isset($form['module']) && $form['module']['#value'] == 'node' && user_access('use advanced search')) {
// Keywords
$form['advanced'] = array(
'#type' => 'fieldset',
'#title' => t('Advanced search'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
'#attributes' => array('class' => array('search-advanced')),
);
$form['advanced']['keywords-fieldset'] = array(
'#type' => 'fieldset',
'#title' => t('Keywords'),
'#collapsible' => FALSE,
);
$form['advanced']['keywords-fieldset']['keywords'] = array(
'#prefix' => '<div class="criterion">',
'#suffix' => '</div>',
);
$form['advanced']['keywords-fieldset']['keywords']['or'] = array(
'#type' => 'textfield',
'#title' => t('Containing any of the words'),
'#size' => 30,
'#maxlength' => 255,
);
$form['advanced']['keywords-fieldset']['keywords']['phrase'] = array(
'#type' => 'textfield',
'#title' => t('Containing the phrase'),
'#size' => 30,
'#maxlength' => 255,
);
$form['advanced']['keywords-fieldset']['keywords']['negative'] = array(
'#type' => 'textfield',
'#title' => t('Containing none of the words'),
'#size' => 30,
'#maxlength' => 255,
);
// Node types
$types = array_map('check_plain', node_type_get_names());
$form['advanced']['types-fieldset'] = array(
'#type' => 'fieldset',
'#title' => t('Types'),
'#collapsible' => FALSE,
);
$form['advanced']['types-fieldset']['type'] = array(
'#type' => 'checkboxes',
'#prefix' => '<div class="criterion">',
'#suffix' => '</div>',
'#options' => $types,
);
$form['advanced']['submit'] = array(
'#type' => 'submit',
'#value' => t('Advanced search'),
'#prefix' => '<div class="action advanced-search-submit">',
'#suffix' => '</div>',
'#weight' => 99,
);
// Languages
$language_options = array();
foreach (language_list('language') as $key => $entity) {
$language_options[$key] = $entity->name;
}
if (count($language_options) > 1) {
$form['advanced']['lang-fieldset'] = array(
'#type' => 'fieldset',
'#title' => t('Languages'),
'#collapsible' => FALSE,
'#collapsed' => FALSE,
);
$form['advanced']['lang-fieldset']['language'] = array(
'#type' => 'checkboxes',
'#prefix' => '<div class="criterion">',
'#suffix' => '</div>',
'#options' => $language_options,
);
}
$form['#validate'][] = 'node_search_validate';
}
}