Browse Source

Fixed bugs in pub module

Stephen Ficklin 9 years ago
parent
commit
1e3a76b5e5

+ 2 - 0
tripal_core/tripal_core.drush.inc

@@ -307,6 +307,7 @@ function drush_tripal_core_trp_run_jobs() {
   if ($user and is_numeric($user)) {
   if ($user and is_numeric($user)) {
   }
   }
   elseif ($user) {
   elseif ($user) {
+    print "\nNOTE: Use of the --user argument is deprecated as it conflicts with the --user argument of Drush 7.x. Please now use --username instead.\n\n";
     $username = $user;
     $username = $user;
   }
   }
   if ($uname) {
   if ($uname) {
@@ -377,6 +378,7 @@ function drush_tripal_core_trp_rerun_job() {
   if ($user and is_numeric($user)) {
   if ($user and is_numeric($user)) {
   }
   }
   elseif ($user) {
   elseif ($user) {
+    print "\nNOTE: Use of the --user argument is deprecated as it conflicts with the --user argument of Drush 7.x. Please now use --username instead.\n\n";
     $username = $user;
     $username = $user;
   }
   }
   if ($uname) {
   if ($uname) {

+ 4 - 4
tripal_pub/includes/tripal_pub.chado_node.inc

@@ -371,7 +371,7 @@ function chado_pub_validate($node, $form, &$form_state) {
     return;
     return;
   }
   }
 
 
-  // get the media name looking at the properties
+  // Get the media name looking at the properties
   $series_name = '';
   $series_name = '';
   $properties = chado_retrieve_node_form_properties($node);
   $properties = chado_retrieve_node_form_properties($node);
   foreach ($properties as $key => $prop_values) {
   foreach ($properties as $key => $prop_values) {
@@ -380,13 +380,13 @@ function chado_pub_validate($node, $form, &$form_state) {
     if ($prop_type[0]->name == 'Conference Name' or
     if ($prop_type[0]->name == 'Conference Name' or
         $prop_type[0]->name == 'Journal Name' or
         $prop_type[0]->name == 'Journal Name' or
         $prop_type[0]->name == 'Series Name') {
         $prop_type[0]->name == 'Series Name') {
-      $series_name = $prop_values[0];
+      $series_name = array_values($prop_values)[0];
     }
     }
     if ($prop_type[0]->name == 'Citation') {
     if ($prop_type[0]->name == 'Citation') {
-      $uniquename = $prop_values[0];
+      $uniquename = array_values($prop_values)[0];
     }
     }
     if (count($prop_values) == 1) {
     if (count($prop_values) == 1) {
-      $pub[$prop_type[0]->name] = $prop_values[0];
+      $pub[$prop_type[0]->name] = array_values($prop_values)[0];
     }
     }
     else {
     else {
       $pub[$prop_type[0]->name] = $prop_values;
       $pub[$prop_type[0]->name] = $prop_values;

+ 153 - 0
tripal_pub/theme/templates/pub_types/default.inc

@@ -0,0 +1,153 @@
+<?php
+// ========================================================================
+// TO CUSTOMIZE A SPECIFIC PUBLICATION TYPE, CUT-AND-PASTE THE CODE
+// BELOW INTO A NEW FILE WITH THE SAME NAME AS THE TYPE (SEE INSTRUCTIONS
+// ABOVE), AND EDIT.
+// ========================================================================
+
+// 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
+// This table for the analysis has a vertical header (down the first column)
+// so we do not provide headers here, but specify them in the $rows array below.
+$headers = array();
+
+// 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();
+
+// Title row
+$title = '';
+if ($url) {
+  $title =  l(htmlspecialchars($pub->title), $url, array('attributes' => array('target' => '_blank')));
+}
+elseif ($dbxref and $dbxref->db_id->urlprefix) {
+  $title =  l(htmlspecialchars($pub->title), $dbxref->db_id->urlprefix . $dbxref->accession, array('attributes' => array('target' => '_blank')));
+}
+else {
+  $title =  htmlspecialchars($pub->title);
+}
+$rows[] = array(
+  array(
+    'data' => 'Title',
+    'header' => TRUE,
+    'width' => '20%',
+  ),
+  $title,
+);
+// Authors row
+$rows[] = array(
+  array(
+    'data' => 'Authors',
+    'header' => TRUE
+  ),
+  $authors_list,
+);
+// Type row
+$rows[] = array(
+  array(
+    'data' => 'Type',
+    'header' => TRUE
+  ),
+  $pub->type_id->name,
+);
+// Media Title
+$rows[] = array(
+  array(
+    'data' => 'Media Title',
+    'header' => TRUE,
+    'nowrap' => 'nowrap'
+  ),
+  $pub->series_name,
+);
+// Volume
+$rows[] = array(
+  array(
+    'data' => 'Volume',
+    'header' => TRUE
+  ),
+  $pub->volume ? $pub->volume : 'N/A',
+);
+// Issue
+$rows[] = array(
+  array(
+    'data' => 'Issue',
+    'header' => TRUE
+  ),
+  $pub->issue ? $pub->issue : 'N/A'
+);
+// Year
+$rows[] = array(
+  array(
+    'data' => 'Year',
+    'header' => TRUE
+  ),
+  $pub->pyear
+);
+// Pages
+$rows[] = array(
+  array(
+    'data' => 'Page(s)',
+    'header' => TRUE
+  ),
+  $pub->pages ? $pub->pages : 'N/A'
+);
+// Citation row
+$rows[] = array(
+  array(
+    'data' => 'Citation',
+    'header' => TRUE
+  ),
+  htmlspecialchars($citation->value)
+);
+// allow site admins to see the pub ID
+if (user_access('view ids')) {
+  // Pub ID
+  $rows[] = array(
+    array(
+      'data' => 'Pub ID',
+      'header' => TRUE,
+      'class' => 'tripal-site-admin-only-table-row',
+    ),
+    array(
+      'data' => $pub->pub_id,
+      'class' => 'tripal-site-admin-only-table-row',
+    ),
+  );
+}
+// Is Obsolete Row
+if($pub->is_obsolete == TRUE){
+  $rows[] = array(
+    array(
+      'data' => '<div class="tripal_pub-obsolete">This publication is obsolete</div>',
+      'colspan' => 2
+    ),
+  );
+}
+// 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_pub-table-base',
+    'class' => 'tripal-data-table'
+  ),
+  '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);
+
+if ($abstract_text) { ?>
+  <p><b>Abstract</b></p>
+  <div style="text-align: justify"><?php print $abstract_text; ?></div> <?php
+}

+ 27 - 187
tripal_pub/theme/templates/tripal_pub_base.tpl.php

@@ -1,15 +1,10 @@
 <?php
 <?php
-/*
- * Note, the table generated by this template that lists the publication
- * details is generic. It can be customized to look different for different
- * publication types.  To create a custom template for a given type, create a 
- * new file in the pub_types directory.  Name the file using the name of the
- * type. The name must be all lower-case and spaces should be replaced with
- * and underscore symbol.  For example, to create a custom table for the
- * "Conference Proceedings", create the file conference_proceedings.inc inside
- * of the pub_types folder.  Cut and paste the code below that generates the table
- * structure into the new file.  Then edit to your liking.
- * 
+/**
+ * The page generated by this template depends on the publication type.  Each
+ * publication type may appear differently. You can find the publication
+ * templates for each type in the pub_types folder. The files have the same
+ * name as the type.  If a publication type is not found in that file then the
+ * generic.inc template is used for display of the publication.
  */
  */
 
 
 $pub = $variables['node']->pub;
 $pub = $variables['node']->pub;
@@ -20,22 +15,22 @@ $pub = chado_expand_var($pub, 'field', 'pub.volumetitle');
 
 
 // get the citation
 // get the citation
 $values = array(
 $values = array(
-  'pub_id' => $pub->pub_id, 
+  'pub_id' => $pub->pub_id,
   'type_id' => array(
   'type_id' => array(
     'name' => 'Citation',
     'name' => 'Citation',
   ),
   ),
 );
 );
-$citation = chado_generate_var('pubprop', $values); 
+$citation = chado_generate_var('pubprop', $values);
 $citation = chado_expand_var($citation, 'field', 'pubprop.value');
 $citation = chado_expand_var($citation, 'field', 'pubprop.value');
 
 
 // get the abstract
 // get the abstract
 $values = array(
 $values = array(
-  'pub_id' => $pub->pub_id, 
+  'pub_id' => $pub->pub_id,
   'type_id' => array(
   'type_id' => array(
     'name' => 'Abstract',
     'name' => 'Abstract',
   ),
   ),
 );
 );
-$abstract = chado_generate_var('pubprop', $values); 
+$abstract = chado_generate_var('pubprop', $values);
 $abstract = chado_expand_var($abstract, 'field', 'pubprop.value');
 $abstract = chado_expand_var($abstract, 'field', 'pubprop.value');
 $abstract_text = '';
 $abstract_text = '';
 if ($abstract) {
 if ($abstract) {
@@ -44,23 +39,23 @@ if ($abstract) {
 
 
 // get the author list
 // get the author list
 $values = array(
 $values = array(
-  'pub_id' => $pub->pub_id, 
+  'pub_id' => $pub->pub_id,
   'type_id' => array(
   'type_id' => array(
     'name' => 'Authors',
     'name' => 'Authors',
   ),
   ),
 );
 );
-$authors = chado_generate_var('pubprop', $values); 
+$authors = chado_generate_var('pubprop', $values);
 $authors = chado_expand_var($authors, 'field', 'pubprop.value');
 $authors = chado_expand_var($authors, 'field', 'pubprop.value');
 $authors_list = 'N/A';
 $authors_list = 'N/A';
 if ($authors) {
 if ($authors) {
   $authors_list = $authors->value;
   $authors_list = $authors->value;
-} 
+}
 
 
 // get the first database cross-reference with a url
 // get the first database cross-reference with a url
 $options = array('return_array' => 1);
 $options = array('return_array' => 1);
 $pub = chado_expand_var($pub, 'table', 'pub_dbxref', $options);
 $pub = chado_expand_var($pub, 'table', 'pub_dbxref', $options);
 $dbxref = NULL;
 $dbxref = NULL;
-if ($pub->pub_dbxref) { 
+if ($pub->pub_dbxref) {
   foreach ($pub->pub_dbxref as $index => $pub_dbxref) {
   foreach ($pub->pub_dbxref as $index => $pub_dbxref) {
     if ($pub_dbxref->dbxref_id->db_id->urlprefix) {
     if ($pub_dbxref->dbxref_id->db_id->urlprefix) {
       $dbxref = $pub_dbxref->dbxref_id;
       $dbxref = $pub_dbxref->dbxref_id;
@@ -71,184 +66,29 @@ if ($pub->pub_dbxref) {
 // get the URL
 // get the URL
 // get the author list
 // get the author list
 $values = array(
 $values = array(
-  'pub_id' => $pub->pub_id, 
+  'pub_id' => $pub->pub_id,
   'type_id' => array(
   'type_id' => array(
     'name' => 'URL',
     'name' => 'URL',
   ),
   ),
 );
 );
 $options = array('return_array' => 1);
 $options = array('return_array' => 1);
-$urls = chado_generate_var('pubprop', $values, $options); 
+$urls = chado_generate_var('pubprop', $values, $options);
 $urls = chado_expand_var($urls, 'field', 'pubprop.value');
 $urls = chado_expand_var($urls, 'field', 'pubprop.value');
 $url = '';
 $url = '';
 if (count($urls) > 0) {
 if (count($urls) > 0) {
-  $url = $urls[0]->value; 
-}?>
-
-<div class="tripal_pub-data-block-desc tripal-data-block-desc"></div> <?php 
+  $url = $urls[0]->value;
+} ?>
+<div class="tripal_pub-data-block-desc tripal-data-block-desc"></div> <?php
 
 
-// to simplify the template, we have a subdirectory named 'pub_types'.  This directory
-// should have include files each specific to a publication type. If the type is 
+// To simplify the template, we have a subdirectory named 'pub_types'.  This directory
+// should have include files each specific to a publication type. If the type is
 // not present then the base template will be used, otherwise the template in the
 // not present then the base template will be used, otherwise the template in the
 // include file is used.
 // include file is used.
 $inc_name = strtolower(preg_replace('/ /', '_', $pub->type_id->name)) . '.inc';
 $inc_name = strtolower(preg_replace('/ /', '_', $pub->type_id->name)) . '.inc';
-$inc_path = drupal_realpath(drupal_get_path('module', 'tripal_pub') . "/theme/tripal_pub/pub_types/$inc_name");
+$inc_path = DRUPAL_ROOT . '/' . drupal_get_path('module', 'tripal_pub') . "/theme/templates/pub_types/$inc_name";
 if (file_exists($inc_path)) {
 if (file_exists($inc_path)) {
-  require_once "pub_types/$inc_name";  
-} 
-else { 
-  // ========================================================================
-  // TO CUSTOMIZE A SPECIFIC PUBLICATION TYPE, CUT-AND-PASTE THE CODE
-  // BELOW INTO A NEW FILE WITH THE SAME NAME AS THE TYPE (SEE INSTRUCTIONS
-  // ABOVE), AND EDIT.
-  // ========================================================================
-  
-  // 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
-  // This table for the analysis has a vertical header (down the first column)
-  // so we do not provide headers here, but specify them in the $rows array below.
-  $headers = array();
-  
-  // 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();
-
-  // Title row
-  $title = '';
-  if ($url) {
-    $title =  l(htmlspecialchars($pub->title), $url, array('attributes' => array('target' => '_blank')));
-  }
-  elseif ($dbxref and $dbxref->db_id->urlprefix) {
-    $title =  l(htmlspecialchars($pub->title), $dbxref->db_id->urlprefix . $dbxref->accession, array('attributes' => array('target' => '_blank')));
-  }
-  else {
-    $title =  htmlspecialchars($pub->title);
-  }
-  $rows[] = array(
-    array(
-      'data' => 'Title',
-      'header' => TRUE,
-      'width' => '20%',
-    ),
-    $title,
-  );
-  // Authors row
-  $rows[] = array(
-    array(
-      'data' => 'Authors',
-      'header' => TRUE
-    ),
-    $authors_list,
-  );
-  // Type row
-  $rows[] = array(
-    array(
-      'data' => 'Type',
-      'header' => TRUE
-    ),
-    $pub->type_id->name,
-  );
-  // Media Title
-  $rows[] = array(
-    array(
-      'data' => 'Media Title',
-      'header' => TRUE,
-      'nowrap' => 'nowrap'
-    ),
-    $pub->series_name,
-  );
-  // Volume
-  $rows[] = array(
-    array(
-      'data' => 'Volume',
-      'header' => TRUE
-    ),
-    $pub->volume ? $pub->volume : 'N/A',
-  );
-  // Issue
-  $rows[] = array(
-    array(
-      'data' => 'Issue',
-      'header' => TRUE
-    ),
-    $pub->issue ? $pub->issue : 'N/A'
-  );
-  // Year
-  $rows[] = array(
-    array(
-      'data' => 'Year',
-      'header' => TRUE
-    ),
-    $pub->pyear
-  );
-  // Pages
-  $rows[] = array(
-    array(
-      'data' => 'Page(s)',
-      'header' => TRUE
-    ),
-    $pub->pages ? $pub->pages : 'N/A'
-  );
-  // Citation row
-  $rows[] = array(
-    array(
-      'data' => 'Citation',
-      'header' => TRUE
-    ),
-    htmlspecialchars($citation->value)
-  );
-  // allow site admins to see the pub ID
-  if (user_access('view ids')) {
-    // Pub ID
-    $rows[] = array(
-      array(
-        'data' => 'Pub ID',
-        'header' => TRUE,
-        'class' => 'tripal-site-admin-only-table-row',
-      ),
-      array(
-        'data' => $pub->pub_id,
-        'class' => 'tripal-site-admin-only-table-row',
-      ),
-    );
-  }
-  // Is Obsolete Row
-  if($pub->is_obsolete == TRUE){
-    $rows[] = array(
-      array(
-        'data' => '<div class="tripal_pub-obsolete">This publication is obsolete</div>',
-        'colspan' => 2
-      ),
-    );
-  }
-  // 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_pub-table-base',
-      'class' => 'tripal-data-table'
-    ),
-    '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);
-  if ($abstract_text) { ?>
-    <p><b>Abstract</b></p>
-    <div style="text-align: justify"><?php print $abstract_text; ?></div> <?php 
-  } 
-  
-  // ========================================================================
-  // END OF CUT-AND-PASTE REGION
-  // ========================================================================
-} 
+  require_once "pub_types/$inc_name";
+}
+else {
+  require_once "pub_types/default.inc";
+}