function _freelinking_make_link in Freelinking 6
Same name and namespace in other branches
- 5 freelinking.module \_freelinking_make_link()
- 6.2 freelinking.module \_freelinking_make_link()
2 calls to _freelinking_make_link()
File
- ./
freelinking.module, line 561
Code
function _freelinking_make_link($thetitle) {
// helper function for freelinking_page
global $user;
$freelink = array(
'options' => array(),
);
// ensure that 'options' is an array
// Returns a link to a node named $thetitle if found, or a link to new content otherwise.
$nid = _freelinking_exists($thetitle);
if ($nid) {
// the node exists, set the path to go there
$freelink['path'] = 'node/' . $nid;
}
else {
// node doesn't exist, set path to create it
switch (variable_get('freelinking_notfound', 'no access search')) {
case 'create only':
$freelink['path'] = 'node/add/' . variable_get('freelinking_nodetype', 'story');
$freelink['path'] = str_replace('_', '-', $freelink['path']);
$freelink['options'] = array(
'query' => 'edit[title]=' . str_replace('&', '%26', $thetitle),
);
break;
case 'no access search':
if (node_access('create', variable_get('freelinking_nodetype', 'story'))) {
$freelink['path'] = 'node/add/' . variable_get('freelinking_nodetype', 'story');
$freelink['path'] = str_replace('_', '-', $freelink['path']);
$freelink['options'] = array(
'query' => 'edit[title]=' . $thetitle,
);
}
else {
$freelink['path'] = 'search/node/' . $thetitle;
}
break;
case 'always search':
$freelink['path'] = 'search/node/' . $thetitle;
break;
}
// endswitch notfound options
return $freelink;
}
_freelinking_store($thetitle, $freelink['path'], isset($freelink['args']) ? $freelink['args'] : '');
return $freelink;
}