tripal_cv.vocabulary.inc 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <?php
  2. /**
  3. *
  4. *
  5. */
  6. class TrpVocabularyController extends DrupalDefaultEntityController {
  7. /**
  8. *
  9. * @param $ids
  10. * An array of entity IDs, or FALSE to load all entities.
  11. * @param $conditions
  12. * DEPRECATED. An array of conditions. Keys are field names on the entity's
  13. * base table.Values will be compared for equality. All the comparisons will
  14. * be ANDed together. This parameter is deprecated; use an EntityFieldQuery
  15. * instead.
  16. * @return multitype:An
  17. */
  18. public function load($ids = array(), $conditions = array()) {
  19. $entities = array();
  20. $queried_entities = array();
  21. // Get the list of records that match the loading criteria
  22. $sql = "
  23. SELECT CVDB.cv_id, CVDB.name, CVDB.namespace, DB.url, DB.urlprefix
  24. FROM {cv_db} CVDB
  25. INNER JOIN {db} DB on DB.db_id = CVDB.db_id
  26. LEFT JOIN {cvprop} CVP on CVP.cv_id = CVDB.cv_id
  27. ";
  28. $where = '';
  29. if ($ids) {
  30. $where .= ' CVDB.cv_id IN (:ids)';
  31. }
  32. if ($where) {
  33. $sql .= "WHERE $where";
  34. }
  35. $sql .= "ORDER BY CVDB.name ";
  36. $sql .= "LIMIT 10 OFFSET 0 ";
  37. $results = chado_query($sql, array(':ids' => $ids));
  38. while ($result = $results->fetchObject()) {
  39. $cv = new stdClass();
  40. $cv->internal_id = $result->cv_id;
  41. $cv->name = $result->name;
  42. $cv->format = 'OBO v1.4';
  43. $cv->namespace = $result->namespace;
  44. $cv->url = $result->url;
  45. $cv->term_url = $result->urlprefix ? $result->urlprefix . '{id}' : '';
  46. $queried_entities[$cv->internal_id] = $cv;
  47. }
  48. // Pass all entities loaded from the database through $this->attachLoad(),
  49. // which attaches fields (if supported by the entity type) and calls the
  50. // entity type specific load callback, for example hook_node_load().
  51. if (!empty($queried_entities)) {
  52. // $this->attachLoad($queried_entities);
  53. $entities += $queried_entities;
  54. }
  55. // Ensure that the returned array is ordered the same as the original
  56. // $ids array if this was passed in and remove any invalid ids.
  57. return $entities;
  58. }
  59. }