瀏覽代碼

Tripal stock: Added blocks per piece of content to integrate with panels and changed default template to match organism/feature

laceysanderson 14 年之前
父節點
當前提交
5ee5ee63c3
共有 3 個文件被更改,包括 258 次插入63 次删除
  1. 117 14
      theme_tripal/node-chado_stock.tpl.php
  2. 45 0
      tripal_stock/tripal_stock.api.inc
  3. 96 49
      tripal_stock/tripal_stock.module

+ 117 - 14
theme_tripal/node-chado_stock.tpl.php

@@ -28,22 +28,125 @@
  //print '<pre>'.print_r($node,TRUE).'</pre>';
 ?>
 
-<!-- Base Theme -->
-<?php include('tripal_stock/tripal_stock_base.tpl.php'); ?>
+<script type="text/javascript">
+if (Drupal.jsEnabled) {
+   $(document).ready(function() {
+      // hide all tripal info boxes at the start
+      $(".tripal-info-box").hide();
+ 
+      // iterate through all of the info boxes and add their titles
+      // to the table of contents
+      $(".tripal-info-box-title").each(function(){
+        var parent = $(this).parent();
+        var id = $(parent).attr('id');
+        var title = $(this).text();
+        $('#tripal_stock_toc_list').append('<li><a href="#'+id+'" class="tripal_stock_toc_item">'+title+'</a></li>');
+      });
 
-<?php if (!$teaser) { ?>
-<!-- Database References -->
-<?php include('tripal_stock/tripal_stock_references.tpl.php'); ?>
+      // when a title in the table of contents is clicked, then
+      // show the corresponding item in the details box
+      $(".tripal_stock_toc_item").click(function(){
+         $(".tripal-info-box").hide();
+         href = $(this).attr('href');
+         $(href).fadeIn('slow');
+         // we want to make sure our table of contents and the details
+         // box stay the same height
+         $("#tripal_stock_toc").height($(href).parent().height());
+         return false;
+      }); 
 
-<!-- Properties -->
-<?php include('tripal_stock/tripal_stock_properties.tpl.php'); ?>
+      // we want the base details to show up when the page is first shown
+      $("#tripal_stock-base-box").show();
+      $("#tripal_stock_toc").height($("#tripal_stock-base-box").parent().height());
+   });
+}
+</script>
 
-<!-- Synonyms -->
-<?php include('tripal_stock/tripal_stock_synonyms.tpl.php'); ?>
+<style type="text/css">
+  /* these styles are specific for this template and is not included 
+     in the main CSS files for the theme as it is anticipated that the
+     elements on this page may not be used for other customizations */
+  #tripal_stock_toc {
+     float: left;
+     width: 20%;
+     background-color: #EEEEEE;
+     -moz-border-radius: 15px;
+     border-radius: 15px;
+     -moz-box-shadow: 3px 3px 4px #000;
+	  -webkit-box-shadow: 3px 3px 4px #000;
+	  box-shadow: 3px 3px 4px #000;
+     padding: 20px;
+     min-height: 500px;
+     border-style:solid;
+     border-width:1px;
+  }
+  #tripal_stock_toc ul {
+    margin-left: 0px;
+    margin-top: 5px;
+    padding-left: 15px;
+  }
+  #tripal_stock_toc_title {
+     font-size: 1.5em;
+  }
+  #tripal_stock_toc_desc {
+    font-style: italic;
+  }
+  #tripal_stock_details {
+     float: left;
+     width: 70%;
+     background-color: #FFFFFF;
+     -moz-border-radius: 15px;
+     border-radius: 15px;
+     -moz-box-shadow: 3px 3px 4px #000;
+	  -webkit-box-shadow: 3px 3px 4px #000;
+	  box-shadow: 3px 3px 4px #000;
+     padding: 20px;
+     min-height: 500px;
+     margin-right: 10px;
+     border-style:solid;
+     border-width:1px;
+  }
+  #tripal_stock-base-box img {
+    float: left;
+    margin-bottom: 10px;
+  }
+  #tripal_stock-table-base {
+    float: left;
+    width: 400px;
+    margin-left: 10px;
+    margin-bottom: 10px;
+  }
+</style>
 
-<!-- Object Relationships -->
-<?php include('tripal_stock/tripal_stock_relationships_as_object.tpl.php'); ?>
 
