You are here

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

Same name and namespace in other branches
  1. 7.2 plugins/export_ui/sexybookmarks_profiles.inc \theme_sexybookmarks_services()
1 theme call to theme_sexybookmarks_services()
sexybookmarks_profiles_export_ui_form in plugins/export_ui/sexybookmarks_profiles.inc
SexyBookmarks profiles settings form.

File

plugins/export_ui/sexybookmarks_profiles.inc, line 440

Code

function theme_sexybookmarks_services($variables) {
  $output = '';
  $form_element = $variables['form_element'];

  // List of SexyBookmarks services.
  $services = array(
    2,
    3,
    4,
    5,
    6,
    7,
    10,
    24,
    38,
    39,
    40,
    52,
    54,
    74,
    88,
    201,
    219,
    257,
    27,
    33,
    41,
    43,
    45,
    46,
    53,
    78,
    195,
    196,
    205,
    207,
    210,
    236,
    247,
    264,
    44,
    48,
    61,
    77,
    80,
    100,
    105,
    140,
    191,
    202,
    218,
    238,
    240,
    266,
    269,
    280,
    289,
    1,
    14,
    21,
    89,
    98,
    102,
    106,
    243,
    267,
    268,
    277,
    278,
    283,
    284,
    285,
    286,
    288,
    20,
    59,
    92,
    188,
    190,
    192,
    204,
    246,
    263,
    265,
    279,
    281,
    282,
    287,
    290,
    291,
    292,
    293,
    294,
  );
  $directory = md5(implode(',', $services));

  // Attach Javascript and Styles.
  $api = 'http://www.shareaholic.com/api/sprite/?v=2&apikey=' . SB_APIKEY . '&service=' . implode(',', $services);
  drupal_add_css(sexybookmarks_get_file($api, "{$directory}/sprite.css"));
  drupal_add_css('
    li.shareaholic {
      background-image: url("' . file_create_url(sexybookmarks_get_file("{$api}&apitype=png", "{$directory}/sprite.png")) . '");
    }

    div.shr-bookmarks ul.shr-socials li {
      cursor: move !important;
    }
  ', 'inline');
  drupal_add_js(drupal_get_path('module', 'sexybookmarks') . '/scripts/sexybookmarks.admin.js');
  drupal_add_library('system', 'ui.sortable');

  // Active services list.
  $active = array();
  foreach (explode(',', $form_element['#default_value']) as $item) {
    $active[] = array(
      'data' => '',
      'id' => "shr-{$item}",
      'class' => array(
        "shr-{$item}",
        'shareaholic',
      ),
    );
  }
  $output .= '<div class="shr-bookmarks clearfix">' . theme('item_list', array(
    'title' => t('Active services'),
    'items' => $active,
    'attributes' => array(
      'id' => 'sexybookmarks-active',
      'class' => array(
        'shr-socials',
      ),
    ),
  )) . '</div>';

  // Inactive services list.
  $inactive = array();
  foreach (array_diff($services, explode(',', $form_element['#default_value'])) as $item) {
    $inactive[] = array(
      'data' => '',
      'id' => "shr-{$item}",
      'class' => array(
        "shr-{$item}",
        'shareaholic',
      ),
    );
  }
  $output .= '<div class="shr-bookmarks clearfix">' . theme('item_list', array(
    'title' => t('Inactive services'),
    'items' => $inactive,
    'attributes' => array(
      'id' => 'sexybookmarks-inactive',
      'class' => array(
        'shr-socials',
      ),
    ),
  )) . '</div>';

  // Hidden field.
  element_set_attributes($form_element, array(
    'id',
    'name',
    'value',
    'size',
    'maxlength',
  ));
  $output .= theme('hidden', array(
    'element' => $form_element,
  ));
  return $output;
}