function _janrain_capture_widget_get_screen in Janrain Registration 7.2
Same name and namespace in other branches
- 7.4 includes/janrain_capture.widget.inc \_janrain_capture_widget_get_screen()
Get the contents of a JTL or events file
Parameters
string screenName: The type of screen (signin, forgot, etc...)
string fileType: 'html' for JTL or 'js' for events
Return value
string return empty string on error conditions, otherwise returns the JTL or javascript content of the file.
1 call to _janrain_capture_widget_get_screen()
- janrain_capture_page_build in ./
janrain_capture.module - Implements hook_page_build().
File
- includes/
janrain_capture.widget.inc, line 71 - Widget-related functions
Code
function _janrain_capture_widget_get_screen($screenName, $fileType) {
global $base_url;
// wtb oop
static $allowedScreens = array(
'signin',
'edit-profile',
'public-profile',
'forgot',
'verify',
);
static $allowedTypes = array(
'js',
'html',
);
// sanity check that it's a valid screen request
if (!(in_array($screenName, $allowedScreens) && in_array($fileType, $allowedTypes))) {
// no such screen exists, return empty string.
return '';
}
// check for screens module
if (module_exists('janrain_capture_screens')) {
$fileName = sprintf('%s.%s', $screenName, $fileType);
// proceed with screens module
if (!in_array($fileName, _janrain_capture_get_screens())) {
return '';
}
if ($screen_file = _janrain_capture_get_screen_file($fileName)) {
return file_get_contents($screen_file);
}
return '';
}
// screen name and type are valid get the content
if (_janrain_capture_widget_is_remote_screens()) {
// files are remote so pull from local cache (updated by _janrain_capture_widget_update_screens();
$fileName = sprintf('%s/%s.%s', JANRAIN_CAPTURE_WIDGET_SCREEN_CACHE_DIR, $screenName, $fileType);
}
else {
$screenPath = variable_get('janrain_capture_screens_folder', 'file:///sites/all/themes/janrain-capture-screens/');
if (strpos($screenPath, 'file:///', 0) === 0) {
// files are local, usually in sites/all/themes
$fileName = sprintf('%s%s%s.%s', DRUPAL_ROOT, str_replace('file://', '', $screenPath), $screenName, $fileType);
}
else {
// invalid screens folder setting
$fileName = sprintf('%s/janrain-capture-screens/%s.%s', drupal_get_path('module', 'janrain_capture'), $screenName, $fileType);
}
}
if (!is_readable($fileName)) {
// let everyone know there was a problem with the file, but don't kill the site.
drupal_set_message("Unable to read {$fileName}", 'error');
return '';
}
// file exists and is readable, return the contents.
return file_get_contents($fileName);
}