socialfeed.module in Social Feed 6
Same filename and directory in other branches
Module for fetching data from Facebook, Twitter, Youtube, and Foursquare. This module provides block content retrieved from a
File
socialfeed.moduleView source
<?php
/**
* @file
* Module for fetching data from Facebook, Twitter, Youtube, and Foursquare.
* This module provides block content retrieved from a
*/
/**
* Implements hook_menu().
*/
function socialfeed_menu() {
$items = array();
$items['admin/settings/socialfeed'] = array(
'title' => 'Feed settings',
'description' => 'This is the socialfeed module settings.',
'page callback' => 'drupal_get_form',
'page arguments' => array(
'socialfeed_settings_form',
),
'access callback' => 'user_access',
'access arguments' => array(
'administer social media feed',
),
);
return $items;
}
/**
* Implements hook_perm().
*/
function socialfeed_perm() {
return array(
'administer social media feed',
);
}
/**
* Form constructor for the socialfeed settings form.
*
* Path: admin/settings/socialfeed
*/
function socialfeed_settings_form() {
drupal_add_js(drupal_get_path('module', 'socialfeed') . '/js/socialfeed_form.js');
$form = array();
$form['socialfeed_meta_set'] = array(
'#type' => 'fieldset',
'#title' => t('Basic settings'),
'#collapsible' => TRUE,
'#collapsed' => FALSE,
);
$form['socialfeed_meta_set']['socialfeed_title'] = array(
'#type' => 'textfield',
'#title' => t('Title'),
'#description' => t('This is the title of the person or organization represented by your feed.'),
'#default_value' => variable_get('socialfeed_title', FALSE),
'#required' => TRUE,
);
$form['socialfeed_meta_set']['socialfeed_displaycount'] = array(
'#type' => 'textfield',
'#title' => t('Display count'),
'#description' => t('This is the number of items that will display.'),
'#default_value' => variable_get('socialfeed_displaycount', FALSE),
'#maxlength' => 3,
'#size' => 3,
'#required' => TRUE,
);
// Facebook Fieldset.
$form['socialfeed_facebook'] = array(
'#type' => 'fieldset',
'#title' => t('Facebook settings'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
$form['socialfeed_facebook']['socialfeed_facebook_title_checkbox'] = array(
'#type' => 'checkbox',
'#title' => t('Use default title'),
'#description' => t('This is the name that appears over each post Facebook post. If this is not defined, it will use the username of the API instead.'),
'#default_value' => variable_get('socialfeed_facebook_title_checkbox', FALSE),
);
$form['socialfeed_facebook']['socialfeed_facebook_title'] = array(
'#type' => 'textfield',
'#description' => t('Put the title of your choice here.'),
'#default_value' => variable_get('socialfeed_facebook_title', FALSE),
);
$form['socialfeed_facebook']['socialfeed_facebook_profile_id'] = array(
'#type' => 'textfield',
'#title' => t('Profile id'),
'#description' => t('This is the id of the Facebook profile you wish to pull data from.'),
'#default_value' => variable_get('socialfeed_facebook_profile_id', FALSE),
);
$form['socialfeed_facebook']['socialfeed_facebook_app_id'] = array(
'#type' => 'textfield',
'#title' => t('App id'),
'#description' => t('This is the id of your Facebook application. This is needed to retrieve an access token.'),
'#default_value' => variable_get('socialfeed_facebook_app_id', FALSE),
);
$form['socialfeed_facebook']['socialfeed_facebook_app_secret'] = array(
'#type' => 'textfield',
'#title' => t('App secret'),
'#description' => t('This is the app secret of your Facebook application. This is needed to retrieve an access token.'),
'#default_value' => variable_get('socialfeed_facebook_app_secret', FALSE),
);
// Twitter Fieldset.
$form['socialfeed_twitter'] = array(
'#type' => 'fieldset',
'#title' => t('Twitter settings'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
$form['socialfeed_twitter']['socialfeed_twitter_title_checkbox'] = array(
'#type' => 'checkbox',
'#title' => t('Use default title'),
'#description' => t('This is the name that appears over each post Twitter post. If this is not defined, it will use the username of the API instead.'),
'#default_value' => variable_get('socialfeed_twitter_title_checkbox', FALSE),
);
$form['socialfeed_twitter']['socialfeed_twitter_title'] = array(
'#type' => 'textfield',
'#description' => t('Put the title of your choice here.'),
'#default_value' => variable_get('socialfeed_twitter_title', FALSE),
);
$form['socialfeed_twitter']['socialfeed_twitter_profile_id'] = array(
'#type' => 'textfield',
'#title' => t('Profile id'),
'#description' => t('This is the id of the Twitter profile you wish to pull data from.'),
'#default_value' => variable_get('socialfeed_twitter_profile_id', FALSE),
);
// Youtube Fieldset.
$form['socialfeed_youtube'] = array(
'#type' => 'fieldset',
'#title' => t('Youtube settings'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
$form['socialfeed_youtube']['socialfeed_youtube_title_checkbox'] = array(
'#type' => 'checkbox',
'#title' => t('Use default title'),
'#description' => t('This is the name that appears over each post Youtube post. If this is not defined, it will use the username of the API instead.'),
'#default_value' => variable_get('socialfeed_youtube_title_checkbox', FALSE),
);
$form['socialfeed_youtube']['socialfeed_youtube_title'] = array(
'#type' => 'textfield',
'#description' => t('Put the title of your choice here.'),
'#default_value' => variable_get('socialfeed_youtube_title', FALSE),
);
$form['socialfeed_youtube']['socialfeed_youtube_profile_name'] = array(
'#type' => 'textfield',
'#title' => t('Profile name'),
'#description' => t('This is the name of the Youtube profile you wish to pull data from.'),
'#default_value' => variable_get('socialfeed_youtube_profile_name', FALSE),
);
// Foursquare Fieldset.
$form['socialfeed_foursquare'] = array(
'#type' => 'fieldset',
'#title' => t('Foursquare settings'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
$form['socialfeed_foursquare']['socialfeed_foursquare_title_checkbox'] = array(
'#type' => 'checkbox',
'#title' => t('Use default title'),
'#description' => t('This is the name that appears over each post Foursquare post. If this is not defined, it will use the username of the API instead.'),
'#default_value' => variable_get('socialfeed_foursquare_title_checkbox', FALSE),
);
$form['socialfeed_foursquare']['socialfeed_foursquare_title'] = array(
'#type' => 'textfield',
'#description' => t('Put the title of your choice here.'),
'#default_value' => variable_get('socialfeed_foursquare_title', FALSE),
);
$form['socialfeed_foursquare']['socialfeed_foursquare_access_token'] = array(
'#type' => 'textfield',
'#title' => t('Access token'),
'#description' => t('This is the access token of the Foursquare profile you wish to pull data from.'),
'#default_value' => variable_get('socialfeed_foursquare_access_token', FALSE),
);
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Save settings'),
);
return $form;
}
/**
* Implements form_validate().
*/
function socialfeed_settings_form_validate(&$form, &$form_state) {
// We make sure the title is a number or a letter.
if (!ctype_alnum($form_state['values']['socialfeed_title'])) {
form_set_error('socialfeed_title', t('You can only enter letters or numbers in the title.'));
}
// We make sure the display count is a number greater than zero.
if (!is_numeric($form_state['values']['socialfeed_displaycount'])) {
form_set_error('socialfeed_displaycount', t('You must enter a number for the count.'));
}
elseif ($form_state['values']['socialfeed_displaycount'] < 1) {
form_set_error('socialfeed_displaycount', t('The count must be greater than zero.'));
}
// Make sure the Facebook title is a number or a letter if it is declared.
if ($form_state['values']['socialfeed_facebook_title'] != '') {
if (!ctype_alnum($form_state['values']['socialfeed_facebook_title'])) {
form_set_error('socialfeed_facebook_title', t('You can only enter letters or numbers in the custom Facebook title.'));
}
}
// Make sure the Facebook profile ID is a number if it is declared.
if ($form_state['values']['socialfeed_facebook_profile_id'] != '') {
if (!is_numeric($form_state['values']['socialfeed_facebook_profile_id'])) {
form_set_error('socialfeed_facebook_profile_id', t('You must enter a number for the profile ID.'));
}
}
// We make sure the Facebook App ID is a number but only if it is declared.
if ($form_state['values']['socialfeed_facebook_app_id'] != '') {
if (!is_numeric($form_state['values']['socialfeed_facebook_app_id'])) {
form_set_error('socialfeed_facebook_app_id', t('You must enter a number for the app id.'));
}
}
// Make sure the App Secret is a number or a letter if it is declared.
if ($form_state['values']['socialfeed_facebook_app_secret'] != '') {
if (!ctype_alnum($form_state['values']['socialfeed_facebook_app_secret'])) {
form_set_error('socialfeed_facebook_app_secret', t('You must enter an alphanumeric string for the app secret.'));
}
}
// Make sure the custom Twitter title is a number or a letter if its declared.
if ($form_state['values']['socialfeed_twitter_title'] != '') {
if (!ctype_alnum($form_state['values']['socialfeed_twitter_title'])) {
form_set_error('socialfeed_twitter_title', t('You can only enter letters or numbers in the custom Twitter title.'));
}
}
// Make sure the Twitter Profile ID is a number or a letter if its declared.
if ($form_state['values']['socialfeed_twitter_profile_id'] != '') {
if (!ctype_alnum($form_state['values']['socialfeed_twitter_profile_id'])) {
form_set_error('socialfeed_twitter_profile_id', t('You can only enter letters or numbers in the Twitter Profile ID.'));
}
}
// Make sure the Youtube title is a number or a letter if its declared.
if ($form_state['values']['socialfeed_youtube_title'] != '') {
if (!ctype_alnum($form_state['values']['socialfeed_youtube_title'])) {
form_set_error('socialfeed_youtube_title', t('You can only enter letters or numbers in the custom Youtube title.'));
}
}
// Make sure the Youtube Name is a number or a letter if its declared.
if ($form_state['values']['socialfeed_youtube_profile_name'] != '') {
if (!ctype_alnum($form_state['values']['socialfeed_youtube_profile_name'])) {
form_set_error('socialfeed_youtube_profile_name', t('You can only enter letters or numbers in the custom Youtube Profile Name.'));
}
}
// Make sure the Foursquare title is a number or a letter if its declared.
if ($form_state['values']['socialfeed_foursquare_title'] != '') {
if (!ctype_alnum($form_state['values']['socialfeed_foursquare_title'])) {
form_set_error('socialfeed_foursquare_title', t('You can only enter letters or numbers in the custom Foursquare title.'));
}
}
// Make sure the Foursquare Access Token is a number if its declared.
if ($form_state['values']['socialfeed_foursquare_access_token'] != '') {
if (!ctype_alnum($form_state['values']['socialfeed_foursquare_access_token'])) {
form_set_error('socialfeed_foursquare_access_token', t('You must enter an alphanumeric string for the access token.'));
}
}
}
/**
* Implements form_submit().
*/
function socialfeed_settings_form_submit(&$form, &$form_state) {
$socialfeed_vars = array(
'socialfeed_facebook_profile_id' => $form_state['values']['socialfeed_facebook_profile_id'],
'socialfeed_facebook_app_id' => $form_state['values']['socialfeed_facebook_app_id'],
'socialfeed_facebook_app_secret' => $form_state['values']['socialfeed_facebook_app_secret'],
'socialfeed_twitter_profile_id' => $form_state['values']['socialfeed_twitter_profile_id'],
'socialfeed_youtube_profile_name' => $form_state['values']['socialfeed_youtube_profile_name'],
'socialfeed_foursquare_access_token' => $form_state['values']['socialfeed_foursquare_access_token'],
'socialfeed_title' => $form_state['values']['socialfeed_title'],
'socialfeed_displaycount' => $form_state['values']['socialfeed_displaycount'],
'socialfeed_facebook_title_checkbox' => $form_state['values']['socialfeed_facebook_title_checkbox'],
'socialfeed_facebook_title' => $form_state['values']['socialfeed_facebook_title'],
'socialfeed_twitter_title_checkbox' => $form_state['values']['socialfeed_twitter_title_checkbox'],
'socialfeed_twitter_title' => $form_state['values']['socialfeed_twitter_title'],
'socialfeed_youtube_title_checkbox' => $form_state['values']['socialfeed_youtube_title_checkbox'],
'socialfeed_youtube_title' => $form_state['values']['socialfeed_youtube_title'],
'socialfeed_foursquare_title_checkbox' => $form_state['values']['socialfeed_foursquare_title_checkbox'],
'socialfeed_foursquare_title' => $form_state['values']['socialfeed_foursquare_title'],
);
foreach ($socialfeed_vars as $key => $value) {
variable_set($key, $value);
}
// Flush the table when these feeds are changed to keep data clean.
socialfeed_flush();
// Retrieve data.
if ($form_state['values']['socialfeed_facebook_profile_id'] && $form_state['values']['socialfeed_facebook_app_id'] && $form_state['values']['socialfeed_facebook_app_secret']) {
socialfeed_facebook();
drupal_set_message(t("Facebook data has been updated as needed."));
}
if ($form_state['values']['socialfeed_twitter_profile_id']) {
socialfeed_twitter();
drupal_set_message(t("Twitter data has been updated as needed."));
}
if ($form_state['values']['socialfeed_youtube_profile_name']) {
socialfeed_youtube();
drupal_set_message(t("Youtube data has been updated as needed."));
}
if ($form_state['values']['socialfeed_foursquare_access_token']) {
socialfeed_foursquare();
drupal_set_message(t("Foursquare data has been updated as needed."));
}
drupal_set_message(t("Your feed settings have been saved. Data has been change accordingly."));
}
/**
* Flushes the cached data.
*/
function socialfeed_flush() {
// Flush the all feed data.
$query = "TRUNCATE TABLE {socialfeed_post}";
$sql = db_query($query);
}
/**
* Implements hook_cron().
*
* Fires hook_update_index() in all modules and cleans up dirty words (see
* search_dirty).
*/
function socialfeed_cron() {
// Retrieve our variables.
$facebook_profile_id = variable_get('socialfeed_facebook_profile_id', FALSE);
$facebook_app_id = variable_get('socialfeed_facebook_app_id', FALSE);
$facebook_app_secret = variable_get('socialfeed_facebook_app_secret', FALSE);
$twitter_profile_name = variable_get('socialfeed_twitter_profile_id', FALSE);
$youtube_profile_name = variable_get('socialfeed_youtube_profile_name', FALSE);
$foursquare_access_token = variable_get('socialfeed_foursquare_access_token', FALSE);
if ($facebook_profile_id && $facebook_app_id && $facebook_app_secret) {
socialfeed_facebook();
}
if ($twitter_profile_name) {
socialfeed_twitter();
}
if ($youtube_profile_name) {
socialfeed_youtube();
}
if ($foursquare_access_token) {
socialfeed_foursquare();
}
}
/**
* Retrieves Data from Facebook.
*/
function socialfeed_facebook() {
$profile_id = variable_get('socialfeed_facebook_profile_id', FALSE);
// App Info, needed for Auth.
$app_id = variable_get('socialfeed_facebook_app_id', FALSE);
$app_secret = variable_get('socialfeed_facebook_app_secret', FALSE);
// Retrieve auth token.
$authtoken = drupal_http_request("https://graph.facebook.com/oauth/access_token?type=client_cred&client_id={$app_id}&client_secret={$app_secret}", array(), 'GET', NULL, 1);
if ($authtoken->status_message == 'OK') {
$data = drupal_http_request("https://graph.facebook.com/{$profile_id}/feed?{$authtoken->data}", array(), 'GET', NULL, 1);
$data_con = $data->data;
$result = json_decode(str_replace("\\u2019", "'", $data_con));
/**
* Inserts Facebook Data.
*/
function socialfeed_facebook_insert($table, $data) {
$query = "SELECT * FROM {socialfeed_post} WHERE id = '%s'";
$sql = db_query_range($query, $data->id, 0, 1);
while ($item = db_fetch_object($sql)) {
$myterms[] = $item;
}
if (!$myterms) {
$post = array();
$post['id'] = $data->id;
$post['time'] = strtotime($data->created_time);
$post['message'] = $data->message;
$post['fbtype'] = $data->type;
$post['picture'] = $data->picture;
$post['link'] = $data->link;
$post['name'] = $data->from->name;
$post['description'] = $data->description;
$post['post_type'] = 'facebook';
drupal_write_record('socialfeed_post', $post);
}
}
if ($result->data) {
foreach ($result->data as $object) {
$profileid = explode('_', $object->id);
if ($object->from->id == $profileid[0]) {
socialfeed_facebook_insert("socialfeed_post", $object);
}
}
}
}
}
/**
* Retrieves Data from Twitter.
*/
function socialfeed_twitter() {
$twitterprofile = variable_get('socialfeed_twitter_profile_id', FALSE);
$twitter_url = "http://twitter.com/statuses/user_timeline/{$twitterprofile}.xml";
$buffer = drupal_http_request($twitter_url, array(), 'GET', NULL, 1);
if ($buffer->status_message == 'OK') {
libxml_use_internal_errors(TRUE);
try {
$xml = new SimpleXMLElement($buffer->data);
} catch (Exception $e) {
// Retreat!
return;
}
$status = $xml->status;
/**
* Inserts Twitter Data.
*/
function socialfeed_twitter_insert($table, $data) {
$query = "SELECT * FROM {socialfeed_post} WHERE id = '%s'";
$sql = db_query_range($query, $data->id, 0, 1);
while ($item = db_fetch_object($sql)) {
$myterms[] = $item;
}
if (!$myterms) {
$post = array();
$post['time'] = strtotime($data->created_at);
$post['message'] = $data->text;
$post['post_type'] = 'twitter';
$post['id'] = $data->id;
$post['name'] = $data->user->screen_name;
drupal_write_record('socialfeed_post', $post);
}
}
if ($status) {
foreach ($status as $object) {
socialfeed_twitter_insert("socialfeed_post", $object);
}
}
}
}
/**
* Retrieves Data from Youtube.
*/
function socialfeed_youtube() {
$youtubeprofile = variable_get('socialfeed_youtube_profile_name', FALSE);
$feedurl = drupal_http_request("http://gdata.youtube.com/feeds/api/users/{$youtubeprofile}/uploads?format=5", array(), 'GET', NULL, 1);
if ($feedurl->status_message == 'OK') {
libxml_use_internal_errors(TRUE);
try {
$sxml = new SimpleXMLElement($feedurl->data);
} catch (Exception $e) {
// Retreat!
return;
}
/**
* Inserts Youtube Data.
*/
function socialfeed_youtube_insert($table, $data) {
// Retrieve this early for the check query.
$arr = explode('/', $data->id);
$id = $arr[count($arr) - 1];
$query = "SELECT * FROM {socialfeed_post} WHERE id = '%s'";
$sql = db_query_range($query, $id, 0, 1);
while ($item = db_fetch_object($sql)) {
$myterms[] = $item;
}
if (!$myterms) {
$media = $data
->children('http://search.yahoo.com/mrss/');
$attrs = $media->group->player
->attributes();
$watch = $attrs['url'];
$attrs = $media->group->thumbnail[0]
->attributes();
$thumbnail = $attrs['url'];
$post = array();
$post['time'] = strtotime($data->published);
$post['message'] = $media->group->description;
$post['picture'] = $thumbnail;
$post['link'] = $watch;
$post['title'] = $media->group->title;
$post['id'] = $id;
$post['post_type'] = 'youtube';
$post['name'] = $data->author->name;
drupal_write_record('socialfeed_post', $post);
}
}
if ($sxml->entry) {
foreach ($sxml->entry as $object) {
socialfeed_youtube_insert("socialfeed_post", $object);
}
}
}
}
/**
* Retrieves Data from Foursquare.
*/
function socialfeed_foursquare() {
$foursquare_access_token = variable_get('socialfeed_foursquare_access_token', FALSE);
$thedata = drupal_http_request('https://api.foursquare.com/v2/users/self/checkins?oauth_token=' . $foursquare_access_token . '', array(), 'GET', NULL, 1);
$theuserdata = drupal_http_request('https://api.foursquare.com/v2/users/self?oauth_token=' . $foursquare_access_token . '', array(), 'GET', NULL, 1);
if ($thedata->status_message == 'OK' && $theuserdata->status_message == 'OK') {
$fq_object = json_decode(str_replace("\\u2019", "'", $thedata->data));
$fq_userobject = json_decode(str_replace("\\u2019", "'", $theuserdata->data));
/**
* Inserts Foursquare Data.
*/
function socialfeed_foursquare_insert($table, $data, $user) {
$query = "SELECT * FROM {socialfeed_post} WHERE id = '%s'";
$sql = db_query_range($query, $data->id, 0, 1);
while ($item = db_fetch_object($sql)) {
$myterms[] = $item;
}
if (!$myterms) {
if ($data->type == 'venueless') {
$post = array();
$post['id'] = $data->id;
$post['venue'] = $data->location->name;
$post['time'] = $data->createdAt;
$post['shout'] = $data->shout;
$post['post_type'] = 'foursquare';
$post['name'] = $user->id;
$post['title'] = $user->firstName;
}
else {
$post = array();
$post['id'] = $data->id;
$post['venue'] = $data->venue->name;
$post['city'] = $data->venue->location->city;
$post['state'] = $data->venue->location->state;
$post['time'] = $data->createdAt;
$post['shout'] = $data->shout;
$post['post_type'] = 'foursquare';
$post['name'] = $user->id;
$post['title'] = $user->firstName;
}
drupal_write_record('socialfeed_post', $post);
}
}
if ($fq_object->response->checkins->items) {
foreach ($fq_object->response->checkins->items as $object) {
socialfeed_foursquare_insert("socialfeed_post", $object, $fq_userobject->response->user);
}
}
}
}
/**
* Implements hook_block().
*/
function socialfeed_block($op = 'list', $delta = 0, $edit = array()) {
// Adds CSS.
drupal_add_css(drupal_get_path('module', 'socialfeed') . '/css/socialfeed.css');
$feedtitle = variable_get('socialfeed_title', FALSE);
switch ($op) {
case 'list':
$blocks[0]['info'] = t('Social Media Feed');
return $blocks;
case 'view':
$blocks['subject'] = t($feedtitle);
$blocks['content'] = socialfeed_build_the_feed();
return $blocks;
}
}
/**
* Builds the block using data based on settings.
*/
function socialfeed_build_the_feed() {
$displaycount = variable_get('socialfeed_displaycount', FALSE);
$query = "SELECT * FROM {socialfeed_post} ORDER BY time DESC";
$sql = db_query_range($query, 0, $displaycount);
while ($item = db_fetch_object($sql)) {
$feeditems[] = $item;
}
$feedname = variable_get('socialfeed_title', FALSE);
$facebookprofile = variable_get('socialfeed_facebook_profile_id', FALSE);
$facebooknamecustom = variable_get('socialfeed_facebook_title', FALSE);
$twitternamecustom = variable_get('socialfeed_twitter_title', FALSE);
$youtubenamecustom = variable_get('socialfeed_facebook_title', FALSE);
$foursquarenamecustom = variable_get('socialfeed_foursquare_title', FALSE);
return theme('socialfeed_feed_structure', 'socialfeed', $feeditems, $feedname, $facebookprofile, $facebooknamecustom, $twitternamecustom, $youtubenamecustom, $foursquarenamecustom);
}
/**
* Implements hook_theme().
*/
function socialfeed_theme() {
return array(
'socialfeed_feed_structure' => array(
'arguments' => array(
'element' => NULL,
),
),
);
}
/**
* Themes the block.
*/
function theme_socialfeed_feed_structure($element, $feeditems, $feedname, $facebookprofile, $facebooknamecustom, $twitternamecustom, $youtubenamecustom, $foursquarenamecustom) {
$output = '<div id="socialfeed">';
if ($feeditems) {
foreach ($feeditems as $fitem) {
switch ($fitem->post_type) {
case 'facebook':
$output .= '<div class="fbitem">';
$output .= l('<div class="socialtitle bpfacebook"><span>' . ($facebooknamecustom ? check_plain($facebooknamecustom) : check_plain($fitem->name)) . '</span></div>', 'http://www.facebook.com/' . check_plain($facebookprofile) . '', array(
'attributes' => array(
'target' => '_blank',
),
'html' => TRUE,
));
$output .= '<p>';
$output .= l(t(check_plain($fitem->name)), 'http://www.facebook.com/' . check_plain($facebookprofile) . '', array(
'attributes' => array(
'target' => '_blank',
),
)) . ' ';
$output .= check_plain($fitem->message);
$output .= '</p>';
if ($fitem->picture) {
$output .= '<img class="asmediaimg" src="' . check_url($fitem->picture) . '">';
}
$output .= '<p class="socialdate">';
$output .= format_date(check_plain($fitem->time), 'custom', 'l F d, Y');
$output .= '</p>';
$output .= '</div>';
break;
case 'twitter':
$output .= '<div class="fbitem">';
$output .= l('<div class="socialtitle bptwitter"><span>@' . ($twitternamecustom ? check_plain($twitternamecustom) : check_plain($fitem->name)) . '</span></div>', 'http://www.twitter.com/' . check_plain($fitem->name) . '', array(
'attributes' => array(
'target' => '_blank',
),
'html' => TRUE,
));
$output .= '<p>';
$output .= check_plain($fitem->message);
$output .= '</p><p class="socialdate">';
$output .= format_date(check_plain($fitem->time), 'custom', 'l F d, Y');
$output .= '</p>';
$output .= '</div>';
break;
case 'foursquare':
$output .= '<div class="fbitem">';
$output .= l('<div class="socialtitle bpfoursaquare"><span>' . ($foursquarenamecustom ? check_plain($foursquarenamecustom) : check_plain($fitem->title)) . '</span></div>', 'http://www.foursquare.com/user/' . check_plain($fitem->name) . '', array(
'attributes' => array(
'target' => '_blank',
),
'html' => TRUE,
));
$output .= '<p>';
$output .= '@';
$output .= check_plain($fitem->venue);
$output .= '<br />';
$output .= check_plain($fitem->shout);
$output .= '</p><p class="socialdate">';
$output .= format_date(check_plain($fitem->time), 'custom', 'l F d, Y');
$output .= '</p>';
$output .= '</div>';
break;
case 'youtube':
$output .= '<div class="fbitem">';
$output .= l('<div class="socialtitle bpyoutube"><span>' . ($youtubenamecustom ? check_plain($youtubenamecustom) : check_plain($fitem->name)) . '</span></div>', 'http://www.youtube.com/' . check_plain($fitem->name) . '', array(
'attributes' => array(
'target' => '_blank',
),
'html' => TRUE,
));
$output .= '<p>';
$output .= check_plain($fitem->message);
$output .= '</p><p class="socialdate">';
$output .= format_date(check_plain($fitem->time), 'custom', 'l F d, Y');
$output .= '</p>';
$output .= '</div>';
break;
}
}
}
$output .= '</div><br />';
return $output;
}
Functions
Name | Description |
---|---|
socialfeed_block | Implements hook_block(). |
socialfeed_build_the_feed | Builds the block using data based on settings. |
socialfeed_cron | Implements hook_cron(). |
socialfeed_facebook | Retrieves Data from Facebook. |
socialfeed_flush | Flushes the cached data. |
socialfeed_foursquare | Retrieves Data from Foursquare. |
socialfeed_menu | Implements hook_menu(). |
socialfeed_perm | Implements hook_perm(). |
socialfeed_settings_form | Form constructor for the socialfeed settings form. |
socialfeed_settings_form_submit | Implements form_submit(). |
socialfeed_settings_form_validate | Implements form_validate(). |
socialfeed_theme | Implements hook_theme(). |
socialfeed_twitter | Retrieves Data from Twitter. |
socialfeed_youtube | Retrieves Data from Youtube. |
theme_socialfeed_feed_structure | Themes the block. |