5
5
*/
6
6
7
7
/**
8
- * Implementation of hook_block_info().
8
+ * Implements hook_config_info().
9
+ */
10
+ function on_the_web_config_info() {
11
+ $prefixes['on_the_web.settings'] = array(
12
+ 'label' => t('On The Web Settings'),
13
+ 'group' => t('Configuration'),
14
+ );
15
+
16
+ return $prefixes;
17
+ }
18
+
19
+ /**
20
+ * Implements hook_block_info().
9
21
*/
10
22
function on_the_web_menu() {
11
23
$items['admin/config/services/on_the_web'] = array(
@@ -21,19 +33,7 @@ function on_the_web_menu() {
21
33
}
22
34
23
35
/**
24
- * Implements hook_config_info().
25
- */
26
- function on_the_web_config_info() {
27
- $prefixes['on_the_web.settings'] = array(
28
- 'label' => t('Links to social media sites, and their order.'),
29
- 'group' => t('Configuration'),
30
- );
31
-
32
- return $prefixes;
33
- }
34
-
35
- /**
36
- * Implementation of hook_block_info().
36
+ * Implements hook_block_info().
37
37
*/
38
38
function on_the_web_block_info() {
39
39
$blocks['social_links'] = array(
@@ -45,7 +45,7 @@ function on_the_web_block_info() {
45
45
}
46
46
47
47
/**
48
- * Implementation of hook_block_configure().
48
+ * Implements hook_block_configure().
49
49
*/
50
50
function on_the_web_block_configure($delta = 'social_links', $settings = array()) {
51
51
$form = array();
@@ -126,7 +126,7 @@ function on_the_web_block_configure($delta = 'social_links', $settings = array()
126
126
}
127
127
128
128
/**
129
- * Implementation of hook_block_view().
129
+ * Implements hook_block_view().
130
130
*/
131
131
function on_the_web_block_view($delta = 'social_links', $settings = array(), $contexts = array()) {
132
132
$block = array(
@@ -158,7 +158,7 @@ function on_the_web_display_block($delta, $settings = array(), $contexts = array
158
158
$name = t('me');
159
159
}
160
160
161
- // Get the display style, and enabled icons .
161
+ // Get the display style.
162
162
$display = $settings['services']['display'];
163
163
if ($display == 'manual') {
164
164
$enabled = $settings['services']['enabled'];
@@ -170,7 +170,7 @@ function on_the_web_display_block($delta, $settings = array(), $contexts = array
170
170
foreach ($services as $service => $info) {
171
171
$link = $config->get($service . '_page');
172
172
173
- if (($display == 'auto' && ($link != '')) ||
173
+ if (($display == 'auto' && ($link != '')) ||
174
174
($display == 'manual' && array_key_exists($service, $enabled) && $enabled[$service] === $service)) {
175
175
176
176
if ($service != 'rss') {
@@ -188,6 +188,8 @@ function on_the_web_display_block($delta, $settings = array(), $contexts = array
188
188
'#theme' => 'on_the_web_item',
189
189
'#service' => $service,
190
190
'#link' => $link,
191
+ '#icon' => $info['fa'],
192
+ '#size' => $size,
191
193
'#title' => $title,
192
194
'#classes' => $classes,
193
195
'#weight' => $weight,
@@ -200,51 +202,30 @@ function on_the_web_display_block($delta, $settings = array(), $contexts = array
200
202
'css' => array(backdrop_get_path('module', 'on_the_web') . '/css/on_the_web.css'),
201
203
);
202
204
}
205
+ elseif ($type == 'font') {
206
+ $links['#attached'] = array(
207
+ 'css' => array('https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css', array('external' => TRUE)),
208
+ );
209
+ }
203
210
}
204
211
205
212
return backdrop_render($links);
206
213
}
207
214
208
215
/**
209
- * Helper function: Gets the available services.
210
- *
211
- * @return array
212
- * List of services with icons.
213
- */
214
- function on_the_web_get_services() {
215
- $services = array(
216
- 'twitter' => array('name' => 'Twitter'),
217
- 'facebook' => array('name' => 'Facebook'),
218
- 'pinterest' => array('name' => 'Pinterest'),
219
- 'instagram' => array('name' => 'Instagram'),
220
- 'google' => array('name' => 'Google+'),
221
- 'youtube' => array('name' => 'YouTube'),
222
- 'flickr' => array('name' => 'Flickr'),
223
- 'myspace' => array('name' => 'MySpace'),
224
- 'linkedin' => array('name' => 'LinkedIn'),
225
- 'itunes' => array('name' => 'iTunes'),
226
- 'delicious' => array('name' => 'Delicious'),
227
- 'soundcloud' => array('name' => 'Soundcloud'),
228
- 'friendfeed' => array('name' => 'FriendFeed'),
229
- 'rss' => array('name' => 'RSS'),
230
- );
231
-
232
- backdrop_alter('on_the_web_get_services', $services);
233
-
234
- return $services;
235
- }
236
-
237
- /**
238
- * Implementation of hook_theme().
216
+ * Implements hook_theme().
239
217
*/
240
218
function on_the_web_theme($existing, $type, $theme, $path) {
241
219
return array(
242
220
'on_the_web_item' => array(
243
- 'variables' => array('service' => NULL, 'link' => NULL, 'title' => NULL, 'classes' => array()),
244
- 'file' => 'on_the_web.theme.inc',
245
- ),
246
- 'on_the_web_image' => array(
247
- 'variables' => array('service' => NULL, 'title' => NULL),
221
+ 'variables' => array(
222
+ 'service' => NULL,
223
+ 'link' => NULL,
224
+ 'icon' => 'fa-fort-awesome',
225
+ 'size' => 'sm',
226
+ 'title' => NULL,
227
+ 'classes' => array(),
228
+ ),
248
229
'file' => 'on_the_web.theme.inc',
249
230
),
250
231
@@ -255,3 +236,36 @@ function on_the_web_theme($existing, $type, $theme, $path) {
255
236
),
256
237
);
257
238
}
239
+
240
+ /*******************************************************************************
241
+ * Untilty functions.
242
+ *******************************************************************************/
243
+
244
+ /**
245
+ * Gets the available services.
246
+ *
247
+ * @return array
248
+ * List of services with icons.
249
+ */
250
+ function on_the_web_get_services() {
251
+ $services = array(
252
+ 'twitter' => array('name' => 'Twitter', 'fa' => 'fa-twitter-square'),
253
+ 'facebook' => array('name' => 'Facebook', 'fa' => 'fa-facebook-square'),
254
+ 'pinterest' => array('name' => 'Pinterest', 'fa' => 'fa-pinterest-square'),
255
+ 'instagram' => array('name' => 'Instagram', 'fa' => 'fa-instagram'),
256
+ 'google' => array('name' => 'Google+', 'fa' => 'fa-google-plus-square'),
257
+ 'youtube' => array('name' => 'YouTube', 'fa' => 'fa-youtube-square'),
258
+ 'flickr' => array('name' => 'Flickr', 'fa' => 'fa-flickr'),
259
+ 'linkedin' => array('name' => 'LinkedIn', 'fa' => 'fa-linkedin-square'),
260
+ 'myspace' => array('name' => 'MySpace', 'fa' => 'fa-user'),
261
+ 'itunes' => array('name' => 'iTunes', 'fa' => 'fa-apple'),
262
+ 'delicious' => array('name' => 'Delicious', 'fa' => 'fa-delicious'),
263
+ 'soundcloud' => array('name' => 'Soundcloud', 'fa' => 'fa-soundcloud'),
264
+ 'github' => array('name' => 'GitHub', 'fa' => 'fa-github-square'),
265
+ 'rss' => array('name' => 'RSS', 'fa' => 'fa-rss-square'),
266
+ );
267
+
268
+ backdrop_alter('on_the_web_get_services', $services);
269
+
270
+ return $services;
271
+ }
0 commit comments