-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcoderwall.module
92 lines (81 loc) · 2.24 KB
/
coderwall.module
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 Coderwall module
* @author Rob Knight http://drupal.org/user/36475
*/
/**
* Implementation of hook_theme
*/
function coderwall_theme() {
return array(
'coderwall_achievements' => array(
'render element' => 'element',
'template' => 'coderwall_achievements',
'path' => drupal_get_path('module', 'coderwall') . '/templates'
)
);
}
/**
* Implementation of hook_block_info()
*/
function coderwall_block_info() {
$blocks['coderwall'] = array(
'info' => t('Coderwall Achievements'),
);
return $blocks;
}
/**
* Implementation of hook_block_configure()
*/
function coderwall_block_configure($delta = '') {
$form = array();
if ($delta == 'coderwall') {
$form['username'] = array(
'#type' => 'textfield',
'#title' => t('Your Coderwall username'),
'#default_value' => variable_get('coderwall_username'),
'#required' => TRUE
);
$form['orientation'] = array(
'#type' => 'radios',
'#title' => t('Orientation of the Coderwall widget'),
'#default_value' => variable_get('coderwall_orientation'),
'#options' => array(
'horizontal' => t('Horizontal'),
'vertical' => t('Vertical')
),
'#required' => TRUE
);
}
return $form;
}
/**
* Implementation of hook_block_save()
*/
function coderwall_block_save($delta = '', $edit = array()) {
if ($delta == 'coderwall') {
variable_set('coderwall_username', $edit['username']);
variable_set('coderwall_orientation', $edit['orientation']);
}
}
/**
* Implementation of hook_block_view()
*/
function coderwall_block_view($delta = '') {
$block = array();
if ($delta == 'coderwall') {
$block['subject'] = t('Coderwall achievements');
$block['content'] = array(
'#theme' => 'coderwall_achievements',
'#username' => check_plain(variable_get('coderwall_username')),
'#orientation' => check_plain(variable_get('coderwall_orientation')),
'#attached' => array(
'js' => array('http://coderwall.com/javascripts/jquery.coderwall.js' => array(
'type' => 'external')),
'css' => array('http://coderwall.com/stylesheets/jquery.coderwall.css' => array(
'type' => 'external'))
),
);
}
return $block;
}