You are here

function theme_hierarchical_select_common_config_form_editability in Hierarchical Select 6.3

Same name and namespace in other branches
  1. 5.3 includes/common.inc \theme_hierarchical_select_common_config_form_editability()
  2. 7.3 includes/theme.inc \theme_hierarchical_select_common_config_form_editability()

File

includes/theme.inc, line 301
All theme functions for the Hierarchical Select module.

Code

function theme_hierarchical_select_common_config_form_editability($form) {

  // Recover the stored strings.
  $strings = $form['#strings'];
  $output = '';
  $header = array(
    t('Level'),
    t('Allow'),
    t('!item_type', array(
      '!item_type' => drupal_ucfirst($strings['item_type']),
    )),
  );
  $rows = array();
  $output .= drupal_render($form['status']);
  $output .= '<div class="editability-per-level-settings">';
  if (isset($form['item_types']) && count(element_children($form['item_types']))) {
    foreach (element_children($form['item_types']) as $depth) {
      $row = array();
      $row[]['data'] = $depth == 0 ? t('Root level') : t('Sublevel !depth', array(
        '!depth' => $depth,
      ));
      $row[]['data'] = drupal_render($form['allowed_levels'][$depth]);
      $row[]['data'] = drupal_render($form['item_types'][$depth]);
      $rows[] = $row;
    }

    // Render the table and description.
    $output .= theme('table', $header, $rows, array(
      'style' => 'width: auto;',
    ), '<em>' . t('Per-level settings for creating new !items.', array(
      '!items' => $strings['items'],
    )));
    $output .= '<div class="description">';
    $output .= t('The %item_type you enter for each level is what will be used in
      each level to replace a "&lt;create new item&gt;" option with a
      "&lt;create new %item_type&gt;" option, which is often more
      intuitive.', array(
      '%item_type' => $strings['item_type'],
    ));
    $output .= '</div>';
  }
  else {

    // No levels exist yet in the hierarchy!
    $output .= '<p><strong>';
    $output .= t('There are no levels yet in this !hierarchy!', array(
      '!hierarchy' => $strings['hierarchy'],
    ));
    $output .= '</strong></p>';
  }
  $output .= '</div>';

  // Render the remaining form items.
  $output .= drupal_render($form);
  return $output;
}