Browse Source

Issue #72: Updating API to include 2.1 improvements: 74e4f6f

Stephen Ficklin 7 years ago
parent
commit
49b6547cd4

+ 16 - 16
legacy/tripal_featuremap/theme/templates/tripal_featuremap_publication.tpl.php

@@ -1,65 +1,65 @@
 <?php
 $featuremap = $variables['node']->featuremap;
 
-// expand featuremap to include pubs 
+// expand featuremap to include pubs
 $options = array('return_array' => 1);
 $featuremap = chado_expand_var($featuremap, 'table', 'featuremap_pub', $options);
-$featuremap_pubs = $featuremap->featuremap_pub; 
+$featuremap_pubs = $featuremap->featuremap_pub;
 
 
 if (count($featuremap_pubs) > 0) { ?>
-  <div class="tripal_featuremap_pub-data-block-desc tripal-data-block-desc"></div> <?php 
+  <div class="tripal_featuremap_pub-data-block-desc tripal-data-block-desc"></div> <?php
 
   // 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('Year', 'Publication');
-  
+
   // 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();
-  
+
   foreach ($featuremap_pubs as $featuremap_pub) {
     $pub = $featuremap_pub->pub_id;
     $pub = chado_expand_var($pub, 'field', 'pub.title');
     $citation = $pub->title;  // use the title as the default citation
-    
+
     // get the citation for this pub if it exists
     $values = array(
-      'pub_id' => $pub->pub_id, 
+      'pub_id' => $pub->pub_id,
       'type_id' => array(
         'name' => 'Citation',
       ),
     );
     $options = array('return_array' => 1);
-    $citation_prop = chado_generate_var('pubprop', $values, $options); 
+    $citation_prop = chado_generate_var('pubprop', $values, $options);
     if (count($citation_prop) == 1) {
       $citation_prop = chado_expand_var($citation_prop, 'field', 'pubprop.value');
       $citation = $citation_prop[0]->value;
     }
-    
+
     // if the publication is synced then link to it
     if (property_exists($pub, 'nid')) {
       // replace the title with a link
       $link = l($pub->title, 'node/' . $pub->nid ,array('attributes' => array('target' => '_blank')));
       $patterns = array(
-        '/(\()/', '/(\))/', 
+        '/(\()/', '/(\))/',
         '/(\])/', '/(\[)/',
         '/(\{)/', '/(\})/',
-        '/(\+)/', '/(\.)/', '/(\?)/', 
+        '/(\+)/', '/(\.)/', '/(\?)/',
       );
       $fixed_title = preg_replace($patterns, "\\\\$1", $pub->title);
-      $citation = preg_replace('/' . $fixed_title . '/', $link, $citation);
+      $citation = preg_replace('/' . str_replace('/', ' ', $fixed_title) . '/', $link, $citation);
     }
-    
+
     $rows[] = array(
       $pub->pyear,
       $citation,
     );
   }
-  
+
   // 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:
@@ -76,8 +76,8 @@ if (count($featuremap_pubs) > 0) { ?>
     '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);  
+  print theme_table($table);
 }

+ 1 - 1
tripal_chado/api/tripal_chado.query.api.inc

@@ -1687,7 +1687,7 @@ function chado_pager_query($query, $args, $limit, $element, $count_query = '') {
   $pages = explode(',', $page_arg);
   $page = 0;
   if (count($pages) >= $element) {
-     $page = $pages[$element];
+     $page = key_exists($element, $pages) ? $pages[$element] : 0;
   }
   $offset = $limit * $page;
   $q = $_GET['q'];