You are here

function theme_sexybookmarks in Share Buttons, Related Posts, Content Analytics - Shareaholic 7

Same name and namespace in other branches
  1. 7.2 sexybookmarks.module \theme_sexybookmarks()

Theme callback for SexyBookmarks.

6 theme calls to theme_sexybookmarks()
sexybookmarks_block_current_view in includes/block.inc
sexybookmarks_block_site_view in includes/block.inc
sexybookmarks_entity_view in includes/field_ui.inc
Implements hook_entity_view().
sexybookmarks_field_formatter_view in includes/field_ui.inc
Implements hook_field_formatter_view().
sexybookmarks_sexybookmarks_content_type_render in plugins/content_types/sexybookmarks.inc
Render callback.

... See full list

File

./sexybookmarks.module, line 105
Contains core functions for the SexyBookmarks module.

Code

function theme_sexybookmarks($variables) {
  if ($config = sexybookmarks_get_config($variables)) {
    if ($config['changethis'] == 1) {
      $id = isset($variables['id']) ? $variables['id'] : "{$variables['profile']}-" . rand(1000, 9999);
      $directory = md5($config['service']);
      $api = 'http://www.shareaholic.com/api/sprite/?v=2&apikey=' . SB_APIKEY . '&service=' . urlencode($config['service']);
      $settings = drupal_json_encode(array(
        "sexybookmarks-{$id}" => array_merge($config, array(
          'apikey' => SB_APIKEY,
          'src' => file_create_url("public://sexybookmarks/{$directory}"),
          'link' => isset($variables['url']) ? $variables['url'] : '',
          'title' => isset($variables['title']) ? $variables['title'] : (drupal_get_title() ? strip_tags(drupal_get_title()) : check_plain(variable_get('site_name', 'Drupal'))),
          'notes' => isset($variables['text']) ? $variables['text'] : '',
          'localize' => TRUE,
        )),
      ));
      drupal_add_js("jQuery.extend(SHRSB_Settings, {$settings});", 'inline');
      drupal_add_js(sexybookmarks_get_file('http://www.shareaholic.com/media/js/jquery.shareaholic-publishers-sb.min.js'));
      drupal_add_css(sexybookmarks_get_file($api, "{$directory}/sprite.css"), array(
        'basename' => "{$directory}.css",
      ));
      drupal_add_css("\n      .sexybookmarks-{$id} ul.shr-socials li.shareaholic {\n        background-image: url('" . file_create_url(sexybookmarks_get_file("{$api}&apitype=png", "{$directory}/sprite.png")) . "') !important;\n      }\n    ", 'inline');
      return "<div class='sexybookmarks-{$id}'></div>";
    }
    else {
      $config['service'] = "5,7,313,309,78,304,88";
      $config['size'] = $config['classic_options'];
      $id = isset($variables['id']) ? $variables['id'] : "{$variables['profile']}-" . rand(1000, 9999);
      $settings = drupal_json_encode(array(
        "shr_classic-{$id}" => array_merge($config, array(
          'apikey' => SB_APIKEY,
          'link' => isset($variables['url']) ? $variables['url'] : '',
          'title' => isset($variables['title']) ? $variables['title'] : (drupal_get_title() ? strip_tags(drupal_get_title()) : check_plain(variable_get('site_name', 'Drupal'))),
          'notes' => isset($variables['text']) ? $variables['text'] : '',
          'localize' => TRUE,
        )),
      ));
      drupal_add_js("jQuery.extend(SHRCB_Settings, {$settings});", 'inline');
      drupal_add_js(sexybookmarks_get_file('http://www.shareaholic.com/media/js/jquery.shareaholic-publishers-cb.min.js'));
      return "<div style='clear:both'></div><div class='shr_classic-{$id} shareaholic-show-on-load'></div><div style='clear:both'></div>";
    }
  }
  return '';
}