Browse Source

Fixed some bugs prior to 3.0a release

Stephen Ficklin 9 years ago
parent
commit
09400b0036

+ 18 - 10
tripal/includes/tripal.extensions.inc

@@ -1,10 +1,11 @@
 <?php
 
 function tripal_extensions_form($form, &$form_state = NULL) {
-  // Get the RSS feed XML from the tripa.info website and save it to
+
+  // Get the RSS feed XML from the tripal.info website and save it to
   // a temp file so that we don't have to keep pulling the XML
   // everythime the page is loaded. If the temp file is older than 1 hours
-  // then we'll pull it again. The number of seconds in an hour is 3600
+  // then we'll pull it again. The number of seconds in an hour is 3600.
   $tmp_file = sys_get_temp_dir() . '/tripal_rss_extensions.xml';
   if (!file_exists($tmp_file) or time() - filemtime($tmp_file) > 3600) {
     $content = file_get_contents("http://tripal.info/rss/extensions.xml");
@@ -229,8 +230,13 @@ function tripal_extensions_form($form, &$form_state = NULL) {
   }
 
   // Iterate through all of the extensions and add them to the form.
+  $compatible_extensions = array();
+  if (array_key_exists($tripal_version, $extensions) and
+      array_key_exists($chado_version, $extensions[$tripal_version])) {
+    $compatible_extensions = $extensions[$tripal_version][$chado_version];
+  }
   tripal_extension_form_add_extensions($form, $form_state,
-    $extensions[$tripal_version][$chado_version], $categories, $tripal_version,
+    $compatible_extensions, $categories, $tripal_version,
     $chado_version, $my_tripal_version, $my_chado_version, $type_ids,
     $namespace, $filters);
 
@@ -343,13 +349,15 @@ function tripal_extension_form_add_extensions(&$form, $form_state, $extensions,
       $is_installed = '';
       switch ($type) {
         case 'Bulk Loader Template':
-          $blk_id = db_select('tripal_bulk_loader_template' ,'tblt')
-            ->fields('tblt', array('template_id'))
-            ->condition('name', $extension['title'])
-            ->execute()
-            ->fetchField();
-          if ($blk_id) {
-            $is_installed = '<li>A bulk loader template with this name is already installed.</li>';
+          if (module_exists('tripal_bulk_loader')) {
+            $blk_id = db_select('tripal_bulk_loader_template' ,'tblt')
+              ->fields('tblt', array('template_id'))
+              ->condition('name', $extension['title'])
+              ->execute()
+              ->fetchField();
+            if ($blk_id) {
+              $is_installed = '<li>A bulk loader template with this name is already installed.</li>';
+            }
           }
           break;
         case 'Materialized View':

+ 64 - 9
tripal/tripal.module

@@ -54,12 +54,10 @@ function tripal_init() {
   global $base_url;
 
   // add some variables for all javasript to use for building URLs
-  $theme_dir = drupal_get_path('theme', 'tripal');
   $clean_urls = variable_get('clean_url', 0);
   drupal_add_js(
-    " var baseurl  = '$base_url';
-      var themedir = '$theme_dir';
-      var isClean  =  $clean_urls;",
+    "var baseurl  = '$base_url';" .
+    "var isClean  =  $clean_urls;",
     'inline', 'header');
 
   // make sure the date time settings are the way Tripal will insert them
@@ -91,7 +89,13 @@ function tripal_menu() {
   );
   $items['admin/tripal/tripal_jobs'] = array(
     'title' => 'Jobs',
-    'description' => t('Jobs managed by Tripal'),
+    'description' => t('Provides tools for managing jobs submitted to Tripal.  In some
+        cases, long-running tasks are too slow to complete within a single
+        browser session.  The Tripal jobs system allows long-running tasks
+        to be submitted to a queue that can be executed manually by the
+        site admin or automatically using a module such as the ') .
+        l('Tripal Daemon', 'https://www.drupal.org/project/tripal_daemon', array('attributes' => array('target' => '_blank'))) .
+        ' extension module.',
     'page callback' => 'tripal_jobs_admin_view',
     'access arguments' => array('administer tripal'),
     'type' => MENU_NORMAL_ITEM,
@@ -102,9 +106,11 @@ function tripal_menu() {
 
   $items['admin/tripal/storage'] = array(
     'title' => 'Storage Backend',
-    'description' => t("Tripal is designed so that it can store biological
-        data in any data storage back-end.  Tripal provides by default a
-        module for storing data in Chado.  All available storage backends
+    'description' => t("Tripal is designed to access biological
+        data in any data storage back-end.  A storage back-end must have a
+        module that can be installed that interfaces with Tripal.  By default
+        the base Tripal package provides The Tripal Chado module for storing
+        data in the GMOD Chado database schema.  All available storage backends
         and their administrative tools are found here."),
     'weight' => 8,
     'access arguments' => array('administer tripal'),
@@ -134,8 +140,15 @@ function tripal_menu() {
   // Menu items for facilitating import of extension modules.
   $items['admin/tripal/extension'] = array(
     'title' => 'Extensions',
-    'description' => t('Configuration for Tripal extensions.'),
+    'description' => t('Look for extensions to add new functionality to this
+        site. Tripal can be extended with new functionality developed
+        by other Tripal site developers. These include modules with new or
+        different functionality, bulk loading templates, or materialized
+        views.  Anyone can create new extensions and share those for
+        others to use.  Once shared they will appear in this list.'),
     'access arguments' => array('administer tripal'),
+    'page callback' => 'drupal_get_form',
+    'page arguments' => array('tripal_extensions_form'),
     'type' => MENU_NORMAL_ITEM,
     'file' => 'includes/tripal.extensions.inc',
     'file path' => drupal_get_path('module', 'tripal'),
@@ -722,3 +735,45 @@ function TripalEntity_load($id, $reset = FALSE) {
   $entity = entity_load('TripalEntity', array($id), array(), $reset);
   return reset($entity);
 }
+
+/**
+ *
+ * Implements hook_form_FORM_ID_alter().
+ *
+ * The field_ui_field_edit_form is used for customizing the settings of
+ * a field attached to an entity.
+ */
+function tripal_form_field_ui_field_edit_form_alter(&$form, &$form_state, $form_id) {
+
+  // For entity fields added by Tripal Entities we don't want the
+  // the end-user to change the cardinality and the required fields
+  // such that record can't be saved in Chado.
+
+  // TODO: this shouldn't be hardcoded here.  These settings
+  // should be part of the field and handled by the tripal_entity module.
+  if ($form['#instance']['entity_type'] == 'TripalEntity') {
+    $form['field']['cardinality']['#access'] = FALSE;
+    $form['instance']['required']['#access'] = FALSE;
+  }
+
+  // TODO: don't the the maximum length be larger than the field size.
+}
+
+/**
+ * Implements hook_menu_alter().
+ */
+function tripal_menu_alter(&$items) {
+  // We don't want to allow deletion of fields added by the storage backend.
+  // TODO: this shouldn't be hardcoded here.  These settings
+  // should be part of the field and handled by the tripal_entity module.
+  $items['admin/structure/bio-data/manage/%TripalBundle/fields/%field_ui_menu/delete']['page callback'] = 'tripal_field_no_delete';
+  $items['admin/structure/bio-data/manage/%TripalBundle/fields/%field_ui_menu/delete']['page arguments'] = array();
+}
+
+/**
+ * Simple provides a message indicating that the field cannot be deleted.
+ */
+function tripal_field_no_delete() {
+  drupal_set_message('This field is currently managed by the biological data store and cannot be removed.', 'warning');
+  return '';
+}

+ 45 - 40
tripal_chado/api/modules/tripal_chado.cv.api.inc

@@ -396,28 +396,28 @@ function tripal_insert_cv($name, $definition) {
 }
 
 /**
- *  Add's a controlled vocabulary term to the cvterm table.
+ *  Add's a controlled vocabulary term to Chado.
  *
- *  If the parent CV does not exist then
- *  that too is added to the CV table.  If the cvterm is a relationship term
- *  then the $is_relationship argument should be set.  The function will try
+ *  This function will add a cvterm record (and a dbxref record if appropriate
+ *  values are provided). If the parent vocabulary does not exist then
+ *  that also is added to the cv table.  If the cvterm is a relationship term
+ *  then the 'is_relationship' value should be set.  The function will try
  *  to first find the relationship in the relationship ontology for updating and
- *  if it can't be found will add the relationship to the "local" CV.  All terms
- *  must also have a corresponding database.  This is specified in the term's
- *  ID just before the colon (e.g. GO:003824).  If the database does not exist
- *  in the DB table then it will be added automatically.  The accession (the
- *  value just after the colon in the term's ID) will be added to the dbxref
- *  table.  If the CVterm already exists and $update is set (default) then the
- *  cvterm is updated.  If the CVTerm already exists and $update is not set, then
- *  no changes are made and the CVTerm object is returned.
+ *  if it can not be found it will add the relationship to the "local" CV.  All
+ *  terms must also have a corresponding database.  This is specified in the
+ *  term's ID just before the colon (e.g. GO:003824).  If the database does not
+ *  exist in the DB table then it will be added automatically.  The accession
+ *  (the value just after the colon in the term's ID) will be added to the
+ *  dbxref table.  If the CVterm already exists and $update is set (default)
+ *  then the cvterm is updated.  If the CVTerm already exists and $update is
+ *  not set, then no changes are made and the CVTerm object is returned.
  *
  * @param $term
  *   An associative array with the following keys:
- *    - id: the term accession. must be of the form <DB>:<ACCESSION>, where <DB> is the
- *        name of the database to which the cvterm belongs and the <ACCESSION> is the
- *        term's accession number in the database.
+ *    - id: the term accession. must be of the form <DB>:<ACCESSION>, where
+ *      <DB> is the name of the database to which the cvterm belongs and the
+ *      <ACCESSION> is the term's accession number in the database.
  *    - name: the name of the term. usually meant to be human-readable.
- *    - namespace: the CV name for the term. DEPRECATED. Please use cv_name instead.
  *    - is_obsolete: is present and set to 1 if the term is defunct
  *    - definition: the definition of the term
  *    - cv_name: The CV name to which the term belongs.  If this arugment is
@@ -425,27 +425,45 @@ function tripal_insert_cv($name, $definition) {
  *        CV table with the same name provided in the $term[namespace].  If
  *        this field is provided then it overrides what the value in
  *        $term[namespace]
- *    - is_relationship: If this term is a relationship term then this value should be 1.
- *    - db_name: In some cases the database name will not be part of the $term['id'] and it
- *        needs to be explicitly set.  Use this argument only if the database name
- *        cannot be specififed in the term ID (e.g. <DB>:<ACCESSION>).
+ *    - is_relationship: If this term is a relationship term then this value
+ *        should be 1.
+ *    - db_name: In some cases the database name will not be part of the
+ *        $term['id'] and it needs to be explicitly set.  Use this argument
+ *        only if the database name cannot be specififed in the term ID
+ *        (e.g. <DB>:<ACCESSION>).
+ *    - namespace: the CV name for the term. DEPRECATED. Please use cv_name
+ *       instead.
  * @param $options
  *   An associative array with the following keys:
- *    - update_existing: By default this is TRUE.  If the term exists it is automatically updated.
+ *    - update_existing: By default this is TRUE.  If the term exists it is
+ *      automatically updated.
  *
  * @return
- *   A CVTerm object
+ *   A cvterm object
  *
  * @ingroup tripal_chado_api
  */
 function tripal_insert_cvterm($term, $options = array()) {
 
+  // get the term properties
+  $id = (isset($term['id'])) ? $term['id'] : '';
+  $name = '';
+  $cvname = '';
+  $definition = '';
+  $is_obsolete = 0;
+  $accession = '';
+
   // Set Defaults
   if (isset($term['cv_name'])) {
-    $defaultcv = $term['cv_name'];
+    $cvname = $term['cv_name'];
   }
   else {
-    $defaultcv = 'local';
+    $cvname = 'local';
+  }
+  // Namespace is deprecated but must be supported for backwards
+  // compatability
+  if (array_key_exists('namespace', $term)) {
+    $cvname = $term['namespace'];
   }
 
   if (isset($term['is_relationship'])) {
@@ -469,14 +487,6 @@ function tripal_insert_cvterm($term, $options = array()) {
     $update = 1;
   }
 
-  // get the term properties
-  $id = (isset($term['id'])) ? $term['id'] : '';
-  $name = '';
-  $cvname = '';
-  $definition = '';
-  $is_obsolete = 0;
-  $accession = '';
-
   if (array_key_exists('name', $term)) {
     $name = $term['name'];
   }
@@ -484,12 +494,7 @@ function tripal_insert_cvterm($term, $options = array()) {
     $name = $id;
   }
 
-  if (array_key_exists('namespace', $term)) {
-    $cvname = $term['namespace'];
-  }
-  else {
-    $cvname = $defaultcv;
-  }
+
   if (array_key_exists('definition', $term)) {
     $definition = preg_replace('/^\"(.*)\"/', '\1', $term['definition']);
   }
@@ -540,10 +545,10 @@ function tripal_insert_cvterm($term, $options = array()) {
     return 0;
   }
 
-  // this SQL statement will be used a lot to find a cvterm so just set it
+  // This SQL statement will be used a lot to find a cvterm so just set it
   // here for easy reference below.  Because CV terms can change their names
   // but accessions don't change, the following SQL finds cvterms based on
-  // their accession rather than the name
+  // their accession rather than the name.
   $cvtermsql = "
     SELECT CVT.name, CVT.cvterm_id, CV.cv_id, CV.name as cvname,
       DB.name as dbname, DB.db_id, DBX.accession

+ 5 - 0
tripal_panes/theme/css/tripal_panes.css

@@ -107,3 +107,8 @@
   margin: 2px 0 2px 0 !important;
 }
 
+.tripal-panes-button {
+  height: 15px;
+  width: 15px;
+  vertical-align: text-top;
+}

BIN
tripal_panes/theme/images/close_btn.png


+ 1 - 1
tripal_panes/theme/js/tripal_panes.js

@@ -5,7 +5,7 @@
     
       // Add a close button for each pane
       $('.tripal_pane-fieldset .fieldset-legend').each(function (i) {
-        $(this).append('<div class="tripal_pane-fieldset-close_button">[X]</div>');
+        $(this).append('<div class="tripal_pane-fieldset-close_button"><img src="' + panes_theme_dir + '/images/close_btn.png" id="tripal-panes-close-button" class="tripal-panes-button"></div>');
       });
       
       // Hide the pane when the close button is clicked

+ 2 - 2
tripal_panes/tripal_panes.info

@@ -1,5 +1,5 @@
-name = Tripal Pane
-description = Provides a layout for Tripal.
+name = Tripal Panes
+description = Provides display options for Tripal Entities.  It includes a template that includes a sidebar with links to removable panes.
 core = 7.x
 project = tripal
 package = Tripal

+ 16 - 26
tripal_panes/tripal_panes.module

@@ -1,24 +1,12 @@
 <?php
 
+
 /**
- *
- * Implements hook_form_FORM_ID_alter().
- *
- * The field_ui_field_edit_form is used for customizing the settings of
- * a field attached to an entity.
+ * Implements hook_form_init();
  */
-function tripal_panes_form_field_ui_field_edit_form_alter(&$form, &$form_state, $form_id) {
-  // For entity fields added by Tripal Entities we don't want the
-  // the end-user to change the cardinality and the required fields
-  // such that record can't be saved in Chado.
-  // TODO: this shouldn't be hardcoded here.  These settings
-  // should be part of the field and handled by the tripal_entity module.
-  if (in_array($form['#instance']['entity_type'], $dbs)) {
-    $form['field']['cardinality']['#access'] = FALSE;
-    $form['instance']['required']['#access'] = FALSE;
-  }
-
-  // TODO: don't the the maximum length be larger than the field size.
+function tripal_panes_init() {
+  $theme_dir = url(drupal_get_path('module', 'tripal_panes') . '/theme');
+  drupal_add_js("var panes_theme_dir  = '$theme_dir';", 'inline', 'header');
 }
 /**
  * Implements hook_form_FORM_ID_alter().
@@ -28,6 +16,7 @@ function tripal_panes_form_field_ui_field_edit_form_alter(&$form, &$form_state,
  */
 function tripal_panes_form_field_ui_display_overview_form_alter(&$form, &$form_state, $form_id) {
 
+  drupal_set_message('For the Tripal v3.0a release there are two bugs to keep in mind. Dragging fields outside of a their assigned pane does not yet work. Use the "Region" select box instead. Also, dragging a field may set it\'s format to "hidden" in which case you will want to set it back', 'warning');
   drupal_add_css(drupal_get_path('module','tripal_panes') . '/theme/css/tripal_panes.css');
 
   $entity_type = $form['#entity_type'];
@@ -45,7 +34,7 @@ function tripal_panes_form_field_ui_display_overview_form_alter(&$form, &$form_s
         module. If you would like to use Tripal-style panes for the layout
         of your pages please disable the Display Suite module. If you
         prefer to use the Display Suite module then disable the Tripal
-        Fields Layout (tripal_panes) module.', 'warning');
+        Panes (tripal_panes) module.', 'warning');
   }
 
   // Add a vertical tab fieldset at the bottom of the
@@ -63,15 +52,15 @@ function tripal_panes_form_field_ui_display_overview_form_alter(&$form, &$form_s
   );
 
   // Make sure our default pane are in the database.
-  _tripal_panes_check_default_field_panes($bundle);
+  tripal_panes_check_default_field_panes($bundle);
 
-  // Add a pane
+  // Adds form elments as a vertical tab for adding a pane.
   tripal_panes_form_field_ui_display_overview_form_pane_add($form, $form_state);
 
-  // Arrange panes
+  // Adds form elments as a vertical tab for arranging panes.
   tripal_panes_form_field_ui_display_overview_form_pane_arrange($form, $form_state, $bundle);
 
-  // Configure panes
+  // Adds form elments as a vertical tab for configuring panes.
   tripal_panes_form_field_ui_display_overview_form_pane_configure($form, $form_state, $bundle);
 
   // Now add each pane as a region.
@@ -83,6 +72,7 @@ function tripal_panes_form_field_ui_display_overview_form_alter(&$form, &$form_s
     ->orderBy('label', 'ASC')
     ->execute();
   $pane_options = array();
+
   while ($pane = $panes->fetchObject()) {
     $settings = unserialize($pane->settings);
     $form['fields']['#regions'][$pane->name] = array(
@@ -367,7 +357,7 @@ function tripal_panes_form_field_ui_display_overview_form_pane_configure (&$form
 /**
  * A helper function for checking if the default panes are in the database.
  */
-function _tripal_panes_check_default_field_panes($bundle) {
+function tripal_panes_check_default_field_panes($bundle) {
   // Make sure we have records for our default regions: te_base and te_hidden.
   // First check if the base region is in the database. If not, add it.
   $te_base = db_select('tripal_panes', 'tp')
@@ -659,8 +649,8 @@ function tripal_panes_action_order_panes (&$form, &$form_state) {
 /**
  *  Theme the Arrange panes as a draggable table
  *
- * @param unknown $variables
- * @return unknown
+ * @param $variables
+ * @return
  */
 function theme_tripal_panes_form_arrange_panes ($variables) {
   $element = $variables['element'];
@@ -831,7 +821,7 @@ function tripal_panes_entity_view($entity, $type, $view_mode, $langcode) {
           ->execute()
           ->fetchObject();
 
-        _tripal_panes_check_default_field_panes($bundle);
+        tripal_panes_check_default_field_panes($bundle);
 
         $results = db_select('tripal_panes', 'tp')
           ->fields('tp', array('pane_id','name', 'label', 'settings'))