Browse Source

Removed local__gbrowse_image field. it will go to the trpfancy_fields module

Stephen Ficklin 6 years ago
parent
commit
ccd6b1410d

+ 0 - 174
tripal_chado/includes/TripalFields/local__gbrowse_image/local__gbrowse_image.inc

@@ -1,174 +0,0 @@
-<?php
-
-class local__gbrowse_image extends ChadoField {
-
-
-  // --------------------------------------------------------------------------
-  //                     EDITABLE STATIC CONSTANTS
-  //
-  // The following constants SHOULD be set for each descendent class.  They are
-  // used by the static functions to provide information to Drupal about
-  // the field and it's default widget and formatter.
-  // --------------------------------------------------------------------------
-
-  // The default lable for this field.
-  public static $default_label = 'GBrowse View';
-
-  // The default description for this field.
-  public static $description = 'A GBrowse image of a feature alignment to another sequence.';
-
-  // Provide a list of instance specific settings. These can be access within
-  // the instanceSettingsForm.  When the instanceSettingsForm is submitted
-  // then Drupal with automatically change these settings for the instnace.
-  // It is recommended to put settings at the instance level whenever possible.
-  // If you override this variable in a child class be sure to replicate the
-  // term_name, term_vocab, term_accession and term_fixed keys as these are
-  // required for all TripalFields.
-  public static $default_instance_settings  = array(
-    // The short name for the vocabulary (e.g. shcema, SO, GO, PATO, etc.).
-    'term_vocabulary' => 'local',
-    // The name of the term.
-    'term_name' => 'Gbrowse Image',
-    // The unique ID (i.e. accession) of the term.
-    'term_accession' => 'gbrowse_image',
-    // Set to TRUE if the site admin is allowed to change the term
-    // type. This will create form elements when editing the field instance
-    // to allow the site admin to change the term settings above.
-    'term_fixed' => FALSE,    
-    // The URL for the GBrowse image
-    'gbrowse_url' => '',
-  );
-
-  // The default widget for this field.
-  public static $default_widget = 'local__gbrowse_image_widget';
-
-  // The default formatter for this field.
-  public static $default_formatter = 'local__gbrowse_image_formatter';
-
-
-  /**
-   * @see TripalField::elementInfo()
-   */
-  public function elementInfo() {
-    $field_term = $this->getFieldTermID();
-    return array(
-      $field_term => array(
-        'sortable' => FALSE,
-        'searchable' => FALSE,
-        'type' => 'xs:string',
-        'readonly' => TRUE,
-      ),
-    );
-  }
-
-  /**
-   * @see TripalField::load()
-   */
-  public function load($entity) {
-    $field_name = $this->field['field_name'];
-    $feature = $entity->chado_record;
-    
-    $record = $entity->chado_record;
-    $settings = $this->instance['settings'];
-
-    // Set some defauls for the empty record
-    $entity->{$field_name}['und'][0] = array(
-      'value' => '',
-    );
-    
-    // If we don't have a record then just return
-    if (!$record) {
-      return;
-    }
-    
-    // Replace any tokens in the string.
-    $gbrowse_url = NULL;
-    $g_urls = $settings['gbrowse_url'];   
-    $g_urls = explode("\n", $g_urls);
-    foreach ($g_urls as $g_url) {
-      $matches = [];
-      if (preg_match('/^(.*)\s+(.*)\s+(http.*)$/', $g_url, $matches)) {
-        if ($record->organism_id->genus == $matches[1] and
-            $record->organism_id->species == $matches[2]) {
-          $gbrowse_url = $matches[3];
-        }
-      }
-      elseif (preg_match('/^http.*$/', $g_url)) {
-        $gbrowse_url = $g_url;
-      }
-    }
-    if (!$gbrowse_url) {
-      return;
-    }
-    $bundle = tripal_load_bundle_entity(['name' => $this->instance['bundle']]);
-    $gbrowse_url = tripal_replace_entity_tokens($gbrowse_url, $entity, $bundle);
-        
-    // Use the term associated to the db.url table of Chado.
-    $url_term = chado_get_semweb_term('db', 'url');
-    
-    // Add the URL to the values
-    $entity->{$field_name}['und'][0]['value'] = [
-      $url_term => $gbrowse_url
-    ];
-  }
-  
-  /**
-   * @see TripalField::globalSettingsForm()
-   */
-  public function instanceSettingsForm() {
-    $element = parent::instanceSettingsForm();
-    
-    $settings = $this->instance['settings'];
-    
-    $element['gbrowse_url'] = array(
-      '#type' => 'textarea',
-      '#title' => 'GBrowse URL',
-      '#description' => t('Please enter the URL for generating feature ' . 
-        'images on the remote GBrowse site. You may use tokens to substitute ' .
-        'field values from this content type. Open the "Available Tokens" fieldset below. ' .
-        'For example, to show a view of a gene from the rice genome GBrowse the ' .
-        'following URL with tokens can be used: ' . 
-        'http://rice.plantbiology.msu.edu/cgi-bin/gbrowse_img/rice/?name=[schema__name];type=Landmarks%3Aregion+Genes+Rice_Annotation' . 
-        '. If you need to specify different GBrowse URLs for different ' .
-        'species, put the genus, species and URL all on one line with each separated ' . 
-        'by a space. For example: ' . 
-        '"Oryza sativa http://rice.plantbiology.msu.edu/cgi-bin/gbrowse_img/rice/?name=[schema__name];type=Landmarks%3Aregion+Genes+Rice_Annotation"'),
-      '#default_value' => $settings['gbrowse_url'],
-    );
-    
-    $element['tokens'] = array(
-      '#type' => 'fieldset',
-      '#collapsed' => TRUE,
-      '#collapsible' => TRUE,
-      '#title' => 'Available Tokens'
-    );
-    $headers = array('Token', 'Description');
-    $rows = array();
-    
-    // Get the bundle tokens
-    $bundle = tripal_load_bundle_entity(['name' => $this->instance['bundle']]);
-    $tokens = tripal_get_entity_tokens($bundle);
-    foreach ($tokens as $token) {
-      $rows[] = array(
-        $token['token'],
-        $token['description'],
-      );
-    }
-    
-    $table_vars = array(
-      'header'     => $headers,
-      'rows'       => $rows,
-      'attributes' => array(),
-      'sticky'     => FALSE,
-      'caption'    => '',
-      'colgroups'  => array(),
-      'empty'      => 'There are no tokens',
-    );
-    $element['tokens']['list'] = array(
-      '#type' => 'item',
-      '#markup' => theme_table($table_vars),
-    );
-    
-    return $element;
-  }
-}

