protected function TripalField::_addWebServiceElement

3.x TripalField.inc protected TripalField::_addWebServiceElement(&$searchable_keys, &$sortable_keys, $parent_term_name, $parent_term, $element_name, $element_details)

Parameters

$searchabe_keys:

$field_name:

$element_name:

$element_details:

1 call to TripalField::_addWebServiceElement()
TripalField::webServicesData in tripal/includes/TripalFields/TripalField.inc
Describes this field to Tripal web services.

File

tripal/includes/TripalFields/TripalField.inc, line 274

Class

TripalField

Code

protected function _addWebServiceElement(&$searchable_keys, &$sortable_keys, 
$parent_term_name, $parent_term, $element_name, $element_details) {

  // Skip the 'entity' element, as we'll never make this searchable or
  // viewable. It's meant for linking.
  if ($element_name == 'entity') {
    return;
  }

  list($vocabulary, $accession) = explode(':', $element_name);
  $term = tripal_get_term_details($vocabulary, $accession);
  $field_term = $parent_term . ',' . $term['vocabulary']['short_name'] . ':' . $term['accession'];
  $field_term_name = $parent_term_name . '.' . strtolower(preg_replace('/[^\w]/', '_', $term['name']));

  // Is the field searchable?
  if (array_key_exists('searchable', $element_details) and $element_details['searchable']) {
    $searchable_keys[$field_term_name] = $field_term;
  }
  if (array_key_exists('sortable', $element_details) and $element_details['sortable']) {
    $sortable_keys[$field_term_name] = $field_term;
  }

  // Now add any entries for child elements.
  if (array_key_exists('elements', $element_details)) {
    $elements = $element_details['elements'];
    foreach ($elements as $element_name => $element_details) {
      $this->_addWebServiceElement($searchable_keys, $sortable_keys, $field_term_name, $field_term, $element_name, $element_details);
    }
  }
}