You are here

function _linkit_autocomplete_search in Linkit 7.2

Perform internal autocomplete search.

Parameters

$search_string: The search string.

Return value

$results An array with the result objects.

1 call to _linkit_autocomplete_search()
_linkit_autocomplete in ./linkit.module
Autocomplete callback function.

File

./linkit.module, line 286
Main file for linkit module.

Code

function _linkit_autocomplete_search($search_string, $enabled_plugins) {
  $matches = array();
  if ($search_string) {
    $profile = linkit_get_dashboard_profile();
    foreach ($enabled_plugins as $plugin) {

      // Get an instance of the handler for this plugin.
      $handler = linkit_get_plugin_handler($plugin, $profile);

      // If the handler is broken, just continue.
      if ($handler
        ->broken()) {
        continue;
      }

      // Add the search string.
      $handler
        ->setSearchString($search_string);

      // Call the plugin search metod.
      $results = $handler
        ->autocomplete_callback();

      // Merge the results.
      $matches = array_merge($matches, $results);
    }

    // Special for link to frontpage.
    if (strpos($search_string, 'front') !== FALSE) {
      $results = array(
        array(
          'title' => t('Frontpage'),
          'description' => 'The frontpage for this site.',
          'path' => url('<front>'),
          'group' => t('System'),
        ),
      );
      $matches = array_merge($matches, $results);
    }
  }
  if (!empty($matches)) {
    return $matches;
  }
  return FALSE;
}