function rate_link in Rate 6.2
Implements hook_link()
File
- ./
rate.module, line 617 - Rate module
Code
function rate_link($type, $object, $teaser = FALSE) {
$links = array();
// Adding widget to node links
if ($type == 'node') {
$widgets = rate_get_active_widgets('node', $object->type, $teaser);
foreach ($widgets as $widget_id => $widget) {
_rate_check_widget($widget);
$widget_name = 'rate_' . $widget->name;
$display_mode = $teaser ? $widget->teaser_display_mode : $widget->node_display_mode;
$widget_code = rate_generate_widget($widget_id, 'node', $object->nid, $display_mode);
if ($widget->node_display == RATE_DISPLAY_LINKS) {
$links[$widget_name] = array(
'title' => $widget_code,
'html' => TRUE,
);
}
}
}
// Adding widget to comment links
if ($type == 'comment') {
$node = node_load($object->nid);
$widgets = rate_get_active_widgets('comment', $node->type);
foreach ($widgets as $widget_id => $widget) {
_rate_check_widget($widget);
$widget_name = 'rate_' . $widget->name;
$widget_code = rate_generate_widget($widget_id, 'comment', $object->cid, $widget->comment_display_mode);
if ($widget->comment_display == RATE_DISPLAY_LINKS) {
$links[$widget_name] = array(
'title' => $widget_code,
'html' => TRUE,
);
}
}
}
return $links;
}