You are here

function linkit_node_linkit_get_search_styled_link in Linkit 7

Same name and namespace in other branches
  1. 6 plugins/linkit_node/linkit_node.module \linkit_node_linkit_get_search_styled_link()

Implements hook_linkit_get_search_styled_link().

File

plugins/linkit_node/linkit_node.module, line 107
Extend Linkit with node links.

Code

function linkit_node_linkit_get_search_styled_link($string) {

  // Check to see that the link really is a node link
  // Backwards compatible with internal: links
  $escaped_string = str_replace('internal:', '', $string);
  $splitted_string = explode('/', $escaped_string);
  if ($splitted_string[0] != 'node') {
    return;
  }

  // This is a node link created with Linkit, try to grab the title and path now.
  $result = db_select('node', 'n')
    ->fields('n', array(
    'title',
  ))
    ->condition('n.nid', $splitted_string[1])
    ->addTag('node_access')
    ->execute()
    ->fetchObject();

  // No reault was found
  if (!$result) {
    return;
  }
  return check_plain($result->title) . ' [path:' . $escaped_string . ']';
}