function tripal_views_handler_filter_select_string::get_select_options
2.x tripal_views_handler_filter_select_string.inc | tripal_views_handler_filter_select_string::get_select_options() |
3.x tripal_views_handler_filter_select_string.inc | tripal_views_handler_filter_select_string::get_select_options() |
Provide the options used in the select list. Override this function in extended handlers to easily change option list.
Return value
An array of options where the key is the value of this field in the database
1 call to tripal_views_handler_filter_select_string::get_select_options()
- tripal_views_handler_filter_select_string::value_form in tripal_views/
views/ handlers/ tripal_views_handler_filter_select_string.inc - Provide a simple textfield for equality
2 methods override tripal_views_handler_filter_select_string::get_select_options()
- tripal_views_handler_filter_select_cvterm::get_select_options in tripal_views/
views/ handlers/ tripal_views_handler_filter_select_cvterm.inc - Provide the options used in the select list. Override this function in extended handlers to easily change option list.
- tripal_views_handler_filter_select_id::get_select_options in tripal_views/
views/ handlers/ tripal_views_handler_filter_select_id.inc - Provide the options used in the select list. Override this function in extended handlers to easily change option list.
File
- tripal_views/
views/ handlers/ tripal_views_handler_filter_select_string.inc, line 87 - Contains tripal_views_handler_filter_select_string Filter Handler
Class
- tripal_views_handler_filter_select_string
- This Handler provides a generic select list for any chado field that is a string The select list includes all distinct values for that field.
Code
function get_select_options() {
$return = $this->get_select_option_where();
$where_clauses = $return['where_clauses'];
$arguments = $return['arguments'];
$where = '';
if (!empty($where_clauses)) {
$where = ' WHERE ' . implode(' AND ', $where_clauses);
}
// get the values from the table
$sql = 'SELECT ' . $this->real_field . ' FROM {' . $this->table . '} ' . $where . ' ORDER BY ' . $this->field . ' ASC';
$results = chado_query($sql, $arguments);
// Build the select box options
$max_length = (isset($this->options['max_length'])) ? $this->options['max_length'] : 40;
if (!$max_length) {
$max_length = 40;
}
$options = array();
if ($this->options['select_optional']) {
$options['All'] = '--Any--';
}
foreach ($results as $r) {
if (drupal_strlen($r->{$this->field}) > $max_length) {
$options[$r->{$this->field}] = drupal_substr($r->{$this->field}, 0, $max_length) . '...';
}
else {
$options[$r->{$this->field}] = $r->{$this->field};
}
}
return $options;
}