function theme_linkicon in Link Icon 7
Formats a linkicon field widget.
2 theme calls to theme_linkicon()
- linkicon_field_formatter_view in ./
linkicon.module - Implements hook_field_formatter_view().
- _linkicon_field_formatter_settings_form in includes/
linkicon.admin.inc - Implements hook_field_formatter_settings_form().
File
- ./
linkicon.theme.inc, line 11 - Hooks and preprocess functions for the Linkicon module.
Code
function theme_linkicon($variables) {
$element = $variables['element'];
$build = '';
$wrappers = $attributes = array();
$settings = $element['#config'];
$wrappers['id'] = $settings['id'];
$wrappers['class'][] = 'item-list';
$wrappers['class'][] = 'item-list--linkicon';
if ($settings['wrapper_class']) {
$wrappers['class'][] = check_plain($settings['wrapper_class']);
}
$attributes['class'][] = 'linkicon';
if ($settings['load']) {
if (!$settings['vertical']) {
$attributes['class'][] = 'linkicon--inline';
}
if ($settings['color']) {
$attributes['class'][] = 'linkicon--color';
}
if ($settings['size'] && empty($settings['_preview'])) {
$attributes['class'][] = 'linkicon--' . $settings['size'];
}
foreach ([
'style',
'tooltip',
'position',
'color',
'no_text',
] as $key) {
if ($settings[$key]) {
$value = in_array($key, array(
'tooltip',
'no_text',
)) ? $key : $settings[$key];
$attributes['class'][] = 'linkicon--' . str_replace('_', '-', $value);
}
}
}
$build .= '<div ' . drupal_attributes($wrappers) . '>';
$build .= '<ul ' . drupal_attributes($attributes) . '>';
foreach ($element['#items'] as $item) {
$build .= '<li>' . drupal_render($item) . '</li>';
}
$build .= '</ul>';
$build .= '</div>';
return $build;
}