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:57:06 -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; } } @@ -230,8 +230,29 @@ * Page to display a user's loved node list. */ function ilovethis_view_page() { - $nid = arg(2); - $output = theme('ilovethis_view_' . variable_get(ILOVETHIS_PAGE_TYPE, 'table'), ilovethis_get($nid), $nid); + $node = node_load($nid = arg(2)); + + $header = array(t('User'), t('Added')); + + $rows = array(); + $row = ilovethis_get($nid); + if (isset($row)) { + foreach ($row as $nid => $data) { + $username = db_fetch_object(db_query("SELECT name FROM {users} WHERE uid = %d", $data->uid)); + $title = array(l($username->name, 'user/'. $data->uid), format_date($data->last, 'custom', 'Y-m-d H:i')); + global $user; + if ($user->uid == $data->uid || $user->uid == 1) { + $delete = array(l(t('delete'), 'ilovethis/delete/'. $node->nid. '/'. $data->uid)); + $result = array_merge($title, $delete); + $header[] = t('Action'); + } + else { + $result = $title; + } + $rows[] = array('data' => $result); + } + } + $output = theme('ilovethis_view_' . variable_get(ILOVETHIS_PAGE_TYPE, 'table'), $node, $header, $rows); print theme('page', $output); } @@ -258,79 +279,41 @@ /** * Table which displays loved node lists. */ -function theme_ilovethis_view_table($row = array(), $nid) { - global $user; - - $node = array(); - $node= node_load($nid); - - $header = array( t('User'), t('Added')); - - $rows = array(); - if (isset($row)) { - - unset ($you_love_this); - foreach($row as $nid => $data) { - $tmp_sql = "SELECT name FROM {users} WHERE uid = '".$data->uid."'"; - $tmp_res = db_query(db_rewrite_sql($tmp_sql)); - $username = db_fetch_object($tmp_res); - $username = $username->name; - - $title = array( l($username, "user/".$data->uid) , format_date($data->last, 'custom', 'Y-m-d H:i')); - if ($user->uid == $data->uid || $user->uid == 1) { - $delete = array(l(t('delete'), "ilovethis/delete/".$node->nid. "/". $data->uid )); - $result = array_merge($title, $delete); - $header = array( t('User'), t('Added'), t('Action')); - } - else { - $result = $title; - } - $rows[] = array('data' => $result); +function theme_ilovethis_view_table($node, $header, $rows) { + if (count($rows) > 0) { + $ilovethis .= theme('table', $header, $rows); + $ilovethis .= theme('pager'); + } + else { + $ilovethis .= t('None (yet) loves this !type', array('!type' => $node->type)); + } + $ilovethis .= '
(".l(t('who loves this')." " . ucfirst ($type) ,"ilovethis/view/".$node, array('class' => '', 'title' => t('List of people loving this '. ucfirst ($type)))) .")
"; - } - $widget .= "('. $link .')
'; + } + + return '