+ 0 - 28
tripal_chado/includes/TripalFields/local__gbrowse_image/local__gbrowse_image_formatter.inc

@@ -1,28 +0,0 @@
-<?php
-
-class local__gbrowse_image_formatter extends ChadoFieldFormatter {
-  // The default lable for this field.
-  public static $default_label = 'GBrowse View';
-
-  // The list of field types for which this formatter is appropriate.
-  public static $field_types = array('local__gbrowse_image');
-
-  /**
-   * @see TripalFieldFormatter::view()
-   */
-  public function view(&$element, $entity_type, $entity, $langcode, $items, $display) {
-    $content = '';
-    if (count($items) > 0) {
-      $url_term = chado_get_semweb_term('db', 'url');
-      if (is_array($items[0]['value']) and array_key_exists($url_term, $items[0]['value'])) {
-        $content = '<img src="' . $items[0]['value'][$url_term] . '" class="tripal-local--gbrowse-image"/>';
-      
-        $element[0] = array(
-          // We create a render array to produce the desired markup,
-          '#type' => 'markup',
-          '#markup' => $content,
-        );
-      }
-    }
-  }
-}

+ 0 - 29
tripal_chado/includes/TripalFields/local__gbrowse_image/local__gbrowse_image_widget.inc

@@ -1,29 +0,0 @@
-<?php
-
-class local__gbrowse_image_widget extends ChadoFieldWidget {
-  // The default lable for this field.
-  public static $default_label = 'GBrowse View';
-
-  // The list of field types for which this formatter is appropriate.
-  public static $field_types = array('local__gbrowse_image');
-
-  /**
-   *
-   * @see TripalFieldWidget::form()
-   */
-  public function form(&$widget, &$form, &$form_state, $langcode, $items, $delta, $element) {
-    parent::form($widget, $form, $form_state, $langcode, $items, $delta, $element);
-
-    // TODO: add a widget...
-  }
-
-
-  /**
-   *
-   * @see TripalFieldWidget::submit()
-   */
-  public function submit($form, &$form_state, $entity_type, $entity, $langcode, $delta) {
-    $field_name = $this->field['field_name'];
-
-  }
-}

