You are here

function template_preprocess_social_media_links_platforms in Social Media Links Block and Field 7

Preprocesses variables for social media links platforms.

See also

theme_social_media_links_platforms()

File

./social_media_links.module, line 323
Functions for the Social Media Links module.

Code

function template_preprocess_social_media_links_platforms(&$variables) {
  $platform_infos = social_media_links_platforms();
  $icon_style = explode(':', $variables['icon_style']);

  // Apply the link settings to the render array.
  foreach ($variables['link_attributes'] as $key => $value) {
    if ($value == '<none>') {
      unset($variables['link_attributes'][$key]);
    }
  }

  // Sort and loop over the platforms.
  $variables['platforms'] = array();
  uasort($variables['platform_values'], 'drupal_sort_weight');
  foreach ($variables['platform_values'] as $platform_name => $platform_value) {

    // Build the platform data array.
    $variables['platforms'][$platform_name] = array(
      '#theme' => 'social_media_links_platform',
      '#name' => $platform_name,
      '#info' => $platform_infos[$platform_name],
      '#value' => $platform_value['platform_value'],
      '#icon_style' => $icon_style,
      '#appearance' => $variables['appearance'],
      '#attributes' => $variables['link_attributes'],
    );
  }
  if ($variables['appearance']['orientation'] == 'h') {
    $variables['attributes']['class'][] = 'inline horizontal';
  }
  else {
    $variables['attributes']['class'][] = 'vertical';
  }
}