function forward_link in Forward 5
Same name and namespace in other branches
- 6 forward.module \forward_link()
Generate links for pages
File
- ./
forward.module, line 768
Code
function forward_link($type, $node = 0, $teaser = 0) {
if ('comment' == $type && !variable_get('forward_display_comments', false)) {
return;
}
if (($type == 'node' || $type == 'comment') && user_access('access forward') && variable_get('forward_form_type', 'link') == 'link' && variable_get('forward_display_' . $node->type, '1')) {
$links = array();
if ($type == 'system') {
// URL, page title, func called for page content, arg, 1 = don't disp menu
menu('forward', t(variable_get('forward_link_title', 'Email this !type'), array(
'!type' => 'page',
)), 'forward_page', 1, 1);
}
// This var is set in the settings section under the admin/modules/forward section
// It shows 'email this $nodetype' or 'email this page'
if (variable_get('forward_link_type', 0)) {
$forward_link_type = $type == 'comment' ? t('comment') : node_get_types("name", $node);
}
else {
$forward_link_type = $type == 'comment' ? t('comment') : t('page');
}
if (!$teaser || variable_get('forward_display_teasers', 0)) {
drupal_add_css(drupal_get_path('module', 'forward') . '/forward.css');
$title = t(variable_get('forward_link_title', 'Email this !type'), array(
'!type' => $forward_link_type,
));
$img = drupal_get_path('module', 'forward') . '/forward.gif';
$html = false;
switch (variable_get('forward_link_style', 0)) {
case 1:
$title = theme('image', $img, $title, '', array(
'class' => 'forward-icon',
));
$html = true;
break;
case 2:
$title = theme('image', $img, $title, '', array(
'class' => 'forward-icon forward-icon-margin',
)) . $title;
$html = true;
break;
}
$path = 'node/' . $node->nid;
$cid = $type == 'comment' ? '&cid=' . $node->cid : NULL;
$links['forward_links'] = array(
'title' => $title,
'href' => 'forward',
'html' => $html,
'attributes' => array(
'title' => t('Forward this page to a friend'),
'class' => 'forward-page',
),
'query' => 'path=' . $path . $cid,
);
return $links;
}
}
}