123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121 |
- <?php
- 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(),
- ),
- );
- }
- 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) {
-
-
- $tables = array();
- foreach ($fields as $field_id => $ids) {
-
-
-
-
- $field = field_info_field_by_id($field_id);
- $field_name = $field['field_name'];
- $field_type = $field['type'];
- $field_module = $field['module'];
-
-
-
- tripal_load_include_field_class($field_type);
- if (class_exists($field_type)) {
- $tfield = new $field_type($field);
- $tfield->load($entity);
- }
- }
- }
- }
- function tripal_field_storage_query($query) {
- $filter = array();
- $entity_ids = array();
-
- $select = db_select('tripal_entity', 'TE');
- $select->join('tripal_bundle', 'TB', 'TE.bundle = TB.name');
- $select->fields('TE', array('id'));
- $select->fields('TB', array('name'));
-
- foreach ($query->fieldConditions as $index => $condition) {
- $field = $condition['field'];
-
- if ($field['storage']['type'] != 'tripal_no_storage') {
- continue;
- }
- $value = $condition['value'];
- $operator = $condition['operator'] ? $condition['operator'] : '=';
-
- if ($field['field_name'] == 'content_type') {
- $select->condition('TB.label', $value, $operator);
- }
- }
-
- foreach ($query->order as $index => $sort) {
- $field = $sort['specifier']['field'];
-
- if ($field['storage']['type'] != 'tripal_no_storage') {
- continue;
- }
- $direction = $sort['direction'];
-
- if ($field['field_name'] == 'content_type') {
- $select->orderBy('TB.label', $direction);
- }
- }
-
- $entities = $select->execute();
- $result = array(
- 'TripalEntity' => array(),
- );
- while ($entity = $entities->fetchObject()) {
- $ids = array($entity->id, '0', $entity->name);
- $result['TripalEntity'][$entity->id] = entity_create_stub_entity('TripalEntity', $ids);
- }
- return $result;
- }
|