You are here

function _social_media_links_generate_example_table in Social Media Links Block and Field 7

Helper function to generate the icon set example table.

Parameters

array $platforms: Keyed array with all available platforms.

array $iconset: Array with the information about the icon set.

Return value

string The generated table markup.

1 call to _social_media_links_generate_example_table()
social_media_links_form in ./social_media_links.module

File

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

Code

function _social_media_links_generate_example_table($platforms, $iconset) {
  if (!is_array($platforms) && count($platforms) == 0) {
    return '';
  }
  $groups = array_chunk($platforms, 10, TRUE);
  $output = '';

  // Use the first iconset style for the sample table.
  $style = key($iconset['styles']);
  foreach ($groups as $group) {
    $header = array();
    $row = array();
    foreach ($group as $platform_name => $platform) {
      $header[] = array(
        'data' => $platform['title'],
        'style' => 'text-align: center; ',
      );
      $vars = array(
        'path' => call_user_func($iconset['path callback'], $platform_name, $style),
      );
      if (file_exists($vars['path'])) {
        $row[] = array(
          'data' => theme('image', $vars) . ' ',
          'style' => 'text-align: center;',
        );
      }
      else {
        $row[] = array(
          'data' => '–',
          'style' => 'text-align: center;',
        );
      }
    }
    $vars = array(
      'header' => $header,
      'rows' => array(
        'data' => $row,
      ),
    );
    $output .= theme('table', $vars);
    $output .= '<br />';
  }
  return $output;
}