View source
<?php
include_once 'oa_search.features.inc';
function oa_search_ctools_plugin_directory($module, $plugin) {
return 'plugins/' . $plugin;
}
function oa_search_theme() {
$path = drupal_get_path('module', 'oa_search') . '/templates';
return array(
'oa_toolbar_search' => array(
'template' => 'oa-toolbar-search',
'variables' => array(
'options' => array(),
),
'path' => $path,
),
'oa_sidebar_search' => array(
'template' => 'oa-sidebar-search',
'variables' => array(
'options' => array(),
'spaces' => array(),
'extra_classes' => '',
),
'path' => $path,
),
'views_view_fields__search_database_results' => array(
'template' => 'views-view-fields--search-database-results',
'base hook' => 'views_view_fields',
'preprocess functions' => array(
'template_preprocess',
'template_preprocess_views_view_fields',
),
'arguments' => array(
'view' => NULL,
'options' => NULL,
'row' => NULL,
),
'path' => $path,
),
'views_view_fields__search_user_results' => array(
'template' => 'views-view-fields--search-user-results',
'base hook' => 'views_view_fields',
'preprocess functions' => array(
'template_preprocess',
'template_preprocess_views_view_fields',
),
'arguments' => array(
'view' => NULL,
'options' => NULL,
'row' => NULL,
),
'path' => $path,
),
'views_view_fields__search_solr_results' => array(
'template' => 'views-view-fields--search-solr-results',
'base hook' => 'views_view_fields',
'preprocess functions' => array(
'template_preprocess',
'template_preprocess_views_view_fields',
),
'arguments' => array(
'view' => NULL,
'options' => NULL,
'row' => NULL,
),
'path' => $path,
),
'views_view_fields__search_user_solr_results' => array(
'template' => 'views-view-fields--search-user-solr-results',
'base hook' => 'views_view_fields',
'preprocess functions' => array(
'template_preprocess',
'template_preprocess_views_view_fields',
),
'arguments' => array(
'view' => NULL,
'options' => NULL,
'row' => NULL,
),
'path' => $path,
),
);
}
function oa_search_default_search_api_index_alter(&$data) {
if (isset($data['database_node_index'])) {
$data['database_node_index']->options['fields']['created'] = array(
'type' => 'date',
);
$data['database_node_index']->options['fields']['og_group_ref:title'] = array(
'type' => 'string',
);
$data['database_node_index']->options['fields']['oa_section_ref:title'] = array(
'type' => 'string',
);
}
if (isset($data['node_index'])) {
$data['node_index']->options['fields']['created'] = array(
'type' => 'date',
);
$data['node_index']->options['fields']['og_group_ref:title'] = array(
'type' => 'string',
);
$data['node_index']->options['fields']['oa_section_ref:title'] = array(
'type' => 'string',
);
}
}
function oa_search_preprocess_oa_toolbar_search(&$vars) {
$vars['oa_toolbar_btn_class'] = variable_get('oa_toolbar_style', 0) ? '' : 'btn-inverse';
oa_search_add_js();
}
function oa_search_preprocess_oa_sidebar_search(&$vars) {
oa_search_add_js();
}
function oa_search_add_js() {
$space_title = '';
$space_id = oa_core_get_space_context();
if ($space_id) {
$space = node_load($space_id);
if (!empty($space->title)) {
$space_title = $space->title;
}
}
drupal_add_js(array(
'oa_search' => array(
'space' => $space_title,
),
), 'setting');
global $language;
$lang_prefix = $language->prefix;
drupal_add_js(array(
'sitelang' => $lang_prefix,
), 'setting');
drupal_add_js(drupal_get_path('module', 'oa_search') . '/js/oa_search.js');
}