-
Notifications
You must be signed in to change notification settings - Fork 0
/
template.php
executable file
·873 lines (804 loc) · 29 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
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
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
<?php
/**
* @file
* template.php
*/
/**
* Implements hook_css_alter().
*/
function bootstrap_css_alter(&$css) {
$theme_path = drupal_get_path('theme', 'bootstrap');
if ($bootstrap_cdn = theme_get_setting('bootstrap_cdn')) {
// Add CDN.
if ($bootswatch = theme_get_setting('bootstrap_bootswatch')) {
$cdn = '//netdna.bootstrapcdn.com/bootswatch/' . $bootstrap_cdn . '/' . $bootswatch . '/bootstrap.min.css';
}
else {
$cdn = '//netdna.bootstrapcdn.com/bootstrap/' . $bootstrap_cdn . '/css/bootstrap.min.css';
}
$css[$cdn] = array(
'data' => $cdn,
'type' => 'external',
'every_page' => TRUE,
'media' => 'all',
'preprocess' => FALSE,
'group' => CSS_THEME,
'browsers' => array('IE' => TRUE, '!IE' => TRUE),
'weight' => -2,
);
// Add overrides.
$override = $theme_path . '/css/overrides.css';
$css[$override] = array(
'data' => $override,
'type' => 'file',
'every_page' => TRUE,
'media' => 'all',
'preprocess' => TRUE,
'group' => CSS_THEME,
'browsers' => array('IE' => TRUE, '!IE' => TRUE),
'weight' => -1,
);
}
if ($font_awesome = theme_get_setting('bootstrap_font_awesome')) {
$awesome = 'https://maxcdn.bootstrapcdn.com/font-awesome/' . $font_awesome . '/css/font-awesome.min.css';
$css[$awesome] = array(
'data' => $awesome,
'type' => 'external',
'every_page' => TRUE,
'media' => 'all',
'preprocess' => FALSE,
'group' => CSS_THEME,
'browsers' => array('IE' => TRUE, '!IE' => TRUE),
'weight' => -2,
);
}
}
/**
* Implements hook_js_alter().
*/
function bootstrap_js_alter(&$js) {
if (theme_get_setting('bootstrap_cdn')) {
$cdn = '//netdna.bootstrapcdn.com/bootstrap/' . theme_get_setting('bootstrap_cdn') . '/js/bootstrap.min.js';
$js[$cdn] = backdrop_js_defaults();
$js[$cdn]['data'] = $cdn;
$js[$cdn]['type'] = 'external';
$js[$cdn]['every_page'] = TRUE;
$js[$cdn]['weight'] = -100;
}
}
/**
* Internal function to make sure Header block is rendered.
*/
function bootstrap_is_header($set){
static $is_header;
if(0 == strcmp($set, 'get') ){
return $is_header;
} else{
$is_header = $set;
}
}
/**
* Implements hook_preprocess_layout().
*/
function bootstrap_preprocess_layout(&$variables) {
$layout = $variables['layout'];
$layout_name = $layout->layout;
foreach($layout->content as $key => $block){
if($block->module == 'system' && $block->delta == 'header'){
bootstrap_is_header(true);
}
}
backdrop_add_js('(function($){ $(".layout").addClass("' . theme_get_setting('bootstrap_container') . '");})(jQuery);', array('type' => 'inline', 'scope' => 'footer'));
}
/**
* Implements hook_preprocess_page().
*/
function bootstrap_preprocess_page(&$variables){
$no_old_ie_compatibility_modes = array(
'#tag' => 'meta',
'#attributes' => array(
'http-equiv' => 'X-UA-Compatible',
'content' => 'IE=edge',
),
);
backdrop_add_html_head($no_old_ie_compatibility_modes, 'no_old_ie_compatibility_modes');
if(bootstrap_is_header('get')){
if (user_access('access administration bar') && !admin_bar_suppress(FALSE)) {
$variables['classes'][] = 'navbar-admin-bar';
}
if($navbar_position = theme_get_setting('bootstrap_navbar_position'))
{
$variables['classes'][] = 'navbar-is-' . $navbar_position;
$config = config('admin_bar.settings');
if($navbar_position == 'fixed-top' && user_access('access administration bar') && !admin_bar_suppress(FALSE) && !$config->get('position_fixed') ){
backdrop_add_js(backdrop_get_path('theme', 'bootstrap') . '/js/navbar-fixed-top.js');
}
if($navbar_position == 'static-top'){
backdrop_add_js(backdrop_get_path('theme', 'bootstrap') . '/js/navbar-static-top.js');
}
}
}
}
/**
* Implements hook_preprocess_header().
*/
function bootstrap_preprocess_header(&$variables){
$variables['navigation'] = '';
if($navbar_position = theme_get_setting('bootstrap_navbar_user_menu'))
{
$user_menu = menu_tree('user-menu');
$variables['navigation'] = render($user_menu);
}
$variables['navbar_classes_array'] = array('navbar');
if($navbar_position = theme_get_setting('bootstrap_navbar_position'))
{
$variables['navbar_classes_array'][] = 'navbar-' . $navbar_position;
}
$variables['container_class'] = theme_get_setting('bootstrap_container');
if (theme_get_setting('bootstrap_navbar_inverse')) {
$variables['navbar_classes_array'][] = 'navbar-inverse';
}
else {
$variables['navbar_classes_array'][] = 'navbar-default';
}
}
/**
* Implements hook_links().
*/
function bootstrap_links__header_menu($menu){
$menu['attributes']['class'] = array('menu','nav','navbar-nav');
if($navbar_menu_position = theme_get_setting('bootstrap_navbar_menu_position')){
$menu['attributes']['class'][] = $navbar_menu_position;
}
return theme_links($menu);
}
/**
* Implements hook_menu_tree().
*/
function bootstrap_menu_tree__user_menu($variables){
if($navbar_position = theme_get_setting('bootstrap_navbar_user_menu')){
return '
<ul class="menu nav navbar-nav navbar-right">
<li class="dropdown">
<a href="#" class="user-cog-link dropdown-toggle" data-toggle="dropdown"> <span class="glyphicon glyphicon-cog"></span></a>
<ul class="dropdown-menu">
' . $variables['tree'] . '
</ul>
</li>
</ul>';
}
return theme_menu_tree($variables);
}
/**
* Returns HTML for a fieldset form element and its children.
*
* @param $variables
* An associative array containing:
* - element: An associative array containing the properties of the element.
* Properties used: #attributes, #children, #collapsed, #collapsible,
* #description, #id, #title, #value.
*
* @ingroup themeable
*/
function bootstrap_fieldset($variables) {
if(isset($variables['element']['#group_fieldset']) && !empty($variables['element']['#group_fieldset'])){
return theme_fieldset($variables);
}
$element = $variables['element'];
element_set_attributes($element, array('id'));
_form_set_class($element, array('form-wrapper'));
$element['#attributes']['class'][] = 'panel';
$element['#attributes']['class'][] = 'panel-default';
$output = '<fieldset' . backdrop_attributes($element['#attributes']) . '>';
if (!empty($element['#title'])) {
// Always wrap fieldset legends in a SPAN for CSS positioning.
$output .= '<legend class="panel-heading"><span class="fieldset-legend">' . $element['#title'] . '</span></legend>';
}
$output .= '<div class="fieldset-wrapper panel-body">';
if (!empty($element['#description'])) {
$output .= '<div class="fieldset-description">' . $element['#description'] . '</div>';
}
$output .= $element['#children'];
if (isset($element['#value'])) {
$output .= $element['#value'];
}
$output .= '</div>';
$output .= "</fieldset>\n";
return $output;
}
/**
* Returns HTML for a button form element.
*
* @param $variables
* An associative array containing:
* - element: An associative array containing the properties of the element.
* Properties used: #attributes, #button_type, #name, #value.
*
* @ingroup themeable
*/
function bootstrap_button($variables) {
if(isset($variables['element']['#attributes']['class'])){
$default = TRUE;
foreach($variables['element']['#attributes']['class'] as $key => $class){
if(FALSE !== strpos($class, 'secondary')){
if($variables['element']['#id'] == 'edit-delete'){
$variables['element']['#attributes']['class'][$key] = 'btn-danger';
$default = FALSE;
}else{
$class = $variables['element']['#attributes']['class'][$key] = str_replace('secondary', 'default', $class);
}
}
if(FALSE !== strpos($class, 'button')){
$variables['element']['#attributes']['class'][$key] = str_replace('button', 'btn', $class);
$default = FALSE;
}
}
if($default){
$variables['element']['#attributes']['class'][] = 'btn-default';
}
} else{
$variables['element']['#attributes']['class'][] = 'btn-default';
}
$variables['element']['#attributes']['class'][] = 'btn';
return theme_button($variables);
}
/**
* Returns HTML for an email form element.
*
* @param $variables
* An associative array containing:
* - element: An associative array containing the properties of the element.
* Properties used: #title, #value, #description, #size, #maxlength,
* #placeholder, #required, #attributes, #autocomplete_path.
*
* @ingroup themeable
*/
function bootstrap_email($variables) {
$variables['element']['#attributes']['class'][] = 'form-control';
return theme_email($variables);
}
/**
* Returns HTML for a textfield form element.
*
* @param $variables
* An associative array containing:
* - element: An associative array containing the properties of the element.
* Properties used: #title, #value, #description, #size, #maxlength,
* #placeholder, #required, #attributes, #autocomplete_path.
*
* @ingroup themeable
*/
function bootstrap_textfield($variables) {
$variables['element']['#attributes']['class'][] = 'form-control';
return theme_textfield($variables);
}
/**
* Returns HTML for a textarea form element.
*
* @param $variables
* An associative array containing:
* - element: An associative array containing the properties of the element.
* Properties used: #title, #value, #description, #rows, #cols,
* #placeholder, #required, #attributes
*
* @ingroup themeable
*/
function bootstrap_textarea($variables) {
$variables['element']['#attributes']['class'][] = 'form-control';
return theme_textarea($variables);
}
/**
* Returns HTML for a form element.
*
* Each form element is wrapped in a DIV container having the following CSS
* classes:
* - form-item: Generic for all form elements.
* - form-type-#type: The internal element #type.
* - form-item-#name: The internal form element #name (usually derived from the
* $form structure and set via form_builder()).
* - form-disabled: Only set if the form element is #disabled.
*
* In addition to the element itself, the DIV contains a label for the element
* based on the optional #title_display property, and an optional #description.
*
* The optional #title_display property can have these values:
* - before: The label is output before the element. This is the default.
* The label includes the #title and the required marker, if #required.
* - after: The label is output after the element. For example, this is used
* for radio and checkbox #type elements as set in system_element_info().
* If the #title is empty but the field is #required, the label will
* contain only the required marker.
* - invisible: Labels are critical for screen readers to enable them to
* properly navigate through forms but can be visually distracting. This
* property hides the label for everyone except screen readers.
* - attribute: Set the title attribute on the element to create a tooltip
* but output no label element. This is supported only for checkboxes
* and radios in form_pre_render_conditional_form_element(). It is used
* where a visual label is not needed, such as a table of checkboxes where
* the row and column provide the context. The tooltip will include the
* title and required marker.
*
* If the #title property is not set, then the label and any required marker
* will not be output, regardless of the #title_display or #required values.
* This can be useful in cases such as the password_confirm element, which
* creates children elements that have their own labels and required markers,
* but the parent element should have neither. Use this carefully because a
* field without an associated label can cause accessibility challenges.
*
* @param $variables
* An associative array containing:
* - element: An associative array containing the properties of the element.
* Properties used: #title, #title_display, #description, #id, #required,
* #children, #type, #name.
*
* @ingroup themeable
*/
function bootstrap_form_element($variables){
if($variables['element']['#type'] == 'checkbox'){
$variables['element']['#wrapper_attributes']['class'][] = 'checkbox';
}
if($variables['element']['#type'] == 'radio'){
$variables['element']['#wrapper_attributes']['class'][] = 'radio';
}
$description = FALSE;
if(isset($variables['element']['#description'])){
$description = $variables['element']['#description'];
unset($variables['element']['#description']);
}
$output = theme_form_element($variables);
if($description){
$output .= '<div class="description help-block">' . $description . "</div>\n";
}
return $output;
}
/**
* Returns HTML for a password form element.
*
* @param $variables
* An associative array containing:
* - element: An associative array containing the properties of the element.
* Properties used: #title, #value, #description, #size, #maxlength,
* #placeholder, #required, #attributes.
*
* @ingroup themeable
*/
function bootstrap_password($variables) {
$variables['element']['#attributes']['class'][] = 'form-control';
return theme_password($variables);
}
/**
* Returns HTML for a search form element.
*
* @param $variables
* An associative array containing:
* - element: An associative array containing the properties of the element.
* Properties used: #title, #value, #description, #size, #maxlength,
* #placeholder, #required, #attributes, #autocomplete_path.
*
* @ingroup themeable
*/
function bootstrap_search($variables) {
if(isset($variables['element']['#attributes']['placeholder']) && $variables['element']['#attributes']['placeholder'] == t('Menu search')){
return theme_search($variables);
}
$variables['element']['#attributes']['class'][] = 'form-control';
return theme_search($variables);
}
/**
* Returns HTML for a select form element.
*
* It is possible to group options together; to do this, change the format of
* $options to an associative array in which the keys are group labels, and the
* values are associative arrays in the normal $options format.
*
* @param $variables
* An associative array containing:
* - element: An associative array containing the properties of the element.
* Properties used: #title, #value, #options, #description, #extra,
* #multiple, #required, #name, #attributes, #size.
*
* @ingroup themeable
*/
function bootstrap_select($variables) {
if(isset($variables['element']['#size'])){
unset($variables['element']['#size']);
}
$variables['element']['#attributes']['class'][] = 'form-control';
return theme_select($variables);
}
/**
* Implements hook_preprocess_table().
*/
function bootstrap_preprocess_table(&$variables) {
$variables['attributes']['class'][] = 'table';
$variables['attributes']['class'][] = 'table-hover';
if (!in_array('table-no-striping', $variables['attributes']['class'])) {
$variables['attributes']['class'][] = 'table-striped';
}
}
/**
* Returns HTML for an individual permission description.
*
* @param $variables
* An associative array containing:
* - permission_item: An associative array representing the permission whose
* description is being themed. Useful keys include:
* - description: The text of the permission description.
* - warning: A security-related warning message about the permission (if
* there is one).
*
* @ingroup themeable
*/
function bootstrap_user_permission_description($variables) {
$description = array();
$permission_item = $variables['permission_item'];
if (!empty($permission_item['description'])) {
$description[] = $permission_item['description'];
}
if (!empty($permission_item['warning'])) {
$description[] = '<em class="permission-warning text-danger">' . $permission_item['warning'] . '</em>';
}
if (!empty($description)) {
return implode(' ', $description);
}
}
/**
* Returns HTML for an administrative block for display.
*
* @param $variables
* An associative array containing:
* - block: An array containing information about the block:
* - show: A Boolean whether to output the block. Defaults to FALSE.
* - title: The block's title.
* - content: (optional) Formatted content for the block.
* - description: (optional) Description of the block. Only output if
* 'content' is not set.
*
* @ingroup themeable
*/
function bootstrap_admin_block($variables) {
$block = $variables['block'];
$output = '';
// Don't display the block if it has no content to display.
if (empty($block['show'])) {
return $output;
}
$output .= '<div class="panel panel-default">';
if (!empty($block['title'])) {
$output .= '<div class="panel-heading"><h3 class="panel-title">' . $block['title'] . '</h3></div>';
}
if (!empty($block['content'])) {
$output .= '<div class="body panel-body">' . $block['content'] . '</div>';
}
else {
$output .= '<div class="description panel-body">' . $block['description'] . '</div>';
}
$output .= '</div>';
return $output;
}
/**
* Returns HTML for the output of the dashboard page.
*
* @param $variables
* An associative array containing:
* - menu_items: An array of modules to be displayed.
*
* @ingroup themeable
*/
function bootstrap_system_admin_index($variables) {
$menu_items = $variables['menu_items'];
$stripe = 0;
$container = array('left' => '', 'right' => '');
$flip = array('left' => 'right', 'right' => 'left');
$position = 'left';
// Iterate over all modules.
foreach ($menu_items as $module => $block) {
list($description, $items) = $block;
// Output links.
if (count($items)) {
$block = array();
$block['title'] = $module;
$block['content'] = theme('admin_block_content', array('content' => $items));
$block['description'] = t($description);
$block['show'] = TRUE;
if ($block_output = theme('admin_block', array('block' => $block))) {
if (!isset($block['position'])) {
// Perform automatic striping.
$block['position'] = $position;
$position = $flip[$position];
}
$container[$block['position']] .= $block_output;
}
}
}
$output = '<div class="admin clearfix">';
foreach ($container as $id => $data) {
$output .= '<div class=" col-md-6 col-sm-12 clearfix">';
$output .= $data;
$output .= '</div>';
}
$output .= '</div>';
return $output;
}
/**
* Returns HTML for an administrative page.
*
* @param $variables
* An associative array containing:
* - blocks: An array of blocks to display. Each array should include a
* 'title', a 'description', a formatted 'content' and a 'position' which
* will control which container it will be in. This is usually 'left' or
* 'right'.
*
* @ingroup themeable
*/
function bootstrap_admin_page($variables) {
$blocks = $variables['blocks'];
$stripe = 0;
$container = array();
foreach ($blocks as $block) {
if ($block_output = theme('admin_block', array('block' => $block))) {
if (empty($block['position'])) {
// perform automatic striping.
$block['position'] = ++$stripe % 2 ? 'left' : 'right';
}
if (!isset($container[$block['position']])) {
$container[$block['position']] = '';
}
$container[$block['position']] .= $block_output;
}
}
$output = '<div class="admin clearfix">';
foreach ($container as $id => $data) {
$output .= '<div class="clearfix col-md-6 col-sm-12 ">';
$output .= $data;
$output .= '</div>';
}
$output .= '</div>';
return $output;
}
/**
* Returns HTML for primary and secondary local tasks.
*
* @param $variables
* An associative array containing:
* - primary: (optional) An array of local tasks (tabs).
* - secondary: (optional) An array of local tasks (tabs).
*
* @ingroup themeable
* @see menu_local_tasks()
*/
function bootstrap_menu_local_tasks(&$variables) {
$output = '';
if (!empty($variables['primary'])) {
$variables['primary']['#prefix'] = '<h2 class="element-invisible">' . t('Primary tabs') . '</h2>';
$variables['primary']['#prefix'] .= '<ul class="nav nav-tabs tabs-primary">';
$variables['primary']['#suffix'] = '</ul>';
$output .= backdrop_render($variables['primary']);
}
if (!empty($variables['secondary'])) {
$variables['secondary']['#prefix'] = '<h2 class="element-invisible">' . t('Secondary tabs') . '</h2>';
$variables['secondary']['#prefix'] .= '<ul class="nav nav-pills secondary">';
$variables['secondary']['#suffix'] = '</ul>';
$output .= backdrop_render($variables['secondary']);
}
return $output;
}
/**
* Implements hook_links().
*/
function bootstrap_links__dropbutton($menu){
foreach($menu['links'] as $name => $settings){
$menu['links'][$name]['attributes']['class'][] = 'btn';
$menu['links'][$name]['attributes']['class'][] = 'btn-default';
}
return theme_links($menu);
}
/**
* Returns rendered HTML for the local actions.
*/
function bootstrap_menu_local_actions(&$variables) {
foreach($variables['actions'] as $key => $link){
switch($link['#link']['path']){
case 'admin/people/create':
$variables['actions'][$key]['#link']['title'] = '<i class="fa fa-user-plus"></i>' . $link['#link']['title'];
$variables['actions'][$key]['#link']['options']['html'] = TRUE;
$variables['actions'][$key]['#link']['localized_options']['html'] = TRUE;
break;
default:
$variables['actions'][$key]['#link']['title'] = '<i class="fa fa-plus"></i>' . $link['#link']['title'];
$variables['actions'][$key]['#link']['options']['html'] = TRUE;
$variables['actions'][$key]['#link']['localized_options']['html'] = TRUE;
}
}
$output = backdrop_render($variables['actions']);
if ($output) {
$output = '<ul class="nav nav-pills action-links">' . $output . '</ul>';
}
return $output;
}
/**
* Returns HTML for a breadcrumb trail.
*
* @param $variables
* An associative array containing:
* - breadcrumb: An array containing the breadcrumb links.
*/
function bootstrap_breadcrumb($variables) {
$breadcrumb = $variables['breadcrumb'];
$output = '';
if (!empty($breadcrumb)) {
$output .= '<nav role="navigation">';
// Provide a navigational heading to give context for breadcrumb links to
// screen-reader users. Make the heading invisible with .element-invisible.
$output .= '<h2 class="element-invisible">' . t('You are here') . '</h2>';
$output .= '<ol class="breadcrumb" >';
$count = 1;
foreach($breadcrumb as $item){
if($count == count($breadcrumb)){
$output .= '<li class="active">' . $item . '</li>';
}else{
$output .= '<li>' . $item . '</li>';
}
$count ++;
}
$output .= '</ol></nav>';
}
return $output;
}
/**
* Implements hook_preprocess_breadcrumb().
*/
function bootstrap_preprocess_breadcrumb(&$variables) {
$breadcrumb = &$variables['breadcrumb'];
// Optionally get rid of the homepage link.
$show_breadcrumb_home = theme_get_setting('bootstrap_breadcrumb_home');
if (!$show_breadcrumb_home) {
array_shift($breadcrumb);
}
if (theme_get_setting('bootstrap_breadcrumb_title') && !empty($breadcrumb)) {
$item = menu_get_item();
$breadcrumb[] = !empty($item['tab_parent']) ? check_plain($item['title']) : drupal_get_title();
}
}
/**
* Returns HTML to wrap child elements in a container.
*
* Used for grouped form items. Can also be used as a #theme_wrapper for any
* renderable element, to surround it with a <div> and add attributes such as
* classes or an HTML id.
*
* @param $variables
* An associative array containing:
* - element: An associative array containing the properties of the element.
* Properties used: #id, #attributes, #children.
*
* @ingroup themeable
*/
function bootstrap_container($variables) {
if(isset($variables['element']['#attributes']['class'][0]) && $variables['element']['#attributes']['class'][0] == 'views-display-column'){
$variables['element']['#attributes']['class'] = array('col-xs-12','cols-sm-12', 'col-md-4');
}
return theme_container($variables);
}
/**
* Display a view as a table style.
*/
function bootstrap_preprocess_views_view_table(&$variables) {
$variables['classes'][] = 'table';
}
/**
* Implements hook_form_alter().
*/
function bootstrap_form_alter(array &$form, array &$form_state = array(), $form_id = NULL) {
if ($form_id) {
if(isset($form['actions']['cancel']) && isset($form['actions']['cancel']['#type']) && $form['actions']['cancel']['#type'] == 'link'){
$form['actions']['cancel']['#options']['attributes']['class'][] = 'btn';
$form['actions']['cancel']['#options']['attributes']['class'][] = 'btn-default';
}
if(isset($form['actions']['cancel_form']) && $form['actions']['cancel_form']['#type'] == 'link'){
$form['actions']['cancel']['#options']['attributes']['class'][] = 'btn';
$form['actions']['cancel']['#options']['attributes']['class'][] = 'btn-default';
}
}
}
/**
* Overrides theme_node_add_list().
*
* Display the list of available node types for node creation.
*/
function bootstrap_node_add_list($variables) {
$content = $variables['content'];
$output = '';
if ($content) {
$output = '<ul class="list-group">';
foreach ($content as $item) {
$title = '<h4 class="list-group-item-heading">' . $item['title'] . '</h4>';
if(isset($item['description'])){
$title .= '<p class="list-group-item-text">' . filter_xss_admin($item['description']) . '</p>';
}
$item['localized_options']['attributes']['class'][] = 'list-group-item';
$item['localized_options']['html'] = TRUE;
$output .= l($title, $item['href'], $item['localized_options']);
}
$output .= '</ul>';
}
else {
$output = '<p>' . t('You have not created any content types yet. Go to the <a href="@create-content">content type creation page</a> to add a new content type.', array('@create-content' => url('admin/structure/types/add'))) . '</p>';
}
return $output;
}
/**
* Overrides theme_admin_block_content().
*
* Use unordered list markup in both compact and extended mode.
*/
function bootstrap_admin_block_content($variables) {
return bootstrap_node_add_list($variables);
}
/**
* Process variables for user-picture.tpl.php.
*
* The $variables array contains the following arguments:
* - $account: A user, node or comment object with 'name', 'uid' and 'picture'
* fields.
*
* @see user-picture.tpl.php
*/
function bootstrap_preprocess_user_picture(&$variables) {
$variables['user_picture'] = '';
if (config_get('system.core', 'user_pictures')) {
$account = $variables['account'];
if (!empty($account->picture)) {
// @TODO: Ideally this function would only be passed file entities, but
// since there's a lot of legacy code that JOINs the {users} table to
// {node} or {comments} and passes the results into this function if we
// a numeric value in the picture field we'll assume it's a file id
// and load it for them. Once we've got user_load_multiple() and
// comment_load_multiple() functions the user module will be able to load
// the picture files in mass during the object's load process.
if (is_numeric($account->picture)) {
$account->picture = file_load($account->picture);
}
if (!empty($account->picture->uri)) {
$filepath = $account->picture->uri;
}
}
elseif (config_get('system.core', 'user_picture_default')) {
$filepath = config_get('system.core', 'user_picture_default');
}
if (isset($filepath)) {
$alt = t("@user's picture", array('@user' => user_format_name($account)));
// If the image does not have a valid Backdrop scheme (for eg. HTTP),
// don't load image styles.
if (module_exists('image') && file_valid_uri($filepath) && $style = config_get('system.core', 'user_picture_style')) {
$variables['user_picture'] = theme('image_style', array('style_name' => $style, 'uri' => $filepath, 'alt' => $alt, 'title' => $alt, 'attributes' => array('class' => 'img-circle')));
}
else {
$variables['user_picture'] = theme('image', array('uri' => $filepath, 'alt' => $alt, 'title' => $alt, 'attributes' => array('class' => 'img-circle')));
}
if (!empty($account->uid) && user_access('access user profiles')) {
$attributes = array('attributes' => array('title' => t('View user profile.')), 'html' => TRUE);
$variables['user_picture'] = l($variables['user_picture'], "user/$account->uid", $attributes);
}
}
}
}
/**
* Implements hook_preprocess_comment().
*/
function bootstrap_preprocess_comment(&$variables){
if (theme_get_setting('bootstrap_datetime')) {
$comment = $variables['elements']['#comment'];
$variables['timeago'] = t('@time ago', array('@time' => format_interval(time() - $comment->changed)));
}
}
/**
* Implements hook_preprocess_node().
*/
function bootstrap_preprocess_node(&$variables){
if (theme_get_setting('bootstrap_datetime')) {
$node = $variables['elements']['#node'];
$variables['timeago'] = t('@time ago', array('@time' => format_interval(time() - $node->created)));
}
}