Переглянути джерело

Tripal Stock Bug Fixes: Tripal stock module now compatible with php5

laceysanderson 13 роки тому
батько
коміт
550bb60f55

+ 1 - 1
theme_tripal/tripal_stock/tripal_stock_references.tpl.php

@@ -74,6 +74,6 @@
     } ?>
   </table>
   <?php } else {
-    print '<b>There are no external database references for the current stock.</b>';
+    print '<div class="tripal-no-results">There are no external database references for the current stock.</div>';
   }?>
 </div>

+ 1 - 1
tripal_stock/tripal_stock-db_references.inc

@@ -225,7 +225,7 @@ function tripal_stock_edit_ALL_dbreferences_page($node) {
  *
  * @ingroup tripal_stock
  */                                        
-function tripal_stock_edit_ALL_db_references_form($form_state, &$node) {
+function tripal_stock_edit_ALL_db_references_form($form_state, $node) {
   $form = array();
 
   // Add database references to the node

+ 1 - 1
tripal_stock/tripal_stock-properties.inc

@@ -184,7 +184,7 @@ function tripal_stock_edit_ALL_properties_page($node) {
  *
  * @ingroup tripal_stock
  */
-function tripal_stock_edit_ALL_properties_form($form_state, &$node) {
+function tripal_stock_edit_ALL_properties_form($form_state, $node) {
   $form = array();
 
   // Add properties and synonyms

+ 22 - 12
tripal_stock/tripal_stock-relationships.inc

@@ -11,9 +11,7 @@ function tripal_stock_add_ALL_relationships_page($node) {
   $output .= tripal_stock_add_chado_properties_progress('relationships').'<br>';
   $output .= '<b>All Relationships should include the CURRENT Individual ('.$node->stock->uniquename.')</b><br>';
   $output .= '<br>';
-  $output .= theme('tripal_stock_relationships_as_object', $node);
-  $output .= '<br>';
-  $output .= theme('tripal_stock_relationships_as_subject', $node);
+  $output .= theme('tripal_stock_relationships', $node);
   $output .= '<br><br>';
   $output .= drupal_get_form('tripal_stock_add_ONE_relationship_form', $node);
   $output .= '<br>';
@@ -207,15 +205,27 @@ function tripal_stock_edit_ALL_relationships_page($node) {
  */                                                   
 function tripal_stock_edit_ALL_relationships_form($form_state, $node) {
   $form = array();
-
+  
   // All Stock Relationships
   $node = tripal_core_expand_chado_vars($node, 'table', 'stock_relationship');    
-  if (!$node->stock->stock_relationship) { 
-    $node->stock->stock_relationship = array(); 
-  } elseif (!is_array($node->stock->stock_relationship)) { 
-    $node->stock->stock_relationship = array($node->stock->stock_relationship); 
-  }  
-  
+   
+  // compile all relationships into one variable
+  $relationships = array();
+  if (is_array($node->stock->stock_relationship->subject_id)) {
+    foreach ($node->stock->stock_relationship->subject_id as $r) {
+      $relationships[$r->stock_relationship_id] = $r;
+    }
+  } elseif (is_object($node->stock->stock_relationship->subject_id)) { 
+    $relationships[$node->stock->stock_relationship->subject_id->stock_relationship_id] = $node->stock->stock_relationship->subject_id;
+  }
+
+  if (is_array($node->stock->stock_relationship->object_id)) {
+    foreach ($node->stock->stock_relationship->object_id as $r) {
+      $relationships[$r->stock_relationship_id] = $r;
+    }
+  } elseif (is_object($node->stock->stock_relationship->object_id)) { 
+    $relationships[$node->stock->stock_relationship->object_id->stock_relationship_id] = $node->stock->stock_relationship->object_id;
+  }
     
   $form['nid'] = array(
     '#type' => 'hidden',
@@ -228,8 +238,8 @@ function tripal_stock_edit_ALL_relationships_form($form_state, $node) {
   );
 
   $i=0;
-  if (sizeof($node->stock->stock_relationship) != 0) {
-  foreach ($node->stock->stock_relationship as $r) {
+  if (sizeof($relationships) != 0) {
+  foreach ($relationships as $r) {
 
     $i++;
     $form["num-$i"] = array(

+ 6 - 18
tripal_stock/tripal_stock.module

@@ -272,14 +272,10 @@ function tripal_stock_theme() {
       'arguments' => array('node'=> null),
       'template' => 'tripal_stock_references',
     ),
-    'tripal_stock_relationships_as_object' => array (
+    'tripal_stock_relationships' => array (
       'arguments' => array('node'=> null),
-      'template' => 'tripal_stock_relationships_as_object',
+      'template' => 'tripal_stock_relationships',
     ),    
-    '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',
@@ -906,12 +902,9 @@ function tripal_stock_block ($op = 'list', $delta = 0, $edit=array()) {
       $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']['info'] = t('Tripal Stock Relationships');
       $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;
                   
@@ -939,14 +932,9 @@ function tripal_stock_block ($op = 'list', $delta = 0, $edit=array()) {
 						$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);
+					case 'relationships':
+						$block['subject'] = t('Relationships');
+						$block['content'] = theme('tripal_stock_relationships',$node);
 						break;
 						
 					case 'synonyms':