+ 0 - 49
tripal_chado/includes/tripal_chado.fields.inc

@@ -411,20 +411,6 @@ function tripal_chado_bundle_fields_info_custom(&$info, $details, $entity_type,
       ),
     );
   }
-  
-  if ($table_name == 'feature') {
-    $field_name = 'local__gbrowse_image';
-    $field_type = 'local__gbrowse_image';
-    $info[$field_name] = array(
-      'field_name' => $field_name,
-      'type' => $field_type,
-      'cardinality' => 1,
-      'locked' => FALSE,
-      'storage' => array(
-        'type' => 'field_chado_storage',
-      ),
-    );
-  }
 
   // GENE TRANSCRIPTS
   $rel_table = $table_name . '_relationship';
@@ -1739,41 +1725,6 @@ function tripal_chado_bundle_instances_info_custom(&$info, $entity_type, $bundle
      ),
     );
   }
-  
-  if ($table_name == 'feature') {
-    $field_name = 'local__gbrowse_image';
-    $info[$field_name] = array(
-      'field_name' => $field_name,
-      'entity_type' => $entity_type,
-      'bundle' => $bundle->name,
-      'label' => 'GBrowse image',
-      'description' => 'A GBrowse image of a feature alignment.',
-      'required' => FALSE,
-      'settings' => array(
-        'auto_attach' => FALSE,
-        'chado_table' => '',
-        'chado_column' => '',
-        'base_table' => 'feature',
-        'term_vocabulary' => 'local',
-        'term_name' => 'Gbrowse Image',
-        'term_accession' => 'gbrowse_image',
-        'gbrowse_url' => '',
-      ),
-      'widget' => array(
-        'type' => 'local__gbrowse_image_widget',
-        'settings' => array(
-          'display_label' => 1,
-        ),
-      ),
-      'display' => array(
-        'default' => array(
-          'label' => 'above',
-          'type' => 'local__gbrowse_image_formatter',
-          'settings' => array(),
-        ),
-      ),
-    );
-  }
 
   // GENE TRANSCRIPTS
   $rel_table = $table_name . '_relationship';

+ 0 - 13
tripal_chado/includes/tripal_chado.semweb.inc

@@ -1658,19 +1658,6 @@ function tripal_chado_populate_vocab_LOCAL() {
     'cv_name' => 'local',
   ));
   chado_associate_semweb_term('arraydesign', 'num_sub_rows', $term);
-  
-  $term = chado_insert_cvterm(array(
-    'id' => 'local:gbrowse_image',
-    'name' => 'Gbrowse Image',
-    'definition' => 'A GBrowse image of a feature alignment to another sequence',
-    'cv_name' => 'local',
-  ));
-  $term = chado_insert_cvterm(array(
-    'id' => 'local:jbrowse_image',
-    'name' => 'Jbrowse Image',
-    'definition' => 'A JBrowse image of a feature aligned to another sequence.',
-    'cv_name' => 'local',
-  ));
 }
 /**
  * Adds the Systems Biology Ontology database and terms.

+ 0 - 4
tripal_chado/theme/css/tripal_chado.css

@@ -62,8 +62,4 @@
 
 .properties-field-list {
   margin: 0px;
-}
-
-.tripal-local--gbrowse-image {
-	width: 100%;
 }

+ 0 - 12
tripal_chado/tripal_chado.install

@@ -1561,18 +1561,6 @@ function tripal_chado_update_7327() {
       'cv_name' => 'EDAM',
       'definition' => 'Visualise, format or render a molecular sequence or sequences such as a sequence alignment, possibly with sequence features or properties shown.',
     ));
-    $term = chado_insert_cvterm(array(
-      'id' => 'local:gbrowse_image',
-      'name' => 'Gbrowse Image',
-      'definition' => 'A GBrowse image of a feature alignment to another sequence',
-      'cv_name' => 'local',
-    ));
-    $term = chado_insert_cvterm(array(
-      'id' => 'local:jbrowse_image',
-      'name' => 'Jbrowse Image',
-      'definition' => 'A JBrowse image of a feature aligned to another sequence.',
-      'cv_name' => 'local',
-    ));
   }
   catch (\PDOException $e) {
     $error = $e->getMessage();