freelinking_nid.inc in Freelinking 6.3
File
plugins/freelinking_nid.inc
View source
<?php
$freelinking['nid'] = array(
'indicator' => '/(n(id|ode)?)$/A',
'callback' => 'freelinking_nid_callback',
'tip' => t('Link to a local node by nid'),
'run on view' => TRUE,
);
function freelinking_nid_callback($target, $plugin) {
if (is_numeric($target['dest'])) {
$params = array(
'nid' => $target['dest'],
);
if ($node = node_load($params)) {
if (node_access('view', $node)) {
$title = $target['text'] ? $target['text'] : $node->title;
if (!$target['tooltip']) {
$target['tooltip'] = freelinking_internal_tooltip('node', $target['dest']);
}
return array(
check_plain($title),
'node/' . $target['dest'],
array(
'attributes' => array(
'title' => $target['tooltip'],
),
),
);
}
}
}
return array(
'failover' => 'error',
'message' => t('Invalid Node ID "!nid"', array(
'!nid' => $target['dest'],
)),
);
}