function theme_tripal_library_search_index

1.x tripal_library.module theme_tripal_library_search_index($node)

This function is an extension of the chado_feature_view and chado_organism_view by providing the markup for the library object THAT WILL BE INDEXED.

Related topics

1 theme call to theme_tripal_library_search_index()
tripal_library_nodeapi in tripal_library/tripal_library.module
Implementation of hook_nodeapi(). Display library information for associated features or organisms This function also provides contents for indexing

File

tripal_library/tripal_library.module, line 276

Code

function theme_tripal_library_search_index($node) {

  if ($node->type == 'chado_organism') {
    $content = "";
    // get the libraries for the organism
    $sql = "SELECT * FROM {library} L " .
      "WHERE L.organism_id = %d";
    $libraries = array();
    $results = chado_query($sql, $node->organism->organism_id);
    while ($library = db_fetch_object($results)) {
      // get the description
      $sql = "SELECT * FROM {libraryprop} LP " .
        "  INNER JOIN {CVTerm} CVT ON CVT.cvterm_id = LP.type_id " .
        "WHERE LP.library_id = $library->library_id " .
        "  AND CVT.name = 'library_description'";
      $desc = db_fetch_object(chado_query($sql));
      $library->description = $desc->value;
      $libraries[] = $library;
    }
    if (count($libraries) > 0) {
      foreach ($libraries as $library) {
        $content .= "$library->name ";
        $content .= "$library->description";
      }
    }
    // Provide library names to show in a feature page
  }
  elseif ($node->type == 'chado_feature') {
    $content = "";
    $organism_id = $node->feature->organism_id;
    $sql = "SELECT * FROM {library} L " .
      "  INNER JOIN {Library_feature} LF ON L.library_id = LF.library_id " .
      "WHERE LF.feature_id = " . $node->feature->feature_id;
    $libraries = array();
    $results = chado_query($sql);
    while ($library = db_fetch_object($results)) {
      $libraries[] = $library;
    }
    if (count($libraries) > 0) {
      $lib_additions = array();
      foreach ($libraries as $library) {
        $content .= $library->name;
      }
    }
  }
  return $content;
}