| 1 |
<?php
|
| 2 |
// $Id: service_links.module,v 1.25 2008/01/31 17:47:09 apsivam Exp $
|
| 3 |
|
| 4 |
/**
|
| 5 |
* @file
|
| 6 |
* Current Maintainer: Sivanandhan, P. apsivam .at. apsivam .dot. in
|
| 7 |
* Original Author: Fredrik Jonsson fredrik at combonet dot se
|
| 8 |
* A module that adds Digg, del.icio.us, reddit, Technorati etc. links to nodes.
|
| 9 |
*/
|
| 10 |
|
| 11 |
/**
|
| 12 |
* Implementation of hook_help().
|
| 13 |
*/
|
| 14 |
function service_links_help($path, $arg) {
|
| 15 |
switch ($path) {
|
| 16 |
case 'admin/help#service_links':
|
| 17 |
return '<p>'. t('Display links to social sharing websites like Digg, del.icio.us, reddit, Technorati etc.') .'</p>';
|
| 18 |
break;
|
| 19 |
case "admin/modules#description":
|
| 20 |
return '<p>'. t('Control which and where service links should be active.') .'</p>';
|
| 21 |
}
|
| 22 |
}
|
| 23 |
|
| 24 |
/**
|
| 25 |
* Implementation of hook_perm().
|
| 26 |
*/
|
| 27 |
function service_links_perm() {
|
| 28 |
return array('access service links', 'administer service links');
|
| 29 |
}
|
| 30 |
|
| 31 |
function service_links_admin_settings() {
|
| 32 |
|
| 33 |
$form['where_to_show_the_links'] = array(
|
| 34 |
'#type' => 'fieldset',
|
| 35 |
'#title' => t('Where to show the service links'),
|
| 36 |
'#description' => t('Set the node types and categories you want to display links for.'),
|
| 37 |
);
|
| 38 |
$form['where_to_show_the_links']['service_links_node_types'] = array(
|
| 39 |
'#type' => 'checkboxes',
|
| 40 |
'#title' => t('Node types'),
|
| 41 |
'#default_value' => variable_get('service_links_node_types', array()),
|
| 42 |
'#options' => node_get_types('names'),
|
| 43 |
);
|
| 44 |
if (module_exists('taxonomy')) {
|
| 45 |
$form['where_to_show_the_links']['service_links_category_types'] = array(
|
| 46 |
'#type' => 'select',
|
| 47 |
'#multiple' => TRUE,
|
| 48 |
'#title' => t('Categories'),
|
| 49 |
'#default_value' => variable_get('service_links_category_types', array()),
|
| 50 |
'#options' => _service_links_get_terms(),
|
| 51 |
);
|
| 52 |
}
|
| 53 |
|
| 54 |
$form['what_links_to_show'] = array(
|
| 55 |
'#type' => 'fieldset',
|
| 56 |
'#title' => t('What bookmark links to show'),
|
| 57 |
);
|
| 58 |
$form['what_links_to_show']['service_links_show_delicious'] = array(
|
| 59 |
'#type' => 'checkbox',
|
| 60 |
'#title' => t('Show del.icio.us link'),
|
| 61 |
'#return_value' => 1,
|
| 62 |
'#default_value' => variable_get('service_links_show_delicious', 1),
|
| 63 |
);
|
| 64 |
$form['what_links_to_show']['service_links_show_digg'] = array(
|
| 65 |
'#type' => 'checkbox',
|
| 66 |
'#title' => t('Show Digg link'),
|
| 67 |
'#return_value' => 1,
|
| 68 |
'#default_value' => variable_get('service_links_show_digg', 1),
|
| 69 |
);
|
| 70 |
$form['what_links_to_show']['service_links_show_stumbleupon'] = array(
|
| 71 |
'#type' => 'checkbox',
|
| 72 |
'#title' => t('Show StumbleUpon link'),
|
| 73 |
'#return_value' => 1,
|
| 74 |
'#default_value' => variable_get('service_links_show_stumbleupon', 0),
|
| 75 |
);
|
| 76 |
$form['what_links_to_show']['service_links_show_propeller'] = array(
|
| 77 |
'#type' => 'checkbox',
|
| 78 |
'#title' => t('Show Propeller link'),
|
| 79 |
'#return_value' => 1,
|
| 80 |
'#default_value' => variable_get('service_links_show_propeller', 0),
|
| 81 |
);
|
| 82 |
$form['what_links_to_show']['service_links_show_reddit'] = array(
|
| 83 |
'#type' => 'checkbox',
|
| 84 |
'#title' => t('Show Reddit link'),
|
| 85 |
'#return_value' => 1,
|
| 86 |
'#default_value' => variable_get('service_links_show_reddit', 0),
|
| 87 |
);
|
| 88 |
$form['what_links_to_show']['service_links_show_magnoliacom'] = array(
|
| 89 |
'#type' => 'checkbox',
|
| 90 |
'#title' => t('Show ma.gnolia.com link'),
|
| 91 |
'#return_value' => 1,
|
| 92 |
'#default_value' => variable_get('service_links_show_magnoliacom', 0),
|
| 93 |
);
|
| 94 |
$form['what_links_to_show']['service_links_show_newsvine'] = array(
|
| 95 |
'#type' => 'checkbox',
|
| 96 |
'#title' => t('Show Newsvine link'),
|
| 97 |
'#return_value' => 1,
|
| 98 |
'#default_value' => variable_get('service_links_show_newsvine', 0),
|
| 99 |
);
|
| 100 |
$form['what_links_to_show']['service_links_show_furl'] = array(
|
| 101 |
'#type' => 'checkbox',
|
| 102 |
'#title' => t('Show Furl link'),
|
| 103 |
'#return_value' => 1,
|
| 104 |
'#default_value' => variable_get('service_links_show_furl', 0),
|
| 105 |
);
|
| 106 |
$form['what_links_to_show']['service_links_show_facebook'] = array(
|
| 107 |
'#type' => 'checkbox',
|
| 108 |
'#title' => t('Show Facebook link'),
|
| 109 |
'#return_value' => 1,
|
| 110 |
'#default_value' => variable_get('service_links_show_facebook', 0),
|
| 111 |
);
|
| 112 |
$form['what_links_to_show']['service_links_show_google'] = array(
|
| 113 |
'#type' => 'checkbox',
|
| 114 |
'#title' => t('Show Google link'),
|
| 115 |
'#return_value' => 1,
|
| 116 |
'#default_value' => variable_get('service_links_show_google', 0),
|
| 117 |
);
|
| 118 |
$form['what_links_to_show']['service_links_show_yahoo'] = array(
|
| 119 |
'#type' => 'checkbox',
|
| 120 |
'#title' => t('Show Yahoo link'),
|
| 121 |
'#return_value' => 1,
|
| 122 |
'#default_value' => variable_get('service_links_show_yahoo', 0),
|
| 123 |
);
|
| 124 |
|
| 125 |
$form['what_links2_to_show'] = array(
|
| 126 |
'#type' => 'fieldset',
|
| 127 |
'#title' => t('What search links to show'),
|
| 128 |
);
|
| 129 |
$form['what_links2_to_show']['service_links_show_technorati'] = array(
|
| 130 |
'#type' => 'checkbox',
|
| 131 |
'#title' => t('Show Technorati link'),
|
| 132 |
'#return_value' => 1,
|
| 133 |
'#default_value' => variable_get('service_links_show_technorati', 1),
|
| 134 |
);
|
| 135 |
$form['what_links2_to_show']['service_links_show_icerocket'] = array(
|
| 136 |
'#type' => 'checkbox',
|
| 137 |
'#title' => t('Show IceRocket link'),
|
| 138 |
'#return_value' => 1,
|
| 139 |
'#default_value' => variable_get('service_links_show_icerocket', 0),
|
| 140 |
);
|
| 141 |
|
| 142 |
$form['how_to_show_the_links'] = array(
|
| 143 |
'#type' => 'fieldset',
|
| 144 |
'#title' => t('When and how to show the links'),
|
| 145 |
);
|
| 146 |
$form['how_to_show_the_links']['service_links_in_links'] = array(
|
| 147 |
'#type' => 'select',
|
| 148 |
'#title' => t('Service links in links'),
|
| 149 |
'#default_value' => variable_get('service_links_in_links', 0),
|
| 150 |
'#options' => array(0 => t('Disabled'), 1 => t('Teaser view'), 2 => t('Full-page view'), 3 => t('Teasers and full-page view')),
|
| 151 |
'#description' => t('When to display the services in the links section.'),
|
| 152 |
);
|
| 153 |
$form['how_to_show_the_links']['service_links_in_node'] = array(
|
| 154 |
'#type' => 'select',
|
| 155 |
'#title' => t('Service links in nodes'),
|
| 156 |
'#default_value' => variable_get('service_links_in_node', 2),
|
| 157 |
'#options' => array(0 => t('Disabled'), 1 => t('Teaser view'), 2 => t('Full-page view'), 3 => t('Teasers and full-page view')),
|
| 158 |
'#description' => t('When to display the services after the node text.'),
|
| 159 |
);
|
| 160 |
$form['how_to_show_the_links']['service_links_style'] = array(
|
| 161 |
'#type' => 'select',
|
| 162 |
'#title' => t('Service links style'),
|
| 163 |
'#default_value' => variable_get('service_links_style', 1),
|
| 164 |
'#options' => array(1 => t('Text links'), 2 => t('Image links'), 3 => t('Image and text links')),
|
| 165 |
);
|
| 166 |
|
| 167 |
if (module_exists('aggregator2')) {
|
| 168 |
$form['aggregator2_settings'] = array(
|
| 169 |
'#type' => 'fieldset',
|
| 170 |
'#title' => t('Aggregator2 settings'),
|
| 171 |
);
|
| 172 |
$form['aggregator2_settings']['service_links_agg2_link'] = array(
|
| 173 |
'#type' => 'checkbox',
|
| 174 |
'#title' => t('Use link to original article aggregated by aggregator2 module'),
|
| 175 |
'#return_value' => 1,
|
| 176 |
'#default_value' => variable_get('service_links_agg2_link', 0),
|
| 177 |
);
|
| 178 |
}
|
| 179 |
|
| 180 |
return system_settings_form($form);
|
| 181 |
}
|
| 182 |
|
| 183 |
/**
|
| 184 |
* Implementation of hook_menu().
|
| 185 |
*/
|
| 186 |
function service_links_menu() {
|
| 187 |
$items = array();
|
| 188 |
|
| 189 |
$items['admin/settings/servicelinks'] = array(
|
| 190 |
'title' => 'Service links',
|
| 191 |
'description' => 'Control which and where service links should be active.',
|
| 192 |
'page callback' => 'drupal_get_form',
|
| 193 |
'page arguments' => array('service_links_admin_settings'),
|
| 194 |
'access arguments' => array('administer service links'),
|
| 195 |
'type' => MENU_NORMAL_ITEM,
|
| 196 |
);
|
| 197 |
|
| 198 |
return $items;
|
| 199 |
}
|
| 200 |
|
| 201 |
/**
|
| 202 |
* Implementation of hook_nodeapi().
|
| 203 |
*/
|
| 204 |
function service_links_nodeapi(&$node, $op, $teaser, $page) {
|
| 205 |
switch ($op) {
|
| 206 |
case 'view':
|
| 207 |
$links_show = _service_links_show($node);
|
| 208 |
if ($links_show && user_access('access service links')) {
|
| 209 |
switch (variable_get('service_links_in_node', 0)) {
|
| 210 |
case 1:
|
| 211 |
if ($teaser) {
|
| 212 |
$node->content['service_links'] = array(
|
| 213 |
'#value' => theme('service_links_node_format', service_links_render($node, TRUE)),
|
| 214 |
'#weight' => 10,
|
| 215 |
);
|
| 216 |
}
|
| 217 |
break;
|
| 218 |
case 2:
|
| 219 |
if ($page) {
|
| 220 |
$node->content['service_links'] = array(
|
| 221 |
'#value' => theme('service_links_node_format', service_links_render($node, TRUE)),
|
| 222 |
'#weight' => 10,
|
| 223 |
);
|
| 224 |
}
|
| 225 |
break;
|
| 226 |
case 3:
|
| 227 |
if ($teaser) {
|
| 228 |
$node->content['service_links'] = array(
|
| 229 |
'#value' => theme('service_links_node_format', service_links_render($node, TRUE)),
|
| 230 |
'#weight' => 10,
|
| 231 |
);
|
| 232 |
}
|
| 233 |
else if ($page) {
|
| 234 |
$node->content['service_links'] = array(
|
| 235 |
'#value' => theme('service_links_node_format', service_links_render($node, TRUE)),
|
| 236 |
'#weight' => 10,
|
| 237 |
);
|
| 238 |
}
|
| 239 |
break;
|
| 240 |
}
|
| 241 |
}
|
| 242 |
break;
|
| 243 |
}
|
| 244 |
}
|
| 245 |
|
| 246 |
/**
|
| 247 |
* Implementation of hook_link().
|
| 248 |
*/
|
| 249 |
function service_links_link($type, $node = NULL, $teaser = FALSE) {
|
| 250 |
$links = array();
|
| 251 |
|
| 252 |
switch (variable_get('service_links_in_links', 0)) {
|
| 253 |
case 0:
|
| 254 |
$show_links = FALSE;
|
| 255 |
break;
|
| 256 |
case 1:
|
| 257 |
$show_links = $teaser ? TRUE : FALSE;
|
| 258 |
break;
|
| 259 |
case 2:
|
| 260 |
$show_links = $teaser ? FALSE : TRUE;
|
| 261 |
break;
|
| 262 |
case 3:
|
| 263 |
$show_links = TRUE;
|
| 264 |
break;
|
| 265 |
default:
|
| 266 |
$show_links = FALSE;
|
| 267 |
}
|
| 268 |
|
| 269 |
$links_show = _service_links_show($node);
|
| 270 |
|
| 271 |
if ($type == 'node' && $links_show && $show_links && user_access('access service links')) {
|
| 272 |
$links = service_links_render($node, TRUE);
|
| 273 |
}
|
| 274 |
|
| 275 |
return $links;
|
| 276 |
}
|
| 277 |
|
| 278 |
/**
|
| 279 |
* Implementation of hook_block().
|
| 280 |
*/
|
| 281 |
function service_links_block($op = 'list', $delta = 0, $edit = array()) {
|
| 282 |
if ($op == 'list') {
|
| 283 |
$blocks[0]['info'] = t('Service links');
|
| 284 |
return $blocks;
|
| 285 |
}
|
| 286 |
else if ($op == 'view') {
|
| 287 |
if (user_access('access service links') && arg(0) == 'node' && is_numeric(arg(1))) {
|
| 288 |
$node = node_load(arg(1));
|
| 289 |
$links_show = _service_links_show($node);
|
| 290 |
if ($links_show) {
|
| 291 |
$block['subject'] = t('Bookmark/Search this post');
|
| 292 |
$block['content'] = theme('service_links_block_format', service_links_render($node));
|
| 293 |
}
|
| 294 |
|
| 295 |
return $block;
|
| 296 |
}
|
| 297 |
}
|
| 298 |
}
|
| 299 |
|
| 300 |
/**
|
| 301 |
* Implementation of hook_theme().
|
| 302 |
*/
|
| 303 |
function service_links_theme() {
|
| 304 |
return array(
|
| 305 |
'service_links_build_link' => array(
|
| 306 |
'arguments' => array(
|
| 307 |
'text' => NULL,
|
| 308 |
'url' => NULL,
|
| 309 |
'title' => NULL,
|
| 310 |
'image' => NULL,
|
| 311 |
'nodelink' => NULL,
|
| 312 |
),
|
| 313 |
),
|
| 314 |
'service_links_node_format' => array(
|
| 315 |
'arguments' => array('links' => NULL),
|
| 316 |
),
|
| 317 |
'service_links_block_format' => array(
|
| 318 |
'arguments' => array('items' => NULL),
|
| 319 |
),
|
| 320 |
);
|
| 321 |
}
|
| 322 |
|
| 323 |
/**
|
| 324 |
* Function that renders the service links.
|
| 325 |
* This is the function themers want to call to insert the service links.
|
| 326 |
*/
|
| 327 |
function service_links_render($node, $nodelink = FALSE) {
|
| 328 |
$links = array();
|
| 329 |
|
| 330 |
if (variable_get('service_links_agg2_link', 0) && $node->link) {
|
| 331 |
$url = ($node->source_link ? $node->source_link : $node->link);
|
| 332 |
}
|
| 333 |
else if (!empty($node)) {
|
| 334 |
$url = url("node/$node->nid", array('absolute' => TRUE));
|
| 335 |
}
|
| 336 |
else {
|
| 337 |
$url = url($_GET['q'], array('absolute' => TRUE));
|
| 338 |
}
|
| 339 |
|
| 340 |
$url = urlencode($url);
|
| 341 |
$title = urlencode($node->title);
|
| 342 |
|
| 343 |
if (variable_get('service_links_show_delicious', 0)) {
|
| 344 |
$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);
|
| 345 |
}
|
| 346 |
if (variable_get('service_links_show_digg', 0)) {
|
| 347 |
$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);
|
| 348 |
}
|
| 349 |
if (variable_get('service_links_show_stumbleupon', 0)) {
|
| 350 |
$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);
|
| 351 |
}
|
| 352 |
if (variable_get('service_links_show_propeller', 0)) {
|
| 353 |
$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);
|
| 354 |
}
|
| 355 |
if (variable_get('service_links_show_reddit', 0)) {
|
| 356 |
$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);
|
| 357 |
}
|
| 358 |
if (variable_get('service_links_show_magnoliacom', 0)) {
|
| 359 |
$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);
|
| 360 |
}
|
| 361 |
if (variable_get('service_links_show_newsvine', 0)) {
|
| 362 |
$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);
|
| 363 |
}
|
| 364 |
if (variable_get('service_links_show_furl', 0)) {
|
| 365 |
$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);
|
| 366 |
}
|
| 367 |
if (variable_get('service_links_show_facebook', 0)) {
|
| 368 |
$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);
|
| 369 |
}
|
| 370 |
if (variable_get('service_links_show_google', 0)) {
|
| 371 |
$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);
|
| 372 |
}
|
| 373 |
if (variable_get('service_links_show_yahoo', 0)) {
|
| 374 |
$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);
|
| 375 |
}
|
| 376 |
if (variable_get('service_links_show_technorati', 0)) {
|
| 377 |
$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);
|
| 378 |
}
|
| 379 |
if (variable_get('service_links_show_icerocket', 0)) {
|
| 380 |
$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);
|
| 381 |
}
|
| 382 |
|
| 383 |
// Add your own link by modifing the link below and uncomment it.
|
| 384 |
//$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);
|
| 385 |
|
| 386 |
return $links;
|
| 387 |
}
|
| 388 |
|
| 389 |
function theme_service_links_build_link($text, $url, $title, $image, $nodelink) {
|
| 390 |
global $base_path;
|
| 391 |
|
| 392 |
if ($nodelink) {
|
| 393 |
switch (variable_get('service_links_style', 1)) {
|
| 394 |
case 1:
|
| 395 |
$link = array(
|
| 396 |
'title' => $text,
|
| 397 |
'href' => $url,
|
| 398 |
'attributes' => array('title' => $title, 'rel' => 'nofollow')
|
| 399 |
);
|
| 400 |
break;
|
| 401 |
case 2:
|
| 402 |
$link = array(
|
| 403 |
'title' => '<img src="'. $base_path . drupal_get_path('module', 'service_links') .'/'. $image .'" alt="'. $text .'" />',
|
| 404 |
'href' => $url,
|
| 405 |
'attributes' => array('title' => $title, 'rel' => 'nofollow'),
|
| 406 |
'html' => TRUE
|
| 407 |
);
|
| 408 |
break;
|
| 409 |
case 3:
|
| 410 |
$link = array(
|
| 411 |
'title' => '<img src="'. $base_path . drupal_get_path('module', 'service_links') .'/'. $image .'" alt="'. $text .'" /> '. $text,
|
| 412 |
'href' => $url,
|
| 413 |
'attributes' => array('title' => $title, 'rel' => 'nofollow'),
|
| 414 |
'html' => TRUE
|
| 415 |
);
|
| 416 |
break;
|
| 417 |
}
|
| 418 |
}
|
| 419 |
else {
|
| 420 |
switch (variable_get('service_links_style', 1)) {
|
| 421 |
case 1:
|
| 422 |
$link = '<a href="'. check_url($url) .'" title="'. $title .'" rel="nofollow">'. $text .'</a>';
|
| 423 |
break;
|
| 424 |
case 2:
|
| 425 |
$link = '<a href="'. check_url($url) .'" title="'. $title .'" rel="nofollow"><img src="'. $base_path . drupal_get_path('module', 'service_links') .'/'. $image .'" alt="'. $text .'" /></a>';
|
| 426 |
break;
|
| 427 |
case 3:
|
| 428 |
$link = '<a href="'. check_url($url) .'" title="'. $title .'" rel="nofollow"><img src="'. $base_path . drupal_get_path('module', 'service_links') .'/'. $image .'" alt="'. $text .'" /> '. $text .'</a>';
|
| 429 |
break;
|
| 430 |
}
|
| 431 |
}
|
| 432 |
|
| 433 |
return $link;
|
| 434 |
}
|
| 435 |
|
| 436 |
function theme_service_links_node_format($links) {
|
| 437 |
return '<div class="service-links"><div class="service-label">'. t('Bookmark/Search this post with: ') .'</div>'. theme('links', $links) .'</div>';
|
| 438 |
}
|
| 439 |
|
| 440 |
function theme_service_links_block_format($items) {
|
| 441 |
return '<div class="service-links">'. theme('item_list', $items) .'</div>';
|
| 442 |
}
|
| 443 |
|
| 444 |
/**
|
| 445 |
* Build an array of all taxonomy terms.
|
| 446 |
*/
|
| 447 |
function _service_links_get_terms() {
|
| 448 |
$types = array();
|
| 449 |
$vocabularies = taxonomy_get_vocabularies();
|
| 450 |
foreach ($vocabularies as $vocabulary) {
|
| 451 |
$tree = taxonomy_get_tree($vocabulary->vid);
|
| 452 |
foreach ($tree as $term) {
|
| 453 |
$types[$term->tid] = $term->name;
|
| 454 |
}
|
| 455 |
}
|
| 456 |
|
| 457 |
return $types;
|
| 458 |
}
|
| 459 |
|
| 460 |
/**
|
| 461 |
* Check if the service links should be displayed for the node type/category.
|
| 462 |
*/
|
| 463 |
function _service_links_show($node) {
|
| 464 |
$links_show = FALSE;
|
| 465 |
$category_type = FALSE;
|
| 466 |
$node_type = in_array($node->type, variable_get('service_links_node_types', array()), TRUE);
|
| 467 |
if (module_exists('taxonomy')) {
|
| 468 |
$terms = taxonomy_node_get_terms($node);
|
| 469 |
foreach ($terms as $term) {
|
| 470 |
$category_type |= in_array($term->tid, variable_get('service_links_category_types', array()), FALSE);
|
| 471 |
}
|
| 472 |
}
|
| 473 |
if ($node_type || $category_type) {
|
| 474 |
$links_show = TRUE;
|
| 475 |
}
|
| 476 |
|
| 477 |
return $links_show;
|
| 478 |
}
|