|
|
|
|
@ -3076,11 +3076,20 @@ 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/'; |
|
|
|
|
$path = api_get_path(WEB_LIBRARY_PATH).'javascript/'; |
|
|
|
|
|
|
|
|
|
$js = ' |
|
|
|
|
$(\'video:not(.skip), audio.audio_preview\').mediaelementplayer({ |
|
|
|
|
features: [\'playpause\'], |
|
|
|
|
audioWidth: 30, |
|
|
|
|
audioHeight: 30, |
|
|
|
|
success: function(mediaElement, originalNode, instance) { |
|
|
|
|
} |
|
|
|
|
});'; |
|
|
|
|
|
|
|
|
|
$a = ' |
|
|
|
|
$("#jquery_jplayer_'.$params['count'].'").jPlayer({ |
|
|
|
|
ready: function() { |
|
|
|
|
$(this).jPlayer("setMedia", { |
|
|
|
|
@ -3092,13 +3101,13 @@ class DocumentManager |
|
|
|
|
}, |
|
|
|
|
//errorAlerts: true, |
|
|
|
|
//warningAlerts: true, |
|
|
|
|
swfPath: "'.$js_path.'jquery-jplayer/jplayer/", |
|
|
|
|
swfPath: "'.$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"; |
|
|
|
|
});'."\n\n"; |
|
|
|
|
|
|
|
|
|
return $js; |
|
|
|
|
} |
|
|
|
|
@ -3106,40 +3115,16 @@ 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; |
|
|
|
|
} |
|
|
|
|
@ -4971,20 +4956,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 +4978,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 +5004,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 +5076,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 +5086,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 +5123,6 @@ class DocumentManager |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$pdf_icon = ''; |
|
|
|
|
$extension = pathinfo($path, PATHINFO_EXTENSION); |
|
|
|
|
if (!$isAllowedToEdit && |
|
|
|
|
api_get_setting('students_export2pdf') == 'true' && |
|
|
|
|
$filetype == 'file' && |
|
|
|
|
@ -5152,7 +5138,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 +5200,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 +5244,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 +5289,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 +5314,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 +5679,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; |
|
|
|
|
|