You are here

function _path_breadcrumbs_render_table in Path Breadcrumbs 7.3

Same name and namespace in other branches
  1. 7.2 path_breadcrumbs_ui/path_breadcrumbs_ui.theme.inc \_path_breadcrumbs_render_table()

Parameters

$vars:

Return value

string

2 calls to _path_breadcrumbs_render_table()
theme_path_breadcrumbs_ui_add_form in path_breadcrumbs_ui/path_breadcrumbs_ui.theme.inc
theme_path_breadcrumbs_ui_edit_form in path_breadcrumbs_ui/path_breadcrumbs_ui.theme.inc
Theme table with path breadcrumbs values.

File

path_breadcrumbs_ui/path_breadcrumbs_ui.theme.inc, line 27

Code

function _path_breadcrumbs_render_table($vars) {
  $form = $vars['form'];
  if (isset($form['breadcrumbs_table'])) {
    $rows = array();
    foreach (element_children($form['breadcrumbs_table']) as $value) {
      $row = array();
      $input = $form['breadcrumbs_table'][$value];
      if (isset($input['left_value']) && isset($input['right_value']) && isset($input['delete'])) {
        $input['weight']['#attributes']['class'][] = 'path-weight';
        $row[] = array(
          'data' => $input['left_value'],
        );
        $row[] = array(
          'data' => $input['right_value'],
        );
        $row[] = array(
          'data' => $input['weight'],
        );
        $row[] = array(
          'data' => $input['delete'],
        );
        $rows[] = array(
          'data' => $row,
          'class' => array(
            'draggable',
          ),
        );
      }
    }
    unset($form['breadcrumbs_table']);
    $rows[] = array(
      'data' => array(
        array(
          'data' => render($form['more']),
          'colspan' => 4,
        ),
      ),
    );
    $headers = array(
      t('Link title'),
      t('Link path'),
      t('Weight'),
      t('Delete link'),
    );
    $output = theme('table', array(
      'header' => $headers,
      'rows' => $rows,
      'attributes' => array(
        'class' => array(
          'breadcrumb-tokens',
        ),
        'id' => 'breadcrumbs-table',
      ),
    ));

    // Build some other elements after table.
    $context_placeholders = render($form['contexts']);
    $custom = !empty($form['custom']) ? render($form['custom']) : '';
    $buttons = render($form['actions']);
    drupal_add_tabledrag('breadcrumbs-table', 'order', 'sibling', 'path-weight');
    return drupal_render_children($form) . $output . $context_placeholders . $custom . $buttons;
  }
}