function socialfeed_facebook_data in Social Feed 7.2
Rendering values from the Facebook feed.
Parameters
int $i: Accepts int as value.
string $facebook_entry: Accepts string as value.
bool $display_all_posts: Accepts bool as value.
bool $display_time: Accepts bool as value.
bool $display_pic: Accepts bool as value.
bool $display_video: Accepts bool as value.
string $teaser_text: Accepts string as value.
string $facebook_hash_tag: Accepts string as value.
Return value
mixed Returns mixed.
1 call to socialfeed_facebook_data()
- socialfeed_facebook_feeds in ./
socialfeed.block.inc - Returns HTML with feeds in required format.
File
- ./
socialfeed.block.inc, line 48 - File include for Social Feed module.
Code
function socialfeed_facebook_data($i, $facebook_entry, $display_all_posts, $display_time, $display_pic, $display_video, $teaser_text, $facebook_hash_tag) {
$trim_length = variable_get('socialfeed_facebook_trim_length');
if (array_key_exists('message', $facebook_entry)) {
if (isset($facebook_entry['full_picture']) && $display_all_posts == 0) {
if ($display_pic == 1) {
$message_feed['full_picture'] = $facebook_entry['full_picture'];
}
}
if (isset($facebook_entry['source']) && $display_all_posts == 0) {
if ($display_video == 1) {
$message_feed['video'] = $facebook_entry['source'];
}
}
if (isset($facebook_entry['message'])) {
if (isset($trim_length) && !empty($trim_length)) {
$trimmed_message = substr($facebook_entry['message'], 0, $trim_length);
$message_feed['message'] = $trimmed_message;
}
else {
$message_feed['message'] = substr($facebook_entry['message'], 0, 200);
}
}
if (isset($teaser_text) && !empty($teaser_text) && isset($facebook_entry['permalink_url'])) {
$message_feed['full_feed_link'] = l(t('@teaser_text', [
'@teaser_text' => $teaser_text,
]), $facebook_entry['permalink_url'], [
'attributes' => [
'target' => '_blank',
],
]);
}
else {
$message_feed['full_feed_link'] = t('@teaser_text', [
'@teaser_text' => $teaser_text,
]);
}
if ($facebook_hash_tag == 1) {
$message_feed['message'] = preg_replace_callback('/#(\\w+)/', function ($hash) {
return l($hash[0], 'https:facebook.com/hashtag/' . $hash[1], [
'attributes' => [
'target' => '_blank',
],
]);
}, $message_feed['message']);
}
if ($display_time == 1) {
$formatted_date = new DateTime($facebook_entry['created_time']);
$message_feed['created_stamp'] = $formatted_date
->format(variable_get('socialfeed_facebook_time_format'));
}
}
else {
if (isset($facebook_entry['full_picture']) && $display_all_posts == 0) {
if ($display_pic == 1) {
$message_feed['full_picture'] = $facebook_entry['full_picture'];
}
}
if (isset($facebook_entry['source']) && $display_all_posts == 0) {
if ($display_video == 1) {
$message_feed['video'] = $facebook_entry['source'];
}
}
if (isset($facebook_entry['message']) && !empty($facebook_entry['message'])) {
$message_feed['message'] = substr($facebook_entry['message'], 0, variable_get('socialfeed_facebook_trim_length'));
}
if (isset($teaser_text) && !empty($teaser_text) && isset($facebook_entry['permalink_url'])) {
$message_feed['full_feed_link'] = l(t('@teaser_text', [
'@teaser_text' => $teaser_text,
]), $facebook_entry['permalink_url'], [
'attributes' => [
'target' => '_blank',
],
]);
}
else {
$message_feed['full_feed_link'] = t('@teaser_text', [
'@teaser_text' => $teaser_text,
]);
}
}
return $message_feed;
}