function _easy_social_render_widgets in Easy Social 7.2
Return an array of rendered Easy Social Widgets
Parameters
string $url:
string $title:
int $type:
string $enabled_widgets:
string $node->language:
Return value
array
4 calls to _easy_social_render_widgets()
- easy_social_block_view in ./
easy_social.module - Implements hook_block_view().
- easy_social_comment_view in ./
easy_social.module - Implements hook_comment_view().
- easy_social_handler_field::render in views/
easy_social_handler_field.inc - Render field.
- easy_social_node_view in ./
easy_social.module - Implements hook_node_view().
File
- ./
easy_social.module, line 733 - Easy social module.
Code
function _easy_social_render_widgets($url, $title, $type = NULL, $enabled_widgets = NULL, $lang = 'en') {
drupal_add_css(drupal_get_path('module', 'easy_social') . '/css/easy_social.css');
if (!_easy_social_page_ignore()) {
// If settings aren't passed, fallback to defaults.
if (!isset($type)) {
$type = variable_get_value('easy_social_global_type');
}
if (!$enabled_widgets) {
$enabled_widgets = variable_get_value('easy_social_global_widgets');
}
// Load enabled widgets.
$widgets = easy_social_get_widgets();
// Sort widgets.
$order = variable_get_value('easy_social_global_order');
$ordered_widgets = array();
foreach ($order as $value) {
if (in_array($value, $enabled_widgets, TRUE)) {
$ordered_widgets[] = $value;
}
}
$widget_links = array();
// Process enabled widgets.
foreach ($ordered_widgets as $service) {
// Add javascript includes, if any.
if (isset($widgets[$service]['scripts']) && is_array($widgets[$service]['scripts'])) {
foreach ($widgets[$service]['scripts'] as $script) {
$script_type = isset($script['type']) ? $script['type'] : 'external';
if ($script_type !== 'module') {
drupal_add_js($script['path'], $script_type);
}
else {
drupal_add_js($script['path']);
}
}
}
// Add css includes, if any.
if (isset($widgets[$service]['styles']) && is_array($widgets[$service]['styles'])) {
foreach ($widgets[$service]['styles'] as $style) {
$style_type = isset($style['type']) ? $style['type'] : 'external';
if ($style_type !== 'module') {
drupal_add_css($style['path'], $style_type);
}
else {
drupal_add_css($style['path']);
}
}
}
// Finally, add widget markup.
if (isset($widgets[$service]['markup'])) {
$widget_url = is_array($url) ? $url[$service] : $url;
$widget_links[$service] = call_user_func($widgets[$service]['markup'], $widget_url, $type, $title, $lang);
}
}
return $widget_links;
}
}