-<!-- Subject Relationships -->
-<?php include('tripal_stock/tripal_stock_relationships_as_subject.tpl.php'); ?>
-<?php } ?>
+<div id="tripal_stock_details">
+
+  <!-- Base Theme -->
+  <?php include('tripal_stock/tripal_stock_base.tpl.php'); ?>
+
+  <?php if (!$teaser) { ?>
+  <!-- Database References -->
+  <?php include('tripal_stock/tripal_stock_references.tpl.php'); ?>
+
+  <!-- Properties -->
+  <?php include('tripal_stock/tripal_stock_properties.tpl.php'); ?>
+
+  <!-- Synonyms -->
+  <?php include('tripal_stock/tripal_stock_synonyms.tpl.php'); ?>
+
+  <!-- Object Relationships -->
+  <?php include('tripal_stock/tripal_stock_relationships_as_object.tpl.php'); ?>
+
+  <!-- Subject Relationships -->
+  <?php include('tripal_stock/tripal_stock_relationships_as_subject.tpl.php'); ?>
+  <?php } ?>
+</div>
+
+<!-- Table of contents -->
+<div id="tripal_stock_toc">
+   <div id="tripal_stock_toc_title"><?php print $node->stock_name ?></div>
+   <span id="tripal_stock_toc_desc">Select a link below for more information</span>
+   <ul id="tripal_stock_toc_list">
+
+   </ul>
+</div>

+ 45 - 0
tripal_stock/tripal_stock.api.inc

@@ -34,6 +34,51 @@ function tripal_stock_get_stock_by_stock_id ($stock_id) {
 	
 }
 
+/*************************************************************************
+ * @section: Get Additional Data Associated with a stock
+ *************************************************************************/
+
+/*************************************************************************
+ * Purpose:
+ *
+ * @params $stock_id
+ *   the unique identifier for the stock to load properties of
+ * @return
+ *   an array of properties where each element is a property object with
+ *   the following fields:
+ *     - stockprop_id (stockprop):
+ *     - value (stockprop):
+ *     - rank (stockprop):
+ *     - type_id (stockprop):
+ *     - type_name (cvterm):
+ *     - type_definition (cvterm):
+ *     - type_is_obsolete (cvterm):
+ *     - type_is_relationshiptype (cvterm):
+ *     - type_cv_id (cvterm):
+ *     - type_db_reference_id (cvterm):
+ *     - type_cv_name (cv):
+ *     - type_cv_definition (cv):
+ *     - type_db_reference_acession (dbxref):
+ *     - type_db_reference_version (dbxref):
+ *     - type_db_reference_description (dbxref):
+ *     - type_db_reference_db_id (dbxref):
+ *     - type_db_reference_db_name (db):
+ *     - type_db_reference_db_description (db):
+ *     - type_db_reference_db_url (db):
+ *     - type_db_reference_db_urlprefix (db):
+ */
+function tripal_stock_load_properties($stock_id) {
+
+  $properties = tripal_core_chado_select(
+    'stockprop',
+    array('stockprop_id', 'value', 'rank','type_id'),
+    array('stock_id' => $stock_id)
+  );
+  
+  dpm($properties);
+  return $properties;  
+}
+
 /*************************************************************************
  * @section: Return Multiple Stocks
  *************************************************************************/

+ 96 - 49
tripal_stock/tripal_stock.module

@@ -206,56 +206,34 @@ function tripal_stock_theme() {
       'arguments' => array('form'),
       'function' => 'theme_tripal_stock_edit_ALL_relationships_form',
     ),
-//    'tripal_stock_base' => array (
-//      'arguments' => array('node'=> null),
-//      'template' => 'tripal_stock_base',
-//    ),
+    // Block Templates------------------------------
+    'tripal_stock_base' => array (
+      'arguments' => array('node'=> null),
+      'template' => 'tripal_stock_base',
+    ),
+    'tripal_stock_properties' => array (
+      'arguments' => array('node'=> null),
+      'template' => 'tripal_stock_properties',
+    ),
+    'tripal_stock_references' => array (
+      'arguments' => array('node'=> null),
+      'template' => 'tripal_stock_references',
+    ),
+    'tripal_stock_relationships_as_object' => array (
+      'arguments' => array('node'=> null),
+      'template' => 'tripal_stock_relationships_as_object',
+    ),    
+    'tripal_stock_relationships_as_subject' => array (
+      'arguments' => array('node'=> null),
+      'template' => 'tripal_stock_relationships_as_subject',
+    ),
+    'tripal_stock_synonyms' => array (
+      'arguments' => array('node'=> null),
+      'template' => 'tripal_stock_synonyms',
+    ),
 	);
 }
 
