|
@@ -104,6 +104,7 @@ class DocumentManager
|
|
|
'etx' => 'text/x-setext',
|
|
|
'exe' => 'application/octet-stream',
|
|
|
'ez' => 'application/andrew-inset',
|
|
|
+ 'flv' => 'video/flv',
|
|
|
'gif' => 'image/gif',
|
|
|
'gtar' => 'application/x-gtar',
|
|
|
'gz' => 'application/x-gzip',
|
|
@@ -375,6 +376,7 @@ class DocumentManager
|
|
|
header('Content-type: application/octet-stream');
|
|
|
break;
|
|
|
}
|
|
|
+
|
|
|
header('Content-type: '.$contentType);
|
|
|
header('Content-Length: '.$len);
|
|
|
$user_agent = strtolower($_SERVER['HTTP_USER_AGENT']);
|
|
@@ -3076,29 +3078,16 @@ class DocumentManager
|
|
|
*
|
|
|
* @return string
|
|
|
*/
|
|
|
- public static function generate_jplayer_jquery($params = [])
|
|
|
+ public static function generateAudioJavascript($params = [])
|
|
|
{
|
|
|
- $js_path = api_get_path(WEB_LIBRARY_PATH).'javascript/';
|
|
|
-
|
|
|
$js = '
|
|
|
- $("#jquery_jplayer_'.$params['count'].'").jPlayer({
|
|
|
- ready: function() {
|
|
|
- $(this).jPlayer("setMedia", {
|
|
|
- '.$params['extension'].' : "'.$params['url'].'"
|
|
|
- });
|
|
|
- },
|
|
|
- play: function() { // To avoid both jPlayers playing together.
|
|
|
- $(this).jPlayer("pauseOthers");
|
|
|
- },
|
|
|
- //errorAlerts: true,
|
|
|
- //warningAlerts: true,
|
|
|
- swfPath: "'.$js_path.'jquery-jplayer/jplayer/",
|
|
|
- //supplied: "m4a, oga, mp3, ogg, wav",
|
|
|
- supplied: "'.$params['extension'].'",
|
|
|
- wmode: "window",
|
|
|
- solution: "flash, html", // Do not change this setting
|
|
|
- cssSelectorAncestor: "#jp_container_'.$params['count'].'",
|
|
|
- }); '."\n\n";
|
|
|
+ $(\'video:not(.skip), audio.audio_preview\').mediaelementplayer({
|
|
|
+ features: [\'playpause\'],
|
|
|
+ audioWidth: 30,
|
|
|
+ audioHeight: 30,
|
|
|
+ success: function(mediaElement, originalNode, instance) {
|
|
|
+ }
|
|
|
+ });';
|
|
|
|
|
|
return $js;
|
|
|
}
|
|
@@ -3106,94 +3095,34 @@ class DocumentManager
|
|
|
/**
|
|
|
* Shows a play icon next to the document title in the document list.
|
|
|
*
|
|
|
- * @param int
|
|
|
- * @param string
|
|
|
+ * @param string $documentWebPath
|
|
|
+ * @param array $documentInfo
|
|
|
*
|
|
|
- * @return string html content
|
|
|
+ * @return string
|
|
|
*/
|
|
|
- public static function generate_media_preview($i, $type = 'simple')
|
|
|
+ public static function generateAudioPreview($documentWebPath, $documentInfo)
|
|
|
{
|
|
|
- $i = intval($i);
|
|
|
- $extra_controls = $progress = '';
|
|
|
- if ($type == 'advanced') {
|
|
|
- $extra_controls = ' <li><a href="javascript:;" class="jp-stop" tabindex="1">stop</a></li>
|
|
|
- <li><a href="#" class="jp-mute" tabindex="1">mute</a></li>
|
|
|
- <li><a href="#" class="jp-unmute" tabindex="1">unmute</a></li>';
|
|
|
- $progress = '<div class="jp-progress">
|
|
|
- <div class="jp-seek-bar">
|
|
|
- <div class="jp-play-bar"></div>
|
|
|
- </div>
|
|
|
- </div>';
|
|
|
- }
|
|
|
-
|
|
|
- //Shows only the play button
|
|
|
- $html = '<div id="jquery_jplayer_'.$i.'" class="jp-jplayer"></div>
|
|
|
- <div id="jp_container_'.$i.'" class="jp-audio">
|
|
|
- <div class="jp-type-single">
|
|
|
- <div class="jp-gui jp-interface">
|
|
|
- <ul class="jp-controls">
|
|
|
- <li><a href="javascript:;" class="jp-play" tabindex="1">play</a></li>
|
|
|
- <li><a href="javascript:;" class="jp-pause" tabindex="1">pause</a></li>
|
|
|
- '.$extra_controls.'
|
|
|
- </ul>
|
|
|
- '.$progress.'
|
|
|
- </div>
|
|
|
- </div>
|
|
|
- </div>';
|
|
|
+ $filePath = $documentWebPath.$documentInfo['path'];
|
|
|
+ $extension = $documentInfo['file_extension'];
|
|
|
+ $html = '<span class="preview"> <audio class="audio_preview skip" src="'.$filePath.'" type="audio/'.$extension.'" > </audio></span>';
|
|
|
|
|
|
return $html;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * @param array $document_data
|
|
|
+ * @param string $file
|
|
|
+ * @param string $extension
|
|
|
*
|
|
|
* @return string
|
|
|
*/
|
|
|
- public static function generate_video_preview($document_data = [])
|
|
|
+ public static function generateVideoPreview($file, $extension)
|
|
|
{
|
|
|
- $html = '
|
|
|
- <div id="jp_container_1" class="jp-video center-block" role="application" aria-label="media player">
|
|
|
- <div class="jp-type-single">
|
|
|
- <div id="jquery_jplayer_1" class="jp-jplayer"></div>
|
|
|
- <div class="jp-gui">
|
|
|
- <div class="jp-video-play">
|
|
|
- </div>
|
|
|
- <div class="jp-interface">
|
|
|
- <div class="jp-progress">
|
|
|
- <div class="jp-seek-bar">
|
|
|
- <div class="jp-play-bar"></div>
|
|
|
- </div>
|
|
|
- </div>
|
|
|
- <div class="jp-current-time" role="timer" aria-label="time"> </div>
|
|
|
- <div class="jp-duration" role="timer" aria-label="duration"> </div>
|
|
|
- <div class="jp-controls-holder">
|
|
|
- <div class="jp-controls">
|
|
|
- <button class="jp-play" role="button" tabindex="0">play</button>
|
|
|
- <button class="jp-stop" role="button" tabindex="0">stop</button>
|
|
|
- </div>
|
|
|
- <div class="jp-volume-controls">
|
|
|
- <button class="jp-mute" role="button" tabindex="0">mute</button>
|
|
|
- <button class="jp-volume-max" role="button" tabindex="0">max volume</button>
|
|
|
- <div class="jp-volume-bar">
|
|
|
- <div class="jp-volume-bar-value"></div>
|
|
|
- </div>
|
|
|
- </div>
|
|
|
- <div class="jp-toggles">
|
|
|
- <button class="jp-repeat" role="button" tabindex="0">repeat</button>
|
|
|
- <button class="jp-full-screen" role="button" tabindex="0">full screen</button>
|
|
|
- </div>
|
|
|
- </div>
|
|
|
- <div class="jp-details">
|
|
|
- <div class="jp-title" aria-label="title"> </div>
|
|
|
- </div>
|
|
|
- </div>
|
|
|
- </div>
|
|
|
- <div class="jp-no-solution">
|
|
|
- <span>'.get_lang('UpdateRequire').'</span>
|
|
|
- '.get_lang("ToPlayTheMediaYouWillNeedToUpdateYourBrowserToARecentVersionYouCanAlsoDownloadTheFile").'
|
|
|
- </div>
|
|
|
- </div>
|
|
|
- </div>';
|
|
|
+ $type = '';
|
|
|
+ /*if ($extension != 'flv') {
|
|
|
+
|
|
|
+ }*/
|
|
|
+ //$type = "video/$extension";
|
|
|
+ $html = '<video id="myvideo" src="'.$file.'" controls '.$type.'">';
|
|
|
|
|
|
return $html;
|
|
|
}
|
|
@@ -4971,20 +4900,20 @@ class DocumentManager
|
|
|
/**
|
|
|
* Create a html hyperlink depending on if it's a folder or a file.
|
|
|
*
|
|
|
- * @param array $document_data
|
|
|
- * @param array $course_info
|
|
|
- * @param bool $show_as_icon - if it is true, only a clickable icon will be shown
|
|
|
- * @param int $visibility (1/0)
|
|
|
- * @param int $counter
|
|
|
- * @param int $size
|
|
|
- * @param bool $isAllowedToEdit
|
|
|
- * @param bool $isCertificateMode
|
|
|
+ * @param string $documentWebPath
|
|
|
+ * @param array $document_data
|
|
|
+ * @param bool $show_as_icon - if it is true, only a clickable icon will be shown
|
|
|
+ * @param int $visibility (1/0)
|
|
|
+ * @param int $counter
|
|
|
+ * @param int $size
|
|
|
+ * @param bool $isAllowedToEdit
|
|
|
+ * @param bool $isCertificateMode
|
|
|
*
|
|
|
* @return string url
|
|
|
*/
|
|
|
public static function create_document_link(
|
|
|
+ $documentWebPath,
|
|
|
$document_data,
|
|
|
- $course_info,
|
|
|
$show_as_icon = false,
|
|
|
$counter = null,
|
|
|
$visibility,
|
|
@@ -4993,10 +4922,10 @@ class DocumentManager
|
|
|
$isCertificateMode = false
|
|
|
) {
|
|
|
global $dbl_click_id;
|
|
|
+ $www = $documentWebPath;
|
|
|
|
|
|
- $current_session_id = api_get_session_id();
|
|
|
+ $sessionId = api_get_session_id();
|
|
|
$courseParams = api_get_cidreq();
|
|
|
- $www = api_get_path(WEB_COURSE_PATH).$course_info['path'].'/document';
|
|
|
$webODFList = self::get_web_odf_extension_list();
|
|
|
|
|
|
// Get the title or the basename depending on what we're using
|
|
@@ -5019,11 +4948,11 @@ class DocumentManager
|
|
|
|
|
|
if (!$show_as_icon) {
|
|
|
// Build download link (icon)
|
|
|
- $forcedownload_link = ($filetype == 'folder') ? api_get_self().'?'.$courseParams.'&action=downloadfolder&id='.$document_data['id'] : api_get_self().'?'.$courseParams.'&action=download&id='.$document_data['id'];
|
|
|
+ $forcedownload_link = $filetype == 'folder' ? api_get_self().'?'.$courseParams.'&action=downloadfolder&id='.$document_data['id'] : api_get_self().'?'.$courseParams.'&action=download&id='.$document_data['id'];
|
|
|
// Folder download or file download?
|
|
|
- $forcedownload_icon = ($filetype == 'folder') ? 'save_pack.png' : 'save.png';
|
|
|
+ $forcedownload_icon = $filetype == 'folder' ? 'save_pack.png' : 'save.png';
|
|
|
// Prevent multiple clicks on zipped folder download
|
|
|
- $prevent_multiple_click = ($filetype == 'folder') ? " onclick=\"javascript: if(typeof clic_$dbl_click_id == 'undefined' || !clic_$dbl_click_id) { clic_$dbl_click_id=true; window.setTimeout('clic_".($dbl_click_id++)."=false;',10000); } else { return false; }\"" : '';
|
|
|
+ $prevent_multiple_click = $filetype == 'folder' ? " onclick=\"javascript: if(typeof clic_$dbl_click_id == 'undefined' || !clic_$dbl_click_id) { clic_$dbl_click_id=true; window.setTimeout('clic_".($dbl_click_id++)."=false;',10000); } else { return false; }\"" : '';
|
|
|
}
|
|
|
|
|
|
$target = '_self';
|
|
@@ -5091,6 +5020,8 @@ class DocumentManager
|
|
|
$curdirpath = isset($_GET['curdirpath']) ? Security::remove_XSS($_GET['curdirpath']) : null;
|
|
|
$send_to = null;
|
|
|
$checkExtension = $path;
|
|
|
+ $extension = pathinfo($path, PATHINFO_EXTENSION);
|
|
|
+ $document_data['file_extension'] = $extension;
|
|
|
|
|
|
if (!$show_as_icon) {
|
|
|
if ($filetype == 'folder') {
|
|
@@ -5099,9 +5030,9 @@ class DocumentManager
|
|
|
api_get_setting('students_download_folders') == 'true'
|
|
|
) {
|
|
|
// filter: when I am into a shared folder, I can only show "my shared folder" for donwload
|
|
|
- if (self::is_shared_folder($curdirpath, $current_session_id)) {
|
|
|
+ if (self::is_shared_folder($curdirpath, $sessionId)) {
|
|
|
if (preg_match('/shared_folder\/sf_user_'.api_get_user_id().'$/', urldecode($forcedownload_link)) ||
|
|
|
- preg_match('/shared_folder_session_'.$current_session_id.'\/sf_user_'.api_get_user_id().'$/', urldecode($forcedownload_link)) ||
|
|
|
+ preg_match('/shared_folder_session_'.$sessionId.'\/sf_user_'.api_get_user_id().'$/', urldecode($forcedownload_link)) ||
|
|
|
$isAllowedToEdit || api_is_platform_admin()
|
|
|
) {
|
|
|
$force_download_html = ($size == 0) ? '' : '<a href="'.$forcedownload_link.'" style="float:right"'.$prevent_multiple_click.'>'.
|
|
@@ -5136,7 +5067,6 @@ class DocumentManager
|
|
|
}
|
|
|
|
|
|
$pdf_icon = '';
|
|
|
- $extension = pathinfo($path, PATHINFO_EXTENSION);
|
|
|
if (!$isAllowedToEdit &&
|
|
|
api_get_setting('students_export2pdf') == 'true' &&
|
|
|
$filetype == 'file' &&
|
|
@@ -5152,7 +5082,7 @@ class DocumentManager
|
|
|
}
|
|
|
|
|
|
if ($filetype == 'file') {
|
|
|
- // Sound preview with jplayer
|
|
|
+ // Sound preview
|
|
|
if (preg_match('/mp3$/i', urldecode($checkExtension)) ||
|
|
|
(preg_match('/wav$/i', urldecode($checkExtension))) ||
|
|
|
preg_match('/ogg$/i', urldecode($checkExtension))
|
|
@@ -5214,16 +5144,16 @@ class DocumentManager
|
|
|
// Icon column
|
|
|
if (preg_match('/shared_folder/', urldecode($checkExtension)) &&
|
|
|
preg_match('/shared_folder$/', urldecode($checkExtension)) == false &&
|
|
|
- preg_match('/shared_folder_session_'.$current_session_id.'$/', urldecode($url)) == false
|
|
|
+ preg_match('/shared_folder_session_'.$sessionId.'$/', urldecode($url)) == false
|
|
|
) {
|
|
|
if ($filetype == 'file') {
|
|
|
- //Sound preview with jplayer
|
|
|
+ //Sound preview
|
|
|
if (preg_match('/mp3$/i', urldecode($checkExtension)) ||
|
|
|
(preg_match('/wav$/i', urldecode($checkExtension))) ||
|
|
|
preg_match('/ogg$/i', urldecode($checkExtension))) {
|
|
|
- $sound_preview = self::generate_media_preview($counter);
|
|
|
+ $soundPreview = self::generateAudioPreview($documentWebPath, $document_data);
|
|
|
|
|
|
- return $sound_preview;
|
|
|
+ return $soundPreview;
|
|
|
} elseif (
|
|
|
// Show preview
|
|
|
preg_match('/swf$/i', urldecode($checkExtension)) ||
|
|
@@ -5258,9 +5188,9 @@ class DocumentManager
|
|
|
if (preg_match('/mp3$/i', urldecode($checkExtension)) ||
|
|
|
(preg_match('/wav$/i', urldecode($checkExtension))) ||
|
|
|
preg_match('/ogg$/i', urldecode($checkExtension))) {
|
|
|
- $sound_preview = self::generate_media_preview($counter);
|
|
|
+ $soundPreview = self::generateAudioPreview($documentWebPath, $document_data);
|
|
|
|
|
|
- return $sound_preview;
|
|
|
+ return $soundPreview;
|
|
|
} elseif (
|
|
|
//Show preview
|
|
|
preg_match('/html$/i', urldecode($checkExtension)) ||
|
|
@@ -5303,7 +5233,7 @@ class DocumentManager
|
|
|
public static function build_document_icon_tag($type, $path, $isAllowedToEdit = null)
|
|
|
{
|
|
|
$basename = basename($path);
|
|
|
- $current_session_id = api_get_session_id();
|
|
|
+ $sessionId = api_get_session_id();
|
|
|
if (is_null($isAllowedToEdit)) {
|
|
|
$isAllowedToEdit = api_is_allowed_to_edit(null, true);
|
|
|
}
|
|
@@ -5328,7 +5258,7 @@ class DocumentManager
|
|
|
$basename = get_lang('UserFolder').' '.$userInfo['complete_name'];
|
|
|
$user_image = true;
|
|
|
} elseif (strstr($path, 'shared_folder_session_')) {
|
|
|
- $sessionName = api_get_session_name($current_session_id);
|
|
|
+ $sessionName = api_get_session_name($sessionId);
|
|
|
if ($isAllowedToEdit) {
|
|
|
$basename = '***('.$sessionName.')*** '.get_lang('HelpUsersFolder');
|
|
|
} else {
|
|
@@ -5693,16 +5623,16 @@ class DocumentManager
|
|
|
* Checks whether the user is in shared folder.
|
|
|
*
|
|
|
* @param string $curdirpath
|
|
|
- * @param int $current_session_id
|
|
|
+ * @param int $sessionId
|
|
|
*
|
|
|
* @return bool Return true when user is into shared folder
|
|
|
*/
|
|
|
- public static function is_shared_folder($curdirpath, $current_session_id)
|
|
|
+ public static function is_shared_folder($curdirpath, $sessionId)
|
|
|
{
|
|
|
$clean_curdirpath = Security::remove_XSS($curdirpath);
|
|
|
if ($clean_curdirpath == '/shared_folder') {
|
|
|
return true;
|
|
|
- } elseif ($clean_curdirpath == '/shared_folder_session_'.$current_session_id) {
|
|
|
+ } elseif ($clean_curdirpath == '/shared_folder_session_'.$sessionId) {
|
|
|
return true;
|
|
|
} else {
|
|
|
return false;
|