tripal_bulk_loader.theme.inc 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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 = [
  9. 'Match Pattern',
  10. 'Replacement Pattern',
  11. 'Order',
  12. '',
  13. ];
  14. $rows = [];
  15. foreach (element_children($element) as $key) {
  16. $row = [];
  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'] = ['draggable']; // needed for table dragging
  22. $rows[] = $row;
  23. }
  24. return theme('table', [
  25. 'header' => $header,
  26. 'rows' => $rows,
  27. 'attributes' => ['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. }