You are here

oa_search.module in Open Atrium Search 7.2

File

oa_search.module
View source
<?php

/**
 * @file
 * Code for the Open Atrium Search feature.
 */
include_once 'oa_search.features.inc';

/**
 * Implements hook_ctools_plugin_directory()
 */
function oa_search_ctools_plugin_directory($module, $plugin) {
  return 'plugins/' . $plugin;
}

/**
 * Implements hook_theme().
 */
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,
    ),
  );
}

/**
 * Implements hook_default_search_api_index_alter().
 */
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',
    );

    /* WAS: '' */
    $data['database_node_index']->options['fields']['og_group_ref:title'] = array(
      'type' => 'string',
    );

    /* WAS: '' */
    $data['database_node_index']->options['fields']['oa_section_ref:title'] = array(
      'type' => 'string',
    );

    /* WAS: '' */
  }
  if (isset($data['node_index'])) {
    $data['node_index']->options['fields']['created'] = array(
      'type' => 'date',
    );

    /* WAS: '' */
    $data['node_index']->options['fields']['og_group_ref:title'] = array(
      'type' => 'string',
    );

    /* WAS: '' */
    $data['node_index']->options['fields']['oa_section_ref:title'] = array(
      'type' => 'string',
    );

    /* WAS: '' */
  }
}

/**
 * Implements hook_preprocess_oa_toolbar_search().
 */
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();
}

/**
 * Implements hook_preprocess_oa_sidebar_search().
 */
function oa_search_preprocess_oa_sidebar_search(&$vars) {
  oa_search_add_js();
}

/**
 * Adds variables and js to search panes.
 */
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');
}

Functions

Namesort descending Description
oa_search_add_js Adds variables and js to search panes.
oa_search_ctools_plugin_directory Implements hook_ctools_plugin_directory()
oa_search_default_search_api_index_alter Implements hook_default_search_api_index_alter().
oa_search_preprocess_oa_sidebar_search Implements hook_preprocess_oa_sidebar_search().
oa_search_preprocess_oa_toolbar_search Implements hook_preprocess_oa_toolbar_search().
oa_search_theme Implements hook_theme().