Pārlūkot izejas kodu

Swithced admin messages in templates to use new tripal_set_message function

Stephen Ficklin 11 gadi atpakaļ
vecāks
revīzija
eb4f582268

+ 0 - 27
tripal_core/api/tripal_core.tripal.api.inc

@@ -177,31 +177,4 @@ function tripal_set_message($message, $importance = TRIPAL_INFO, $options = arra
   else {
     drupal_set_message($full_message, 'tripal-site-admin-only');
   }
-
-}
-
-/**
- * Use this function to encapsulate text intended to be
- * visible only by the site administrator. A small tripal logo
- * appears alongside the text.  Do not call this function directly, but
- * rather, use the theme() function:
- *
- *   theme('tripal_admin_message', array('message' => $my_message));
- *
- * @param $message
- *   The message to be displayed to the site administrator
- *
- * @ingroup tripal_api
- */
-function theme_tripal_admin_message($variables) {
-
-  $message = $variables['message'];
-
-  if (!user_access('access administration pages')) {
-    return '';
-  }
-  return "
-    <div class=\"tripal-site-admin-only\">
-      <div class=\"tripal-site-admin-message\">$message</div>
-    </div>";
 }

+ 2 - 1
tripal_core/tripal_core.module

@@ -645,7 +645,8 @@ function tripal_core_node_view_alter(&$build) {
             site's default theme, edit then " .
             l('clear the Drupal cache', 'admin/config/development/performance', array('attributes' => array('target' => '_blank'))) . ".
             Currently, the content above is provided by this template: <br><br>$path",
-            TRIPAL_INFO, array('return_html' => 1)
+            TRIPAL_INFO, 
+            array('return_html' => 1)
           );
         }
 

+ 4 - 5
tripal_feature/includes/tripal_feature.seq_extract.inc

