This repository has been archived by the owner on Jan 17, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathyashare_counters.admin.inc
77 lines (66 loc) · 2.3 KB
/
yashare_counters.admin.inc
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
<?php
/**
* @file
* Administrative page forms and functions for the Yandex.Share with Counters.
*/
/**
* Menu callback administration settings.
*/
function yashare_counters_admin_settings() {
$form['style'] = array(
'#type' => 'fieldset',
'#title' => t('Style'),
);
$form['style']['yashare_counters_small_size'] = array(
'#type' => 'checkbox',
'#title' => t('Use small buttons.'),
'#default_value' => variable_get('yashare_counters_small_size', YASHARE_COUNTERS_SMALL),
);
$form['services'] = array(
'#type' => 'fieldset',
'#title' => t('Services'),
'#theme' => 'yashare_counters_admin_settings_services_table',
);
foreach (yashare_counters_services_list() as $service_id => $service_name) {
$form['services'][$service_id]['yashare_counters_service_' . $service_id . '_enabled'] = array(
'#type' => 'checkbox',
'#title' => drupal_placeholder($service_name),
'#default_value' => variable_get('yashare_counters_service_' . $service_id . '_enabled', 1),
);
$form['services'][$service_id]['yashare_counters_service_' . $service_id . '_weight'] = array(
'#type' => 'weight',
'#delta' => 10,
'#default_value' => variable_get('yashare_counters_service_' . $service_id . '_weight', 0),
'#attributes' => array('class' => array('yashare-counters-service-weight')),
);
}
return system_settings_form($form, TRUE);
}
/**
* Theme function for settings table.
*/
function theme_yashare_counters_admin_settings_services_table($vars) {
$form = $vars['form'];
$header = array(
array('data' => t('Service name'), 'colspan' => 2),
);
$rows = array();
foreach (element_children($form) as $service_id) {
$row = array(
drupal_render($form[$service_id]['yashare_counters_service_' . $service_id . '_enabled']),
drupal_render($form[$service_id]['yashare_counters_service_' . $service_id . '_weight']),
);
$rows[] = array(
'data' => $row,
'class' => array('draggable'),
);
}
$output = theme('table', array(
'header' => $header,
'rows' => $rows,
'attributes' => array('id' => 'yashare-counters-services'),
));
$output .= drupal_render_children($form);
drupal_add_tabledrag('yashare-counters-services', 'order', 'sibling', 'yashare-counters-service-weight');
return $output;
}