|
@@ -7,6 +7,9 @@
|
|
|
// Import the full Tripal API into scope.
|
|
|
tripal_import_api();
|
|
|
|
|
|
+require_once "includes/tripal.field_storage.inc";
|
|
|
+require_once "includes/tripal.fields.inc";
|
|
|
+
|
|
|
require_once "includes/TripalVocab.inc";
|
|
|
require_once "includes/TripalVocabController.inc";
|
|
|
require_once "includes/TripalVocabViewsController.inc";
|
|
@@ -824,13 +827,7 @@ function tripal_menu_alter(&$items) {
|
|
|
$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 cannot be removed.', 'warning');
|
|
|
- return '';
|
|
|
-}
|
|
|
+
|
|
|
|
|
|
/**
|
|
|
* Imports all of the Tripal API into scope.
|
|
@@ -856,96 +853,6 @@ function tripal_import_api() {
|
|
|
module_load_include('inc', 'tripal', 'api/tripal.variables.api');
|
|
|
}
|
|
|
|
|
|
-/**
|
|
|
- * Implements hook_field_storage_info().
|
|
|
- *
|
|
|
- * The Tripal module does not provide a storage back-end. But it does provide
|
|
|
- * a placeholder when no storage backend is needed but a field
|
|
|
- * is still desired. The 'tripal_no_storage' backend is used for the
|
|
|
- * content_type field which adds a type field to every entity.
|
|
|
- */
|
|
|
-function tripal_field_storage_info() {
|
|
|
- return array(
|
|
|
- 'tripal_no_storage' => array(
|
|
|
- 'label' => t('Tripal'),
|
|
|
- 'description' => t('The NULL storage is a placeholder for field values
|
|
|
- that are not stored in any storage backend (e.g. entity types).'),
|
|
|
- 'settings' => array(),
|
|
|
- ),
|
|
|
- );
|
|
|
-}
|
|
|
-/**
|
|
|
- * Implements hook_field_info().
|
|
|
- */
|
|
|
-function tripal_field_info() {
|
|
|
- $fields = array(
|
|
|
- 'content_type' => array(
|
|
|
- 'label' => t('Record Type'),
|
|
|
- 'description' => t('The content type.'),
|
|
|
- 'default_widget' => 'tripal_content_type_widget',
|
|
|
- 'default_formatter' => 'tripal_content_type_formatter',
|
|
|
- 'settings' => array(),
|
|
|
- 'storage' => array(
|
|
|
- 'type' => 'tripal_no_storage',
|
|
|
- 'module' => 'tripal',
|
|
|
- 'active' => TRUE
|
|
|
- ),
|
|
|
- ),
|
|
|
- );
|
|
|
- return $fields;
|
|
|
-}
|
|
|
-/**
|
|
|
- * Implements hook_field_widget_info();
|
|
|
- */
|
|
|
-function tripal_field_widget_info() {
|
|
|
- return array(
|
|
|
- 'tripal_content_type_widget' => array(
|
|
|
- 'label' => t('Record Type'),
|
|
|
- 'field types' => array('content_type')
|
|
|
- ),
|
|
|
- );
|
|
|
-}
|
|
|
-
|
|
|
-/**
|
|
|
- * Implements hook_field_formatter_info().
|
|
|
- */
|
|
|
-function tripal_field_formatter_info() {
|
|
|
- return array(
|
|
|
- 'tripal_content_type_formatter' => array(
|
|
|
- 'label' => t('Record Type'),
|
|
|
- 'field types' => array('content_type')
|
|
|
- ),
|
|
|
- );
|
|
|
-}
|
|
|
-/**
|
|
|
- * Implements hook_field_widget_form().
|
|
|
- */
|
|
|
-function tripal_field_widget_form(&$form, &$form_state, $field,
|
|
|
- $instance, $langcode, $items, $delta, $element) {
|
|
|
-
|
|
|
- $widget = $element;
|
|
|
- switch ($instance['widget']['type']) {
|
|
|
- case 'tripal_content_type_widget':
|
|
|
- // There is no widget for this type.
|
|
|
- break;
|
|
|
- }
|
|
|
-}
|
|
|
-/**
|
|
|
- * Implements hook_field_formatter_view().
|
|
|
- */
|
|
|
-function tripal_field_formatter_view($entity_type, $entity, $field,
|
|
|
- $instance, $langcode, $items, $display) {
|
|
|
-
|
|
|
- $element = array();
|
|
|
- switch ($display['type']) {
|
|
|
- case 'tripal_content_type_formatter':
|
|
|
- module_load_include('inc', 'tripal', 'includes/fields/content_type');
|
|
|
- tripal_content_type_formatter($element, $entity_type, $entity, $field,
|
|
|
- $instance, $langcode, $items, $display);
|
|
|
- break;
|
|
|
- }
|
|
|
- return $element;
|
|
|
-}
|
|
|
|
|
|
/**
|
|
|
* Implemenation of hook_add_bundle_fields().
|
|
@@ -983,77 +890,5 @@ function tripal_add_bundle_fields($entity_type, $bundle, $term) {
|
|
|
tripal_add_bundle_field($field_name, $field_info, $entity_type, $bundle_name);
|
|
|
}
|
|
|
|
|
|
-/**
|
|
|
- * Implements hook_field_storage_query().
|
|
|
- *
|
|
|
- * Used by EntityFieldQuery to find the entities having certain entity
|
|
|
- * and field conditions and sort them in the given field order.
|
|
|
- *
|
|
|
- * NOTE: This function needs to exist or errors are triggered but so far it doesn't
|
|
|
- * appear to actually need to do anything...
|
|
|
- */
|
|
|
-function tripal_field_storage_query($query) { }
|
|
|
-
|
|
|
-/**
|
|
|
- * Implements hook_field_storage_load().
|
|
|
- *
|
|
|
- * Responsible for loading the fields from the Chado database and adding
|
|
|
- * their values to the entity.
|
|
|
- */
|
|
|
-function tripal_field_storage_load($entity_type, $entities, $age,
|
|
|
- $fields, $options) {
|
|
|
-
|
|
|
- $load_current = $age == FIELD_LOAD_CURRENT;
|
|
|
- global $language;
|
|
|
- $langcode = $language->language;
|
|
|
-
|
|
|
- foreach ($entities as $id => $entity) {
|
|
|
-
|
|
|
- // Iterate through the entity's fields so we can get the column names
|
|
|
- // that need to be selected from each of the tables represented.
|
|
|
- $tables = array();
|
|
|
- foreach ($fields as $field_id => $ids) {
|
|
|
-
|
|
|
- // By the time this hook runs, the relevant field definitions have been
|
|
|
- // populated and cached in FieldInfo, so calling field_info_field_by_id()
|
|
|
- // on each field individually is more efficient than loading all fields in
|
|
|
- // memory upfront with field_info_field_by_ids().
|
|
|
- $field = field_info_field_by_id($field_id);
|
|
|
- $field_name = $field['field_name'];
|
|
|
- $field_type = $field['type'];
|
|
|
- $field_module = $field['module'];
|
|
|
-
|
|
|
- // Allow the creating module to alter the value if desired. The
|
|
|
- // module should do this if the field has any other form elements
|
|
|
- // that need populationg besides the default value.
|
|
|
- $load_function = $field_module . '_' . $field_type . '_field_load';
|
|
|
- module_load_include('inc', $field_module, 'includes/fields/' . $field_type);
|
|
|
- if (function_exists($load_function)) {
|
|
|
- $load_function($field, $entity);
|
|
|
- }
|
|
|
-
|
|
|
- } // end: foreach ($fields as $field_id => $ids) {
|
|
|
- } // end: foreach ($entities as $id => $entity) {
|
|
|
-}
|
|
|
-
|
|
|
-/**
|
|
|
- * Implements hook_field_is_empty().
|
|
|
- */
|
|
|
-function tripal_field_is_empty($item, $field) {
|
|
|
|
|
|
- // If there is no value field then the field is empty.
|
|
|
- if (!array_key_exists('value', $item)) {
|
|
|
- return TRUE;
|
|
|
- }
|
|
|
|
|
|
- // Iterate through all of the fields and if at least one has a value
|
|
|
- // the field is not empty.
|
|
|
- foreach ($item as $form_field_name => $value) {
|
|
|
- if (isset($value) and $value != NULL and $value != '') {
|
|
|
- return FALSE;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- // Otherwise, the field is empty.
|
|
|
- return TRUE;
|
|
|
-}
|