forked from ding2/ding_toggle_format
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathding_toggle_format.module
More file actions
93 lines (82 loc) · 2.21 KB
/
ding_toggle_format.module
File metadata and controls
93 lines (82 loc) · 2.21 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
<?php
/**
* @file
* Ding - toggle short/long format
*/
/**
* Implements hook_block_info().
*/
function ding_toggle_format_block_info() {
return array(
'toggle' => array(
'info' => t('Ding format toggle'),
'cache' => DRUPAL_CACHE_PER_PAGE,
),
);
}
/**
* Implements hook_block_view().
*/
function ding_toggle_format_block_view($delta = '') {
drupal_add_js(drupal_get_path('module', 'ding_toggle_format') . '/js/ding_toggle_format.js');
drupal_add_js(drupal_get_path('module', 'ding_toggle_format') . '/js/jquery.cookie.min.js');
drupal_add_css(drupal_get_path('module', 'ding_toggle_format') . '/css/ding_toggle_format.css');
return array(
'subject' => t('Ding toggle format'),
'content' => ding_toggle_format_render_link(),
);
}
/**
* Return rendered image link to toggle format, and label.
*/
function ding_toggle_format_render_link() {
// get view_type from url
$view_type = arg(1);
$markup = NULL;
// render image html using theme_image (returns NULL if file doesn't exist)
if ($view_type != 'collection') {
$markup = array(
array(
'#markup' => '<div class="btn-toolbar" id="ding-toggle-format"><div class="btn-group">',
),
array(
'#theme' => 'link',
'#text' => '<i class="icon-white icon-list"></i>',
'#path' => current_path(),
'#options' => array(
'attributes' => array(
'class' => array(
'ding-toggle-format-long',
'btn',
'btn-small',
'btn-artesis-turquoise',
),
'title'=> t('Toggle format: long'),
),
'html' => TRUE,
),
),
array(
'#theme' => 'link',
'#text' => '<i class="icon-white icon-th"></i>',
'#path' => current_path(),
'#options' => array(
'attributes' => array(
'class' => array(
'ding-toggle-format-short',
'btn',
'btn-small',
'btn-artesis-turquoise',
),
'title'=> t('Toggle format: short'),
),
'html' => TRUE,
),
),
array(
'#markup' => '</div></div>',
),
);
}
return $markup;
}