-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtemplate.php
More file actions
463 lines (396 loc) · 11.8 KB
/
Copy pathtemplate.php
File metadata and controls
463 lines (396 loc) · 11.8 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
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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
<?php
/**
* Adds body classes if certain regions have content.
*
* @param $variables
* An associative array with generated variables.
*
* @return
* Nothing.
*/
function cites_theme_preprocess_html(&$variables) {
if (!empty($variables['page']['featured'])) {
$variables['classes_array'][] = 'featured';
}
// Adds conditional stylesheets for IE.
drupal_add_css(
path_to_theme() . '/css/ie.css',
array(
'group' => CSS_THEME,
'browsers' => array(
'IE' => 'lte IE 7',
'!IE' => FALSE
),
'preprocess' => FALSE
)
);
// Adds conditional stylesheets for IE.
drupal_add_css(
path_to_theme() . '/css/ie7.css',
array(
'group' => CSS_THEME,
'browsers' => array(
'IE' => 'IE 7',
'!IE' => FALSE
),
'preprocess' => FALSE
)
);
// Adds conditional stylesheets for IE.
drupal_add_css(
path_to_theme() . '/css/ie6.css',
array(
'group' => CSS_THEME,
'browsers' => array(
'IE' => 'IE 6',
'!IE' => FALSE
),
'preprocess' => FALSE
)
);
// Adds the Nice Menu required files if the module is enabled.
if (module_exists('nice_menus')) {
// Adds the Superfish JS library if enabled.
if (variable_get('nice_menus_js', 1) == 1)
drupal_add_library('nice_menus', 'nice_menus');
// Adds the main CSS functionality.
drupal_add_css(
drupal_get_path('module', 'nice_menus') . '/css/nice_menus.css',
array(
'basename' => 'nice_menus.css',
'group' => CSS_DEFAULT
)
);
// Adds the default CSS layout.
drupal_add_css(
drupal_get_path('module', 'nice_menus') . '/css/nice_menus_default.css',
array(
'basename' => '/css/nice_menus_default.css',
'group' => CSS_DEFAULT
)
);
}
}
/**
* Performs alterations before a page is rendered.
*
* @param $page
* Nested array of renderable elements that make up the page.
*
* @return
* Nothing.
*/
function cites_theme_page_alter(&$page) {
global $theme;
$item = menu_get_item();
if (!drupal_is_front_page() && $item['path'] != 'admin/structure/block/demo/' . $theme) {
// Removes the second sidebar region from other pages than front page
// and block regions demonstration.
unset($page['sidebar_second']);
} else if (empty($page['sidebar_second'])) {
// Forces the second sidebar region to render on the front page even if
// it's empty.
$page['sidebar_second'] = array('');
}
}
/**
* Overrides or inserts variables into the page template.
*
* @param $variables
* An associative array with generated variables.
*
* @return
* Nothing.
*/
function cites_theme_process_page(&$variables) {
// Visually hides the site name and slogan if they are toggled off.
$variables['hide_site_name'] = theme_get_setting('toggle_name') ? FALSE : TRUE;
$variables['hide_site_slogan'] = theme_get_setting('toggle_slogan') ? FALSE : TRUE;
if ($variables['hide_site_name']) {
// Rebuilds the site_name if toggle_name is FALSE.
$variables['site_name'] = filter_xss_admin(variable_get('site_name', 'Drupal'));
}
if ($variables['hide_site_slogan']) {
// Rebuilds the site_slogan if toggle_site_slogan is FALSE.
$variables['site_slogan'] = filter_xss_admin(variable_get('site_slogan', ''));
}
// Adds a wrapper div for positioning the title and the shortcut link next
// to each other.
if (!empty($variables['title_suffix']['add_or_remove_shortcut']) && $variables['title']) {
$variables['title_prefix']['shortcut_wrapper'] = array(
'#markup' => '<div class="shortcut-wrapper clearfix">',
'#weight' => 100,
);
$variables['title_suffix']['shortcut_wrapper'] = array(
'#markup' => '</div>',
'#weight' => -99,
);
// Forces the shortcut link to be the first item in title_suffix.
$variables['title_suffix']['add_or_remove_shortcut']['#weight'] = -100;
}
}
/**
* Implements hook_preprocess_maintenance_page().
*
* @see template_preprocess_maintenance_page
*
* @param $variables
* An associative array with generated variables.
*
* @return
* Nothing.
*/
function cites_theme_preprocess_maintenance_page(&$variables) {
// Sets the site_name to an empty string if no database connection is
// available or during site installation.
if (!$variables['db_is_active'])
$variables['site_name'] = '';
// Adds the maintenance CSS layout.
drupal_add_css(drupal_get_path('theme', 'cites_theme') . '/css/maintenance-page.css');
}
/**
* Overrides or inserts variables into the maintenance page template.
*
* @param $variables
* An associative array with generated variables.
*
* @return
* Nothing.
*/
function cites_theme_process_maintenance_page(&$variables) {
// Always print the site name and slogan, but if they are toggled off, we'll
// just hide them visually.
$variables['hide_site_name'] = theme_get_setting('toggle_name') ? FALSE : TRUE;
$variables['hide_site_slogan'] = theme_get_setting('toggle_slogan') ? FALSE : TRUE;
if ($variables['hide_site_name']) {
// If toggle_name is FALSE, the site_name will be empty, so we rebuild it.
$variables['site_name'] = filter_xss_admin(variable_get('site_name', 'Drupal'));
}
if ($variables['hide_site_slogan']) {
// If toggle_site_slogan is FALSE, the site_slogan will be empty, so we rebuild it.
$variables['site_slogan'] = filter_xss_admin(variable_get('site_slogan', ''));
}
}
/**
* Overrides or inserts variables into the node template.
*
* @param $variables
* An associative array with generated variables.
*
* @return
* Nothing.
*/
function cites_theme_preprocess_node(&$variables) {
if ($variables['view_mode'] == 'full' && node_is_page($variables['node']))
$variables['classes_array'][] = 'node-full';
}
/**
* Overrides or inserts variables into the page template.
*
* @param $variables
* An associative array with generated variables.
*
* @return
* Nothing.
*/
function cites_theme_preprocess_page(&$variables) {
if (!isset($variables['node']))
return;
$node = $variables['node'];
if ($node->type != 'document')
return;
$language = $variables['language']->language;
$taxonomy_term = taxonomy_term_load($node->field_document_type['und'][0]['tid']);
$type = $taxonomy_term->name;
$translated_type = $type;
if (module_exists('i18n_taxonomy')) {
$translated_type = i18n_taxonomy_term_name($taxonomy_term, $language);
}
$code = $node->field_document_no['und'][0]['value'];
switch ($type) {
case "Decision":
$title = $node->title . ' ' . $code;
break;
case "Resolution":
$title = $translated_type . ' ' . $code;
break;
default:
return;
}
if (isset($title)) {
drupal_set_title($title);
$variables['title'] = $title;
}
}
/**
* Overrides or inserts variables into the block template.
*
* @param $variables
* An associative array with generated variables.
*
* @return
* Nothing.
*/
function cites_theme_preprocess_block(&$variables) {
// Visually hides block titles in the header and footer regions.
if (in_array($variables['block']->region, array('header', 'footer')))
$variables['title_attributes_array']['class'][] = 'element-invisible';
}
/**
* Implements theme_menu_tree().
*
* @param $variables
* An associative array with generated variables.
*
* @return
* HTML for a wrapper for a menu sub-tree.
*/
function cites_theme_menu_tree($variables) {
return '<ul class="menu clearfix">' . $variables['tree'] . '</ul>';
}
/**
* Implements theme_field__field_type().
*
* @param $variables
* An associative array with generated variables.
*
* @return
* HTML for a field.
*/
function cites_theme_field__taxonomy_term_reference($variables) {
$output = '';
// Renders the label, if it's not hidden.
if (!$variables['label_hidden'])
$output .= '<h3 class="field-label">' . $variables['label'] . ': </h3>';
// Renders the items.
$output .= ($variables['element']['#label_display'] == 'inline') ? '<ul class="links inline">' : '<ul class="links">';
foreach ($variables['items'] as $delta => $item)
$output .= '<li class="taxonomy-term-reference-' . $delta . '"' . $variables['item_attributes'][$delta] . '>' . drupal_render($item) . '</li>';
$output .= '</ul>';
// Renders the top-level DIV.
$output = '<div class="' . $variables['classes'] . (!in_array('clearfix', $variables['classes_array']) ? ' clearfix' : '') . '"' . $variables['attributes'] .'>' . $output . '</div>';
return $output;
}
/**
* Performs alterations before a form is rendered.
*
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*
* @param $form
* Nested array of form elements that comprise the form.
* @param $form_state
* A keyed array containing the current state of the form. The arguments that
* drupal_get_form() was originally called with are available in the array
* $form_state['build_info']['args'].
* @param $form_id
* String representing the name of the form itself. Typically this is the
* name of the function that generated the form.
*
* @return
* Nothing.
*/
function cites_theme_form_alter(&$form, &$form_state, $form_id) {
// Alters the search block forms.
if ($form_id == 'search_block_form') {
// Vissually hides the submit button.
$form['actions']['#attributes']['class'][] = 'element-invisible';
// Adds the placeholder text.
$form['search_block_form']['#attributes']['placeholder'] = t('Search');
}
}
/**
* Performs alterations before the language switcher is rendered.
*
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*
* @param $links
* Nested array of links keyed by language code.
* @param $type
* The language type the links will switch.
* @param $path
* The current path.
*
* @return
* Nothing.
*/
function cites_theme_language_switch_links_alter(&$links, $type, $path) {
global $language;
// Removes the active language link.
unset($links[$language->language]);
}
/**
* Implements theme_feed_icon().
*
* @param $variables
* An associative array with generated variables.
*
* @return
* HTML for a feed icon.
*/
function cites_theme_feed_icon($variables) {
return;
}
/**
* Performs alterations before the social media services are used.
*
* @param $services
* Nested array of social media services.
*
* @return
* Nothing.
*/
function cites_theme_on_the_web_get_services_alter(&$services) {
unset(
$services['itunes'],
$services['pinterest']
);
ksort($services);
}
/**
* Implements theme_on_the_web_image().
*
* @param $variables
* An associative array with generated variables.
*
* @return
* HTML for a social media icon.
*/
function cites_theme_on_the_web_image($variables) {
$service = $variables['service'];
$title = $variables['title'];
$size = variable_get('on_the_web_size', 'sm');
$variables = array(
'alt' => $title,
'path' => drupal_get_path('theme', 'cites_theme') . '/images/social-icons/' . $service . '-' . $size . '.png',
'title' => $title
);
return theme('image', $variables);
}
/**
* Implements hook_views_pre_render().
*
* @param $view
* The view object about to be processed.
*
* @return
* Nothing.
*/
function cites_theme_views_pre_render(&$view) {
if ($view->name == 'national_contacts_and_information') {
switch ($view->current_display) {
case 'page_contacts':
case 'page_reports':
case 'page_registers':
$country = strtoupper($view->args[0]);
$path = drupal_get_path('theme', 'cites_theme') . '/images/flags/' . $country . '.gif';
if (file_exists($path)) {
$variables = array(
'alt' => $view->build_info['title'],
'path' => $path,
'title' => $view->build_info['title']
);
$view->build_info['title'] = theme('image', $variables) . ' ' . $view->build_info['title'];
}
}
}
}