Adding new code to save a nanogong file.

1.10.x
Julio Montoya 12 years ago
parent a89078fe8f
commit c6eac75236
  1. 19
      main/document/showinframes.php
  2. 39
      main/inc/lib/display.lib.php
  3. 262
      main/inc/lib/document.lib.php
  4. 70
      main/inc/lib/fileManager.lib.php
  5. 64
      main/inc/lib/wami-recorder/record_document.php
  6. 4
      main/inc/lib/wami-recorder/recorder.js
  7. 49
      main/newscorm/learnpath.class.php
  8. 115
      main/newscorm/lp_add_audio.php

@ -35,6 +35,7 @@ $document_id = intval($_GET['id']);
$course_info = api_get_course_info();
$course_code = api_get_course_id();
$session_id = api_get_session_id();
if (empty($course_info)) {
api_not_allowed(true);
@ -46,7 +47,10 @@ $show_web_odf = false;
if (!$document_id) {
$document_id = DocumentManager::get_document_id($course_info, $header_file);
}
$document_data = DocumentManager::get_document_data_by_id($document_id, $course_code, true);
$document_data = DocumentManager::get_document_data_by_id($document_id, $course_code, true, $session_id);
if ($session_id != 0 and !$document_data) {
$document_data = DocumentManager::get_document_data_by_id($document_id, $course_code, true, 0);
}
if (empty($document_data)) {
api_not_allowed(true);
@ -406,20 +410,15 @@ if ($is_nanogong_available) {
}
//get file from tmp directory
$to_url=api_get_path(WEB_ARCHIVE_PATH).'temp/audio/'.$file_crip;
$to_url = api_get_path(WEB_ARCHIVE_PATH).'temp/audio/'.$file_crip;
echo '<div align="center">';
echo '<a class="btn" href="'.$file_url_web.'" target="_blank">'.get_lang('Download').'</a>';
echo '<br/>';
echo '<br/>';
echo '<applet id="applet" archive="../inc/lib/nanogong/nanogong.jar" code="gong.NanoGong" width="160" height="40">';
echo '<param name="SoundFileURL" value="'.$to_url.'" />';
echo '<param name="ShowSaveButton" value="false" />';
echo '<param name="ShowTime" value="true" />';
echo '<param name="ShowRecordButton" value="false" />';
echo '</applet>';
echo DocumentManager::readNanogongFile($to_url);
//erase temp file in tmp directory when return to documents
$_SESSION['temp_audio_nanogong']=$to_sys;
echo '</div>';

@ -1886,6 +1886,45 @@ class Display
return $html;
}
/**
* @param string $file
* @param array $params
* @return null|string
*/
public static function getMediaPlayer($file, $params = array())
{
$fileInfo = pathinfo($file);
switch ($fileInfo['extension']) {
case 'wav':
if (isset($params['url'])) {
return DocumentManager::readNanogongFile($params['url']);
}
break;
case 'mp3':
case 'webm':
$autoplay = null;
if (isset($params['autoplay']) && $params['autoplay'] == 'true') {
$autoplay = 'autoplay';
}
$width = isset($params['width']) ? 'width="'.$params['width'].'"' : null;
$id = isset($params['id']) ? $params['id'] : $fileInfo['basename'];
$class = isset($params['class']) ? ' class="'.$params['class'].'"' : null;
$html = '<audio id="'.$id.'" '.$class.' controls '.$autoplay.' '.$width.' src="'.$file.'" >';
$html .= ' <object width="'.$params['width'].'" height="50" type="application/x-shockwave-flash" data="'.api_get_path(WEB_LIBRARY_PATH).'javascript/mediaelement/flashmediaelement.swf">
<param name="movie" value="'.api_get_path(WEB_LIBRARY_PATH).'javascript/mediaelement/flashmediaelement.swf" />
<param name="flashvars" value="controls=true&file='.$fileInfo['basename'].'" />
</object>';
$html .= '</audio>';
return $html;
break;
}
return null;
}
/**
*
* @param int $nextValue

@ -2,13 +2,14 @@
/* For licensing terms, see /license.txt */
/**
* This is the document library for Chamilo.
* It is / will be used to provide a service layer to all document-using tools.
* and eliminate code duplication fro group documents, scorm documents, main documents.
* Include/require it in your code to use its functionality.
* This is the document library for Chamilo.
* It is / will be used to provide a service layer to all document-using tools.
* and eliminate code duplication fro group documents, scorm documents, main documents.
* Include/require it in your code to use its functionality.
*
* @package chamilo.library
* @package chamilo.library
*/
/**
* Code
*/
@ -20,6 +21,7 @@ class DocumentManager
}
/**
* @param string
* @return the document folder quota for the current course, in bytes, or the default quota
*/
public static function get_course_quota($course_code = null)
@ -45,13 +47,14 @@ class DocumentManager
}
/**
* Get the content type of a file by checking the extension
* We could use mime_content_type() with php-versions > 4.3,
* but this doesn't work as it should on Windows installations
* Get the content type of a file by checking the extension
* We could use mime_content_type() with php-versions > 4.3,
* but this doesn't work as it should on Windows installations
*
* @param string $filename or boolean TRUE to return complete array
* @author ? first version
* @author Bert Vanderkimpen
* @param string $filename or boolean TRUE to return complete array
* @author ? first version
* @author Bert Vanderkimpen
* @return string
*
*/
public static function file_get_mime_type($filename)
@ -89,6 +92,7 @@ class DocumentManager
'dotx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.template',
'dvi' => 'application/x-dvi',
'dwg' => 'application/vnd.dwg',
'dwf' => 'application/vnd.dwf',
'dxf' => 'application/vnd.dxf',
'dxr' => 'application/x-director',
'eps' => 'application/postscript',
@ -255,7 +259,8 @@ class DocumentManager
//$filename will be an array if a . was found
if (is_array($extension)) {
$extension = strtolower($extension[sizeof($extension) - 1]);
} //file without extension
}
//file without extension
else {
$extension = 'empty';
}
@ -270,10 +275,12 @@ class DocumentManager
}
/**
* @return true if the user is allowed to see the document, false otherwise
* @author Sergio A Kessler, first version
* @author Roan Embrechts, bugfix
* @todo ??not only check if a file is visible, but also check if the user is allowed to see the file??
* @param string
* @param string
* @return true if the user is allowed to see the document, false otherwise
* @author Sergio A Kessler, first version
* @author Roan Embrechts, bugfix
* @todo not only check if a file is visible, but also check if the user is allowed to see the file??
*/
public static function file_visible_to_user($this_course, $doc_url)
{
@ -2534,15 +2541,15 @@ class DocumentManager
/**
* Uploads a document
*
* @param array the $_FILES variable
* @param string $path
* @param string title
* @param string comment
* @param int unzip or not the file
* @param int if_exists overwrite, rename or warn if exists (default)
* @param bool index document (search xapian module)
* @param bool print html messages
* @return unknown_type
* @param array $files the $_FILES variable
* @param string $path
* @param string $title
* @param string $comment
* @param int $unzip unzip or not the file
* @param int $if_exists if_exists overwrite, rename or warn if exists (default)
* @param bool $index_document index document (search xapian module)
* @param bool $show_output print html messages
* @return array|bool
*/
public static function upload_document(
$files,
@ -3411,7 +3418,7 @@ class DocumentManager
* @param bool When set to true, this runs the indexer without actually saving anything to any database
* @return bool Returns true on presumed success, false on failure
*/
public function index_document(
public static function index_document(
$docid,
$course_code,
$session_id = 0,
@ -3642,11 +3649,19 @@ class DocumentManager
return true;
}
/**
* @return array
*/
public static function get_web_odf_extension_list()
{
return array('ods', 'odt');
}
/**
* @param string $path
* @param bool $is_certificate_mode
* @return bool
*/
public static function is_folder_to_avoid($path, $is_certificate_mode = false)
{
$folders_to_avoid = array(
@ -3695,6 +3710,9 @@ class DocumentManager
return in_array($path, $folders_to_avoid);
}
/**
* @return array
*/
static function get_system_folders()
{
$system_folders = array(
@ -3710,6 +3728,196 @@ class DocumentManager
return $system_folders;
}
/**
* @param string $courseCode
* @return string 'visible' or 'invisible' string
*/
public static function getDocumentDefaultVisibility($courseCode)
{
$settings = api_get_setting('tool_visible_by_default_at_creation');
$defaultVisibility = 'visible';
if (isset($settings['documents'])) {
$portalDefaultVisibility = 'invisible';
if ($settings['documents'] == 'true') {
$portalDefaultVisibility = 'visible';
}
$defaultVisibility = $portalDefaultVisibility;
}
if (api_get_setting('documents_default_visibility_defined_in_course') == 'true') {
$courseVisibility = api_get_course_setting('documents_default_visibility', $courseCode);
if (!empty($courseVisibility) && in_array($courseVisibility, array('visible', 'invisible'))) {
$defaultVisibility = $courseVisibility;
}
}
return $defaultVisibility;
}
/**
* @param array $courseInfo
* @param int $id doc id
* @param string $visibility visible/invisible
* @param int $userId
*/
public static function updateVisibilityFromAllSessions($courseInfo, $id, $visibility, $userId)
{
$sessionList = SessionManager::get_session_by_course($courseInfo['code']);
if (!empty($sessionList)) {
foreach ($sessionList as $session) {
$sessionId = $session['id'];
api_item_property_update(
$courseInfo,
TOOL_DOCUMENT,
$id,
$visibility,
$userId,
null,
null,
null,
null,
$sessionId
);
}
}
}
/**
* @param string $file
* @return string
*/
public static function readNanogongFile($file)
{
$nanoGongJarFile = api_get_path(WEB_LIBRARY_PATH).'nanogong/nanogong.jar';
$html = '<applet id="applet" archive="'.$nanoGongJarFile.'" code="gong.NanoGong" width="160" height="95">';
$html .= '<param name="SoundFileURL" value="'.$file.'" />';
$html .= '<param name="ShowSaveButton" value="false" />';
$html .= '<param name="ShowTime" value="true" />';
$html .= '<param name="ShowRecordButton" value="false" />';
$html .= '</applet>';
return $html;
}
/**
* @param string $filePath
* @param string $path
* @param $courseInfo
* @param string $whatIfFileExists overwrite|rename
* @param null $userId
* @param null $groupId
* @param null $toUserId
* @return bool|path
*/
public static function addFileToDocumentTool(
$filePath,
$path,
$courseInfo,
$userId,
$whatIfFileExists = 'overwrite',
$groupId = null,
$toUserId = null
) {
if (!file_exists($filePath)) {
return false;
}
$fileInfo = pathinfo($filePath);
$file = array(
'name' => $fileInfo['basename'],
'tmp_name' => $filePath,
'size' => filesize($filePath),
'from_file' => true
);
$course_dir = $courseInfo['path'].'/document';
$baseWorkDir = api_get_path(SYS_COURSE_PATH).$course_dir;
$filePath = handle_uploaded_document(
$courseInfo,
$file,
$baseWorkDir,
$path,
$userId,
$groupId,
$toUserId,
false,
$whatIfFileExists,
false
);
if ($filePath) {
return DocumentManager::get_document_id($courseInfo, $filePath);
}
return false;
}
/**
* Converts wav to mp3 file.
* Requires the ffmpeg lib. In ubuntu: sudo apt-get install ffmpeg
* @param string $wavFile
* @param bool $removeWavFileIfSuccess
* @return bool
*/
public static function convertWavToMp3($wavFile, $removeWavFileIfSuccess = false)
{
require_once '../../../../vendor/autoload.php';
if (file_exists($wavFile)) {
try {
$ffmpeg = \FFMpeg\FFMpeg::create();
$video = $ffmpeg->open($wavFile);
$mp3File = str_replace('wav', 'mp3', $wavFile);
$result = $video->save(new FFMpeg\Format\Audio\Mp3(), $mp3File);
if ($result && $removeWavFileIfSuccess) {
unlink($wavFile);
}
if (file_exists($mp3File)) {
return $mp3File;
}
} catch (Exception $e) {
}
}
return false;
}
/**
* @param string $documentData
* @param array $courseInfo
* @param string $whatIfFileExists
* @return bool|path
*/
public static function addAndConvertWavToMp3($documentData, $courseInfo, $userId, $whatIfFileExists = 'overwrite')
{
if (empty($documentData)) {
return false;
}
if (isset($documentData['absolute_path']) && file_exists($documentData['absolute_path'])) {
$mp3FilePath = self::convertWavToMp3($documentData['absolute_path']);
//$mp3FilePath = str_replace('wav', 'mp3', $documentData['absolute_path']);
if (!empty($mp3FilePath)) {
$documentId = self::addFileToDocumentTool(
$mp3FilePath,
dirname($documentData['path']),
$courseInfo,
$userId,
$whatIfFileExists
);
if (!empty($documentId)) {
return $documentId;
}
}
}
return false;
}
}
//end class DocumentManager

@ -1,22 +1,15 @@
<?php
/* For licensing terms, see /license.txt */
/**
* This is the file manage library for Chamilo.
* Include/require it in your code to use its functionality.
* @package chamilo.library
*/
/**
This class contains functions that you can access statically.
This class contains functions that you can access statically.
FileManager::list_all_directories($path)
FileManager::list_all_files($dir_array)
FileManager::compat_load_file($file_name)
FileManager::set_default_settings($upload_path, $filename, $filetype="file", $glued_table, $default_visibility='v')
FileManager::list_all_directories($path)
FileManager::list_all_files($dir_array)
FileManager::compat_load_file($file_name)
FileManager::set_default_settings($upload_path, $filename, $filetype="file", $glued_table, $default_visibility='v')
@author Roan Embrechts
@version 1.1, July 2004
@author Roan Embrechts
@version 1.1, July 2004
* @package chamilo.library
*/
@ -970,7 +963,7 @@ class FileManager
case 'overwrite':
// Check if the target file exists, so we can give another message
$file_exists = file_exists($store_path);
if (@move_uploaded_file($uploaded_file['tmp_name'], $store_path)) {
if (self::moveUploadedFile($uploaded_file, $store_path)) {
chmod($store_path, $files_perm);
if ($file_exists) {
// UPDATE DATABASE
@ -1064,7 +1057,7 @@ class FileManager
$store_path = $where_to_save.$new_name;
$new_file_path = $upload_path.$new_name;
if (@move_uploaded_file($uploaded_file['tmp_name'], $store_path)) {
if (self::moveUploadedFile($uploaded_file, $store_path)) {
chmod($store_path, $files_perm);
@ -1122,7 +1115,7 @@ class FileManager
Display::display_error_message($clean_name.' '.get_lang('UplAlreadyExists'));
}
} else {
if (@move_uploaded_file($uploaded_file['tmp_name'], $store_path)) {
if (self::moveUploadedFile($uploaded_file, $store_path)) {
chmod($store_path, $files_perm);
// Put the document data in the database
@ -1595,16 +1588,19 @@ class FileManager
/**
* Adds a new document to the database
*
* @param array $_course
* @param string $course
* @param string $path
* @param string $filetype
* @param int $filesize
* @param string $title
*
* @return id if inserted document
* @param string $filesize
* @param $title
* @param string $comment
* @param int $readonly
* @param bool $save_visibility
* @param int $group_id
* @param int $session_id Session ID, if any
* @return bool|int
*/
static function add_document(
public static function add_document(
$course,
$path,
$filetype,
@ -1613,9 +1609,14 @@ class FileManager
$comment = null,
$readonly = 0,
$save_visibility = true,
$group_id = null
$group_id = null,
$session_id = 0
) {
$session_id = api_get_session_id();
$session_id = intval($session_id);
if (empty($session_id)) {
$session_id = api_get_session_id();
}
$readonly = intval($readonly);
$comment = Database::escape_string($comment);
$path = Database::escape_string($path);
@ -2054,7 +2055,7 @@ class FileManager
* @param string $base_work_dir
* @param string $current_path, needed for recursivity
*/
static function add_all_documents_in_folder_to_database(
public static function add_all_documents_in_folder_to_database(
$_course,
$user_id,
$base_work_dir,
@ -2149,4 +2150,19 @@ class FileManager
}
}
}
/**
* @param array $file
* @param string $storePath
* @return bool
**/
public static function moveUploadedFile($file, $storePath)
{
$handleFromFile = isset($file['from_file']) && $file['from_file'] ? true : false;
if ($handleFromFile) {
return file_exists($file['tmp_name']);
} else {
return move_uploaded_file($file['tmp_name'], $storePath);
}
}
}

@ -1,9 +1,10 @@
<?php
require_once '../../../inc/global.inc.php';
//Add security from Chamilo
/* For licensing terms, see /license.txt */
// Add security from Chamilo
api_protect_course_script();
api_block_anonymous_users();
//
# Save the audio to a URL-accessible directory for playback.
parse_str($_SERVER['QUERY_STRING'], $params);
@ -78,29 +79,44 @@ if (!DocumentManager::enough_space(filesize($tmpfname), DocumentManager::get_cou
unlink($tmpfname);
//add to disk
// Add to disk
$fh = fopen($documentPath, 'w') or die("can't open file");
fwrite($fh, $content);
fclose($fh);
//add document to database
$doc_id = FileManager::add_document(
$_course,
$wamidir.'/'.$waminame_to_save,
'file',
filesize($documentPath),
$title_to_save
);
api_item_property_update(
$_course,
TOOL_DOCUMENT,
$doc_id,
'DocumentAdded',
$_user['user_id'],
$groupId,
null,
null,
null,
$current_session_id
error_log($documentPath);
$fileInfo = pathinfo($documentPath);
$courseInfo = api_get_course_info();
$file = array(
'file' => array(
'name' => $fileInfo['basename'],
'tmp_name' => $documentPath,
'size' => filesize($documentPath),
'from_file' => true
)
);
?>
$output = true;
$documentData = DocumentManager::upload_document($file, $wamidir, null, null, 0, 'overwrite', false, $output);
if (!empty($documentData)) {
$newDocId = $documentData['id'];
$newMp3DocumentId = DocumentManager::addAndConvertWavToMp3($documentData, $courseInfo, api_get_user_id());
if ($newMp3DocumentId) {
$newDocId = $newMp3DocumentId;
}
if (isset($_REQUEST['lp_item_id']) && !empty($_REQUEST['lp_item_id'])) {
$lpItemId = $_REQUEST['lp_item_id'];
/** @var learnpath $lp */
$lp = isset($_SESSION['oLP']) ? $_SESSION['oLP'] : null;
if (!empty($lp)) {
$lp->set_modified_on();
$lpItem = new learnpathItem($lpItemId);
$lpItem->add_audio_from_documents($newDocId);
}
}
}

@ -75,7 +75,9 @@ Wami.setup = function(options) {
// Detecting the OS is a big no-no in Javascript programming, but
// I can't think of a better way to know if wmode is supported or
// not... since NOT supporting it (like Flash on Ubuntu) is a bug.
return (navigator.platform.indexOf("Linux") == -1);
//return (navigator.platform.indexOf("Linux") == -1);
// Chamilo change
return true;
}
function setOptions(options) {

@ -5,8 +5,8 @@
* learnpaths. It is used by the scorm class.
*
* @package chamilo.learnpath
* @author Yannick Warnier <ywarnier@beeznest.org>
* @author Julio Montoya <gugli100@gmail.com> Several improvements and fixes
* @author Yannick Warnier <ywarnier@beeznest.org>
* @author Julio Montoya <gugli100@gmail.com> Several improvements and fixes
* @todo this file is too big, need a refactor more than 10000 lines!
*/
/**
@ -2263,7 +2263,7 @@ class learnpath
/**
* Returns the HTML necessary to print a mediaplayer block inside a page
* @return string The mediaplayer HTML
* @return string The mediaplayer HTML
*/
public function get_mediaplayer($autostart = 'true')
{
@ -2303,18 +2303,32 @@ class learnpath
$autostart_audio = 'true';
}
$courseInfo = api_get_course_info();
$audio = $row['audio'];
$file = api_get_path(SYS_COURSE_PATH).$courseInfo['path'].'/document/audio/'.$audio;
$url = api_get_path(WEB_COURSE_PATH).$courseInfo['path'].'/document/audio/'.$audio;
if (!file_exists($file)) {
$lpPathInfo = $_SESSION['oLP']->generate_lp_folder(api_get_course_info());
$file = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document'.$lpPathInfo['dir'].$audio;
$url = api_get_path(WEB_COURSE_PATH).$_course['path'].'/document'.$lpPathInfo['dir'].$audio;
}
$player = Display::getMediaPlayer(
$file,
array(
'id' => 'lp_audio_media_player',
'url' => $url,
'autoplay' => $autostart_audio,
'width' => '100%'
)
);
// The mp3 player.
$url = api_get_path(WEB_LIBRARY_PATH).'mediaplayer/';
$fileUrl = api_get_path(WEB_COURSE_PATH).$_course['path'].'/document/audio/'.$row['audio'].'&autostart='.$autostart_audio;
$output = '<div id="container-player">';
$output .= '<script type="text/javascript" src="'.$url.'swfobject.js"></script>';
$output .= '<script type="text/javascript">
var s1 = new SWFObject("'.$url.'player.swf","ply","250","20","9","#FFFFFF");
s1.addParam("allowscriptaccess","always");
s1.addParam("flashvars","file='.$fileUrl.'");
s1.write("container-player");
</script></div>';
echo $output;
$output = '<div id="container">';
$output .= $player;
$output .= '</div>';
}
return $output;
@ -2584,6 +2598,11 @@ class learnpath
}
}
/**
* @param string $size
* @param string $path_type
* @return bool|string
*/
public function get_preview_image_path($size = null, $path_type = 'web')
{
$preview_image = $this->get_preview_image();
@ -4663,7 +4682,7 @@ class learnpath
/**
* Sets the hide_toc_frame parameter of a LP (and save)
* @param int 1 if frame is hiddent 0 thenelse
* @param int 1 if frame is hidden 0 then else
* @return bool Returns true if author's name is not empty
*/
public function set_hide_toc_frame($hide)

@ -13,8 +13,8 @@ $this_section = SECTION_COURSES;
api_protect_course_script();
include 'learnpath_functions.inc.php';
include 'resourcelinker.inc.php';
require_once 'learnpath_functions.inc.php';
require_once 'resourcelinker.inc.php';
$is_allowed_to_edit = api_is_allowed_to_edit(null, true);
@ -22,13 +22,14 @@ $isStudentView = (int) $_REQUEST['isStudentView'];
$learnpath_id = (int) $_REQUEST['lp_id'];
$submit = $_POST['submit_button'];
$type = isset($_GET['type']) ? $_GET['type'] : null;
$action = isset($_GET['action']) ? $_GET['action'] : null;
// Using the resource linker as a tool for adding resources to the learning path.
if ($action == 'add' && $type == 'learnpathitem') {
$htmlHeadXtra[] = "<script language='JavaScript' type='text/javascript'> window.location=\"../resourcelinker/resourcelinker.php?source_id=5&action=$action&learnpath_id=$learnpath_id&chapter_id=$chapter_id&originalresource=no\"; </script>";
$htmlHeadXtra[] = "<script>
window.location=\"../resourcelinker/resourcelinker.php?source_id=5&action=$action&learnpath_id=$learnpath_id&chapter_id=$chapter_id&originalresource=no\";
</script>";
}
if ((!$is_allowed_to_edit) || ($isStudentView)) {
error_log('New LP - User not authorized in lp_add_item.php');
@ -43,9 +44,9 @@ if (isset($_SESSION['gradebook'])) {
if (!empty($gradebook) && $gradebook == 'view') {
$interbreadcrumb[] = array (
'url' => '../gradebook/'.$_SESSION['gradebook_dest'],
'name' => get_lang('ToolGradebook')
);
'url' => '../gradebook/'.$_SESSION['gradebook_dest'],
'name' => get_lang('ToolGradebook')
);
}
$interbreadcrumb[] = array('url' => 'lp_controller.php?action=list', 'name' => get_lang('LearningPaths'));
@ -64,7 +65,7 @@ switch ($type) {
break;
}
if ($action == 'add_item' && $type == 'document' ) {
if ($action == 'add_item' && $type == 'document') {
$interbreadcrumb[]= array ('url' => '#', 'name' => get_lang('NewDocumentCreated'));
}
@ -75,53 +76,85 @@ if (empty($lp_item_id)) {
api_not_allowed();
}
Display::display_header(null, 'Path');
$lp_item = new learnpathItem($lp_item_id);
/** @var Template $tpl */
$tpl = $app['template'];
$form = new FormValidator('add_audio', 'post', api_get_self().'?action=add_audio&id='.$lp_item_id, null, array('enctype' => 'multipart/form-data'));
$suredel = trim(get_lang('AreYouSureToDelete'));
/* DISPLAY SECTION */
$lpPathInfo = $_SESSION['oLP']->generate_lp_folder(api_get_course_info());
$file = null;
if (isset($lp_item->audio) && !empty($lp_item->audio)) {
$file = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document/audio/'.$lp_item->audio;
$urlFile = api_get_path(WEB_COURSE_PATH).$_course['path'].'/document/audio/'.$lp_item->audio;
if (!file_exists($file)) {
$file = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document'.$lpPathInfo['dir'].$lp_item->audio;
$urlFile = api_get_path(WEB_COURSE_PATH).$_course['path'].'/document'.$lpPathInfo['dir'].$lp_item->audio;
}
}
echo $_SESSION['oLP']->build_action_menu();
$page = $_SESSION['oLP']->build_action_menu(true);
$page .= '<div class="row" style="overflow:hidden">';
$page .= '<div id="lp_sidebar" class="col-md-4">';
$page .= $_SESSION['oLP']->return_new_tree(null, true);
echo '<div class="row" style="overflow:hidden">';
echo '<div id="lp_sidebar" class="col-md-4">';
echo $_SESSION['oLP']->return_new_tree(null, true);
// Show the template list.
echo '</div>';
$page .= '</div>';
echo '<div id="doc_form" class="col-md-8">';
$page .= '<div id="doc_form" class="col-md-8">';
$form->addElement('header', get_lang('RecordYourVoice'));
$lp_item = new learnpathItem($lp_item_id);
$form = new FormValidator('add_audio', 'post', api_get_self().'?action=add_audio&id='.$lp_item_id, null, array('enctype' => 'multipart/form-data'));
$tpl->assign('unique_file_id', api_get_unique_id());
$tpl->assign('course_code', api_get_course_id());
$tpl->assign('php_session_id', session_id());
$tpl->assign('filename', $lp_item->get_title().'_nano.wav');
$tpl->assign('enable_nanogong', api_get_setting('enable_nanogong') == 'true' ? 1 : 0);
$tpl->assign('enable_wami', api_get_setting('enable_wami_record') == 'true' ? 1 : 0);
//$tpl->assign('cur_dir_path', api_remove_trailing_slash($lpPathInfo['dir']));
$tpl->assign('cur_dir_path', '/audio');
$tpl->assign('lp_item_id', $lp_item_id);
$tpl->assign('lp_dir', api_remove_trailing_slash($lpPathInfo['dir']));
$voiceContent = $tpl->fetch('default/learnpath/record_voice.tpl');
$form->addElement('html', $voiceContent);
$form->addElement('header', get_lang('UplUpload'));
$form->addElement('html', $lp_item->get_title());
$form->addElement('file', 'file', get_lang('AudioFile'), 'style="width: 250px"');
if (!empty($file)) {
$url = api_get_path(WEB_CODE_PATH).'newscorm/lp_controller.php?lp_id='.$_SESSION['oLP']->get_id().'&action=add_audio&id='.$lp_item_id.'&delete_file=1&'.api_get_cidreq();
$form->addElement('label', null, Display::url(get_lang('RemoveAudio'), $url, array('class' => 'btn btn-danger')));
}
$form->addElement('hidden', 'id', $lp_item_id);
if (isset($lp_item->audio) && !empty($lp_item->audio)) {
$form->addElement('checkbox', 'delete_file', null, get_lang('RemoveAudio'));
$player = '<script type="text/javascript" src="../inc/lib/mediaplayer/swfobject.js"></script>';
$player .= '<div id="preview"></div><script type="text/javascript">
var s1 = new SWFObject("../inc/lib/mediaplayer/player.swf","ply","250","20","9","#FFFFFF");
s1.addParam("allowscriptaccess","always");
s1.addParam("flashvars","file=../../courses/' . $_course['path'] . '/document/audio/' . $lp_item->audio . '");
s1.write("preview");
</script>';
$form->addElement('label', get_lang('Preview'), $player);
if (!empty($file)) {
$audioPlayer = '<div id="preview">'.Display::getMediaPlayer($file, array('url' => $urlFile))."</div>";
$form->addElement('label', get_lang('Preview'), $audioPlayer);
}
$form->addElement('button', 'submit', get_lang('Edit'));
$course_info = api_get_course_info();
$document_tree = DocumentManager::get_document_preview($course_info, null, null, 0, false, '/audio', 'lp_controller.php?action=add_audio&id='.$lp_item_id);
$form->display();
echo '<legend>'.get_lang('SelectAnAudioFileFromDocuments').'</legend>';
echo $document_tree;
echo '</div>';
echo '</div>';
/* FOOTER */
Display::display_footer();
$document_tree = DocumentManager::get_document_preview(
$course_info,
null,
null,
0,
false,
'/audio',
'lp_controller.php?action=add_audio&id='.$lp_item_id
);
$page .= $form->return_form();
$page .= '<legend>'.get_lang('SelectAnAudioFileFromDocuments').'</legend>';
$page .= $document_tree;
$page .= '</div>';
$page .= '</div>';
$tpl->assign('content', $page);

Loading…
Cancel
Save