tripal_core.extensions.inc 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <?php
  2. function tripal_core_extensions_form($form, &$form_state = NULL) {
  3. // Get the RSS feed XML from the tripa.info website.
  4. $content = file_get_contents("http://tripal.info/rss/extensions.xml");
  5. $xml = new SimpleXmlElement($content);
  6. $namespace = "http://tripal.info/rss/extensions/";
  7. // Parse the items into an array indexed by category and compatible versions.
  8. $items = array();
  9. foreach ($xml->channel->item as $item) {
  10. $category = (string) $item->category;
  11. // In order to get fields in the 'tripal_extension' name space we must
  12. // pass in the $namespace to the children function. We first get the
  13. // Tripal versions, then the chado versions and organize the elements
  14. // accordintly.
  15. $tvs = preg_split('/, /', (string) $item->children($namespace)->tripal_version);
  16. foreach($tvs as $tv) {
  17. $cvs = preg_split('/, /', (string) $item->children($namespace)->chado_version);
  18. foreach($cvs as $cv) {
  19. // Index the items by category, tripal version and chado version
  20. $items[$tv][$cv][$category][] = $item;
  21. }
  22. }
  23. }
  24. // Get the Chado version and convert to the expected format
  25. $chado_version = chado_get_version(TRUE);
  26. $chado_version = preg_replace('/^(\d\.\d).*$/', "v$1x", $chado_version);
  27. // Get the Tripal version. This is the version set in the tripal_core.info
  28. $info = system_get_info('module', 'tripal_core');
  29. $tripal_version = $info['version'];
  30. $tripal_version = preg_replace('/^.*?-(\d\.\d+).*$/', "v$1", $tripal_version);
  31. $form['type_select'] = array(
  32. '#type' => 'select',
  33. '#options' => array(
  34. 'Bulk Loader Templates' => 'Bulk Loader Templates',
  35. 'Materialized View' => 'Materialized View',
  36. 'Extension Module' => 'Extension Module',
  37. ),
  38. '#default_value' => 'Extension Module',
  39. );
  40. // Iterate through the compatible extensions
  41. foreach ($items[$tripal_version][$chado_version] as $category) {
  42. $markup = '';
  43. switch ($category) {
  44. case 'Bulk Loader Template':
  45. break;
  46. case 'Materialized View':
  47. break;
  48. case 'Extension Module':
  49. break;
  50. default:
  51. break;
  52. }
  53. }
  54. return $form;
  55. }
  56. function tripal_core_extensions_form_validate($form, &$form_state) {
  57. }
  58. function tripal_core_extensions_form_submit($form, &$form_state) {
  59. }