function theme_socialfield_drag_components in Social field 7
Custom theme output for widget.
1 theme call to theme_socialfield_drag_components()
- socialfield_field_widget_form in ./
socialfield.module - Implements hook_field_widget_form().
File
- ./
socialfield.module, line 596 - Provides a field for adding social services links.
Code
function theme_socialfield_drag_components($vars) {
$element = $vars['element'];
drupal_add_tabledrag('socialfield-table', 'order', 'sibling', 'item-row-weight');
$services = variable_get('socialfield_services');
$header = array(
t('Social links'),
'',
'',
'',
);
$rows = array();
$index = 0;
for ($i = 0; $i < $element['#num_elements']; $i++) {
while (!isset($element['element_' . $index])) {
// There is no element with this index. Moving on to the next possible element.
$index++;
}
$current_element = $element['element_' . $index];
$rows[] = array(
'data' => array(
'<div class="social-links">' . '<span class="service-' . $current_element['#service'] . '">' . '<i class="icon ' . $services[$current_element['#service']]['icon'] . '"></i>' . '</span>' . '</div>',
drupal_render($current_element['url']),
drupal_render($current_element['weight']),
drupal_render($current_element['operation']),
),
'class' => array(
'draggable',
),
'weight' => $current_element['weight']['#value'],
);
$index++;
}
// Sorting elements by their weight.
uasort($rows, 'drupal_sort_weight');
return theme('table', array(
'header' => $header,
'rows' => $rows,
'attributes' => array(
'id' => 'socialfield-table',
),
)) . drupal_render($element['add_one_social']) . '<div class="description">' . drupal_render($element['description']) . '</div>';
}