function janrain_capture_admin_screens_settings in Janrain Registration 7.4
Same name and namespace in other branches
- 7.2 janrain_capture_screens/janrain_capture_screens.admin.inc \janrain_capture_admin_screens_settings()
- 7.3 janrain_capture_screens/janrain_capture_screens.admin.inc \janrain_capture_admin_screens_settings()
Form callback for customizing the Janrain Capture screens.
1 string reference to 'janrain_capture_admin_screens_settings'
- janrain_capture_screens_menu_alter in janrain_capture_screens/
janrain_capture_screens.module - Implements hook_menu_alter().
File
- janrain_capture_screens/
janrain_capture_screens.admin.inc, line 33 - Admin settings form for uploading Capture screens
Code
function janrain_capture_admin_screens_settings($form, &$form_state) {
$screens = _janrain_capture_get_screens();
$cache_directory = 'public://janrain_capture_screens/cache';
// The remote screens are stored locally in our own dir to avoid running
// drupal_http_request during pageload. We have to ensure that the directory
// exists.
if (!file_prepare_directory($cache_directory, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS)) {
watchdog('janrain_capture', 'Failed to create screen cache directory: %directory', array(
'%directory' => $cache_directory,
), WATCHDOG_ERROR);
}
$form = array();
$form['#attributes'] = array(
'enctype' => "multipart/form-data",
);
$form['janrain_capture_screen'] = array(
'#type' => 'vertical_tabs',
);
foreach ($screens as $screen) {
list($screen_category, $extension) = explode('.', $screen);
list($screen_category) = explode('/', $screen_category);
$screen_machine_name = _janrain_capture_get_screen_machine_name($screen);
if (!isset($form['janrain_capture_screen_' . $screen_category])) {
$form['janrain_capture_screen_' . $screen_category] = array(
'#type' => 'fieldset',
'#title' => _janrain_capture_get_screen_title($screen),
'#group' => 'janrain_capture_screen',
'#description' => t('If you want to customize a screen you can either upload a file or provide a URL where it can be found.'),
);
}
$form['janrain_capture_screen_' . $screen_category]['janrain_capture_screen_' . $screen_machine_name] = array(
'#type' => 'managed_file',
'#title' => $screen,
'#upload_location' => 'public://janrain_capture_screens/',
'#upload_validators' => array(
'file_validate_extensions' => array(
$extension,
),
),
'#description' => t('Allowed extensions: %extension', array(
'%extension' => $extension,
)),
'#default_value' => variable_get('janrain_capture_screen_' . $screen_machine_name),
);
$form['janrain_capture_screen_' . $screen_category]['janrain_capture_screen_' . $screen_machine_name . '_remote_url'] = array(
'#type' => 'textfield',
'#title' => t('!screen - remote URL', array(
'!screen' => $screen,
)),
'#default_value' => variable_get('janrain_capture_screen_' . $screen_machine_name . '_remote_url'),
'#description' => t('Example: http://www.example.com/<path to file>/file.extension.'),
);
}
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Save'),
);
return $form;
}