Tripal v1.0 (6.x-1.0)
chado_wrapper_functions.inc File Reference

Go to the source code of this file.

Functions

 chado_wrapper_split_array_agg_results ($handler, &$values)
 chado_wrapper_is_aggregated_by_join ($handler)
 chado_wrapper_is_aggregated_by_result ($handler, $values)
 chado_wrapper_render_items ($handler, $values)

Detailed Description

TODO: add documentation

Definition in file chado_wrapper_functions.inc.


Function Documentation

chado_wrapper_is_aggregated_by_join ( handler)

Determines if the current field is generated via the aggregated join handler

Parameters:
$handlerpass in $this from handler::query()
Returns:
TRUE/FALSE if or if not the field has the aggregated join handler

Definition at line 43 of file chado_wrapper_functions.inc.

                                                       {
  $aggregated = FALSE;

  $table = $handler->query->get_table_info($handler->table);
  if (preg_match('/aggregator/', $table['join']->definition['handler'])) {
    $aggregated = TRUE;
  }

  return $aggregated;
}
chado_wrapper_is_aggregated_by_result ( handler,
values 
)

Determines if the current field is generated via the result returned

Parameters:
$handlerpass in $this from handler::pre_render()
$valuespass in $values from handler::pre_render()
Returns:
TRUE/FALSE if or if not the field is aggregated

Definition at line 65 of file chado_wrapper_functions.inc.

                                                                  {
  $aggregated = FALSE;


  $i = 0;
  while (empty($values[$i]->{$handler->field_alias}) AND $i <= sizeof($values)) {
    $i++;
  }

  if (preg_match('/^{.*}$/', $values[$i]->{$handler->field_alias})) {
    $aggregated = TRUE;
  }

  return $aggregated;
}
chado_wrapper_render_items ( handler,
values 
)

Definition at line 81 of file chado_wrapper_functions.inc.

                                                       {

  // If it's aggregated (an array), then render each part
  // using the parent render functionality
  if ($handler->aggregated) {

    $items = array();

    $parts = $values->{$handler->field_alias};
    foreach ($parts as $p) {
      $v[ $handler->field_alias ] = $p;
      $val = (object) $v;
      $items[] = $handler->parent_render($val);
      unset($v, $val);
    }

    if ($handler->options['type'] == 'separator') {
      return implode(check_plain($handler->options['separator']), $items);
    }
    else {
      return theme('item_list', $items, NULL, $handler->options['type']);
    }

  // Otherwise it is not aggragated
  // Just render like the default handler would
  }
  else {
    return $handler->parent_render($values);
  }
}
chado_wrapper_split_array_agg_results ( handler,
&$  values 
)

Splits an SQL array of results in a single field into a php array

Parameters:
$fieldAn SQL array (ie: {"",^(.*)$,646,tripal_analysis_blast} )
Returns:
A PHP version of the SQL array (ie: array('','^(.*)$','646','tripal_analysis_blast') )

Definition at line 17 of file chado_wrapper_functions.inc.

                                                                   {

  if ($handler->aggregated) {
    foreach ($values as $k => $v) {

      if (preg_match('/^{(.*)}$/', $v->{$handler->field_alias}, $matches)) {
        $values[$k]->{$handler->field_alias} = str_getcsv($matches[1]);
      }
      else {
        $values[$k]->{$handler->field_alias} = array();
      }
    }
  }

  return $values;
}
 All Classes Files Functions Variables