You are here

search_service.module in Services 7

@author Services Dev Team

Link general search functionalities to services module.

File

services/search_service/search_service.module
View source
<?php

/**
 * @author Services Dev Team
 * @file
 *  Link general search functionalities to services module.
 */

/**
 * Implementation of hook_help().
 */
function search_service_help($path, $arg) {
  switch ($path) {
    case 'admin/help#services_search':
      return t('<p>Provides search methods to services applications. Requires services.module.</p>');
    case 'admin/modules#description':
      return t('Provides search methods to services applications. Requires services.module.');
  }
}

/**
 * Implementation of hook_perm().
 */
function search_service_perm() {
  $perms = array(
    'administer search service',
  );
  return $perms;
}

/**
 * Implementation of hook_menu().
 */
function search_service_menu() {
  $items = array();
  $items['admin/settings/search_service'] = array(
    'title' => t('Search Service'),
    'description' => t('Configure search service.'),
    'page callback' => 'drupal_get_form',
    'page arguments' => array(
      'search_service_admin',
    ),
    'file' => 'search_service_admin.inc',
    'access arguments' => array(
      'administer search service',
    ),
  );
  return $items;
}

/**
 * Implementation of hook_service().
 */
function search_service_service() {
  global $conf;
  if (!isset($conf['search_service_options'])) {
    drupal_set_message(t('Please configure <a href="@settings">search_service settings</a> to choose search methods to return with this method.', array(
      '@settings' => url('admin/settings/search_service'),
    )), 'error');
  }
  return array(
    array(
      '#method' => 'search.nodes',
      '#callback' => 'search_service_nodes',
      '#access arguments' => array(
        'search content',
      ),
      '#file' => array(
        'file' => 'inc',
        'module' => 'search_service',
      ),
      '#args' => array(
        array(
          '#name' => 'search_keys',
          '#type' => 'string',
          '#description' => t('Search keys.'),
        ),
        array(
          '#name' => 'simple',
          '#type' => 'string',
          '#optional' => TRUE,
          '#description' => t('If set, returns only the main search fields (link, type, title, user, date, snippet) and no additional data.'),
        ),
        array(
          '#name' => 'fields',
          '#type' => 'array',
          '#optional' => TRUE,
          '#description' => t('A list of fields to filter.'),
        ),
      ),
      '#return' => 'array',
      '#help' => t('Searches nodes according to keys via node_search.'),
    ),
    array(
      '#method' => 'search.content',
      '#callback' => 'search_service_content',
      '#access arguments' => array(
        'search content',
      ),
      '#file' => array(
        'file' => 'inc',
        'module' => 'search_service',
      ),
      '#args' => array(
        array(
          '#name' => 'search_keys',
          '#type' => 'string',
          '#description' => t('Search keys.'),
        ),
        array(
          '#name' => 'simple',
          '#type' => 'string',
          '#optional' => TRUE,
          '#description' => t('If set, returns only the main search fields (link, type, title, user, date, snippet) and no additional data.'),
        ),
      ),
      '#return' => 'array',
      '#help' => t('Uses hook_search() selected under /admin/settings/search_service.'),
    ),
    array(
      '#method' => 'search.users',
      '#callback' => 'search_service_users',
      '#access arguments' => array(
        'search content',
      ),
      '#file' => array(
        'file' => 'inc',
        'module' => 'search_service',
      ),
      '#args' => array(
        array(
          '#name' => 'search_keys',
          '#type' => 'string',
          '#description' => t('Search keys.'),
        ),
      ),
      '#return' => 'array',
      '#help' => t('Searches users according to keys via hook_search.'),
    ),
  );
}

Functions

Namesort descending Description
search_service_help Implementation of hook_help().
search_service_menu Implementation of hook_menu().
search_service_perm Implementation of hook_perm().
search_service_service Implementation of hook_service().