blast_ui.theme.inc 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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. //@deepaksomanadh: code added to use the persisted data in the template file.
  31. $job_id = $vars['job_id'];
  32. $job_data = variable_get('job_data', '');
  33. $vars['job_id_data'] = $job_data[$job_id];
  34. }
  35. /**
  36. * Implements hook_theme_registery_alter().
  37. */
  38. function blast_ui_theme_registry_alter(&$theme_registry) {
  39. $theme_registry_copy = $theme_registry;
  40. $module_path = drupal_get_path('module', 'blast_ui') . '/theme';
  41. _theme_process_registry($theme_registry_copy, 'phptemplate', 'theme_engine', 'my_custom_theme', $module_path);
  42. $theme_registry += array_diff_key($theme_registry_copy, $theme_registry);
  43. // A list of templates the module will provide templates for
  44. $hooks = array('page');
  45. foreach ($hooks as $hook) {
  46. // Add the key 'theme paths' if it doesn't exist in this theme's registry
  47. if (!isset($theme_registry[$hook]['theme paths'])) {
  48. $theme_registry[$hook]['theme paths'] = array();
  49. }
  50. // Shift this module's directory to the top of the theme path list
  51. if (is_array($theme_registry[$hook]['theme paths'])) {
  52. $first_element = array_shift($theme_registry[$hook]['theme paths']);
  53. if ($first_element) {
  54. array_unshift($theme_registry[$hook]['theme paths'], $first_element, $module_path);
  55. }
  56. else {
  57. array_unshift($theme_registry[$hook]['theme paths'], $module_path);
  58. }
  59. }
  60. }
  61. }