function socialmedia_admin_profiles_form in Social media 7
Builds and returns the socialmedia settings form.
1 call to socialmedia_admin_profiles_form()
- socialmedia_setup_1_form in ./
socialmedia.setup.inc - Select social media profiles
1 string reference to 'socialmedia_admin_profiles_form'
- socialmedia_menu in ./
socialmedia.module - Implements hook_menu().
File
- ./
socialmedia.admin.inc, line 274 - Admin page callback for the socialmedia module.
Code
function socialmedia_admin_profiles_form($form, &$form_state, $context = 'site', $user = NULL, $setup_mode = FALSE) {
$uid = is_object($user) ? $user->uid : 0;
$platforms = socialmedia_platform_definitions();
$defaults = array_keys($platforms);
$active_platforms = variable_get('socialmedia_platforms_' . ($user ? 'user' : 'site'), $defaults);
$form['context'] = array(
'#type' => 'value',
'#value' => $context,
);
$form['uid'] = array(
'#type' => 'value',
'#value' => $uid,
);
foreach ($platforms as $name => $platform) {
if ((!isset($active_platforms[$name]) || !$active_platforms[$name]) && !$setup_mode) {
continue;
}
$fields = array();
$profile = socialmedia_profile_load($name, $uid);
$fields[$name] = array(
'#type' => 'fieldset',
'#title' => filter_xss($platform['title']),
'#collapsible' => TRUE,
'#collapsed' => FALSE,
);
// check if custom form callback, else use default form fields
if (isset($platform['form callback'])) {
$fields[$name] = array_merge($fields[$name], call_user_func($platform['form callback'], $profile));
}
else {
$default_description = t('Enter the URL to your @platform profile. To create an account on @platform visit !homepage', array(
'@platform' => $platform['title'],
'!homepage' => l($platform['homepage'], $platform['homepage'], array(
'attributes' => array(
'target' => '_blank',
),
)),
));
$fields[$name]['input_' . $name . '_url'] = array(
'#type' => 'textfield',
'#title' => filter_xss($platform['title'] . ' profile URL'),
'#default_value' => isset($profile['inputs']['url']) ? $profile['inputs']['url'] : '',
'#description' => filter_xss(isset($platform['profile url']) ? $platform['profile description url'] : $default_description),
'#size' => 80,
);
$default_description = t('Enter your @platform profile name how you want it displayed in text links. Leave blank to use the username from the URL.', array(
'@platform' => $platform['title'],
));
$fields[$name]['input_' . $name . '_username'] = array(
'#type' => 'textfield',
'#title' => filter_xss($platform['title'] . ' Username'),
'#default_value' => isset($profile['inputs']['username']) ? $profile['inputs']['username'] : '',
'#description' => filter_xss(isset($platform['description username']) ? $platform['description username'] : $default_description),
'#size' => 32,
);
if ($name == 'twitter') {
$fields[$name]['input_' . $name . '_user_timeline_widget_id'] = array(
'#type' => 'textfield',
'#title' => filter_xss($platform['title'] . ' user timeline widget id'),
'#default_value' => isset($profile['inputs']['user_timeline_widget_id']) ? $profile['inputs']['user_timeline_widget_id'] : '',
'#description' => t('Enter the user timeline widget id from Twitter settings you would like to use for profile timelines.'),
'#size' => 32,
);
}
}
if (isset($platform['group'])) {
if (!isset($form[$platform['group']])) {
$form[$platform['group']] = array(
'#type' => 'fieldset',
'#title' => filter_xss($platform['group']),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
'#weight' => 20,
);
}
$form[$platform['group']] = array_merge($form[$platform['group']], $fields);
}
else {
$form = array_merge($form, $fields);
}
}
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Submit'),
'#weight' => 30,
);
return $form;
}