You are here

function theme_pm_menu_entry_table in Drupal PM (Project Management) 7.3

Theme the pm entry table as a sortable list of menu items.

1 theme call to theme_pm_menu_entry_table()
pm_menu_admin in includes/pm.menu.inc
Generates a table of recommended modules.

File

./pm.theme.inc, line 118
Provides theme functions for Project Management modules.

Code

function theme_pm_menu_entry_table($form) {
  $form = reset($form);

  // For some reason form comes in an empty array...
  if (!empty($form)) {
    $rows = array();

    // Take all the form elements and format theme for theme_table
    foreach (element_children($form) as $key) {
      if (isset($form[$key]['title'])) {

        // Add the table drag functionality
        drupal_add_tabledrag('widget-menu-table', 'order', 'sibling', 'menu-weight');

        // Add class to group weight fields for drag and drop.
        $form[$key]['weight']['#attributes']['class'] = array(
          'menu-weight',
        );

        // array to store row data
        $rows[] = array(
          'data' => array(
            '',
            drupal_render($form[$key]['weight']),
            drupal_render($form[$key]['title']),
            drupal_render($form[$key]['path']) . drupal_render($form[$key]['extra_link']),
            drupal_render($form[$key]['icon']),
            drupal_render($form[$key]['status']),
            drupal_render($form[$key]['delete']),
          ),
          'class' => array(
            'draggable',
          ),
        );
      }
    }

    // The table headers
    $header = array(
      '',
      t('Weight'),
      t('Title'),
      t('Path (main link and sub links)'),
      t('Icon'),
      t('Enabled'),
      t('Delete'),
    );
    $table = array(
      'header' => $header,
      'rows' => $rows,
      'attributes' => array(
        'id' => array(
          'widget-menu-table',
        ),
        'max-width' => '100%',
      ),
    );

    // Theme it as a table
    $output = theme('table', $table);

    // Render the form
    $output .= drupal_render_children($form);
  }
  else {
    $output = drupal_render_children($form);
  }

  // Return the themed activities table
  return $output;
}