Browse Source

Working on organism theming

Stephen Ficklin 11 years ago
parent
commit
e03ae0792e

+ 17 - 7
tripal_core/theme/css/tripal.css

@@ -117,10 +117,19 @@ table.tripal-table-horz .tripal-table-odd-row {
    padding: 10px;
    background-color: #FFEEEE;
 }
+/**
+ * Tripal Contents container: contains both the details 
+ * section and the resources sidebar
+ */
+.tripal_contents {
+  width: 100%;
+}
 
+/**
+ * Resources Sidebar
+ */
 .tripal_toc {
-  float: left;
-  width: 20%;
+  float: right;  
   background-color: #EEEEEE;
 
   -moz-border-radius: 15px;
@@ -148,13 +157,13 @@ table.tripal-table-horz .tripal-table-odd-row {
   padding-bottom: 10px;
 }
 .tripal_toc_desc {
- /*font-style: italic; */
 }
+/**
+ * Details Section
+ */
 .tripal_details {
   float: left;
-  width: 69%;
   background-color: #FFFFFF;
-
   -moz-border-radius: 15px;
   -webkit-border-radius: 15px;
   -khtml-border-radius: 15px;
@@ -175,7 +184,6 @@ table.tripal-table-horz .tripal-table-odd-row {
 
 .tripal_details_full {
   float: left;
-  width: 95%;
   background-color: #FFFFFF;
 
   -moz-border-radius: 15px;
@@ -195,7 +203,9 @@ table.tripal-table-horz .tripal-table-odd-row {
   
   overflow:auto;
 }
-
+/**
+ * Tables
+ */
 .tripal-subtable {
   border-collapse:collapse;
   border: 0px solid black;

+ 2 - 2
tripal_core/tripal_core.module

@@ -61,8 +61,8 @@ function tripal_core_init() {
   global $base_url;
 
   // add javascript files
-  drupal_add_js(drupal_get_path('module', 'tripal_core') . '/theme/js/tripal_core.js');
-  drupal_add_css(drupal_get_path('module', 'tripal_core') . '/theme/css/tripal_core.css');
+  drupal_add_js(drupal_get_path('module', 'tripal_core') . '/theme/js/tripal.js');
+  drupal_add_css(drupal_get_path('module', 'tripal_core') . '/theme/css/tripal.css');
   
 
   // create the 'tripal' controlled volcabulary in chado but only if it doesn't already exist, and

+ 31 - 29
tripal_feature/tripal_feature.module

@@ -266,40 +266,42 @@ function tripal_feature_menu() {
  *
  * @ingroup tripal_feature
  */
-function tripal_feature_theme() {
+function tripal_feature_theme($existing, $type, $theme, $path) {
   return array(
     'tripal_feature_search_index' => array(
-      'arguments' => array('node'),
+      'variables' => array('node'),
     ),
     'tripal_feature_search_results' => array(
-       'arguments' => array('node'),
+       'variables' => array('node'),
     ),
     'tripal_organism_feature_browser' => array(
-       'arguments' => array('node' => NULL),
-       'template' => 'tripal_organism_feature_browser',
+      'variables' => array('node' => NULL),
+      'template' => 'tripal_organism_feature_browser',
+      'path' => "$path/theme/tripal_organism",
     ),
     'tripal_organism_feature_counts' => array(
-       'arguments' => array('node' => NULL),
-       'template' => 'tripal_organism_feature_counts',
+      'variables' => array('node' => NULL),
+      'template' => 'tripal_organism_feature_counts',
+      'path' => "$path/theme/tripal_organism",
     ),
     'tripal_feature_base' => array(
-       'arguments' => array('node' => NULL),
+       'variables' => array('node' => NULL),
        'template' => 'tripal_feature_base',
     ),
     'tripal_feature_sequence' => array(
-       'arguments' => array('node' => NULL),
+       'variables' => array('node' => NULL),
        'template' => 'tripal_feature_sequence',
     ),
     'tripal_feature_proteins' => array(
-       'arguments' => array('node' => NULL),
+       'variables' => array('node' => NULL),
        'template' => 'tripal_feature_proteins',
     ),
     'tripal_feature_synonyms' => array(
-       'arguments' => array('node' => NULL),
+       'variables' => array('node' => NULL),
        'template' => 'tripal_feature_synonyms',
     ),
     'tripal_feature_phenotypes' => array(
-       'arguments' => array('node' => NULL),
+       'variables' => array('node' => NULL),
        'template' => 'tripal_feature_phenotypes',
     ),
     'tripal_feature_featurepos' => array(
@@ -307,27 +309,27 @@ function tripal_feature_theme() {
        'template' => 'tripal_feature_featurepos',
     ),
     'tripal_feature_featureloc_sequences' => array(
-       'arguments' => array('node' => NULL),
+       'variables' => array('node' => NULL),
        'template' => 'tripal_feature_featureloc_sequences',
     ),
     'tripal_feature_references' => array(
-       'arguments' => array('node' => NULL),
+       'variables' => array('node' => NULL),
        'template' => 'tripal_feature_references',
     ),
     'tripal_feature_properties' => array(
-       'arguments' => array('node' => NULL),
+       'variables' => array('node' => NULL),
        'template' => 'tripal_feature_properties',
     ),
     'tripal_feature_terms' => array(
-       'arguments' => array('node' => NULL),
+       'variables' => array('node' => NULL),
        'template' => 'tripal_feature_terms',
     ),
     'tripal_feature_alignments' => array(
-       'arguments' => array('node' => NULL),
+       'variables' => array('node' => NULL),
        'template' => 'tripal_feature_alignments',
     ),
     'tripal_feature_relationships' => array(
-       'arguments' => array('node' => NULL),
+       'variables' => array('node' => NULL),
        'template' => 'tripal_feature_relationships',
     ),
     'tripal_feature_edit_ALL_properties_form' => array(
@@ -336,7 +338,7 @@ function tripal_feature_theme() {
     ),
     'tripal_feature_admin' => array(
       'template' => 'tripal_feature_admin',
-      'arguments' =>  array(NULL),
+      'variables' =>  array(NULL),
       'path' => drupal_get_path('module', 'tripal_feature') . '/theme'
     ),
     
@@ -439,11 +441,11 @@ function tripal_feature_block_view($delta = '') {
         break;
       case 'org_feature_counts':
         $block['subject'] = t('Feature Type Summary');
-        $block['content'] = theme('tripal_organism_feature_counts', $node);
+        $block['content'] = theme('tripal_organism_feature_counts', array('node' => $node));
         break;
       case 'org_feature_browser':
         $block['subject'] = t('Feature Browser');
-        $block['content'] = theme('tripal_organism_feature_browser', $node);
+        $block['content'] = theme('tripal_organism_feature_browser', array('node' => $node));
         break;
       case 'library_feature_browser':
         $block['subject'] = t('Library Feature Browser');
@@ -1890,10 +1892,10 @@ function tripal_feature_node_view($node, $view_mode, $langcode) {
       // Show feature browser and counts
       if ($view_mode == 'full') {
         $node->content['tripal_organism_feature_counts'] = array(
-          '#value' => theme('tripal_organism_feature_counts', $node),
+          '#value' => theme('tripal_organism_feature_counts', array('node' => $node)),
         );
         $node->content['tripal_organism_feature_browser'] = array(
-          '#value' => theme('tripal_organism_feature_browser', $node),
+          '#value' => theme('tripal_organism_feature_browser', array('node' => $node)),
         );
       }
       break;
@@ -2056,9 +2058,9 @@ function tripal_feature_preprocess_tripal_feature_alignments(&$variables) {
  *
  * @ingroup tripal_feature
  */
-function tripal_feature_preprocess_tripal_organism_feature_counts(&$variables) {
-  $organism = $variables['node']->organism;
-  $organism->feature_counts = tripal_feature_load_organism_feature_counts($organism);
+function tripal_feature_preprocess_tripal_organism_feature_counts(&$variables, $hook) {
+ // $organism = $variables['node']->organism;
+  //$organism->feature_counts = tripal_feature_load_organism_feature_counts($organism);
 }
 
 /**
@@ -2066,9 +2068,9 @@ function tripal_feature_preprocess_tripal_organism_feature_counts(&$variables) {
  *
  * @ingroup tripal_feature
  */
-function tripal_feature_preprocess_tripal_organism_feature_browser(&$variables) {
-  $organism = $variables['node']->organism;
-  $organism->feature_browser = tripal_feature_load_organism_feature_browser($organism);
+function tripal_feature_preprocess_tripal_organism_feature_browser(&$variables, $hook) {
+  //$organism = $variables['node']->organism;
+  //$organism->feature_browser = tripal_feature_load_organism_feature_browser($organism);
 }
 
 /**

+ 0 - 8
tripal_organism/theme/css/tripal_organism.css

@@ -25,11 +25,3 @@
  margin-top: 5px;
 
 }
-#tripal_organism-table-base {
- width: auto;
- margin-bottom: 10px;
- min-width: 300px;
- margin-top: 0px;
-
-}
-

+ 63 - 45
tripal_organism/theme/node--chado-organism.tpl.php

@@ -40,15 +40,29 @@ else { ?>
 <script type="text/javascript">
 (function ($) {
   Drupal.behaviors.organismBehavior = {
-    attach: function (context, settings){<?php 
+    attach: function (context, settings){<?php
+      // hide the resource sidbar if requested and strech the details section
       if ($no_sidebar) { ?>    
-        // hide the resource side bar and strech the details section    
         $(".tripal_toc").hide();
         $(".tripal_details").addClass("tripal_details_full");
         $(".tripal_details_full").removeClass("tripal_details"); <?php
-      } else { ?>
-        // use default resource sidebar
-        $(".tripal-info-box").hide(); <?php
+      } 
+      // use default resource sidebar
+      else { ?>        
+        $(".tripal-info-box").hide();
+
+        // set the widths of the details and sidebar sections so they can work 
+        // seemlessly with any theme.
+        total_width = $(".tripal_contents").width();
+        details_width = (total_width * 0.70) - 52; // 52 == 20  x 2 left/right padding + 10 right margin + 2pt border
+        toc_width = (total_width * 0.30) - 42;  // 42 == 20 x 2 left/right padding + 2pt border
+        // don't let sidebar get wider than 200px
+        if (toc_width > 200) {
+          details_width += toc_width - 200;
+          toc_width = 200;
+        }
+        $('#tripal_organism_toc').width(toc_width);
+        $('#tripal_organism_details').width(details_width); <?php
       } ?>
  
       // iterate through all of the info boxes and add their titles
@@ -102,46 +116,50 @@ else { ?>
 })(jQuery);
 </script>
 
-<div id="tripal_organism_details" class="tripal_details">
-
-   <!-- Basic Details Theme -->
-   <?php print theme('tripal_organism_base', $variables); ?>
-   
-   <!-- Resource Blocks CCK elements --> <?php
-   if(property_exists($node, 'field_resource_titles')) {
-	   for($i = 0; $i < count($node->field_resource_titles); $i++){
-	     if($node->field_resource_titles[$i]['value']){ ?>
-	       <div id="tripal_organism-resource_<?php print $i?>-box" class="tripal_organism-info-box tripal-info-box">
-	         <div class="tripal_organism-info-box-title tripal-info-box-title"><?php print $node->field_resource_titles[$i]['value'] ?></div>
-	         <?php print $node->field_resource_blocks[$i]['value']; ?>
-	       </div> <?php
-	     }
-	   } 
-	 }?>
-   <!-- Let modules add more content -->
-   <?php print $content ?>
-   
-</div>
-
-<!-- Table of contents -->
-<div id="tripal_organism_toc" class="tripal_toc">
-   <div id="tripal_organism_toc_title" class="tripal_toc_title">Resources</i></div>
-   <span id="tripal_organism_toc_desc" class="tripal_toc_desc"></span>
-   <ul id="tripal_organism_toc_list" class="tripal_toc_list">
-   
-     <!-- Resource Links CCK elements --><?php
-     if(property_exists($node, 'field_resource_links')) {
-	     for($i = 0; $i < count($node->field_resource_links); $i++){
-	       if($node->field_resource_links[$i]['value']){
-	         $matches = preg_split("/\|/",$node->field_resource_links[$i]['value']);?>
-	         <li><a href="<?php print $matches[1] ?>" target="_blank"><?php print $matches[0] ?></a></li><?php
-	       }
-	     }
-     }
+<div id="tripal_organism_content" class="tripal_contents">
+  <div id="tripal_organism_details" class="tripal_details">
+  
+     <!-- Resource Blocks CCK elements --> <?php
+     if (property_exists($node, 'field_resource_titles')) {
+       for ($i = 0; $i < count($node->field_resource_titles); $i++){
+         if ($node->field_resource_titles[$i]['value']){ ?>
+           <div id="tripal_organism-resource_<?php print $i?>-box" class="tripal_organism-info-box tripal-info-box">
+             <div class="tripal_organism-info-box-title tripal-info-box-title"><?php print $node->field_resource_titles[$i]['value'] ?></div>
+             <?php print $node->field_resource_blocks[$i]['value']; ?>
+           </div> <?php
+         }
+       } 
+     }?>
+     <!-- Let modules add more content -->
+     <?php
+       foreach ($content as $key => $values) {
+         if (array_key_exists('#value', $values)) {
+           print $content[$key]['#value'];
+         }
+       }
+     ?>
      
-     // ADD CUSTOMIZED <li> LINKS HERE 
-     ?> 
-   </ul>
-</div> <?php 
+  </div>
+  
+  <!-- Table of contents -->
+  <div id="tripal_organism_toc" class="tripal_toc">
+     <div id="tripal_organism_toc_title" class="tripal_toc_title">Resources</i></div>
+     <span id="tripal_organism_toc_desc" class="tripal_toc_desc"></span>
+     <ul id="tripal_organism_toc_list" class="tripal_toc_list">
+     
+       <!-- Resource Links CCK elements --><?php
+       if(property_exists($node, 'field_resource_links')) {
+         for($i = 0; $i < count($node->field_resource_links); $i++){
+           if($node->field_resource_links[$i]['value']){
+             $matches = preg_split("/\|/",$node->field_resource_links[$i]['value']);?>
+             <li><a href="<?php print $matches[1] ?>" target="_blank"><?php print $matches[0] ?></a></li><?php
+           }
+         }
+       }
+       ?> 
+     </ul>
+  </div>
+</div> 
+<?php 
 } ?>
 

+ 3 - 2
tripal_organism/theme/tripal_organism/tripal_organism_base.tpl.php

@@ -1,6 +1,7 @@
 <?php
 // the comment field is a database text field so we have to expand it so that
 // it is included in the organism object
+$organism  = $variables['node']->organism;
 $organism = tripal_core_expand_chado_vars($organism,'field','organism.comment');
  
 ?>
@@ -68,7 +69,8 @@ $organism = tripal_core_expand_chado_vars($organism,'field','organism.comment');
   $rows[] = array(
     array(
       'data' => $image . $organism->comment, 
-      'colspan' => 2
+      'colspan' => 2,
+      'style' => 'text-align: justify;',
     ),
   );
   
@@ -81,7 +83,6 @@ $organism = tripal_core_expand_chado_vars($organism,'field','organism.comment');
     'rows' => $rows, 
     'attributes' => array(
       'id' => 'tripal_organism-table-base',
-      'class' => 'tripal-table',
     ), 
     'sticky' => FALSE,
     'caption' => '',

+ 33 - 11
tripal_organism/tripal_organism.module

@@ -152,33 +152,38 @@ function tripal_organism_help ($path, $arg) {
  *
  * @ingroup tripal_organism
  */
-function tripal_organism_theme() {
-  $theme_path = drupal_get_path('module', 'tripal_organism') . '/theme';
+function tripal_organism_theme($existing, $type, $theme, $path) {
   $items = array(
+    'node__chado_organism' => array(
+      'template' => 'node--chado-organism',
+      'render element' => 'node',
+      'base hook' => 'node',
+      'path' => "$path/theme",
+    ),
     'tripal_organism_base' => array(
-      'arguments' => array('node' => NULL),
+      'variables' => array('node' => NULL),
       'template' => 'tripal_organism_base',
-      'path' => "$theme_path/tripal_organism",
+      'path' => "$path/theme/tripal_organism",
     ),
     'tripal_organism_description' => array(
-      'arguments' => array('node' => NULL),
+      'variables' => array('node' => NULL),
       'template' => 'tripal_organism_description',
-      'path' => "$theme_path/tripal_organism",
+      'path' => "$path/theme/tripal_organism",
     ),
     'tripal_organism_image' => array(
-      'arguments' => array('node' => NULL),
+      'variables' => array('node' => NULL),
       'template' => 'tripal_organism_image',
-      'path' => "$theme_path/tripal_organism",
+      'path' => "$path/theme/tripal_organism",
     ),
     'tripal_organism_teaser' => array(
-      'arguments' => array('node' => NULL),
+      'variables' => array('node' => NULL),
       'template' => 'tripal_organism_teaser',
-      'path' => "$theme_path/tripal_organism",
+      'path' => "$path/theme/tripal_organism",
     ),
     'tripal_organism_help' => array(
       'template' => 'tripal_organism_help',
       'arguments' =>  array(NULL),
-      'path' => $theme_path,
+      'path' => $path,
     ),
   );
   return $items;
@@ -438,6 +443,22 @@ function chado_organism_delete($node) {
       "library or feature depends on this organism. It was not removed from chado."));
   }
 }
+/**
+ *
+ * @ingroup tripal_feature
+ */
+function tripal_organism_node_view($node, $view_mode, $langcode) {
+  switch ($node->type) {
+    case 'chado_organism':
+      // Show feature browser and counts
+      if ($view_mode == 'full') {
+        $node->content['tripal_organism_base'] = array(
+          '#value' => theme('tripal_organism_base', array('node' => $node)),
+        );
+      }
+      break;
+  }
+}
 /**
  *
  *
@@ -553,6 +574,7 @@ function chado_organism_load($nodes) {
     // build the organism variable
     $values = array('organism_id' => $organism_id);
     $organism = tripal_core_generate_chado_var('organism', $values);
+    
 
     // add in the description field
     $organism = tripal_core_expand_chado_vars($organism, 'field', 'organism.comment');