'. t('Here you can configure the service links.') .'

'; break; } } /** * Implementation of hook_perm(). */ function service_links_perm() { return array('use service links'); } /** * Implementation of hook_settings(). */ 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_vigillar'] = array( '#type' => 'checkbox', '#title' => t('Show vigillar.se link'), '#return_value' => 1, '#default_value' => variable_get('service_links_show_vigillar', 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), ); //================================================== //Vlad Savitsky starts: $form['what_ru_links_to_show'] = array( '#type' => 'fieldset', '#title' => t('What russian bookmark links to show'), ); $form['what_ru_links_to_show']['service_links_show_slashdot'] = array( '#type' => 'checkbox', '#title' => t('Show Slashdot link'), '#return_value' => 1, '#default_value' => variable_get('service_links_show_slashdot', 0), ); $form['what_ru_links_to_show']['service_links_show_bobrdobr'] = array( '#type' => 'checkbox', '#title' => t('Show Bobrdobr link'), '#return_value' => 1, '#default_value' => variable_get('service_links_show_bobrdobr', 0), ); $form['what_ru_links_to_show']['service_links_show_newsland'] = array( '#type' => 'checkbox', '#title' => t('Show Newsland link'), '#return_value' => 1, '#default_value' => variable_get('service_links_show_newsland', 0), ); $form['what_ru_links_to_show']['service_links_show_smi2'] = array( '#type' => 'checkbox', '#title' => t('Show Smi2 link'), '#return_value' => 1, '#default_value' => variable_get('service_links_show_smi2', 0), ); $form['what_ru_links_to_show']['service_links_show_rumarkz'] = array( '#type' => 'checkbox', '#title' => t('Show Rumarkz link'), '#return_value' => 1, '#default_value' => variable_get('service_links_show_rumarkz', 0), ); $form['what_ru_links_to_show']['service_links_show_vaau'] = array( '#type' => 'checkbox', '#title' => t('Show Vaau link'), '#return_value' => 1, '#default_value' => variable_get('service_links_show_vaau', 0), ); $form['what_ru_links_to_show']['service_links_show_memori'] = array( '#type' => 'checkbox', '#title' => t('Show Memori link'), '#return_value' => 1, '#default_value' => variable_get('service_links_show_memori', 0), ); $form['what_ru_links_to_show']['service_links_show_rucity'] = array( '#type' => 'checkbox', '#title' => t('Show Rucity link'), '#return_value' => 1, '#default_value' => variable_get('service_links_show_rucity', 0), ); $form['what_ru_links_to_show']['service_links_show_moemesto'] = array( '#type' => 'checkbox', '#title' => t('Show Moemesto link'), '#return_value' => 1, '#default_value' => variable_get('service_links_show_moemesto', 0), ); $form['what_ru_links_to_show']['service_links_show_news2'] = array( '#type' => 'checkbox', '#title' => t('Show News2 link'), '#return_value' => 1, '#default_value' => variable_get('service_links_show_news2', 0), ); //Vlad Savitsky ends //================================================== $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($may_cache) { $items = array(); if ($may_cache) { $items[] = array( 'path' => 'admin/settings/servicelinks', 'title' => t('Service links'), 'description' => t('Control which and where service links should be active.'), 'callback' => 'drupal_get_form', 'callback arguments' => 'service_links_admin_settings', 'access' => user_access('administer site configuration'), '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->type, $node->nid); if ($links_show && user_access('use 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->type, $node->nid); if ($type == 'node' && $links_show && $show_links && user_access('use 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('use service links') && arg(0) == 'node' && is_numeric(arg(1))) { $node = node_load(arg(1)); $links_show = _service_links_show($node->type, $node->nid); if ($links_show) { $block['subject'] = t('Bookmark/Search this post'); $block['content'] = theme('service_links_block_format', service_links_render($node)); } return $block; } } } /** * 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 { $url = url("node/$node->nid", NULL, NULL, 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.'), 'delicious.gif', $nodelink); } //http://del.icio.us/post?v=4&noui&jump=close&url=$url&title=$title 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.'), 'digg.gif', $nodelink); } //http://digg.com/submit?url=$url /* if (variable_get('service_links_show_vigillar', 0)) { $links['service_links_vigillar'] = theme('service_links_build_link', t('Add new commentigillar'), "http://vigillar.se/submit?edit[url]=$url&edit[title]=$title", t('Submit this post on vigillar.se.'), 'vigillar.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.'), '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.'), '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.'), '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.'), '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.'), '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.'), '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.'), '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.'), 'technorati.png', $nodelink); } //http://technorati.com/faves?add=$url 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.'), '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); //Vlad Savitsky starts: //=============================================== //google /* $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.'), 'google.png', $nodelink); Есть ещё параметры: *&title= - было пустым *&labels= - было пустым *&annotation=$title */ //=============================================== //slashdot if (variable_get('service_links_show_slashdot', 0)) { $links['service_links_slashdot'] = theme('service_links_build_link', t('Slashdot'), "http://www.slashdot.org/bookmark.pl?url=$url&title=$title", t('Bookmark this post on Slashdot.'), 'slashdot.gif', $nodelink); } //=============================================== //bobrdobr.ru //Выбор кнопки: http://bobrdobr.ru/counters.html //Сохранить страницу на сервисе закладок Bobrdobr.Ru! //Забобрить эту страницу! //Изображение: http://static.bobrdobr.ru/images/buttons/bobr_sml_blu_3.gif if (variable_get('service_links_show_bobrdobr', 0)) { $links['service_links_bobrdobr'] = theme('service_links_build_link', t('Bobrdobr'), "http://www.bobrdobr.ru/addext.html?url=$url&title=$title", t('Bookmark this post on bobrdobr.ru.'), 'bobr_sml_blu_3.gif', $nodelink); } //=============================================== //Добавить на Newsland.ru if (variable_get('service_links_show_newsland', 0)) { $links['service_links_newsland'] = theme('service_links_build_link', t('Newsland'), "http://www.newsland.ru/News/Add/", t('Bookmark this post on newsland.ru.'), 'newsland.gif', $nodelink); } //=============================================== //Добавить на СМИ2 if (variable_get('service_links_show_smi2', 0)) { $links['service_links_smi2'] = theme('service_links_build_link', t('Smi2'), "http://smi2.ru/add/", t('Bookmark this post on smi2.ru.'), 'smi2.gif', $nodelink); } //=============================================== //Добавить на RUmarkz //сохранить на RUmarkz if (variable_get('service_links_show_rumarkz', 0)) { $links['service_links_rumarkz'] = theme('service_links_build_link', t('Rumarkz'), "http://rumarkz.ru/bookmarks/?action=add&popup=1&address=$url&title=$title&description=", t('Bookmark this post on rumarkz.ru.'), 'rumark.png', $nodelink); } /* сохранить на RUmarkz */ //=============================================== //Добавить на Ваау! if (variable_get('service_links_show_vaau', 0)) { $links['service_links_vaau'] = theme('service_links_build_link', t('Vaau'), "http://www.vaau.ru/submit/?action=step2&url=$url", t('Bookmark this post on vaau.ru.'), 'vaau.gif', $nodelink); } //=============================================== //Добавить на Memori.ru if (variable_get('service_links_show_memori', 0)) { $links['service_links_memori'] = theme('service_links_build_link', t('Memori'), "http://memori.ru/link/?sm=1&u_data[url]=$url&u_data[name]=$title", t('Bookmark this post on Memori.ru.'), 'memori.gif', $nodelink); } //=============================================== //Добавить на rucity.com if (variable_get('service_links_show_rucity', 0)) { $links['service_links_rucity'] = theme('service_links_build_link', t('Rucity'), "http://www.rucity.com/bookmarks.php?action=add&address=$url&title=$title", t('Bookmark this post on rucity.com.'), 'rucity.gif', $nodelink); } //=============================================== //Добавить в закладки МоёМесто.ru //http://moemesto.ru/icons/mm_icon.gif //Добавить в МоёМесто.ru if (variable_get('service_links_show_moemesto', 0)) { $links['service_links_moemesto'] = theme('service_links_build_link', t('Moemesto'), "http://moemesto.ru/post.php?url=$url&title=$title", t('Bookmark this post on moemesto.ru.'), 'mm_icon.gif', $nodelink); } //=============================================== //Добавить на news2.ru if (variable_get('service_links_show_news2', 0)) { $links['service_links_news2'] = theme('service_links_build_link', t('News2'), "http://news2.ru/add_story.php?url=$url", t('Bookmark this post on news2.'), 'news2.gif', $nodelink); } //Vlad Savitsky ends 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 theme('item_list', $items); } /** * Build a 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($type, $nid) { $links_show = FALSE; $node_type = in_array($type, variable_get('service_links_node_types', array()), TRUE); if (module_exists('taxonomy')) { $terms = taxonomy_node_get_terms($nid); 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; }