You are here

function theme_biblio_form_types_edit in Bibliography Module 5

File

./biblio.module, line 1252

Code

function theme_biblio_form_types_edit($form) {
  $base = variable_get('biblio_base', 'biblio');
  $tid = !empty($form['tid']['#value']) ? $form['tid']['#value'] : FALSE;
  drupal_set_title($form['type_name'] ? check_plain($form['type_name']['#value']) : t("Default"));

  // build the table with all the fields if no $tid is given, or only the common
  // and customized fields if $tid is given
  $conf_table = array();
  foreach (element_children($form['configured_flds']) as $fld) {
    $conf_row = array();
    $conf_row[] = array(
      'data' => drupal_render($form['configured_flds'][$fld]['name']),
    );
    $conf_row[] = array(
      'data' => drupal_render($form['configured_flds'][$fld]['title']),
      'align' => 'center',
    );
    $conf_row[] = array(
      'data' => drupal_render($form['configured_flds'][$fld]['hint']),
      'align' => 'center',
    );
    foreach (element_children($form['configured_flds'][$fld]['checkboxes']) as $oid) {
      if (is_array($form['configured_flds'][$fld]['checkboxes'])) {
        $conf_row[] = array(
          'data' => drupal_render($form['configured_flds'][$fld]['checkboxes'][$oid]),
          'align' => 'center',
          'title' => $oid,
        );
      }
    }
    $conf_row[] = array(
      'data' => drupal_render($form['configured_flds'][$fld]['weight']),
      'align' => 'center',
    );
    if ($tid) {
      if ($form['cust'][$fld]) {
        $conf_row[] = array(
          'data' => l('remove', "{$base}/type/remove/{$tid}/{$fld}"),
          'align' => 'left',
        );
      }
      else {
        $conf_row[] = array(
          'data' => "common",
          'align' => 'left',
        );
      }
    }
    $conf_table[] = $conf_row;
  }
  if ($tid) {
    $header = array(
      t('Field Name'),
      t('Default Title'),
      t('Hint'),
      t('Required'),
      t('Weight'),
      t('Action'),
    );
  }
  else {
    $header = array(
      t('Field Name'),
      t('Default Title'),
      t('Hint'),
      t('Common'),
      t('Required'),
      t('Autocomplete'),
      t('Weight'),
    );
  }
  $output .= '<p>';
  drupal_add_js('misc/collapse.js');
  $output .= '<p><fieldset class=" collapsible"><legend>Currently configured fields</legend>';
  $output .= theme('table', $header, $conf_table);
  $output .= '<p><center>' . drupal_render($form['submit']) . '</center></p>';
  $output .= '</fieldset>';
  if ($tid) {
    $avail_table = array();
    foreach (element_children($form['avail_flds']) as $fld) {
      $avail_row = array();
      $avail_row[] = array(
        'data' => '<div>' . drupal_render($form['avail_flds'][$fld]['name']) . '</div>',
      );
      $avail_row[] = array(
        'data' => '<div>' . drupal_render($form['avail_flds'][$fld]['size']) . '</div>',
        'align' => 'left',
      );
      $avail_row[] = array(
        'data' => '<b>' . drupal_render($form['avail_flds'][$fld]['title']) . '</b>',
        'align' => 'left',
      );
      $avail_row[] = array(
        'data' => l('add', "{$base}/type/add/{$tid}/{$fld}"),
        'align' => 'left',
      );
      $avail_table[] = $avail_row;
    }
    $header2 = array(
      array(
        'data' => 'Field Name',
        'align' => 'right',
      ),
      'Size',
      'Default Name',
      'Action',
    );
    $output .= '<p><fieldset class=" collapsible"><legend>' . t('Other available fields') . '</legend>';
    $output .= theme('table', $header2, $avail_table);
    $output .= '<p><center>' . drupal_render($form['add']) . '</center></p>';
    $output .= '</fieldset>';
  }
  $output .= drupal_render($form);
  return $output;
}