Jelajahi Sumber

Library templates

spficklin 14 tahun lalu
induk
melakukan
49246ee6cd

+ 60 - 0
theme_tripal/tripal_library/tripal_library_base.tpl.php

@@ -0,0 +1,60 @@
+<?php
+
+$library  = $variables['node']->library;
+
+// expand the library to include the properties.
+$library = tripal_core_expand_chado_vars($library,'table','libraryprop');
+$library = tripal_core_expand_chado_vars($library,'field','libraryprop.value');
+
+?>
+<div id="tripal_library-base-box" class="tripal_library-info-box tripal-info-box">
+  <div class="tripal_library-info-box-title tripal-info-box-title">Library Details</div>
+  <div class="tripal_library-info-box-desc tripal-info-box-desc"></div>
+
+   <?php if(strcmp($library->is_obsolete,'t')==0){ ?>
+      <div class="tripal_library-obsolete">This library is obsolete</div>
+   <?php }?>
+   <table id="tripal_library-base-table" class="tripal_library-table tripal-table tripal-table-vert">
+      <tr class="tripal_library-table-even-row tripal-table-even-row">
+        <th nowrap>Unique Name</th>
+        <td><?php print $library->uniquename; ?></td>
+      </tr>
+      <tr class="tripal_library-table-odd-row tripal-table-odd-row">
+        <th>Internal ID</th>
+        <td><?php print $library->library_id; ?></td>
+      </tr>
+      <tr class="tripal_library-table-even-row tripal-table-even-row">
+        <th>Organism</th>
+        <td>
+          <?php if ($library->organism_id->nid) { 
+      	   print "<a href=\"".url("node/".$library->organism_id->nid)."\">".$library->organism_id->genus ." " . $library->organism_id->species ." (" .$library->organism_id->common_name .")</a>";      	 
+          } else { 
+            print $library->organism_id->genus ." " . $library->organism_id->species ." (" .$library->organism_id->common_name .")";
+          } ?>
+        </td>
+      </tr>      
+      <tr class="tripal_library-table-odd-row tripal-table-odd-row">
+        <th>Type</th>
+        <td><?php 
+            if ($library->type_id->name == 'cdna_library') {
+               print 'cDNA';
+            } else if ($library->type_id->name == 'bac_library') {
+               print 'BAC';
+            } else {
+               print $library->type_id->name;
+            }
+          ?>
+        </td>
+      </tr>
+      <tr class="tripal_library-table-even-row tripal-table-even-row">
+        <th>Description</th>
+        <td><?php
+           // right now we only have one property for libraries. So we can just
+           // refernece it directly.  If we had more than one property
+           // we would need to convert this to an if statment and loop
+           // until we found the right one.
+           print $library->libraryprop->value?>
+        </td>
+     	</tr>           	                                
+   </table>
+</div>

+ 58 - 0
theme_tripal/tripal_library/tripal_library_properties.tpl.php

@@ -0,0 +1,58 @@
+<?php
+// Purpose: Provide layout and content for library properties. This includes all
+//   fields in the libraryprop table with the library_id of the current library
+//   supplemented with extra details for the type to provide human-readable
+//   output
+//
+// Note: This template controls the layout/content for the default library node
+//   template (node-chado_library.tpl.php) and the library Properties Block
+//
+// Variables Available:
+//   - $node: a standard object which contains all the fields associated with
+//       nodes including nid, type, title, taxonomy. It also includes library
+//       specific fields such as library_name, uniquename, library_type, synonyms,
+//       properties, db_references, object_relationships, subject_relationships,
+//       organism, etc.
+//   - $node->properties: an array of library property objects where each object
+//       the following fields: libraryprop_id, type_id, type, value, rank
+//       and includes synonyms
+//   NOTE: For a full listing of fields available in the node object the
+//       print_r $node line below or install the Drupal Devel module which 
+//       provides an extra tab at the top of the node page labelled Devel
+?>
+
+<?php
+ //uncomment this line to see a full listing of the fields avail. to $node
+ //print '<pre>'.print_r($node,TRUE).'</pre>';
+?>
+
+<?php
+  $properties = $node->library->libraryprop;
+  if (!$properties) {
+    $properties = array();
+  } elseif (!is_array($properties)) { 
+    $properties = array($properties); 
+  }
+?>
+
+<div id="tripal_library-properties-box" class="tripal_library-info-box tripal-info-box">
+  <div class="tripal_library-info-box-title tripal-info-box-title">Properties</div>
+  <div class="tripal_library-info-box-desc tripal-info-box-desc">Properties for the library '<?php print $node->library->name ?>' include:</div>
+	<?php if(count($properties) > 0){ ?>
+  <table class="tripal_library-table tripal-table tripal-table-horz">
+  <tr><th>Type</th><th>Value</th></tr>
+	<?php	// iterate through each property
+		$i = 0;
+		foreach ($properties as $result){
+		  $class = 'tripal_library-table-odd-row tripal-table-odd-row';
+      if($i % 2 == 0 ){
+         $class = 'tripal_library-table-odd-row tripal-table-even-row';
+      }
+			print '<tr class="'.$class.'"><td>'.$result->type_id->name.'</td><td>'.$result->value.'</td></tr>';
+			$i++;
+		} ?>
+		</table>
+	<?php } else {
+	  print '<div class="tripal-no-results">There are no properties for the current library.</div>';
+	} ?>
+</div>