-/*************************************************************************
- * Purpose: Implement Blocks relating to stock content
- */
-function tripal_stock_block ($op = 'list', $delta = 0, $edit=array()) {
-  switch($op) {
-    case 'list':
-      $blocks['base']['info'] = t('Tripal Stock Details');
-      $blocks['base']['cache'] = BLOCK_NO_CACHE;
-         
-      return $blocks;
-
- 		case 'view':
- 			if(user_access('access chado_feature content') and arg(0) == 'node' and is_numeric(arg(1))) {
-      	$nid = arg(1);
-      	$node = node_load($nid);
- 
-        $block = array();
-        switch($delta){
-					case 'base':
-						$block['subject'] = t('Stock Details');
-//						$block['content'] = theme('tripal_stock_base',$node);
-						break;
-        }
-				return $blocks;
-			}
-	}
-}
-
-/*************************************************************************
- * Purpose:
- */
-function tripal_stock_nodeapi (&$node, $op, $teaser, $page) {
-	if ($node->type == 'chado_stock') {
-		switch ($op) {
-			case 'view':
-				$node->content['tripal_stock_base'] = array(
-//					'#value' => theme('tripal_stock_base', $node),
-					'#weight' => 0
-				);				
-		}	
-	}
-}
-
 /*************************************************************************
  * Purpose: show stocks stored in drupals chado_stock table
  */
@@ -396,7 +374,7 @@ function chado_stock_load($node) {
     
     $node->properties[] = $r;
   }
-
+  
   // Add in main db reference-----------------------------------------------------------------------
   // this is the dbxref_id in the stock table
   if (!empty($node->main_db_reference->dbxref_id)) {
@@ -944,9 +922,78 @@ function chado_stock_delete($node) {
 }
 
 /**************************************************************************
- * @section 
+ * @section Tripal Stock Blocks and Template Preprocessor Functions
  **************************************************************************/
 
+/*************************************************************************
+ * Purpose: Implement Blocks relating to stock content
+ */
+function tripal_stock_block ($op = 'list', $delta = 0, $edit=array()) {
+  switch($op) {
+    case 'list':
+      $blocks['base']['info'] = t('Tripal Stock Details');
+      $blocks['base']['cache'] = BLOCK_NO_CACHE;
+
+      $blocks['properties']['info'] = t('Tripal Stock Properties');
+      $blocks['properties']['cache'] = BLOCK_NO_CACHE;
+         
+      $blocks['references']['info'] = t('Tripal Stock References');
+      $blocks['references']['cache'] = BLOCK_NO_CACHE;
+         
+      $blocks['relationships_as_object']['info'] = t('Tripal Stock Relationships as Object');
+      $blocks['relationships_as_object']['cache'] = BLOCK_NO_CACHE;
+         
+      $blocks['relationships_as_subject']['info'] = t('Tripal Stock Relationships as Subject');
+      $blocks['relationships_as_subject']['cache'] = BLOCK_NO_CACHE;
+         
+      $blocks['synonyms']['info'] = t('Tripal Stock Synonyms');
+      $blocks['synonyms']['cache'] = BLOCK_NO_CACHE;
+                  
+      return $blocks;
+
+ 		case 'view':
+ 			if(user_access('access chado_stock content') and arg(0) == 'node' and is_numeric(arg(1))) {
+      	$nid = arg(1);
+      	$node = node_load($nid);
+ 
+        $block = array();
+        switch($delta){
+					case 'base':
+						$block['subject'] = t('Stock Details');
+						$block['content'] = theme('tripal_stock_base',$node);
+						break;
+						
+					case 'properties':
+						$block['subject'] = t('Properties');
+						$block['content'] = theme('tripal_stock_properties',$node);
+						break;
+						
+					case 'references':
+						$block['subject'] = t('References');
+						$block['content'] = theme('tripal_stock_references',$node);
+						break;
+						
+					case 'relationships_as_object':
+						$block['subject'] = t('Object Relationships');
+						$block['content'] = theme('tripal_stock_relationships_as_object',$node);
+						break;
+						
+					case 'relationships_as_subject':
+						$block['subject'] = t('Subject Relationships');
+						$block['content'] = theme('tripal_stock_relationships_as_subject',$node);
+						break;
+						
+					case 'synonyms':
+						$block['subject'] = t('Synonyms');
+						$block['content'] = theme('tripal_stock_synonyms',$node);
+						break;
+						
+        }
+				return $block;
+			}
+	}
+}
+
 function tripal_stock_preprocess_node_chado_stock (&$variables) {
 	$variables['testing1'] = 'test';
 	drupal_set_message('here');