'. t('Display links to social sharing websites like Digg, del.icio.us, reddit, Technorati etc.') .'

'; break; case "admin/modules#description": return '

'. t('Control which and where service links should be active.') .'

'; } } /** * Implementation of hook_perm(). */ function service_links_perm() { return array('access service links', 'administer service links'); } function service_links_admin_settings() { $form['where_to_show_the_links'] = array( '#type' => 'fieldset', '#title' => t('Where to show the service links'), '#description' => t('Set the node types and categories you want to display links for.'), ); $form['where_to_show_the_links']['service_links_node_types'] = array( '#type' => 'checkboxes', '#title' => t('Node types'), '#default_value' => variable_get('service_links_node_types', array()), '#options' => node_get_types('names'), ); if (module_exists('taxonomy')) { $form['where_to_show_the_links']['service_links_category_types'] = array( '#type' => 'select', '#multiple' => TRUE, '#title' => t('Categories'), '#default_value' => variable_get('service_links_category_types', array()), '#options' => _service_links_get_terms(), ); } $form['what_links_to_show'] = array( '#type' => 'fieldset', '#title' => t('What bookmark links to show'), ); $form['what_links_to_show']['service_links_show_delicious'] = array( '#type' => 'checkbox', '#title' => t('Show del.icio.us link'), '#return_value' => 1, '#default_value' => variable_get('service_links_show_delicious', 1), ); $form['what_links_to_show']['service_links_show_digg'] = array( '#type' => 'checkbox', '#title' => t('Show Digg link'), '#return_value' => 1, '#default_value' => variable_get('service_links_show_digg', 1), ); $form['what_links_to_show']['service_links_show_stumbleupon'] = array( '#type' => 'checkbox', '#title' => t('Show StumbleUpon link'), '#return_value' => 1, '#default_value' => variable_get('service_links_show_stumbleupon', 0), ); $form['what_links_to_show']['service_links_show_propeller'] = array( '#type' => 'checkbox', '#title' => t('Show Propeller link'), '#return_value' => 1, '#default_value' => variable_get('service_links_show_propeller', 0), ); $form['what_links_to_show']['service_links_show_reddit'] = array( '#type' => 'checkbox', '#title' => t('Show Reddit link'), '#return_value' => 1, '#default_value' => variable_get('service_links_show_reddit', 0), ); $form['what_links_to_show']['service_links_show_magnoliacom'] = array( '#type' => 'checkbox', '#title' => t('Show ma.gnolia.com link'), '#return_value' => 1, '#default_value' => variable_get('service_links_show_magnoliacom', 0), ); $form['what_links_to_show']['service_links_show_newsvine'] = array( '#type' => 'checkbox', '#title' => t('Show Newsvine link'), '#return_value' => 1, '#default_value' => variable_get('service_links_show_newsvine', 0), ); $form['what_links_to_show']['service_links_show_furl'] = array( '#type' => 'checkbox', '#title' => t('Show Furl link'), '#return_value' => 1, '#default_value' => variable_get('service_links_show_furl', 0), ); $form['what_links_to_show']['service_links_show_facebook'] = array( '#type' => 'checkbox', '#title' => t('Show Facebook link'), '#return_value' => 1, '#default_value' => variable_get('service_links_show_facebook', 0), ); $form['what_links_to_show']['service_links_show_google'] = array( '#type' => 'checkbox', '#title' => t('Show Google link'), '#return_value' => 1, '#default_value' => variable_get('service_links_show_google', 0), ); $form['what_links_to_show']['service_links_show_yahoo'] = array( '#type' => 'checkbox', '#title' => t('Show Yahoo link'), '#return_value' => 1, '#default_value' => variable_get('service_links_show_yahoo', 0), ); $form['what_links2_to_show'] = array( '#type' => 'fieldset', '#title' => t('What search links to show'), ); $form['what_links2_to_show']['service_links_show_technorati'] = array( '#type' => 'checkbox', '#title' => t('Show Technorati link'), '#return_value' => 1, '#default_value' => variable_get('service_links_show_technorati', 1), ); $form['what_links2_to_show']['service_links_show_icerocket'] = array( '#type' => 'checkbox', '#title' => t('Show IceRocket link'), '#return_value' => 1, '#default_value' => variable_get('service_links_show_icerocket', 0), ); $form['how_to_show_the_links'] = array( '#type' => 'fieldset', '#title' => t('When and how to show the links'), ); $form['how_to_show_the_links']['service_links_in_links'] = array( '#type' => 'select', '#title' => t('Service links in links'), '#default_value' => variable_get('service_links_in_links', 0), '#options' => array(0 => t('Disabled'), 1 => t('Teaser view'), 2 => t('Full-page view'), 3 => t('Teasers and full-page view')), '#description' => t('When to display the services in the links section.'), ); $form['how_to_show_the_links']['service_links_in_node'] = array( '#type' => 'select', '#title' => t('Service links in nodes'), '#default_value' => variable_get('service_links_in_node', 2), '#options' => array(0 => t('Disabled'), 1 => t('Teaser view'), 2 => t('Full-page view'), 3 => t('Teasers and full-page view')), '#description' => t('When to display the services after the node text.'), ); $form['how_to_show_the_links']['service_links_style'] = array( '#type' => 'select', '#title' => t('Service links style'), '#default_value' => variable_get('service_links_style', 1), '#options' => array(1 => t('Text links'), 2 => t('Image links'), 3 => t('Image and text links')), ); if (module_exists('aggregator2')) { $form['aggregator2_settings'] = array( '#type' => 'fieldset', '#title' => t('Aggregator2 settings'), ); $form['aggregator2_settings']['service_links_agg2_link'] = array( '#type' => 'checkbox', '#title' => t('Use link to original article aggregated by aggregator2 module'), '#return_value' => 1, '#default_value' => variable_get('service_links_agg2_link', 0), ); } return system_settings_form($form); } /** * Implementation of hook_menu(). */ function service_links_menu() { $items = array(); $items['admin/settings/servicelinks'] = array( 'title' => 'Service links', 'description' => 'Control which and where service links should be active.', 'page callback' => 'drupal_get_form', 'page arguments' => array('service_links_admin_settings'), 'access arguments' => array('administer service links'), 'type' => MENU_NORMAL_ITEM, ); return $items; } /** * Implementation of hook_nodeapi(). */ function service_links_nodeapi(&$node, $op, $teaser, $page) { switch ($op) { case 'view': $links_show = _service_links_show($node); if ($links_show && user_access('access service links')) { switch (variable_get('service_links_in_node', 0)) { case 1: if ($teaser) { $node->content['service_links'] = array( '#value' => theme('service_links_node_format', service_links_render($node, TRUE)), '#weight' => 10, ); } break; case 2: if ($page) { $node->content['service_links'] = array( '#value' => theme('service_links_node_format', service_links_render($node, TRUE)), '#weight' => 10, ); } break; case 3: if ($teaser) { $node->content['service_links'] = array( '#value' => theme('service_links_node_format', service_links_render($node, TRUE)), '#weight' => 10, ); } else if ($page) { $node->content['service_links'] = array( '#value' => theme('service_links_node_format', service_links_render($node, TRUE)), '#weight' => 10, ); } break; } } break; } } /** * Implementation of hook_link(). */ function service_links_link($type, $node = NULL, $teaser = FALSE) { $links = array(); switch (variable_get('service_links_in_links', 0)) { case 0: $show_links = FALSE; break; case 1: $show_links = $teaser ? TRUE : FALSE; break; case 2: $show_links = $teaser ? FALSE : TRUE; break; case 3: $show_links = TRUE; break; default: $show_links = FALSE; } $links_show = _service_links_show($node); if ($type == 'node' && $links_show && $show_links && user_access('access service links')) { $links = service_links_render($node, TRUE); } return $links; } /** * Implementation of hook_block(). */ function service_links_block($op = 'list', $delta = 0, $edit = array()) { if ($op == 'list') { $blocks[0]['info'] = t('Service links'); return $blocks; } else if ($op == 'view') { if (user_access('access service links') && arg(0) == 'node' && is_numeric(arg(1))) { $node = node_load(arg(1)); $links_show = _service_links_show($node); if ($links_show) { $block['subject'] = t('Bookmark/Search this post'); $block['content'] = theme('service_links_block_format', service_links_render($node)); } return $block; } } } /** * Implementation of hook_theme(). */ function service_links_theme() { return array( 'service_links_build_link' => array( 'arguments' => array( 'text' => NULL, 'url' => NULL, 'title' => NULL, 'image' => NULL, 'nodelink' => NULL, ), ), 'service_links_node_format' => array( 'arguments' => array('links' => NULL), ), 'service_links_block_format' => array( 'arguments' => array('items' => NULL), ), ); } /** * Function that renders the service links. * This is the function themers want to call to insert the service links. */ function service_links_render($node, $nodelink = FALSE) { $links = array(); if (variable_get('service_links_agg2_link', 0) && $node->link) { $url = ($node->source_link ? $node->source_link : $node->link); } else if (!empty($node)) { $url = url("node/$node->nid", array('absolute' => TRUE)); } else { $url = url($_GET['q'], array('absolute' => TRUE)); } $url = urlencode($url); $title = urlencode($node->title); if (variable_get('service_links_show_delicious', 0)) { $links['service_links_delicious'] = theme('service_links_build_link', t('Delicious'), "http://del.icio.us/post?url=$url&title=$title", t('Bookmark this post on del.icio.us.'), 'images/delicious.png', $nodelink); } if (variable_get('service_links_show_digg', 0)) { $links['service_links_digg'] = theme('service_links_build_link', t('Digg'), "http://digg.com/submit?phase=2&url=$url&title=$title", t('Digg this post on digg.com.'), 'images/digg.png', $nodelink); } if (variable_get('service_links_show_stumbleupon', 0)) { $links['service_links_stumbleupon'] = theme('service_links_build_link', t('StumbleUpon'), "http://www.stumbleupon.com/submit?url=$url&title=$title", t('Thumb this up at StumbleUpon.'), 'images/stumbleit.png', $nodelink); } if (variable_get('service_links_show_propeller', 0)) { $links['service_links_propeller'] = theme('service_links_build_link', t('Propeller'), "http://www.propeller.com/submit/?U=$url&T=$title", t('Submit to Propeller.'), 'images/propeller.png', $nodelink); } if (variable_get('service_links_show_reddit', 0)) { $links['service_links_reddit'] = theme('service_links_build_link', t('Reddit'), "http://reddit.com/submit?url=$url&title=$title", t('Submit this post on reddit.com.'), 'images/reddit.png', $nodelink); } if (variable_get('service_links_show_magnoliacom', 0)) { $links['service_links_magnoliacom'] = theme('service_links_build_link', t('Magnoliacom'), "http://ma.gnolia.com/bookmarklet/add?url=$url&title=$title", t('Submit this post on ma.gnolia.com.'), 'images/magnoliacom.png', $nodelink); } if (variable_get('service_links_show_newsvine', 0)) { $links['service_links_newsvine'] = theme('service_links_build_link', t('Newsvine'), "http://www.newsvine.com/_tools/seed&save?u=$url&h=$title", t('Submit this post on newsvine.com.'), 'images/newsvine.png', $nodelink); } if (variable_get('service_links_show_furl', 0)) { $links['service_links_furl'] = theme('service_links_build_link', t('Furl'), "http://www.furl.net/storeIt.jsp?u=$url&t=$title", t('Submit this post on furl.net.'), 'images/furl.png', $nodelink); } if (variable_get('service_links_show_facebook', 0)) { $links['service_links_facebook'] = theme('service_links_build_link', t('Facebook'), "http://www.facebook.com/sharer.php?u=$url&t=$title", t('Share on Facebook.'), 'images/facebook.png', $nodelink); } if (variable_get('service_links_show_google', 0)) { $links['service_links_google'] = theme('service_links_build_link', t('Google'), "http://www.google.com/bookmarks/mark?op=add&bkmk=$url&title=$title", t('Bookmark this post on Google.'), 'images/google.png', $nodelink); } if (variable_get('service_links_show_yahoo', 0)) { $links['service_links_yahoo'] = theme('service_links_build_link', t('Yahoo'), "http://myweb2.search.yahoo.com/myresults/bookmarklet?u=$url&t=$title", t('Bookmark this post on Yahoo.'), 'images/yahoo.png', $nodelink); } if (variable_get('service_links_show_technorati', 0)) { $links['service_links_technorati'] = theme('service_links_build_link', t('Technorati'), "http://technorati.com/cosmos/search.html?url=$url", t('Search Technorati for links to this post.'), 'images/technorati.png', $nodelink); } if (variable_get('service_links_show_icerocket', 0)) { $links['service_links_icerocket'] = theme('service_links_build_link', t('Icerocket'), "http://blogs.icerocket.com/search?q=$url", t('Search IceRocket for links to this post.'), 'images/icerocket.png', $nodelink); } // Add your own link by modifing the link below and uncomment it. //$links['service_links_delicious'] = theme('service_links_build_link', t('Delicious'), "http://del.icio.us/post?url=$url&title=$title", t('Bookmark this post on del.icio.us.'), 'delicious.png', $nodelink); return $links; } function theme_service_links_build_link($text, $url, $title, $image, $nodelink) { global $base_path; if ($nodelink) { switch (variable_get('service_links_style', 1)) { case 1: $link = array( 'title' => $text, 'href' => $url, 'attributes' => array('title' => $title, 'rel' => 'nofollow') ); break; case 2: $link = array( 'title' => ''. $text .'', 'href' => $url, 'attributes' => array('title' => $title, 'rel' => 'nofollow'), 'html' => TRUE ); break; case 3: $link = array( 'title' => ''. $text .' '. $text, 'href' => $url, 'attributes' => array('title' => $title, 'rel' => 'nofollow'), 'html' => TRUE ); break; } } else { switch (variable_get('service_links_style', 1)) { case 1: $link = ''. $text .''; break; case 2: $link = ''. $text .''; break; case 3: $link = ''. $text .' '. $text .''; break; } } return $link; } function theme_service_links_node_format($links) { return ''; } function theme_service_links_block_format($items) { return ''; } /** * Build an array of all taxonomy terms. */ function _service_links_get_terms() { $types = array(); $vocabularies = taxonomy_get_vocabularies(); foreach ($vocabularies as $vocabulary) { $tree = taxonomy_get_tree($vocabulary->vid); foreach ($tree as $term) { $types[$term->tid] = $term->name; } } return $types; } /** * Check if the service links should be displayed for the node type/category. */ function _service_links_show($node) { $links_show = FALSE; $category_type = FALSE; $node_type = in_array($node->type, variable_get('service_links_node_types', array()), TRUE); if (module_exists('taxonomy')) { $terms = taxonomy_node_get_terms($node); foreach ($terms as $term) { $category_type |= in_array($term->tid, variable_get('service_links_category_types', array()), FALSE); } } if ($node_type || $category_type) { $links_show = TRUE; } return $links_show; }