function fb_admin_app_select_form in Drupal for Facebook 7.4
1 call to fb_admin_app_select_form()
- fb_admin_default_app_form in ./
fb.admin.inc - Form callback.
File
- ./
fb.admin.inc, line 1238
Code
function fb_admin_app_select_form($form, &$form_state, $params = array()) {
// Default settings.
$params = $params + array(
'variable' => FB_VAR_DEFAULT_APP,
);
$form_state['fb']['params'] = $params;
// Present administrator with a choice of applications.
$all_apps = fb_admin_all_apps();
// Include previously saved values.
$current_app = variable_get($params['variable'], array(
'client_id' => '',
));
if ($current_app['client_id'] && empty($all_apps[$current_app['client_id']])) {
$current_app['fba'] = $current_app['client_id'];
$all_apps[$current_app['client_id']] = $current_app;
}
// batch API fails without token.
//$graph = fb_graph_batch($fbas, FB_TOKEN_NONE);
// Less efficient to call fb_graph for each app, but works with our without access token.
foreach ($all_apps as $fba => $app) {
$graph[$fba] = fb_graph($fba, !empty($app['access_token']) ? $app['access_token'] : NULL);
}
if (!empty($graph)) {
foreach ($graph as $fba_data) {
$options[$fba_data['id']] = l('<img src=' . $fba_data['icon_url'] . '></img> ' . $fba_data['name'], $fba_data['link'], array(
'html' => TRUE,
'attributes' => array(
'target' => '_blank',
),
));
}
}
$options[0] = t('None');
$form['application'] = array(
'#type' => 'fieldset',
'#title' => t('Application'),
);
// Remember data for validate and submit handlers.
$form_state['fb']['graph'] = !empty($graph) ? $graph : NULL;
$form_state['fb']['all_apps'] = $all_apps;
// Placeholder
$form['fb_app_data'] = array(
'#type' => 'value',
'#value' => NULL,
);
if (in_array($current_app['client_id'], array_keys($options))) {
$default_select = $current_app['client_id'];
$default_text = NULL;
}
else {
$default_select = 0;
$default_text = $current_app['client_id'];
}
if (count($options) > 1) {
$form['application']['client_id'] = array(
'#type' => 'radios',
'#title' => t('Application'),
'#options' => $options,
'#default_value' => $default_select,
//'#required' => TRUE,
'#description' => t('If your desired application is not shown, use the <a href=!add_app_url>add application form</a>.', array(
'!add_app_url' => url(FB_PATH_ADMIN_APPS . '/add'),
)),
);
$form['#validate'] = array(
'fb_admin_app_select_form_validate',
);
$form['#submit'] = array(
'fb_admin_app_select_form_submit',
);
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Select application'),
);
}
else {
$form['application']['new'] = array(
'#markup' => t('Use the <a href=!add_app_url>add application form</a> to configure an application.', array(
'!add_app_url' => url(FB_PATH_ADMIN_APPS . '/add'),
)),
);
}
return $form;
}