function theme_follow_links_form in Follow 7
Same name and namespace in other branches
- 5 follow.module \theme_follow_links_form()
- 6 follow.module \theme_follow_links_form()
- 7.2 follow.module \theme_follow_links_form()
Theme the drag-and-drop form.
Arranges records in a table, and adds the css and js for draggable sorting.
File
- ./
follow.module, line 650 - Allows users to add links to their social network profiles.
Code
function theme_follow_links_form($variables) {
$form = $variables['form'];
$rows = array();
$disabled_rows = array();
foreach (element_children($form['follow_links']) as $key) {
$row = array();
if (isset($form['follow_links'][$key]['weight'])) {
$row[] = drupal_render($form['follow_links'][$key]['lid']) . drupal_render($form['follow_links'][$key]['name']);
$row[] = drupal_render($form['follow_links'][$key]['url']);
if (user_access('change follow link titles')) {
$row[] = drupal_render($form['follow_links'][$key]['title']);
}
// Now, render the weight row.
$form['follow_links'][$key]['weight']['#attributes']['class'][] = 'follow-links-weight';
$row[] = drupal_render($form['follow_links'][$key]['weight']);
// Add the new row to our collection of rows, and give it the 'draggable' class.
$rows[] = array(
'data' => $row,
'class' => array(
'draggable',
),
);
}
else {
$disabled_rows[] = array(
drupal_render($form['follow_links'][$key]['name']),
drupal_render($form['follow_links'][$key]['url']),
);
}
}
// Render a list of header titles, and our array of rows, into a table.
$header = array(
t('Name'),
t('URL'),
);
if (user_access('change follow link titles')) {
$header[] = t('Customized Name');
}
$header[] = t('Weight');
$disabled_header = array(
t('Name'),
t('URL'),
);
$output = '';
if (count($rows)) {
$output .= theme('table', array(
'header' => $header,
'rows' => $rows,
'attributes' => array(
'id' => 'follow-links-weighted-form',
),
));
}
if (count($disabled_rows)) {
$output .= theme('table', array(
'header' => $disabled_header,
'rows' => $disabled_rows,
));
}
$output .= drupal_render_children($form);
drupal_add_tabledrag('follow-links-weighted-form', 'order', 'self', 'follow-links-weight');
return $output;
}