You are here

function _mpac_get_matches_for_shortcuts in Multi-path autocomplete 7

Helper function to find all menu items containing the given string in their title.

Parameters

$title: The title to search for.

1 call to _mpac_get_matches_for_shortcuts()
mpac_autocomplete in ./mpac.module
Find nodes, shortcuts and URL aliases based on title.

File

./mpac.module, line 208
Find node paths on menu item creation via autocomplete.

Code

function _mpac_get_matches_for_shortcuts($title = '') {
  $matches = array();
  if ($title == '') {
    return $matches;
  }
  $query = db_select('menu_router')
    ->extend('PagerDefault');
  $query
    ->condition('title', '%' . db_like($title) . '%', 'LIKE');
  $query
    ->where('path NOT LIKE :percent', array(
    ':percent' => '%\\%%',
  ));
  $result = $query
    ->fields('menu_router')
    ->limit(variable_get('mpac_max_items', 20))
    ->execute();
  foreach ($result as $menu_item) {
    $matches[$menu_item->path] = check_plain($menu_item->title);
  }
  return $matches;
}