@@ -45,12 +45,11 @@ function tripal_feature_seq_extract_page() {
   // generate the search form
   $output .= '';
   if (user_access('access administration pages')) {
-    $output .= theme('tripal_admin_message', array('message' => "
-        Administrators, the " . l('organism_feature_count', 'admin/tripal/schema/mviews') . " and
-        " . l('analysis_organism', 'admin/tripal/schema/mviews') . " materialized
+    $output .= tripal_set_message("Administrators, the " . 
+        l('organism_feature_count', 'admin/tripal/schema/mviews') . " and " .
+        l('analysis_organism', 'admin/tripal/schema/mviews') . " materialized
         views must be populated before using this form.  Those views should be re-populated
-        when new data is added."
-    ));
+        when new data is added.");
   }
   $output .= "<div id=\"tripal-feature-seq-extract-form-block\">";
   $output .= drupal_get_form('tripal_feature_seq_extract_form');

+ 10 - 8
tripal_feature/theme/tripal_organism/tripal_organism_feature_browser.tpl.php

@@ -71,11 +71,12 @@ if ($enabled) {
     $rows = array();
     
     // let admins know they can customize the terms that appear in the list
-    print theme('tripal_admin_message', array('message' => "
-      Administrators, you can specify the feature types that should appear in 
-      this browser or remove it from the list of resources by navigating to the ". 
-      l("Tripal feature settings page", "admin/tripal/chado/tripal_feature/configuration", array('attributes' => array('target' => '_blank')))
-    ));
+    print tripal_set_message("Administrators, you can specify the feature types ".
+      "that should appear in this browser or remove it from the list of resources ".
+      "by navigating to the ".
+      l("Tripal feature settings page", "admin/tripal/chado/tripal_feature/configuration", array('attributes' => array('target' => '_blank'))),
+      TRIPAL_INFO,
+      array('return_html' => 1));
     
     foreach ($features as $feature){
       $fname =  $feature->name;
@@ -125,7 +126,7 @@ if ($enabled) {
   } 
   else {  ?>
     <p>There are no results.</p><?php
-    print theme('tripal_admin_message', array('message' => "
+    print tripal_set_message("
       Administrators, perform the following to show features in this browser:
       <ul>
         <li>Load features for this organism using the " .
@@ -144,8 +145,9 @@ if ($enabled) {
       that should appear in this browser or remove it from the list of resources by navigating to the " . 
       l("Tripal feature settings page", "admin/tripal/chado/tripal_feature/configuration", array('attributes' => array('target' => '_blank')))  . "
       </p>
-      The feature browser will not appear to site visitors unless features are present. "
-    ));
+      The feature browser will not appear to site visitors unless features are present. ",
+      TRIPAL_INFO,
+      array('return_html' => 1));
   }
 }
 

+ 62 - 32
tripal_feature/theme/tripal_organism/tripal_organism_feature_counts.tpl.php

@@ -14,52 +14,82 @@ if(property_exists($organism, 'feature_counts')) {
 if ($enabled) { 
   if (count($types) > 0){ ?>
     <div class="tripal_organism-data-block-desc tripal-data-block-desc">The following data types are currently present for this organism</div> <?php
+    
     // let admins know they can customize the terms that appear in the list
-    print theme('tripal_admin_message', array('message' => "
-      Administrators, you can customize the types of terms that appear in this report by 
-      navigating to the " . l('Tripal feature configuration page', 'admin/tripal/chado/tripal_feature/configuration') . "
+    print tripal_set_message("
+      Administrators, you can customize the types of terms that appear in this report by navigating to the " . 
+      l('Tripal feature configuration page', 'admin/tripal/chado/tripal_feature/configuration', array('attributes' => array('target' => '_blank'))) . "
       opening the section \"Feature Summary Report\" and adding the list of
-      terms you want to appear in the list. You can rename terms as well.  To disable this report and 
-      remove it from the list of resources, navigate to the " . 
-      l('Tripal feature configuration page', 'admin/tripal/tripal_feature/configuration') . "
-      and hide the \"Feature Summary\". To refresh the data,re-populate the " .
-      l('organism_feature_count', 'admin/tripal/schema/mviews') . " materialized view.")
-    ); ?>
-    <table id="tripal_organism-table-feature_counts" class="tripal_organism-table tripal-table tripal-table-horz">     
-      <tr class="tripal_organism-table-odd-row tripal-table-even-row">
-        <th>Feature Type</th>
-        <th>Count</th>
-      </tr> <?php
-      for ($j = 0; $j < count($types); $j++) {
-        $type = $types[$j];
-        $name = $names[$j];
-        $class = 'tripal_organism-table-odd-row tripal-table-odd-row';
-        if ($i % 2 == 0 ) {
-         $class = 'tripal_organism-table-even-row tripal-table-even-row';
-        }?>
-        <tr class="<?php print $class ?>">
-          <td><span title="<?php print $type->definition ?>"><?php print $name?></span></td>
-          <td><?php print number_format($type->num_features) ?></td>
-        </tr> <?php
-        $i++;  
-      } ?>
-    </table>
+      terms you want to appear in the list. You can rename terms as well. To refresh the data,re-populate the " .
+      l('organism_feature_count', 'admin/tripal/schema/mviews', array('attributes' => array('target' => '_blank'))) . " 
+      materialized view.",
+      TRIPAL_INFO,
+      array('return_html' => 1)
+    ); 
+    
+    // the $headers array is an array of fields to use as the colum headers.
+    // additional documentation can be found here
+    // https://api.drupal.org/api/drupal/includes%21theme.inc/function/theme_table/7
+    $headers = array('Feature Type' ,'Count');
+    
+    // the $rows array contains an array of rows where each row is an array
+    // of values for each column of the table in that row.  Additional documentation
+    // can be found here:
+    // https://api.drupal.org/api/drupal/includes%21theme.inc/function/theme_table/7
+    $rows = array();
+    
+    for ($j = 0; $j < count($types); $j++) {
+      $type = $types[$j];
+      $name = $names[$j];
+      
+      $rows[] = array(
+        "<span title=\"" . $type->definition . "\">$name</span>",
+        number_format($type->num_features),
+      );
+    } 
+    // the $table array contains the headers and rows array as well as other
+    // options for controlling the display of the table.  Additional
+    // documentation can be found here:
+    // https://api.drupal.org/api/drupal/includes%21theme.inc/function/theme_table/7
+    $table = array(
+      'header' => $headers,
+      'rows' => $rows,
+      'attributes' => array(
+        'id' => 'tripal_organism-table-features',
+      ),
+      'sticky' => FALSE,
+      'caption' => '',
+      'colgroups' => array(),
+      'empty' => '',
+    );
+    // once we have our table array structure defined, we call Drupal's theme_table()
+    // function to generate the table.
+    print theme_table($table);
+    
+    ?>
+
     <img class="tripal_cv_chart" id="tripal_feature_cv_chart_<?php print $organism->organism_id?>" src="" border="0"><?php 
    } 
    else { 
     if (user_access('access administration pages')) { ?>
       <div class="tripal_organism-data-block-desc tripal-data-block-desc">The following data types are currently present for this organism</div> <?php 
-      print theme('tripal_admin_message', array('message' => "
+      print tripal_set_message("
          Administrators, to view the feature type report:
          <ul>
-            <li>Populate the " . l('organism_feature_count', 'admin/tripal/schema/mviews') ." materialized view</li>
+            <li>Populate the " . 
+                l('organism_feature_count', 'admin/tripal/schema/mviews', array('attributes' => array('target' => '_blank'))) ." 
+                materialized view</li>
             <li>Refresh this page</li>
          </ul> 
          To disable this report and remove it from the list of resources:
          <ul>
-           <li>Navigate to the " . l('Tripal feature configuration page', 'admin/tripal/chado/tripal_feature/configuration') ." and hide the \"Feature Summary\"</li>
+           <li>Navigate to the " . 
+               l('Tripal feature configuration page', 'admin/tripal/chado/tripal_feature/configuration', array('attributes' => array('target' => '_blank'))) ." 
+               and hide the \"Feature Summary\"</li>
           </ul>
-         </p>")
+         </p>",
+         TRIPAL_INFO,
+         array('return_html' => 1)
       );              
     }
   }

+ 6 - 5
tripal_pub/includes/tripal_pub.pub_search.inc

@@ -171,11 +171,12 @@ function tripal_pub_search_form($form, &$form_state) {
   );
 
   $form['admin-instructions'] = array(
-    '#markup'  =>  theme('tripal_admin_message', array('message' =>
-      t('Administrators, you can select the fields with which a user can use to search,
-         by checking the desired fields on the ' .
-         l('Publication Module Settings Page', 'admin/tripal/chado/tripal_pub/configuration'). ' in
-        the section titled "Search Options".  The selected fields will appear in the dropdowns below.'))),
+    '#markup'  =>  tripal_set_message( 
+      t('Administrators, you can select the fields with which a user can use to search, by checking the desired fields on the ' .
+        l('Publication Module Settings Page', 'admin/tripal/chado/tripal_pub/configuration', array('attributes' => array('target' => '_blank'))) . ' 
+        in the section titled "Search Options".  The selected fields will appear in the dropdowns below.'),
+      TRIPAL_INFO,
+      array('return_html' => 1)),
   );
   $form['instructions'] = array(
     '#markup'  =>  t('To search for publications enter keywords in the text boxes below.