+ 61 - 0
theme_tripal/tripal_library/tripal_library_references.tpl.php

@@ -0,0 +1,61 @@
+<?php
+$library = $variables['node']->library;
+
+// expand the library object to include the external references stored
+// in the library_dbxref table
+$library = tripal_core_expand_chado_vars($library,'table','library_dbxref');
+
+// get the references. if only one reference exists then we want to convert
+// the object into an array, otherwise the value is an array
+$references = $library->library_dbxref;
+if (!$references) {
+   $references = array();
+} elseif (!is_array($references)) { 
+   $references = array($references); 
+}
+// check to see if the reference 'GFF_source' is there.  This reference is
+// used to help the GBrowse chado adapter find librarys.  We don't need to show
+// it
+if($references[0]->dbxref_id->db_id->name == 'GFF_source' and count($references)==1){
+   $references = array();
+}
+?>
+<div id="tripal_library-references-box" class="tripal_library-info-box tripal-info-box">
+  <div class="tripal_library-info-box-title tripal-info-box-title">References</div>
+  <div class="tripal_library-info-box-desc tripal-info-box-desc">External references for this <?php print $library->type_id->name ?></div>
+  <?php if(count($references) > 0){ ?>
+  <table id="tripal_library-references-table" class="tripal_library-table tripal-table tripal-table-horz">
+    <tr>
+      <th>Dababase</th>
+      <th>Accession</th>
+    </tr>
+    <?php
+    $i = 0; 
+    foreach ($references as $library_dbxref){ 
+      if($library_dbxref->dbxref_id->db_id->name == 'GFF_source'){
+         continue;  // skip the GFF_source entry as this is just needed for the GBrowse chado adapter
+      }
+      $class = 'tripal_library-table-odd-row tripal-table-odd-row';
+      if($i % 2 == 0 ){
+         $class = 'tripal_library-table-odd-row tripal-table-even-row';
+      }
+      ?>
+      <tr class="<?php print $class ?>">
+        <td><?php print $library_dbxref->dbxref_id->db_id->name?></td>
+        <td><?php 
+           if($library_dbxref->db_id->urlprefix){ 
+              ?><a href="<?php print $library_dbxref->db_id->urlprefix.$library_dbxref->dbxref_id->accession?>" target="_blank"><?php print $library_dbxref->dbxref_id->accession?></a><?php 
+           } else { 
+             print $library_dbxref->dbxref_id->accession; 
+           } 
+           ?>
+        </td>
+      </tr>
+      <?php
+      $i++;  
+    } ?>
+  </table>
+  <?php } else { ?>
+    <div class="tripal-no-results">There are no external references</div> 
+  <?php }?>
+</div>

+ 44 - 0
theme_tripal/tripal_library/tripal_library_synonyms.tpl.php

@@ -0,0 +1,44 @@
+<?php
+$library = $variables['node']->library;
+
+// expand the library object to include the synonyms from the library_synonym 
+// table in chado.
+$library = tripal_core_expand_chado_vars($library,'table','library_synonym');
+
+// get the references. if only one reference exists then we want to convert
+// the object into an array, otherwise the value is an array
+$synonyms = $library->library_synonym;
+if (!$synonyms) {
+   $synonyms = array();
+} elseif (!is_array($synonyms)) { 
+   $synonyms = array($synonyms); 
+}
+
+?>
+<div id="tripal_library-synonyms-box" class="tripal_library-info-box tripal-info-box">
+  <div class="tripal_library-info-box-title tripal-info-box-title">Synonyms</div>
+  <div class="tripal_library-info-box-desc tripal-info-box-desc">The library '<?php print $library->name ?>' has the following synonyms</div>
+  <?php if(count($synonyms) > 0){ ?>
+  <table id="tripal_library-synonyms-table" class="tripal_library-table tripal-table tripal-table-horz">
+    <tr>
+      <th>Synonym</th>
+    </tr>
+    <?php
+    $i = 0; 
+    foreach ($synonyms as $library_synonym){
+      $class = 'tripal-table-odd-row';
+      if($i % 2 == 0 ){
+         $class = 'tripal-table-even-row';
+      }
+      ?>
+      <tr class="<?php print $class ?>">
+        <td><?php print $library_synonym->synonym_id->name?></td>
+      </tr>
+      <?php
+      $i++;  
+    } ?>
+  </table>
+  <?php } else { ?>
+    <div class="tripal-no-results">There are no synonyms for this library</div> 
+  <?php }?>
+</div>