function brightcove_media_file_uri_to_object in Brightcove Video Connect 7.2
Same name and namespace in other branches
- 7.7 brightcove_media/brightcove_media.module \brightcove_media_file_uri_to_object()
- 7.3 brightcove_media/brightcove_media.module \brightcove_media_file_uri_to_object()
- 7.4 brightcove_media/brightcove_media.module \brightcove_media_file_uri_to_object()
- 7.6 brightcove_media/brightcove_media.module \brightcove_media_file_uri_to_object()
1 call to brightcove_media_file_uri_to_object()
- MediaInternetBrightcoveHandler::getFileObject in brightcove_media/
MediaInternetBrightcoveHandler.inc - Returns a file object which can be used for validation
File
- brightcove_media/
brightcove_media.module, line 651
Code
function brightcove_media_file_uri_to_object($uri, $use_existing = FALSE) {
if ($use_existing) {
$query = db_select('file_managed', 'f')
->fields('f', array(
'fid',
))
->condition('uri', $uri)
->execute()
->fetchCol();
if (!empty($query)) {
$file = file_load(array_shift($query));
}
}
if (!isset($file)) {
global $user;
$uri = file_stream_wrapper_uri_normalize($uri);
$wrapper = file_stream_wrapper_get_instance_by_uri($uri);
$file = new StdClass();
// This is gagged because some uris will not support it.
$file->filesize = @filesize($uri);
$file->timestamp = REQUEST_TIME;
$file->status = FILE_STATUS_PERMANENT;
$file->is_new = TRUE;
$file->uri = $uri;
$file->filemime = file_get_mimetype($uri);
$file->uid = $user->uid;
if (isset($_SESSION['brightcove']["video_just_uploaded_{$user->uid}"])) {
$uploaded_video = $_SESSION['brightcove']["video_just_uploaded_{$user->uid}"];
$file->filename = $uploaded_video->filename;
unset($_SESSION['brightcove']["video_just_uploaded_{$user->uid}"]);
}
else {
if (isset($_SESSION['brightcove']["selected_video_{$user->uid}"])) {
$selected_video = $_SESSION['brightcove']["selected_video_{$user->uid}"];
$file->filename = $selected_video->name;
unset($_SESSION['brightcove']["selected_video_{$user->uid}"]);
}
else {
$file->filename = basename($uri);
}
}
}
return $file;
}