|
@@ -1,5 +1,143 @@
|
|
<?php
|
|
<?php
|
|
|
|
+/**
|
|
|
|
+ * @file
|
|
|
|
+ * Provides an application programming interface (API) for working with
|
|
|
|
+ * TripalEntity content types (bundles) and their entities.
|
|
|
|
+ */
|
|
|
|
+
|
|
|
|
+/**
|
|
|
|
+ * @defgroup tripal_entities_api Tripal Entities
|
|
|
|
+ * @ingroup tripal_api
|
|
|
|
+ * @{
|
|
|
|
+ * Provides an application programming interface (API) for working with
|
|
|
|
+ * TripalEntity content types (bundles) and their entities.
|
|
|
|
+ * @}
|
|
|
|
+ *
|
|
|
|
+ */
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+/**
|
|
|
|
+ * Allows a module to make changes to an entity object after creation.
|
|
|
|
+ *
|
|
|
|
+ * This function is added by Tripal to allow datastore backends to add
|
|
|
|
+ * addition properties to the entity that they themselves will use later.
|
|
|
|
+ *
|
|
|
|
+ * @param $entity
|
|
|
|
+ * @param $entity_type
|
|
|
|
+ *
|
|
|
|
+ * @ingroup tripal_entities_api
|
|
|
|
+ */
|
|
|
|
+function hook_entity_create(&$entity, $entity_type) {
|
|
|
|
+
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+/**
|
|
|
|
+ * Allows a module to perform tasks after a TripalBundle object is created.
|
|
|
|
+ *
|
|
|
|
+ * @param $bundle
|
|
|
|
+ * The newly created TripalBundle object.
|
|
|
|
+ * @param $storage_args
|
|
|
|
+ * Arguments passed to the storage backend for this bundle. These arguments
|
|
|
|
+ * typically provide details for how to associate this bundle with records
|
|
|
|
+ * in the storage system. Each storage system will have its own set of
|
|
|
|
+ * arguments that it will expect.
|
|
|
|
+ *
|
|
|
|
+ * @ingroup tripal_entities_api
|
|
|
|
+ */
|
|
|
|
+function hook_bundle_create(&$bundle, $storage_args) {
|
|
|
|
+
|
|
|
|
+}
|
|
|
|
+/**
|
|
|
|
+ * Allows a module to perform tasks after fields are added to a TripalBundle.
|
|
|
|
+ *
|
|
|
|
+ * @param $bundle
|
|
|
|
+ * The newly created TripalBundle object.
|
|
|
|
+ *
|
|
|
|
+ * @ingroup tripal_entities_api
|
|
|
|
+ */
|
|
|
|
+function hook_bundle_postcreate(&$bundle) {
|
|
|
|
+
|
|
|
|
+}
|
|
|
|
+/**
|
|
|
|
+ * Allows a module to add admin notifications to the associated tripal table
|
|
|
|
+ * during the cron run.
|
|
|
|
+ *
|
|
|
|
+ * @ingroup tripal_entities_api
|
|
|
|
+ */
|
|
|
|
+function hook_tripal_cron_notification() {
|
|
|
|
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+/**
|
|
|
|
+ * Allows a module to perform tasks before a TripalBundle object is deleted.
|
|
|
|
+ *
|
|
|
|
+ * @param $bundle
|
|
|
|
+ * The newly created TripalBundle object.
|
|
|
|
+ *
|
|
|
|
+ * @ingroup tripal_entities_api
|
|
|
|
+ */
|
|
|
|
+function hook_bundle_delete($bundle) {
|
|
|
|
+
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+/**
|
|
|
|
+ * Implement this hook to define default formats for Tripal Content Types.
|
|
|
|
+ *
|
|
|
|
+ * @param TripalBundle $bundle
|
|
|
|
+ * A tripal content type entity with information to be used for determining the default title format.
|
|
|
|
+ * @param array $available_tokens
|
|
|
|
+ * An array of available tokens for this particular tripal content type.
|
|
|
|
+ *
|
|
|
|
+ * @return array
|
|
|
|
+ * An array of potential formats. The lightest weighted format suggested by all modules will be chosen.
|
|
|
|
+ * Each array item should consist of a 'weight' and 'format'. See the hook implementation below
|
|
|
|
+ * for examples.
|
|
|
|
+ * - weight: an integer used to determine priority of suggestions.
|
|
|
|
+ * The smaller/lighter the number the higher the priority.
|
|
|
|
+ * Best practice is to use a weight less than 0 for extension modules.
|
|
|
|
+ * specifically, -2 is a good weight for calculated formats and -5 is a
|
|
|
|
+ * good weight for hard-coded formats specific to a given type.
|
|
|
|
+ * - format: a string including approved tokens used to determine the title
|
|
|
|
+ * on Tripal content pages.
|
|
|
|
+ *
|
|
|
|
+ * @ingroup tripal_entities_api
|
|
|
|
+ */
|
|
|
|
+function hook_tripal_default_title_format($bundle, $available_tokens) {
|
|
|
|
+ $format = array();
|
|
|
|
+
|
|
|
|
+ // If you want to suggest a default format for a particular vocabulary term:
|
|
|
|
+ //---------------------------------------------------------------------------
|
|
|
|
+ // Load the term associated with this Tripal Content type.
|
|
|
|
+ $term = entity_load('TripalTerm', array('id' => $bundle->term_id));
|
|
|
|
+ $term = reset($term);
|
|
|
|
+
|
|
|
|
+ // If it's the term you are interested in then suggest a format.
|
|
|
|
+ if ($term->name == 'organism') {
|
|
|
|
+
|
|
|
|
+ // To suggest a format, add an element to the array with a format & weight key.
|
|
|
|
+ $format[] = array(
|
|
|
|
+ // This is the format/pattern you suggest be used to determine the title of organism pages.
|
|
|
|
+ 'format' => '[organism__genus] [organism__species]',
|
|
|
|
+ // The weight/priority of your suggestion.
|
|
|
|
+ 'weight' => -5
|
|
|
|
+ );
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // Say you know that in your particular site, all 'names' are required
|
|
|
|
+ // and you want to only use the human-readable name:
|
|
|
|
+ //---------------------------------------------------------------------------
|
|
|
|
+ $name_field = preg_grep('/__name]$/', array_keys($available_tokens));
|
|
|
|
+ $name_field = reset($name_field);
|
|
|
|
+ if (is_string($name_field)) {
|
|
|
|
+ $format[] = array(
|
|
|
|
+ 'format' => $name_field,
|
|
|
|
+ 'weight' => -2,
|
|
|
|
+ );
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return $format;
|
|
|
|
+}
|
|
|
|
|
|
/**
|
|
/**
|
|
* A replacement for the entity_load function of Drupal.
|
|
* A replacement for the entity_load function of Drupal.
|
|
@@ -24,6 +162,8 @@
|
|
* @return
|
|
* @return
|
|
* An array of entity objects indexed by their ids. When no results are
|
|
* An array of entity objects indexed by their ids. When no results are
|
|
* found, an empty array is returned.
|
|
* found, an empty array is returned.
|
|
|
|
+ *
|
|
|
|
+ * @ingroup tripal_entities_api
|
|
*/
|
|
*/
|
|
function tripal_load_entity($entity_type, $ids = FALSE, $reset = FALSE,
|
|
function tripal_load_entity($entity_type, $ids = FALSE, $reset = FALSE,
|
|
$field_ids = array()) {
|
|
$field_ids = array()) {
|
|
@@ -58,6 +198,8 @@ function tripal_load_entity($entity_type, $ids = FALSE, $reset = FALSE,
|
|
*
|
|
*
|
|
* @return
|
|
* @return
|
|
* A TripalTerm entity object or NULL if not found.
|
|
* A TripalTerm entity object or NULL if not found.
|
|
|
|
+ *
|
|
|
|
+ * @ingroup tripal_entities_api
|
|
*/
|
|
*/
|
|
function tripal_load_term_entity($values) {
|
|
function tripal_load_term_entity($values) {
|
|
$vocabulary = array_key_exists('vocabulary', $values) ? $values['vocabulary'] : '';
|
|
$vocabulary = array_key_exists('vocabulary', $values) ? $values['vocabulary'] : '';
|
|
@@ -98,6 +240,8 @@ function tripal_load_term_entity($values) {
|
|
*
|
|
*
|
|
* @return
|
|
* @return
|
|
* A TripalVocab entity object or NULL if not found.
|
|
* A TripalVocab entity object or NULL if not found.
|
|
|
|
+ *
|
|
|
|
+ * @ingroup tripal_entities_api
|
|
*/
|
|
*/
|
|
function tripal_load_vocab_entity($values) {
|
|
function tripal_load_vocab_entity($values) {
|
|
$vocabulary = array_key_exists('vocabulary', $values) ? $values['vocabulary'] : '';
|
|
$vocabulary = array_key_exists('vocabulary', $values) ? $values['vocabulary'] : '';
|
|
@@ -134,6 +278,8 @@ function tripal_load_vocab_entity($values) {
|
|
*
|
|
*
|
|
* @return
|
|
* @return
|
|
* A TripalBundle entity object or NULL if not found.
|
|
* A TripalBundle entity object or NULL if not found.
|
|
|
|
+ *
|
|
|
|
+ * @ingroup tripal_entities_api
|
|
*/
|
|
*/
|
|
function tripal_load_bundle_entity($values) {
|
|
function tripal_load_bundle_entity($values) {
|
|
|
|
|
|
@@ -160,47 +306,6 @@ function tripal_load_bundle_entity($values) {
|
|
return NULL;
|
|
return NULL;
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
-/**
|
|
|
|
- * Allows a module to perform tasks before a TripalBundle object is deleted.
|
|
|
|
- *
|
|
|
|
- * @param $bundle
|
|
|
|
- * The newly created TripalBundle object.
|
|
|
|
- */
|
|
|
|
-function hook_bundle_delete($bundle) {
|
|
|
|
-
|
|
|
|
-}
|
|
|
|
-/**
|
|
|
|
- * Allows a module to perform tasks after a TripalBundle object is created.
|
|
|
|
- *
|
|
|
|
- * @param $bundle
|
|
|
|
- * The newly created TripalBundle object.
|
|
|
|
- * @param $storage_args
|
|
|
|
- * Arguments passed to the storage backend for this bundle. These arguments
|
|
|
|
- * typically provide details for how to associate this bundle with records
|
|
|
|
- * in the storage system. Each storage system will have its own set of
|
|
|
|
- * arguments that it will expect.
|
|
|
|
- */
|
|
|
|
-function hook_bundle_create(&$bundle, $storage_args) {
|
|
|
|
-
|
|
|
|
-}
|
|
|
|
-/**
|
|
|
|
- * Allows a module to perform tasks after fields are added to a TripalBundle.
|
|
|
|
- *
|
|
|
|
- * @param $bundle
|
|
|
|
- * The newly created TripalBundle object.
|
|
|
|
- */
|
|
|
|
-function hook_bundle_postcreate(&$bundle) {
|
|
|
|
-
|
|
|
|
-}
|
|
|
|
-/**
|
|
|
|
- * Allows a module to add admin notifications to the associated tripal table
|
|
|
|
- * during the cron run.
|
|
|
|
- *
|
|
|
|
- */
|
|
|
|
-function hook_tripal_cron_notification() {
|
|
|
|
-
|
|
|
|
-}
|
|
|
|
/**
|
|
/**
|
|
* Allows a module to write to the admin notification table
|
|
* Allows a module to write to the admin notification table
|
|
* during the cron run.
|
|
* during the cron run.
|
|
@@ -217,6 +322,8 @@ function hook_tripal_cron_notification() {
|
|
* If not type is required please pass NULL.
|
|
* If not type is required please pass NULL.
|
|
* @param $submitter_id
|
|
* @param $submitter_id
|
|
* A unique ID provided by the submitter for checking to make sure that the notification is not added more than once.
|
|
* A unique ID provided by the submitter for checking to make sure that the notification is not added more than once.
|
|
|
|
+ *
|
|
|
|
+ * @ingroup tripal_entities_api
|
|
*/
|
|
*/
|
|
function tripal_add_notification($title, $details, $type, $actions, $submitter_id) {
|
|
function tripal_add_notification($title, $details, $type, $actions, $submitter_id) {
|
|
$transaction = db_transaction();
|
|
$transaction = db_transaction();
|
|
@@ -259,8 +366,11 @@ function tripal_add_notification($title, $details, $type, $actions, $submitter_i
|
|
* @param $error
|
|
* @param $error
|
|
* A string, passed by reference, that is filled with the error message
|
|
* A string, passed by reference, that is filled with the error message
|
|
* if the function fails.
|
|
* if the function fails.
|
|
|
|
+ *
|
|
* @return
|
|
* @return
|
|
* The bundle object or FALSE if failure.
|
|
* The bundle object or FALSE if failure.
|
|
|
|
+ *
|
|
|
|
+ * @ingroup tripal_entities_api
|
|
*/
|
|
*/
|
|
function tripal_create_bundle($args, &$error = '') {
|
|
function tripal_create_bundle($args, &$error = '') {
|
|
$vocabulary = $args['vocabulary'];
|
|
$vocabulary = $args['vocabulary'];
|
|
@@ -391,6 +501,8 @@ function tripal_entity_permissions($entity) {
|
|
* @return
|
|
* @return
|
|
* An array of bundles. Each bundle is an object containing information
|
|
* An array of bundles. Each bundle is an object containing information
|
|
* about that bundle.
|
|
* about that bundle.
|
|
|
|
+ *
|
|
|
|
+ * @ingroup tripal_entities_api
|
|
*/
|
|
*/
|
|
function tripal_get_content_types() {
|
|
function tripal_get_content_types() {
|
|
return db_select('tripal_bundle', 'tb')
|
|
return db_select('tripal_bundle', 'tb')
|
|
@@ -404,6 +516,8 @@ function tripal_get_content_types() {
|
|
*
|
|
*
|
|
* @param $bundle_name
|
|
* @param $bundle_name
|
|
* The name of the bundle to refresh (e.g. bio_data_4).
|
|
* The name of the bundle to refresh (e.g. bio_data_4).
|
|
|
|
+ *
|
|
|
|
+ * @ingroup tripal_entities_api
|
|
*/
|
|
*/
|
|
function tripal_tripal_cron_notification() {
|
|
function tripal_tripal_cron_notification() {
|
|
$num_created = 0;
|
|
$num_created = 0;
|
|
@@ -483,6 +597,8 @@ function tripal_tripal_cron_notification() {
|
|
*
|
|
*
|
|
* @return
|
|
* @return
|
|
* An object containing information about the bundle.
|
|
* An object containing information about the bundle.
|
|
|
|
+ *
|
|
|
|
+ * @ingroup tripal_entities_api
|
|
*/
|
|
*/
|
|
function tripal_get_content_type($bundle_name) {
|
|
function tripal_get_content_type($bundle_name) {
|
|
return db_select('tripal_bundle', 'tb')
|
|
return db_select('tripal_bundle', 'tb')
|
|
@@ -500,6 +616,8 @@ function tripal_get_content_type($bundle_name) {
|
|
*
|
|
*
|
|
* @return
|
|
* @return
|
|
* The array of field instance names that were added.
|
|
* The array of field instance names that were added.
|
|
|
|
+ *
|
|
|
|
+ * @ingroup tripal_entities_api
|
|
*/
|
|
*/
|
|
function tripal_create_bundle_fields($bundle, $term) {
|
|
function tripal_create_bundle_fields($bundle, $term) {
|
|
|
|
|
|
@@ -607,6 +725,7 @@ function tripal_create_bundle_fields($bundle, $term) {
|
|
* TODO: this function really shouldn't try to create an instance and
|
|
* TODO: this function really shouldn't try to create an instance and
|
|
* attach to a bundle at the same time.
|
|
* attach to a bundle at the same time.
|
|
*
|
|
*
|
|
|
|
+ * @ingroup tripal_entities_api
|
|
*/
|
|
*/
|
|
function tripal_update_bundle_field($field_name, $field_info, $entity_type_name, $bundle_name) {
|
|
function tripal_update_bundle_field($field_name, $field_info, $entity_type_name, $bundle_name) {
|
|
|
|
|
|
@@ -668,19 +787,6 @@ function tripal_update_bundle_field($field_name, $field_info, $entity_type_name,
|
|
field_update_instance($field_instance);
|
|
field_update_instance($field_instance);
|
|
}
|
|
}
|
|
|
|
|
|
-/**
|
|
|
|
- * Allows a module to make changes to an entity object after creation.
|
|
|
|
- *
|
|
|
|
- * This function is added by Tripal to allow datastore backends to add
|
|
|
|
- * addition properties to the entity that they themselves will use later.
|
|
|
|
- *
|
|
|
|
- * @param $entity
|
|
|
|
- * @param $entity_type
|
|
|
|
- */
|
|
|
|
-function hook_entity_create(&$entity, $entity_type) {
|
|
|
|
-
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
* @section
|
|
* @section
|
|
@@ -696,6 +802,8 @@ function hook_entity_create(&$entity, $entity_type) {
|
|
* The unique identfier for the bundle you want the value for.
|
|
* The unique identfier for the bundle you want the value for.
|
|
* @return text
|
|
* @return text
|
|
* The value of the specified variable for the specified bundle.
|
|
* The value of the specified variable for the specified bundle.
|
|
|
|
+ *
|
|
|
|
+ * @ingroup tripal_entities_api
|
|
*/
|
|
*/
|
|
function tripal_get_bundle_variable($variable_name, $bundle_id, $default = FALSE) {
|
|
function tripal_get_bundle_variable($variable_name, $bundle_id, $default = FALSE) {
|
|
|
|
|
|
@@ -731,6 +839,8 @@ function tripal_get_bundle_variable($variable_name, $bundle_id, $default = FALSE
|
|
* The unique identfier for the bundle you want the value for.
|
|
* The unique identfier for the bundle you want the value for.
|
|
* @param $text $value
|
|
* @param $text $value
|
|
* The value of the variable for the given bundle.
|
|
* The value of the variable for the given bundle.
|
|
|
|
+ *
|
|
|
|
+ * @ingroup tripal_entities_api
|
|
*/
|
|
*/
|
|
function tripal_set_bundle_variable($variable_name, $bundle_id, $value) {
|
|
function tripal_set_bundle_variable($variable_name, $bundle_id, $value) {
|
|
$variable = tripal_get_variable($variable_name);
|
|
$variable = tripal_get_variable($variable_name);
|
|
@@ -786,6 +896,8 @@ function tripal_set_bundle_variable($variable_name, $bundle_id, $value) {
|
|
*
|
|
*
|
|
* @param TripalBundle $bundle
|
|
* @param TripalBundle $bundle
|
|
* The Entity object for the Tripal Bundle the title format is for.
|
|
* The Entity object for the Tripal Bundle the title format is for.
|
|
|
|
+ *
|
|
|
|
+ * @ingroup tripal_entities_api
|
|
*/
|
|
*/
|
|
function tripal_get_title_format($bundle) {
|
|
function tripal_get_title_format($bundle) {
|
|
|
|
|
|
@@ -809,6 +921,8 @@ function tripal_get_title_format($bundle) {
|
|
* The Entity object for the Tripal Bundle the title format is for.
|
|
* The Entity object for the Tripal Bundle the title format is for.
|
|
* @param string $format
|
|
* @param string $format
|
|
* The pattern to be used when generating entity titles for the above type.
|
|
* The pattern to be used when generating entity titles for the above type.
|
|
|
|
+ *
|
|
|
|
+ * @ingroup tripal_entities_api
|
|
*/
|
|
*/
|
|
function tripal_save_title_format($entity, $format) {
|
|
function tripal_save_title_format($entity, $format) {
|
|
|
|
|
|
@@ -823,6 +937,8 @@ function tripal_save_title_format($entity, $format) {
|
|
*
|
|
*
|
|
* @return string
|
|
* @return string
|
|
* A default title format.
|
|
* A default title format.
|
|
|
|
+ *
|
|
|
|
+ * @ingroup tripal_entities_api
|
|
*/
|
|
*/
|
|
function tripal_get_default_title_format($bundle) {
|
|
function tripal_get_default_title_format($bundle) {
|
|
$format = '';
|
|
$format = '';
|
|
@@ -863,62 +979,6 @@ function tripal_get_default_title_format($bundle) {
|
|
return $format;
|
|
return $format;
|
|
}
|
|
}
|
|
|
|
|
|
-/**
|
|
|
|
- * Implement this hook to define default formats for Tripal Content Types.
|
|
|
|
- *
|
|
|
|
- * @param TripalBundle $bundle
|
|
|
|
- * A tripal content type entity with information to be used for determining the default title format.
|
|
|
|
- * @param array $available_tokens
|
|
|
|
- * An array of available tokens for this particular tripal content type.
|
|
|
|
- *
|
|
|
|
- * @return array
|
|
|
|
- * An array of potential formats. The lightest weighted format suggested by all modules will be chosen.
|
|
|
|
- * Each array item should consist of a 'weight' and 'format'. See the hook implementation below
|
|
|
|
- * for examples.
|
|
|
|
- * - weight: an integer used to determine priority of suggestions.
|
|
|
|
- * The smaller/lighter the number the higher the priority.
|
|
|
|
- * Best practice is to use a weight less than 0 for extension modules.
|
|
|
|
- * specifically, -2 is a good weight for calculated formats and -5 is a
|
|
|
|
- * good weight for hard-coded formats specific to a given type.
|
|
|
|
- * - format: a string including approved tokens used to determine the title
|
|
|
|
- * on Tripal content pages.
|
|
|
|
- */
|
|
|
|
-function hook_tripal_default_title_format($bundle, $available_tokens) {
|
|
|
|
- $format = array();
|
|
|
|
-
|
|
|
|
- // If you want to suggest a default format for a particular vocabulary term:
|
|
|
|
- //---------------------------------------------------------------------------
|
|
|
|
- // Load the term associated with this Tripal Content type.
|
|
|
|
- $term = entity_load('TripalTerm', array('id' => $bundle->term_id));
|
|
|
|
- $term = reset($term);
|
|
|
|
-
|
|
|
|
- // If it's the term you are interested in then suggest a format.
|
|
|
|
- if ($term->name == 'organism') {
|
|
|
|
-
|
|
|
|
- // To suggest a format, add an element to the array with a format & weight key.
|
|
|
|
- $format[] = array(
|
|
|
|
- // This is the format/pattern you suggest be used to determine the title of organism pages.
|
|
|
|
- 'format' => '[organism__genus] [organism__species]',
|
|
|
|
- // The weight/priority of your suggestion.
|
|
|
|
- 'weight' => -5
|
|
|
|
- );
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- // Say you know that in your particular site, all 'names' are required
|
|
|
|
- // and you want to only use the human-readable name:
|
|
|
|
- //---------------------------------------------------------------------------
|
|
|
|
- $name_field = preg_grep('/__name]$/', array_keys($available_tokens));
|
|
|
|
- $name_field = reset($name_field);
|
|
|
|
- if (is_string($name_field)) {
|
|
|
|
- $format[] = array(
|
|
|
|
- 'format' => $name_field,
|
|
|
|
- 'weight' => -2,
|
|
|
|
- );
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- return $format;
|
|
|
|
-}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
* Returns an array of tokens based on Tripal Entity Fields.
|
|
* Returns an array of tokens based on Tripal Entity Fields.
|
|
@@ -927,6 +987,8 @@ function hook_tripal_default_title_format($bundle, $available_tokens) {
|
|
* The bundle entity for which you want tokens.
|
|
* The bundle entity for which you want tokens.
|
|
* @return
|
|
* @return
|
|
* An array of tokens where the key is the machine_name of the token.
|
|
* An array of tokens where the key is the machine_name of the token.
|
|
|
|
+ *
|
|
|
|
+ * @ingroup tripal_entities_api
|
|
*/
|
|
*/
|
|
function tripal_get_entity_tokens($entity, $options = array()) {
|
|
function tripal_get_entity_tokens($entity, $options = array()) {
|
|
$tokens = array();
|
|
$tokens = array();
|
|
@@ -996,6 +1058,8 @@ function tripal_get_entity_tokens($entity, $options = array()) {
|
|
*
|
|
*
|
|
* @return
|
|
* @return
|
|
* The string will all tokens replaced with values.
|
|
* The string will all tokens replaced with values.
|
|
|
|
+ *
|
|
|
|
+ * @ingroup tripal_entities_api
|
|
*/
|
|
*/
|
|
function tripal_replace_entity_tokens($string, &$entity, $bundle_entity = NULL) {
|
|
function tripal_replace_entity_tokens($string, &$entity, $bundle_entity = NULL) {
|
|
// Determine which tokens were used in the format string
|
|
// Determine which tokens were used in the format string
|
|
@@ -1091,6 +1155,8 @@ function tripal_replace_entity_tokens($string, &$entity, $bundle_entity = NULL)
|
|
* A list of tokens generated via tripal_get_entity_tokens().
|
|
* A list of tokens generated via tripal_get_entity_tokens().
|
|
* @return
|
|
* @return
|
|
* Rendered output describing the available tokens.
|
|
* Rendered output describing the available tokens.
|
|
|
|
+ *
|
|
|
|
+ * @ingroup tripal_entities_api
|
|
*/
|
|
*/
|
|
function theme_token_list($tokens) {
|
|
function theme_token_list($tokens) {
|
|
|
|
|
|
@@ -1113,8 +1179,9 @@ function theme_token_list($tokens) {
|
|
* @param $entity
|
|
* @param $entity
|
|
*
|
|
*
|
|
* @return mixed
|
|
* @return mixed
|
|
|
|
+ *
|
|
|
|
+ * @ingroup tripal_entities_api
|
|
*/
|
|
*/
|
|
-
|
|
|
|
function tripal_entity_label($entity) {
|
|
function tripal_entity_label($entity) {
|
|
if (property_exists($entity, 'title')) {
|
|
if (property_exists($entity, 'title')) {
|
|
return $entity->title;
|
|
return $entity->title;
|
|
@@ -1122,6 +1189,12 @@ function tripal_entity_label($entity) {
|
|
return NULL;
|
|
return NULL;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+/**
|
|
|
|
+ *
|
|
|
|
+ * @param $bundle_name
|
|
|
|
+ *
|
|
|
|
+ * @ingroup tripal_entities_api
|
|
|
|
+ */
|
|
function tripal_get_bundle_details($bundle_name) {
|
|
function tripal_get_bundle_details($bundle_name) {
|
|
global $user;
|
|
global $user;
|
|
|
|
|
|
@@ -1203,6 +1276,8 @@ function tripal_get_bundle_details($bundle_name) {
|
|
* A recursive helper function for the tripal_get_bundle_details.
|
|
* A recursive helper function for the tripal_get_bundle_details.
|
|
*
|
|
*
|
|
* @param $elementInfo
|
|
* @param $elementInfo
|
|
|
|
+ *
|
|
|
|
+ * @ingroup tripal_entities_api
|
|
*/
|
|
*/
|
|
function _tripal_get_bundle_field_element_details($elements, &$field_details) {
|
|
function _tripal_get_bundle_field_element_details($elements, &$field_details) {
|
|
$field_details['elements'] = array();
|
|
$field_details['elements'] = array();
|
|
@@ -1235,6 +1310,15 @@ function _tripal_get_bundle_field_element_details($elements, &$field_details) {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+/**
|
|
|
|
+ *
|
|
|
|
+ * @param unknown $bundle_name
|
|
|
|
+ * @param unknown $values
|
|
|
|
+ *
|
|
|
|
+ * @throws Exception
|
|
|
|
+ *
|
|
|
|
+ * @ingroup tripal_entities_api
|
|
|
|
+ */
|
|
function tripal_insert_entity($bundle_name, $values){
|
|
function tripal_insert_entity($bundle_name, $values){
|
|
global $user;
|
|
global $user;
|
|
|
|
|
|
@@ -1283,6 +1367,12 @@ function tripal_insert_entity($bundle_name, $values){
|
|
$entity = $entity->save();
|
|
$entity = $entity->save();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+/**
|
|
|
|
+ * @param $bundle_name
|
|
|
|
+ * @param $values
|
|
|
|
+ *
|
|
|
|
+ * @ingroup tripal_entities_api
|
|
|
|
+ */
|
|
function tripal_update_entity($bundle_name, $values) {
|
|
function tripal_update_entity($bundle_name, $values) {
|
|
|
|
|
|
|
|
|