blast_ui.theme.inc 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. <?php
  2. /**
  3. * @file
  4. * This file contains functions specifically related to theme-ing the BLAST module
  5. */
  6. /**
  7. * Preprocess function for the show_blast_report.tpl.php
  8. *
  9. * Use this function to prepare variables for use in the template,
  10. * as well as to add css/javascript needed.
  11. *
  12. * @param $vars
  13. * The variables currently available to the template.
  14. */
  15. function blast_ui_preprocess_show_blast_report(&$vars) {
  16. // Add CSS and Javascript files
  17. $path = drupal_get_path('module', 'blast_ui');
  18. drupal_add_css($path . '/theme/css/blast_report.css');
  19. drupal_add_js('http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js');
  20. // Get the filename of the BLAST results
  21. $job = tripal_get_job($vars['job_id']);
  22. $job_args = unserialize($job->arguments);
  23. //eksc- could stand better use of module settings and fewer hardcoded paths.
  24. $vars['xml_filename'] = variable_get('file_public_path', conf_path() . '/files') . '/tripal/tripal_blast/' . $job_args['output_filename'] . '.blast.xml';
  25. $vars['tsv_filename'] = variable_get('file_public_path', conf_path() . '/files') . '/tripal/tripal_blast/' . $job_args['output_filename'] . '.blast.tsv';
  26. $vars['html_filename'] = variable_get('file_public_path', conf_path() . '/files') . '/tripal/tripal_blast/' . $job_args['output_filename'] . '.blast.html';
  27. // Add the blast database node.
  28. // This is needed for link-out functionality.
  29. $vars['blastdb'] = get_blast_database(array('path' => $job_args['database']));
  30. // Get the recent job information.
  31. $vars['recent_jobs'] = get_recent_blast_jobs();
  32. // Make job information available in the template.
  33. $vars['blast_job'] = $job;
  34. $job_data = variable_get('job_data', '');
  35. if (isset($job_data[ $vars['job_id'] ])) {
  36. $vars['blast_job']->form_options = $job_data[ $vars['job_id'] ];
  37. }
  38. if (isset($vars['recent_jobs'][ $vars['job_id'] ])) {
  39. $vars['blast_job']->display = $vars['recent_jobs'][ $vars['job_id'] ];
  40. }
  41. // Determine the blast command for display.
  42. $vars['blast_job']->display['blast_cmd'] = $vars['blast_job']->form_options['program'];
  43. foreach($vars['blast_job']->form_options['options'] as $key => $value) {
  44. $vars['blast_job']->display['blast_cmd'] .= ' -' . $key. ' ' . $value ;
  45. }
  46. // Load the XML file.
  47. $vars['xml'] = NULL;
  48. if (is_readable($vars['xml_filename'])) {
  49. $vars['xml'] = simplexml_load_file($vars['xml_filename']);
  50. }
  51. }
  52. /**
  53. * Implements hook_theme_registery_alter().
  54. */
  55. function blast_ui_theme_registry_alter(&$theme_registry) {
  56. $theme_registry_copy = $theme_registry;
  57. $module_path = drupal_get_path('module', 'blast_ui') . '/theme';
  58. _theme_process_registry($theme_registry_copy, 'phptemplate', 'theme_engine', 'my_custom_theme', $module_path);
  59. $theme_registry += array_diff_key($theme_registry_copy, $theme_registry);
  60. // A list of templates the module will provide templates for
  61. $hooks = array('page');
  62. foreach ($hooks as $hook) {
  63. // Add the key 'theme paths' if it doesn't exist in this theme's registry
  64. if (!isset($theme_registry[$hook]['theme paths'])) {
  65. $theme_registry[$hook]['theme paths'] = array();
  66. }
  67. // Shift this module's directory to the top of the theme path list
  68. if (is_array($theme_registry[$hook]['theme paths'])) {
  69. $first_element = array_shift($theme_registry[$hook]['theme paths']);
  70. if ($first_element) {
  71. array_unshift($theme_registry[$hook]['theme paths'], $first_element, $module_path);
  72. }
  73. else {
  74. array_unshift($theme_registry[$hook]['theme paths'], $module_path);
  75. }
  76. }
  77. }
  78. }