function easy_social_block_view in Easy Social 7.2
Implements hook_block_view().
File
- ./
easy_social.module, line 634 - Easy social module.
Code
function easy_social_block_view($delta = '') {
$num_blocks = variable_get_value('easy_social_block_count');
// Use current page' url and title.
$path = isset($_GET['q']) ? $_GET['q'] : '<front>';
$url = url($path, array(
'absolute' => TRUE,
'query' => drupal_get_query_parameters(),
));
$title = variable_get('site_name');
for ($i = 1; $i <= $num_blocks; ++$i) {
if ($delta === "easy_social_block_{$i}") {
// check if this block has overriden settings
if (variable_get_value("easy_social_block_{$i}_override")) {
$type = variable_get_value("easy_social_block_{$i}_type");
$enabled_widgets = variable_get_value("easy_social_block_{$i}_widgets");
if (variable_get_value("easy_social_block_{$i}_share_title")) {
$title_string = variable_get_value("easy_social_block_{$i}_share_title");
$node = menu_get_object();
if (is_object($node) && is_numeric($node->nid)) {
$title = token_replace($title_string, array(
'node' => $node,
));
}
}
//Overwritten urls
$url = array();
foreach ($enabled_widgets as $en_widgets) {
if ((bool) $en_widgets !== FALSE) {
$url[$en_widgets] = variable_get("easy_social_block_{$i}_url_{$en_widgets}", "[current-path]");
//Empty URL or current path
if (empty($url[$en_widgets]) || trim($url[$en_widgets]) == '[current-path]') {
$url[$en_widgets] = url($path, array(
'absolute' => TRUE,
));
}
else {
//Base URL
if (trim($url[$en_widgets]) == '[base-url]') {
$url[$en_widgets] = url('<front>', array(
'absolute' => TRUE,
));
}
else {
//Internal path
if (!valid_url($url[$en_widgets], TRUE)) {
$url[$en_widgets] = url($url[$en_widgets], array(
'absolute' => TRUE,
));
}
}
}
}
}
}
else {
$type = $enabled_widgets = NULL;
}
global $language;
$widgets = _easy_social_render_widgets($url, $title, $type, $enabled_widgets, $language->language);
return array(
'subject' => variable_get_value("easy_social_block_{$i}_title"),
'content' => array(
'#theme' => 'easy_social_links',
'#widgets' => $widgets,
'#widget_type' => $type,
'#lang' => $language->language,
),
);
}
}
}