Index: ilovethis.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/ilovethis/ilovethis.module,v
retrieving revision 1.1
diff -u -r1.1 ilovethis.module
--- ilovethis.module 15 Nov 2007 13:44:55 -0000 1.1
+++ ilovethis.module 28 Dec 2007 22:23:52 -0000
@@ -142,7 +142,7 @@
break;
case 'view':
// add widget to the begin of the node body
- $node->content['body']['#value'] = ilovethis_widget($node->type, $node->nid, $view_all = 1). $node->content['body']['#value'];
+ $node->content['body']['#value'] = ilovethis_widget($node, $teaser, true) . $node->content['body']['#value'];
break;
}
}
@@ -303,7 +303,7 @@
$output .="
";
#print row below if you want to give an header to the "text node
@@ -314,23 +314,26 @@
return $output;
}
-function ilovethis_widget($type, $node = null, $view_all = false) {
+function ilovethis_widget($node, $teaser = false, $view_all = false) {
+ if (!$teaser && variable_get(ILOVETHIS_NODE_TYPE . $node->type, 0)) {
+ return theme('ilovethis_widget', $node, $view_all, _ilovethis_check($node->nid));
+ }
+}
+
+function theme_ilovethis_widget($node, $view_all, $check) {
global $user;
- if ( !$teaser) {
- if (variable_get(ILOVETHIS_NODE_TYPE . $type, 0)) {
- $widget ="
";
- $widget .="
";
- if (!_ilovethis_check($node)) {
- $widget .= l(t('I love this '.ucfirst ($type)), 'ilovethis/add/'. $node, array('class' => '', 'title' => t('Click here to give your love to this ' . ' '. ucfirst ($type))));
- } else {
- $widget .= l(t('I don\'t love this') ." " . ucfirst ($type) , 'ilovethis/delete/'. $node ."/". $user->uid, array('class' => '', 'title' => t('Click here to remove your love from this'. " " .ucfirst ($type))));
- }
- $widget .="
";
- if ($view_all==1){
- $widget .="
(".l(t('who loves this')." " . ucfirst ($type) ,"ilovethis/view/".$node, array('class' => '', 'title' => t('List of people loving this '. ucfirst ($type)))) .")
";
- }
- $widget .= "
";
- }
+ if ($check) {
+ $link = l(t("I don't love this !type", array('!type' => ucfirst($node->type))), 'ilovethis/delete/'. $node->nid ."/". $user->uid, array('class' => '', 'title' => t('Click here to remove your love from this !type', array('!type' => ucfirst($node->type)))));
+ }
+ else {
+ $link = l(t('I love this !type', array('!type' => ucfirst($node->type))), 'ilovethis/add/'. $node->nid, array('class' => '', 'title' => t('Click here to give your love to this !type', array('!type' => ucfirst($node->type)))));
}
- return $widget;
+ $output = '
';
+
+ if ($view_all) {
+ $link = l(t('who loves this !type', array('!type' => ucfirst($node->type))), 'ilovethis/view/'. $node->nid, array('class' => '', 'title' => t('List of people loving this !type', array('!type' => ucfirst($node->type)))));
+ $output .= '
('. $link .')
';
+ }
+
+ return '
'. $output .'
';
}