function oa_sidebar_search_pane_render in Open Atrium Search 7.2
Renders the widget.
1 string reference to 'oa_sidebar_search_pane_render'
- oa_sidebar_search.inc in plugins/
content_types/ oa_sidebar_search.inc
File
- plugins/
content_types/ oa_sidebar_search.inc, line 24
Code
function oa_sidebar_search_pane_render($subtype, $conf, $args, $context) {
$all_options = array(
'all_spaces' => t('All spaces'),
'this_space' => t('This space'),
'users' => t('Users'),
);
if (isset($conf['allowed_options']) && count(array_filter($conf['allowed_options'])) > 0) {
$keys = array_keys(array_filter($conf['allowed_options']));
}
else {
$keys = array_keys($all_options);
}
$options = array();
foreach ($keys as $key) {
$options[$key] = $all_options[$key];
}
$spaces = array();
if (isset($conf['taxonomy_terms']) && count(array_filter($conf['taxonomy_terms'])) > 0) {
$terms = $conf['taxonomy_terms'];
$terms = array_filter($terms);
// get a list of spaces with those terms
$query = db_select('taxonomy_index', 't');
$result = $query
->fields('t', array(
'nid',
))
->condition('t.tid', $terms, 'IN')
->execute()
->fetchCol(0);
$titles = oa_core_get_titles($result, '', 'title', array(
'title',
'id',
), FALSE);
$spaces[0] = 'Select a space';
foreach ($titles['titles'] as $key => $name) {
$spaces[$titles['ids'][$key]] = $name;
}
$element = array(
'#name' => 'space_select',
'#title' => !empty($conf['select_title']) ? $conf['select_title'] : '',
'#type' => 'select',
'#options' => $spaces,
'#default_value' => array(),
'#multiple' => FALSE,
'#required' => FALSE,
);
$element = form_process_select($element);
$element['#attributes']['class'][] = 'form-control';
$spaces = drupal_render($element);
}
$extra_classes = '';
$solr_server = search_api_server_load('solr_server');
if (isset($solr_server) && $solr_server->enabled) {
$extra_classes .= ' solr-search';
}
$block = new stdClass();
$block->title = t('Search');
$block->content = array(
'#theme' => 'oa_sidebar_search',
'#options' => $options,
'#spaces' => $spaces,
'#extra_classes' => $extra_classes,
);
return $block;
}