tripal.entity.inc 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642
  1. <?php
  2. /**
  3. * Implement hook_entity_info().
  4. *
  5. * See the following for documentaiton of this type setup for Entities:
  6. *
  7. * http://www.bluespark.com/blog/drupal-entities-part-3-programming-hello-drupal-entity
  8. * http://dikini.net/31.08.2010/entities_bundles_fields_and_field_instances
  9. */
  10. function tripal_entity_info() {
  11. $entities = array();
  12. // The TripalVocab entity is meant to house vocabularies. It is these
  13. // vocabs that are used by the TripalTerm entities. The storage backend
  14. // is responsible for setting the values of this entity.
  15. //
  16. $entities['TripalVocab'] = array(
  17. // A human readable label to identify our entity.
  18. 'label' => 'Controlled Vocabulary',
  19. 'plural label' => 'Controlled Vocabularies',
  20. // The entity class and controller class extend the classes provided by the
  21. // Entity API.
  22. 'entity class' => 'TripalVocab',
  23. 'controller class' => 'TripalVocabController',
  24. // Adds Views integration for this entity.
  25. 'views controller class' => 'TripalVocabViewsController',
  26. // The table for this entity defined in hook_schema()
  27. 'base table' => 'tripal_vocab',
  28. // If fieldable == FALSE, we can't attach fields.
  29. 'fieldable' => TRUE,
  30. // entity_keys tells the controller what database fields are used for key
  31. // functions. It is not required if we don't have bundles or revisions.
  32. // Here we do not support a revision, so that entity key is omitted.
  33. 'entity keys' => array (
  34. 'id' => 'id',
  35. ),
  36. // Callback function for access to this entity.
  37. 'access callback' => 'tripal_entity_access',
  38. // FALSE disables caching. Caching functionality is handled by Drupal core.
  39. 'static cache' => TRUE,
  40. // Caching of fields
  41. 'field cache' => TRUE,
  42. // This entity doesn't support bundles.
  43. 'bundles' => array (),
  44. 'view modes' => array (
  45. 'full' => array (
  46. 'label' => t ('Full content'),
  47. 'custom settings' => FALSE
  48. ),
  49. 'teaser' => array (
  50. 'label' => t ('Teaser'),
  51. 'custom settings' => TRUE
  52. ),
  53. ),
  54. );
  55. //
  56. // The TripalTerm entity is meant to house vocabulary terms. It is these
  57. // terms that are used by the TripalEntity entities. The storage backend
  58. // is responsible for setting the values of this entity.
  59. //
  60. $entities['TripalTerm'] = array(
  61. // A human readable label to identify our entity.
  62. 'label' => 'Controlled Vocabulary Term',
  63. 'plural label' => 'Controlled Vocabulary Terms',
  64. // The entity class and controller class extend the classes provided by the
  65. // Entity API.
  66. 'entity class' => 'TripalTerm',
  67. 'controller class' => 'TripalTermController',
  68. // Adds Views integration for this entity.
  69. 'views controller class' => 'TripalTermViewsController',
  70. // The table for this entity defined in hook_schema()
  71. 'base table' => 'tripal_term',
  72. // If fieldable == FALSE, we can't attach fields.
  73. 'fieldable' => TRUE,
  74. // entity_keys tells the controller what database fields are used for key
  75. // functions. It is not required if we don't have bundles or revisions.
  76. // Here we do not support a revision, so that entity key is omitted.
  77. 'entity keys' => array (
  78. 'id' => 'id',
  79. ),
  80. // Callback function for access to this entity.
  81. 'access callback' => 'tripal_entity_access',
  82. // FALSE disables caching. Caching functionality is handled by Drupal core.
  83. 'static cache' => FALSE,
  84. // This entity doesn't support bundles.
  85. 'bundles' => array (),
  86. 'view modes' => array (
  87. 'full' => array (
  88. 'label' => t ('Full content'),
  89. 'custom settings' => FALSE
  90. ),
  91. 'teaser' => array (
  92. 'label' => t ('Teaser'),
  93. 'custom settings' => TRUE
  94. ),
  95. ),
  96. );
  97. //
  98. // The TripalEntity is used for all data. It links data from a storage
  99. // back-end to a TripalTerm entity.
  100. //
  101. $entities['TripalEntity'] = array (
  102. // A human readable label to identify our entity.
  103. 'label' => 'Tripal Content',
  104. 'plural label' => 'Tripal Content',
  105. // The entity class and controller class extend the classes provided by the
  106. // Entity API.
  107. 'entity class' => 'TripalEntity',
  108. 'controller class' => 'TripalEntityController',
  109. // Adds Views integration for this entity.
  110. 'views controller class' => 'TripalEntityViewsController',
  111. // The table for this entity defined in hook_schema()
  112. 'base table' => 'tripal_entity',
  113. // Returns the uri elements of an entity.
  114. 'uri callback' => 'tripal_entity_uri',
  115. // IF fieldable == FALSE, we can't attach fields.
  116. 'fieldable' => TRUE,
  117. // entity_keys tells the controller what database fields are used for key
  118. // functions. It is not required if we don't have bundles or revisions.
  119. // Here we do not support a revision, so that entity key is omitted.
  120. 'entity keys' => array (
  121. 'id' => 'id',
  122. 'bundle' => 'bundle'
  123. ),
  124. 'bundle keys' => array (
  125. 'bundle' => 'name'
  126. ),
  127. // Callback function for access to this entity.
  128. 'access callback' => 'tripal_entity_access',
  129. // FALSE disables caching. Caching functionality is handled by Drupal core.
  130. 'static cache' => TRUE,
  131. // Caching of fields
  132. 'field cache' => TRUE,
  133. // Bundles are added dynamically below.
  134. 'bundles' => array (),
  135. 'label callback' => 'tripal_entity_label',
  136. // The information below is used by the TripalEntityUIController
  137. // (which extends the EntityDefaultUIController). The admin_ui
  138. // key here is mean to appear on the 'Find Content' page of the
  139. // administrative menu.
  140. 'admin ui' => array (
  141. 'path' => 'admin/content/bio_data',
  142. 'controller class' => 'TripalEntityUIController',
  143. 'menu wildcard' => '%TripalEntity',
  144. 'file' => 'includes/TripalEntityUIController.inc',
  145. ),
  146. 'view modes' => array (
  147. 'full' => array (
  148. 'label' => t ('Full content'),
  149. 'custom settings' => FALSE
  150. ),
  151. 'teaser' => array (
  152. 'label' => t ('Teaser'),
  153. 'custom settings' => TRUE
  154. )
  155. )
  156. );
  157. // Search integration
  158. if (module_exists('search')) {
  159. $entities['TripalEntity']['view modes'] += array(
  160. 'search_index' => array(
  161. 'label' => t('Search index'),
  162. 'custom settings' => FALSE,
  163. ),
  164. 'search_result' => array(
  165. 'label' => t('Search result highlighting input'),
  166. 'custom settings' => FALSE,
  167. ),
  168. );
  169. }
  170. // The TripalBundle entity is used manage the bundle types. The 'bundle of'
  171. // attribute links this to the TripalEntity and allows the UI provided
  172. // by the entity module to work for each TripalEntity bundle.
  173. //
  174. $entities['TripalBundle'] = array (
  175. 'label' => 'Tripal Content Type',
  176. 'entity class' => 'TripalBundle',
  177. 'controller class' => 'TripalBundleController',
  178. 'views controller class' => 'TripalBundleViewsController',
  179. 'base table' => 'tripal_bundle',
  180. 'fieldable' => FALSE,
  181. 'bundle of' => 'TripalEntity',
  182. 'exportable' => FALSE,
  183. 'entity keys' => array (
  184. 'id' => 'id',
  185. 'name' => 'name',
  186. 'label' => 'label'
  187. ),
  188. 'access callback' => 'tripal_bundle_access',
  189. 'module' => 'tripal',
  190. // Enable the entity API's admin UI.
  191. 'admin ui' => array (
  192. 'path' => 'admin/structure/bio_data',
  193. 'controller class' => 'TripalBundleUIController',
  194. 'file' => 'includes/TripalBundleUIController.inc',
  195. 'menu wildcard' => '%TripalBundle',
  196. )
  197. );
  198. return $entities;
  199. }
  200. /**
  201. * Implements the Entity URI callback function.
  202. */
  203. function tripal_entity_uri($entity) {
  204. return array(
  205. 'path' => 'bio-data/' . $entity->id,
  206. 'options' => array(),
  207. );
  208. }
  209. /**
  210. * Implements hook_entities_info_alter().
  211. *
  212. * Add in the bundles (entity types) to the TripalEntity entity.
  213. */
  214. function tripal_entity_info_alter(&$entity_info){
  215. if (array_key_exists('TripalEntity', $entity_info)) {
  216. // Dynamically add in the bundles. Bundles are alternative groups of fields
  217. // or configuration associated with an entity type .We want to dynamically
  218. // add the bundles to the entity.
  219. $bundles = db_select('tripal_bundle', 'tb')
  220. ->fields('tb')
  221. ->execute();
  222. while ($bundle = $bundles->fetchObject()) {
  223. $bundle_name = $bundle->name;
  224. $term_id = $bundle->term_id;
  225. $term = entity_load('TripalTerm', array('id' => $term_id));
  226. $term = reset($term);
  227. $label = preg_replace('/_/', ' ', ucwords($term->name));
  228. $entity_info['TripalEntity']['bundles'][$bundle_name] = array (
  229. 'label' => $label,
  230. 'admin' => array (
  231. 'path' => 'admin/structure/bio_data/manage/%TripalBundle',
  232. 'real path' => 'admin/structure/bio_data/manage/' . $bundle_name,
  233. 'bundle argument' => 4,
  234. 'access arguments' => array (
  235. 'manage tripal content types'
  236. )
  237. )
  238. );
  239. }
  240. }
  241. }
  242. /**
  243. * Implements hook_entity_property_info_alter().
  244. *
  245. * For some reason not all our TripalFields end up in the properties field for
  246. * each bundle. This becomes a problem with Search API integration because only
  247. * fields listed in the properties for a bundle are available to be indexed.
  248. * Thus we are altering the property info to add any fields attached to
  249. * TripalEntities which may have been missed.
  250. *
  251. * Furthermore, there are some pecularities with how TripalFields store their
  252. * value that causes the default getter callback difficulties in some edge cases.
  253. * Thus we are overriding that function below.
  254. */
  255. function tripal_entity_property_info_alter(&$info) {
  256. // Sometimes this function is called when there are no Tripal Entities.
  257. // Don't bother to do anything in this case.
  258. if (!isset($info['TripalEntity']['bundles'])) { return TRUE; }
  259. // For each Tripal Content Type, we want to ensure all attached fields
  260. // are added to the bundle properties.
  261. foreach ($info['TripalEntity']['bundles'] as $bundle_name => $bundle) {
  262. // Retrieve information for all fields attached to this Tripal Content Type.
  263. $fields = field_info_instances('TripalEntity', $bundle_name);
  264. foreach ($fields as $field_name => $field_info) {
  265. // If there is a field attached to the current Tripal Content Type that
  266. // is not listed in properties, then add it. We use the full defaults here
  267. // just in case it's not a TripalField or ChadoField.
  268. if (!isset($info['TripalEntity']['bundles'][$bundle_name]['properties'][$field_name])) {
  269. $info['TripalEntity']['bundles'][$bundle_name]['properties'][$field_name] = array(
  270. 'label' => $field_info['label'],
  271. 'type' => 'text',
  272. 'description' => $field_info['description'],
  273. 'getter callback' => 'entity_metadata_field_property_get',
  274. 'setter callback' => 'entity_metadata_field_property_set',
  275. 'access callback' => 'entity_metadata_field_access_callback',
  276. 'query callback' => 'entity_metadata_field_query',
  277. 'translatable' => FALSE,
  278. 'field' => TRUE,
  279. 'required' => $field_info['required'],
  280. );
  281. }
  282. // Now, if it's a TripalField or a ChadoField, then we want to use a custom
  283. // getter callback in order to ensure values are retrieved properly.
  284. // ASSUMPTION: All TripalFields and ChadoFields have an ontology term
  285. // defining them.
  286. if (isset($field_info['settings']['term_accession'])) {
  287. $info['TripalEntity']['bundles'][$bundle_name]['properties'][$field_name]['getter callback'] = 'tripal_field_property_get';
  288. }
  289. }
  290. }
  291. }
  292. /**
  293. * Callback for getting TripalField and ChadoField property values.
  294. *
  295. * This function retrieves the value from a field. Since the value has already
  296. * been set by the Tripal/ChadoField class at this point, it should just be a
  297. * matter of grabbing the value.
  298. *
  299. * @param $entity
  300. * The fully-loaded entity object to be indexed.
  301. * @param $options
  302. * Options that can be ued when retrieving the value.
  303. * @param $field_name
  304. * The machine name of the field we want to retrieve.
  305. * @param $entity_type
  306. * The type of entity (ie: TripalEntity).
  307. *
  308. * @return
  309. * The rendered value of the field specified by $field_name.
  310. */
  311. function tripal_field_property_get($entity, array $options, $field_name, $entity_type, $info) {
  312. // Retrieve information for the field.
  313. $field = field_info_field($field_name);
  314. // Retrieve the language code.
  315. $langcode = isset($options['language']) ? $options['language']->language : LANGUAGE_NONE;
  316. $langcode = entity_metadata_field_get_language($entity_type, $entity, $field, $langcode, TRUE);
  317. $values = array();
  318. if (isset($entity->{$field_name}[$langcode])) {
  319. // For each value of the field... (this will be multiple if cardinality is > 1).
  320. foreach ($entity->{$field_name}[$langcode] as $delta => $data) {
  321. // All Tripal/ChadoFields should have a value key. Only the information
  322. // stored in this value key should be displayed on the page, available
  323. // via web services or indexed for searching. This is there is no value
  324. // key, we will not index anything.
  325. if (!isset($data['value'])) {
  326. return NULL;
  327. }
  328. // Sometimes TripalFields may return multiple pieces of information in the
  329. // value field. In this case, the key should be an ontology term describing
  330. // what each piece of data is and the value should be the data.
  331. if (is_array($data['value'])) {
  332. // Just include all the pieces of information seperated by spaces
  333. // so they are tokenized out later on.
  334. $tmp = $data['value'];
  335. if (isset($tmp['entity'])) { unset($tmp['entity']); }
  336. foreach ($tmp as $k => $v) { $tmp[$k] = strip_tags($v); }
  337. $curr_val = implode(' ', $tmp);
  338. }
  339. else {
  340. // Otherwise, assume the value is a single piece of information
  341. // and add that directly to be indexed.
  342. $curr_val = strip_tags($data['value']);
  343. // Ensure that we have a clean boolean data type.
  344. if ($info['type'] == 'boolean' || $info['type'] == 'list<boolean>') {
  345. $curr_val = (boolean) $curr_val;
  346. }
  347. }
  348. // Only add the current value if it's not empty.
  349. if (!empty(trim($curr_val))) {
  350. $values[$delta] = $curr_val;
  351. }
  352. }
  353. }
  354. // For an empty single-valued field, we have to return NULL.
  355. return $field['cardinality'] == 1 ? ($values ? reset($values) : NULL) : $values;
  356. }
  357. /**
  358. * Checks access permissions for a given entity.
  359. *
  360. * This function is set for TripalEntity access checking in the
  361. * tripal_entity_info() under the 'access callback' element.
  362. *
  363. * @param $op
  364. * The operation. One of: create, view, edit, delete.
  365. * @param $entity
  366. * The entity to check access for.
  367. * @param $account
  368. * The user account.
  369. * @param $entity_type
  370. * The type of entity (will always be TripalEntity).
  371. */
  372. function tripal_entity_access($op, $entity = NULL, $account = NULL, $entity_type = NULL) {
  373. global $user;
  374. $cache = &drupal_static(__FUNCTION__, NULL);
  375. if (!isset($account)) {
  376. $account = $user;
  377. }
  378. if (is_object($entity)) {
  379. $bundle_name = $entity->bundle;
  380. }
  381. elseif (intval($entity) !== 0) {
  382. if (!isset($cache)) {
  383. $cache = cache_get("tripal_entity_access_cache");
  384. if (isset($cache->data)) {
  385. $cache = $cache->data;
  386. }
  387. }
  388. if (empty($cache)) {
  389. $cache = [];
  390. }
  391. if (isset($cache[$entity])) {
  392. $bundle_name = $cache[$entity];
  393. }
  394. else {
  395. $sql = 'SELECT {bundle} FROM tripal_entity WHERE id = :id';
  396. $bundle_name = db_query($sql, [':id' => $entity])->fetchField();
  397. $cache[$entity] = $bundle_name;
  398. cache_set("tripal_entity_access_cache", $cache);
  399. }
  400. }
  401. else {
  402. return FALSE;
  403. }
  404. if (!$entity_type) {
  405. if (is_object($entity)) {
  406. $entity_type = $entity->type;
  407. }
  408. else {
  409. $entity_type = 'TripalEntity';
  410. }
  411. }
  412. // See if other modules want to adust permissions.
  413. $results = module_invoke_all($entity_type . '_access', $entity, $op, $account);
  414. if (in_array(TRUE, $results)) {
  415. return TRUE;
  416. }
  417. switch ($op) {
  418. case 'create':
  419. return user_access('create ' . $bundle_name, $account);
  420. case 'view':
  421. return user_access('view ' . $bundle_name, $account);
  422. case 'edit':
  423. return user_access('edit ' . $bundle_name, $account);
  424. case 'delete':
  425. return user_access('delete ' . $bundle_name, $account);
  426. }
  427. return FALSE;
  428. }
  429. /**
  430. * Implements hook_entity_prepare_view
  431. *
  432. * This function is called before building the content array for an entity. It
  433. * allows us to load any unattached fields if AJAX is turned off.
  434. */
  435. function tripal_entity_prepare_view($entities, $type, $langcode) {
  436. // This is for only TripalEntity content types.
  437. if ($type != 'TripalEntity') {
  438. return;
  439. }
  440. // Iterate through the entities and instancesa and if AJAX loading is turned
  441. // off then we need to load those fields that were not auto attached.
  442. foreach ($entities as $entity_id => &$entity) {
  443. $bundle = tripal_load_bundle_entity(['name' => $entity->bundle]);
  444. $use_ajax = tripal_get_bundle_variable('ajax_field', $bundle->id);
  445. $instances = field_info_instances('TripalEntity', $entity->bundle);
  446. foreach ($instances as $instance) {
  447. $field_name = $instance['field_name'];
  448. $field = field_info_field($field_name);
  449. $auto_attach = array_key_exists('auto_attach', $instance['settings']) ? $instance['settings']['auto_attach'] : TRUE;
  450. $processed = $entity->{$field_name}['#processed'];
  451. // If the field is not ajax loadable and the field is not auto attached
  452. // then we need to add the value.
  453. if (!$use_ajax and $auto_attach == FALSE and $processed == FALSE) {
  454. $temp = tripal_load_entity('TripalEntity', [$entity_id], TRUE, [$field['id']]);
  455. reset($temp);
  456. $entity->{$field_name} = $temp[$entity_id]->{$field_name};
  457. $items = field_get_items('TripalEntity', $entity, $field_name);
  458. }
  459. }
  460. }
  461. }
  462. /**
  463. * Implements hook_entity_view.
  464. *
  465. * Here we want to overwite unattached fields with a div box that will be
  466. * recognized by JavaScript that will then use AJAX to load the field.
  467. * The tripal_ajax_attach_field() function is called by an AJAX call to
  468. * retrieve the field. We also remove empty fields that were auto attached.
  469. */
  470. function tripal_entity_view($entity, $type, $view_mode, $langcode) {
  471. // This is for only TripalEntity content types.
  472. if ($type != 'TripalEntity') {
  473. return;
  474. }
  475. $bundle = tripal_load_bundle_entity(['name' => $entity->bundle]);
  476. $hide_empty = tripal_get_bundle_variable('hide_empty_field', $bundle->id);
  477. $use_ajax = tripal_get_bundle_variable('ajax_field', $bundle->id);
  478. // Iterate through the fields attached to this entity and add IDs to them
  479. // as well as some classe for ajax loading.
  480. foreach (element_children($entity->content) as $child_name) {
  481. // Surround the field with a <div> box for AJAX loading if this
  482. // field is unattached. this will allow JS code to automatically load
  483. // the field.
  484. $instance = field_info_instance('TripalEntity', $child_name, $entity->bundle);
  485. if (!$instance) {
  486. continue;
  487. }
  488. $field = field_info_field($instance['field_name']);
  489. // Check if this is an AJAX loadable field, and if so set the class.
  490. $class = '';
  491. $auto_attach = array_key_exists('auto_attach', $instance['settings']) ? $instance['settings']['auto_attach'] : TRUE;
  492. $processed = $entity->{$child_name}['#processed'];
  493. if ($use_ajax and $auto_attach == FALSE and $processed == FALSE) {
  494. $class = 'class="tripal-entity-unattached"';
  495. }
  496. // Set the prefix and suffix.
  497. if (!array_key_exists('#prefix', $entity->content[$child_name])) {
  498. $entity->content[$child_name]['#prefix'] = '';
  499. }
  500. if (!array_key_exists('#suffix', $entity->content[$child_name])) {
  501. $entity->content[$child_name]['#suffix'] = '';
  502. }
  503. $entity->content[$child_name]['#prefix'] .= '<div id="tripal-entity-' . $entity->id . '--' . $child_name . '" ' . $class . '>';
  504. $entity->content[$child_name]['#suffix'] .= '</div>';
  505. // Remove any auto attached fields if they are empty.
  506. if ($hide_empty and $processed) {
  507. $items = field_get_items('TripalEntity', $entity, $child_name);
  508. if (tripal_field_is_empty($field, $items)) {
  509. unset($entity->content[$child_name]);
  510. }
  511. }
  512. }
  513. //dpm($entity->content);
  514. // Add some settings for AJAX to deal with fields.
  515. $settings = [
  516. 'tripal_display' => [
  517. 'hide_empty' => $hide_empty,
  518. 'use_ajax' => $use_ajax
  519. ]
  520. ];
  521. drupal_add_js($settings, 'setting');
  522. }
  523. /**
  524. * Responds to an AJAX call for populating a field.
  525. *
  526. * @param $id
  527. * The ID of the HTML div box where the field is housed. The ID contains the
  528. * entity ID and field name.
  529. */
  530. function tripal_ajax_attach_field($id) {
  531. $matches = [];
  532. if (preg_match('/^tripal-entity-(\d+)--(.+)$/', $id, $matches)) {
  533. $entity_id = $matches[1];
  534. $field_name = $matches[2];
  535. $field = field_info_field($field_name);
  536. $result = tripal_load_entity('TripalEntity', [$entity_id], FALSE, [$field['id']]);
  537. reset($result);
  538. $entity = $result[$entity_id];
  539. // Get the element render array for this field and turn off the label
  540. // display. It's already on the page. We need to get the display from the
  541. // instance and pass it into the field_view_field. Otherwise it uses the
  542. // instance default display settings. Not sure why it does this. It needs
  543. // more investigation.
  544. $instance = field_info_instance('TripalEntity', $field_name, $entity->bundle);
  545. $items = field_get_items('TripalEntity', $entity, $field_name);
  546. $element = field_view_field('TripalEntity', $entity, $field_name, $instance['display']['default']);
  547. $element['#label_display'] = 'hidden';
  548. $content = drupal_render($element);
  549. return drupal_json_output([
  550. 'id' => $id,
  551. 'content' => $content,
  552. 'is_empty' => tripal_field_is_empty($field, $items),
  553. ]);
  554. }
  555. }