--- favorite_nodes.module_old Thu Apr 17 18:33:41 2008 +++ favorite_nodes.module Thu Apr 17 18:45:25 2008 @@ -12,6 +12,7 @@ define('FAVORITE_NODES_PAGE_LIMIT', define('FAVORITE_NODES_PROFILE_LIMIT', 'favorite_nodes_profile_limit'); define('FAVORITE_NODES_PAGE_TYPE', 'favorite_nodes_page_type'); define('FAVORITE_NODES_MENUS', 'favorite_nodes_menu'); +define('FAVORITE_NODES_SHOWLINK', 'favorite_nodes_showlink'); /** * Implementation of hook_help(). @@ -264,18 +265,10 @@ function favorite_nodes_block($op = 'lis function favorite_nodes_link($type, $node = null, $teaser = false) { global $user; $links = array(); - if ($type == 'node' && !$teaser) { + if ($type == 'node' && !$teaser && variable_get(FAVORITE_NODES_SHOWLINK, 1)) { if (variable_get(FAVORITE_NODES_NODE_TYPE . $node->type, 0)) { if (user_access(FAVORITE_NODES_PERM_ADD)) { - if (!_favorite_nodes_check($node->nid)) { - $links[] = array('title' => t('add to favorites'), 'href' => 'favorite_nodes/add/'. $node->nid); - } - else { - if (user_access(FAVORITE_NODES_PERM_VIEW)) { - $links[] = array('title' => t('in favorites')); - $links[] = array('title' => t('remove from favorites'), 'href' => 'favorite_nodes/delete/'. $node->nid); - } - } + $links = theme('favorite_nodes_links',$node); } } } @@ -283,6 +276,23 @@ function favorite_nodes_link($type, $nod } /** + * Allow theming of links(). + */ +function theme_favorite_nodes_links($node) { + if (!_favorite_nodes_check($node->nid)) { + $links[] = array('title' => t('add to favorites'), 'href' => 'favorite_nodes/add/'. $node->nid); + } + else { + if (user_access(FAVORITE_NODES_PERM_VIEW)) { + $links[] = array('title' => t('in favorites')); + $links[] = array('title' => t('remove from favorites'), 'href' => 'favorite_nodes/delete/'. $node->nid); + } + } + + return $links; +} + +/** * Settings page for this module. */ function favorite_nodes_settings() { @@ -322,6 +332,14 @@ function favorite_nodes_settings() { '#return_value' => 1, '#default_value' => variable_get(FAVORITE_NODES_MENUS, 0), '#description' => t('Whether to show a menu item in the navigation block for each node type?'), + ); + + $form[$set][FAVORITE_NODES_SHOWLINK] = array( + '#type' => 'checkbox', + '#title' => t('Display Favorite Node options as links'), + '#return_value' => 1, + '#default_value' => variable_get(FAVORITE_NODES_SHOWLINK, 1), + '#description' => t('Whether to show link items in the node view?'), ); $set = 'types';