You are here

function theme_service_links_build_link in Service links 7.2

Same name and namespace in other branches
  1. 5 service_links.module \theme_service_links_build_link()
  2. 6.2 service_links.theme.inc \theme_service_links_build_link()
  3. 6 service_links.module \theme_service_links_build_link()

Build a single link following the style rules.

1 theme call to theme_service_links_build_link()
_service_links_render in ./service_links.module
The common render function used privately.

File

./service_links.theme.inc, line 11
Theme function used by Service Links.

Code

function theme_service_links_build_link($variables) {
  $text = $variables['text'];
  $url = $variables['url'];
  $image = $variables['image'];
  $nodelink = $variables['nodelink'];
  $style = $variables['style'];
  $attributes = $variables['attributes'];
  if ($nodelink) {
    $query = isset($url[1]) ? $url[1] : NULL;
    switch ($style) {
      case SERVICE_LINKS_STYLE_TEXT:
        $link = array(
          'title' => $text,
          'href' => $url[0],
          'query' => $query,
          'attributes' => $attributes,
        );
        break;
      case SERVICE_LINKS_STYLE_IMAGE:
        $alt_text = t('!name logo', array(
          '!name' => $text,
        ));
        $link = array(
          'title' => theme('image', array(
            'path' => service_links_expand_path($image),
            'alt' => $alt_text,
          )),
          'href' => $url[0],
          'query' => $query,
          'attributes' => $attributes,
          'html' => TRUE,
        );
        break;
      case SERVICE_LINKS_STYLE_IMAGE_AND_TEXT:
        $alt_text = t('!name logo', array(
          '!name' => $text,
        ));
        $link = array(
          'title' => theme('image', array(
            'path' => service_links_expand_path($image),
            'alt' => $alt_text,
          )) . ' ' . $text,
          'href' => $url[0],
          'query' => $query,
          'attributes' => $attributes,
          'html' => TRUE,
        );
        break;
      case SERVICE_LINKS_STYLE_EMPTY:
        $link = array(
          'title' => '<span class="element-invisible">' . $text . '</span>',
          'href' => $url[0],
          'query' => $query,
          'attributes' => $attributes,
          'html' => TRUE,
        );
        break;
      default:
        $link = theme($style, $variables);
    }
  }
  else {
    $attributes = array(
      'attributes' => $attributes,
    );
    if (isset($url[1])) {
      $attributes['query'] = $url[1];
    }
    switch ($style) {
      case SERVICE_LINKS_STYLE_TEXT:
        $link = l($text, $url[0], $attributes);
        break;
      case SERVICE_LINKS_STYLE_IMAGE:
        $attributes['html'] = TRUE;
        $alt_text = t('!name logo', array(
          '!name' => $text,
        ));
        $link = l(theme('image', array(
          'path' => service_links_expand_path($image),
          'alt' => $alt_text,
        )), $url[0], $attributes);
        break;
      case SERVICE_LINKS_STYLE_IMAGE_AND_TEXT:
        $attributes['html'] = TRUE;
        $alt_text = t('!name logo', array(
          '!name' => $text,
        ));
        $link = l(theme('image', array(
          'path' => service_links_expand_path($image),
          'alt' => $alt_text,
        )) . ' ' . $text, $url[0], $attributes);
        break;
      case SERVICE_LINKS_STYLE_EMPTY:
        $attributes['html'] = TRUE;
        $link = l('<span class="element-invisible">' . $text . '</span>', $url[0], $attributes);
        break;
      case SERVICE_LINKS_STYLE_FISHEYE:
        $attributes['attributes']['class'] = isset($attributes['attributes']['class']) ? array_merge($attributes['attributes']['class'], array(
          'fisheyeItem',
        )) : array(
          'fisheyeItem',
        );
        $attributes['html'] = TRUE;
        $link = l(theme('image', array(
          'path' => service_links_expand_path($image, 'fisheye'),
          'alt' => $text,
          'getsize' => FALSE,
        )) . '<span>' . $text . '</span>', $url[0], $attributes);
        break;
      default:
        $link = theme($style, $variables);
    }
  }
  return $link;
}