You are here

function freelinking_nodetitle_callback in Freelinking 6.3

Same name and namespace in other branches
  1. 7.3 plugins/freelinking_nodetitle.inc \freelinking_nodetitle_callback()

Replacement callback for nodetitle plugin

1 string reference to 'freelinking_nodetitle_callback'
freelinking_nodetitle.inc in plugins/freelinking_nodetitle.inc

File

plugins/freelinking_nodetitle.inc, line 20

Code

function freelinking_nodetitle_callback($target, $plugin) {
  $node = freelinking_nodetitle_nid_from_title($target);

  // if no node was found, identify proceed with configured failover
  if (!$node) {
    $target['target'] = check_plain($target['target']);
    $target['dest'] = check_plain($target['dest']);
    return _freelinking_nodetitle_failure($target);
  }

  // construct values for link
  $title = $target['text'] ? $target['text'] : $node->title;
  $title = check_plain($title);
  if (!$target['tooltip']) {
    $target['tooltip'] = freelinking_internal_tooltip('node', $node->nid);
  }

  // return link structure
  return array(
    $title,
    'node/' . $node->nid,
    array(
      'attributes' => array(
        'title' => $target['tooltip'],
      ),
      'language' => $node->language,
    ),
  );
}