tripal_bulk_loader.theme.inc

  1. 2.x tripal_bulk_loader/theme/tripal_bulk_loader.theme.inc
  2. 3.x tripal_bulk_loader/theme/tripal_bulk_loader.theme.inc

File

tripal_bulk_loader/theme/tripal_bulk_loader.theme.inc
View source
  1. <?php
  2. /**
  3. * Theme the regex data in the tripal_bulk_loader_template_field_form form
  4. */
  5. function tripal_bulk_loader_field_regex_fieldset($variables) {
  6. $element = $variables['element'];
  7. drupal_add_tabledrag('regex_list_form_id', 'order', 'sibling', 'rank-weight'); // needed for table dragging
  8. $header = array(
  9. 'Match Pattern',
  10. 'Replacement Pattern',
  11. 'Order',
  12. ''
  13. );
  14. $rows = array();
  15. foreach (element_children($element) as $key) {
  16. $row = array();
  17. $row['data'][] = $element[$key]['pattern']['#markup'];
  18. $row['data'][] = $element[$key]['replace']['#markup'];
  19. $row['data'][] = drupal_render($element[$key]['new_index']) . drupal_render($element[$key]['id']);
  20. $row['data'][] = drupal_render($element[$key]['submit-delete']);
  21. $row['class'] = array('draggable'); // needed for table dragging
  22. $rows[] = $row;
  23. }
  24. return theme('table', array(
  25. 'header' => $header,
  26. 'rows' => $rows,
  27. 'attributes' => array('id' => 'regex_list_form_id'), // needed for table dragging
  28. ));
  29. }
  30. /**
  31. * Preprocessor function for the tripal_bulk_loader template
  32. *
  33. * @ingroup tripal_bulk_loader
  34. */
  35. function tripal_bulk_loader_preprocess_tripal_bulk_loader_template(&$variables) {
  36. $resource = db_select('tripal_bulk_loader_template','t')
  37. ->fields('t')
  38. ->condition('template_id', $variables['template_id'])
  39. ->execute();
  40. $template = $resource->fetchObject();
  41. $template->template_array = unserialize($template->template_array);
  42. $variables['template'] = $template;
  43. }