This commit is contained in:
Xes
2025-08-14 22:37:50 +02:00
parent fb6d5d5926
commit 3641e93527
9156 changed files with 1813532 additions and 0 deletions

View File

@@ -0,0 +1,41 @@
<?php
/* For licensing terms, see /license.txt */
/**
* Display part of the document sub-process for upload. This script MUST BE included by upload/index.php
* as it prepares most of the variables needed here.
*
* @package chamilo.upload
*
* @author Yannick Warnier <ywarnier@beeznest.org>
*/
/**
* Just display the form needed to upload a SCORM and give its settings.
*/
$nameTools = get_lang('FileUpload');
$interbreadcrumb[] = ["url" => "../lp/lp_controller.php?action=list", "name" => get_lang(TOOL_DOCUMENT)];
Display::display_header($nameTools, "Doc");
// Show the title
api_display_tool_title($nameTools.$add_group_to_title);
$frmUpload = new FormValidator('form_div', 'post', 'upload.php');
$frmUpload->addElement('hidden', 'curdirpath', $path);
$frmUpload->addElement('hidden', 'tool', $my_tool);
$frmUpload->addElement('file', 'user_file', get_lang('FileToUpload'));
$frmUpload->addRule('user_file', get_lang('ThisFieldIsRequired'), 'required');
$frmUpload->addButtonUpload(get_lang('Upload'));
echo '
<div id="dynamic_div" style="display:block;margin-left:40%;margin-top:10px;height:50px;">
</div>
<div id="upload_form_div" name="form_div" style="display:block;">
';
$frmUpload->display();
echo '
</div>
<br/>
';
Display::display_footer();

140
main/upload/form.scorm.php Normal file
View File

@@ -0,0 +1,140 @@
<?php
/* For licensing terms, see /license.txt */
/**
* Display part of the SCORM sub-process for upload. This script MUST BE included by upload/index.php
* as it prepares most of the variables needed here.
*
* @package chamilo.upload
*
* @author Yannick Warnier <ywarnier@beeznest.org>
*/
/**
* Small function to list files in archive/.
*/
function get_zip_files_in_garbage()
{
$list = [];
$dh = opendir(api_get_path(SYS_ARCHIVE_PATH));
if ($dh === false) {
//ignore
} else {
while ($entry = readdir($dh)) {
if (substr($entry, 0, 1) == '.') {
/* ignore files starting with . */
} else {
if (preg_match('/^.*\.zip$/i', $entry)) {
$list[] = $entry;
}
}
}
natcasesort($list);
closedir($dh);
}
return $list;
}
/**
* Just display the form needed to upload a SCORM and give its settings.
*/
$nameTools = get_lang('FileUpload');
$interbreadcrumb[] = [
'url' => api_get_path(WEB_CODE_PATH).'lp/lp_controller.php?action=list&'.api_get_cidreq(),
'name' => get_lang('ToolLearnpath'),
];
Display::display_header($nameTools, 'Path');
require_once '../lp/content_makers.inc.php';
require_once api_get_path(LIBRARY_PATH).'specific_fields_manager.lib.php';
echo '<div class="actions">';
echo '<a href="'.api_get_path(WEB_CODE_PATH).'lp/lp_controller.php?'.api_get_cidreq().'">'.
Display::return_icon('back.png', get_lang('ReturnToLearningPaths'), '', ICON_SIZE_MEDIUM).'</a>';
echo '</div>';
$form = new FormValidator(
'',
'POST',
api_get_path(WEB_CODE_PATH).'upload/upload.php?'.api_get_cidreq(),
'',
[
'id' => 'upload_form',
'enctype' => 'multipart/form-data',
]
);
$form->addHeader($nameTools);
$form->addLabel(null, Display::return_icon('scorm_logo.jpg', null, ['style' => 'width:230px;height:100px']));
$form->addElement('hidden', 'curdirpath', $path);
$form->addElement('hidden', 'tool', $my_tool);
//$form->addElement('file', 'user_file', get_lang('FileToUpload'));
$form->addElement('BigUpload', 'user_file', get_lang('FileToUpload'), ['id' => 'bigUploadFile', 'data-origin' => 'learnpath']);
$form->addProgress();
$form->addRule('user_file', get_lang('ThisFieldIsRequired'), 'required');
unset($content_origins[0]);
unset($content_origins[1]);
if (api_get_setting('search_enabled') == 'true') {
$form->addElement('checkbox', 'index_document', '', get_lang('SearchFeatureDoIndexDocument'));
$specific_fields = get_specific_field_list();
foreach ($specific_fields as $specific_field) {
$form->addElement('text', $specific_field['code'], $specific_field['name'].' : ');
}
}
$form->addElement('checkbox', 'use_max_score', null, get_lang('UseMaxScore100'));
if (api_get_configuration_value('allow_htaccess_import_from_scorm')) {
$form->addElement('checkbox', 'allow_htaccess', null, get_lang('AllowHtaccessScormImport'));
}
$form->addButtonUpload(get_lang('Upload'));
if (api_get_configuration_value('scorm_upload_from_cache')) {
$list = get_zip_files_in_garbage();
$select_file_name = &$form->addElement(
'select',
'file_name',
get_lang('Or').' '.api_strtolower(get_lang('UploadLocalFileFromGarbageDir'))
);
if (count($list) > 0) {
foreach ($list as $file) {
$select_file_name->addOption($file, $file);
}
$form->addButtonUpload(get_lang('Upload'));
} else {
$select_file_name->addOption(get_lang('ImportNoFile'), get_lang('ImportNoFile'));
}
}
if (api_get_setting('status', 'pens') == 'installed') {
require_once api_get_path(SYS_PLUGIN_PATH)."/pens/chamilo_pens.php";
$list = ChamiloPens::findAll();
$select_pens = $form->addElement(
'select',
'pens_package',
'Or select an existing PENS package'
);
if (count($list) > 0) {
foreach ($list as $package) {
$select_pens->addOption($package->getPackageName(), $package->getPackageName());
}
} else {
$select_pens->addOption(get_lang('ImportNoFile'), get_lang('ImportNoFile'));
}
}
// the default values for the form
$defaults = ['index_document' => 'checked="checked"', 'use_max_score' => 1];
$form->setDefaults($defaults);
echo Display::return_message(
Display::tag('strong', get_lang('SupportedScormContentMakers')).': '.implode(', ', $content_origins),
'normal',
false
);
$form->display();
Display::display_footer();

6
main/upload/index.html Normal file
View File

@@ -0,0 +1,6 @@
<html>
<head>
</head>
<body>
</body>
</html>

82
main/upload/index.php Normal file
View File

@@ -0,0 +1,82 @@
<?php
/* For licensing terms, see /license.txt */
use ChamiloSession as Session;
/**
* Main script for the documents tool.
*
* This script allows the user to manage files and directories on a remote http server.
*
* The user can : - upload a file
*
* The script respects the strategical split between process and display, so the first
* part is only processing code (init, process, display preparation) and the second
* part is only display (HTML)
*
* @package chamilo.upload
*/
require_once __DIR__.'/../inc/global.inc.php';
$_course = api_get_course_info();
api_protect_course_script(true);
$htmlHeadXtra[] = "<script>
function check_unzip() {
if (document.upload.unzip.checked) {
document.upload.if_exists[0].disabled=true;
document.upload.if_exists[1].checked=true;
document.upload.if_exists[2].disabled=true;
} else {
document.upload.if_exists[0].checked=true;
document.upload.if_exists[0].disabled=false;
document.upload.if_exists[2].disabled=false;
}
}
</script>";
$is_allowed_to_edit = api_is_allowed_to_edit(null, true);
if (!$is_allowed_to_edit) {
api_not_allowed(true);
}
//what's the current path?
$path = '/';
if (isset($_REQUEST['curdirpath'])) {
$path = $_REQUEST['curdirpath'];
}
$toolFromSession = Session::read('my_tool');
// set calling tool
if (isset($_REQUEST['tool'])) {
$my_tool = $_REQUEST['tool'];
Session::write('my_tool', $_REQUEST['tool']);
} elseif (!empty($toolFromSession)) {
$my_tool = $toolFromSession;
} else {
$my_tool = 'document';
Session::write('my_tool', $my_tool);
}
/**
* Process.
*/
Event::event_access_tool(TOOL_UPLOAD);
/**
* Now call the corresponding display script, the current script acting like a controller.
*/
switch ($my_tool) {
case TOOL_LEARNPATH:
require 'form.scorm.php';
break;
//the following cases need to be distinguished later on
case TOOL_DROPBOX:
case TOOL_STUDENTPUBLICATION:
case TOOL_DOCUMENT:
default:
require 'form.document.php';
break;
}

View File

@@ -0,0 +1,225 @@
<?php
/* For licensing terms, see /license.txt */
exit;
/**
* Process part of the document sub-process for upload. This script MUST BE included by upload/index.php
* as it prepares most of the variables needed here.
*
* @todo check if this file is deprecated ... jmontoya
*
* @package chamilo.upload
*
* @author Yannick Warnier <ywarnier@beeznest.org>
*/
$_course = api_get_course_info();
$courseDir = $_course['path']."/document";
$sys_course_path = api_get_path(SYS_COURSE_PATH);
$base_work_dir = $sys_course_path.$courseDir;
$max_filled_space = DocumentManager::get_course_quota();
//what's the current path?
if (isset($_POST['curdirpath'])) {
$path = Security::remove_XSS($_POST['curdirpath']);
} else {
$path = '/';
}
// Check the path
// If the path is not found (no document id), set the path to /
if (!DocumentManager::get_document_id($_course, $path)) {
$path = '/';
}
/**
* Header.
*/
$nameTools = get_lang('UplUploadDocument');
$interbreadcrumb[] = [
"url" => api_get_path(WEB_CODE_PATH)."document/document.php?curdirpath=".urlencode($path).'&'.api_get_cidreq(),
"name" => get_lang('Documents'),
];
Display::display_header($nameTools, "Doc");
//show the title
api_display_tool_title($nameTools.$add_group_to_title);
/**
* Process.
*/
//user has submitted a file
if (isset($_FILES['user_upload'])) {
$upload_ok = process_uploaded_file($_FILES['user_upload']);
if ($upload_ok) {
//file got on the server without problems, now process it
$new_path = handle_uploaded_document(
$_course,
$_FILES['user_upload'],
$base_work_dir,
$_POST['curdirpath'],
api_get_user_id(),
api_get_group_id(),
$to_user_id,
$_POST['unzip'],
$_POST['if_exists']
);
$new_comment = isset($_POST['comment']) ? Database::escape_string(trim($_POST['comment'])) : '';
$new_title = isset($_POST['title']) ? Database::escape_string(trim($_POST['title'])) : '';
if ($new_path && ($new_comment || $new_title)) {
if (($docid = DocumentManager::get_document_id($_course, $new_path))) {
$table_document = Database::get_course_table(TABLE_DOCUMENT);
$ct = '';
if ($new_comment) {
$ct .= ", comment='$new_comment'";
}
if ($new_title) {
$ct .= ", title='$new_title'";
}
Database::query("UPDATE $table_document SET".substr($ct, 1)." WHERE id = '$docid'");
}
}
//check for missing images in html files
$missing_files = check_for_missing_files($base_work_dir.$_POST['curdirpath'].$new_path);
if ($missing_files) {
//show a form to upload the missing files
echo Display::return_message(
build_missing_files_form(
$missing_files,
$_POST['curdirpath'],
$_FILES['user_upload']['name']
)
);
}
}
}
//missing images are submitted
if (isset($_POST['submit_image'])) {
$number_of_uploaded_images = count($_FILES['img_file']['name']);
//if images are uploaded
if ($number_of_uploaded_images > 0) {
//we could also create a function for this, I'm not sure...
//create a directory for the missing files
$img_directory = str_replace('.', '_', $_POST['related_file']."_files");
$folderData = create_unexisting_directory(
$_course,
api_get_user_id(),
api_get_session_id(),
api_get_group_id(),
$to_user_id,
$base_work_dir,
$img_directory
);
$missing_files_dir = $folderData['path'];
//put the uploaded files in the new directory and get the paths
$paths_to_replace_in_file = move_uploaded_file_collection_into_directory(
$_course,
$_FILES['img_file'],
$base_work_dir,
$missing_files_dir,
$_user['user_id'],
$to_group_id,
$to_user_id,
$max_filled_space
);
//open the html file and replace the paths
replace_img_path_in_html_file(
$_POST['img_file_path'],
$paths_to_replace_in_file,
$base_work_dir.$_POST['related_file']
);
//update parent folders
item_property_update_on_folder($_course, $_POST['curdirpath'], $_user['user_id']);
}
}
//they want to create a directory
if (isset($_POST['create_dir']) && $_POST['dirname'] != '') {
$added_slash = $path == '/' ? '' : '/';
$dir_name = $path.$added_slash.api_replace_dangerous_char($_POST['dirname']);
$created_dir = create_unexisting_directory(
$_course,
api_get_user_id(),
api_get_session_id(),
api_get_group_id(),
$to_user_id,
$base_work_dir,
$dir_name,
$_POST['dirname']
);
if ($created_dir) {
echo Display::return_message(get_lang('DirCr'));
$path = $created_dir;
} else {
echo Display::return_message(get_lang('CannotCreateDir'));
}
}
if (isset($_GET['createdir'])) {
//create the form that asks for the directory name
$new_folder_text = '<form action="'.api_get_self().'" method="POST">';
$new_folder_text .= '<input type="hidden" name="curdirpath" value="'.$path.'"/>';
$new_folder_text .= get_lang('NewDir').' ';
$new_folder_text .= '<input type="text" name="dirname"/>';
$new_folder_text .= '<input type="submit" name="create_dir" value="'.get_lang('Ok').'"/>';
$new_folder_text .= '</form>';
//show the form
echo Display::return_message($new_folder_text, 'normal');
} else {
//give them a link to create a directory?>
<p>
<a href="<?php echo api_get_self(); ?>?path=<?php echo $path; ?>&amp;createdir=1">
<?php echo Display::return_icon('new_folder.gif'); ?>
<?php echo get_lang('CreateDir'); ?>
</a>
</p>
<?php
}
?>
<div id="folderselector">
</div>
<!-- start upload form -->
<form action="<?php echo api_get_self(); ?>" method="POST" name="upload" enctype="multipart/form-data">
<!-- <input type="hidden" name="MAX_FILE_SIZE" value="5400"> -->
<input type="hidden" name="curdirpath" value="<?php echo $path; ?>">
<table>
<tr>
<td valign="top">
<?php echo get_lang('File'); ?>
</td>
<td>
<input type="file" name="user_upload"/>
</td>
</tr>
<tr>
<td><?php echo get_lang('Title'); ?></td>
<td><input type="text" size="20" name="title" style="width:300px;"></td>
</tr>
<tr>
<td valign="top"><?php echo get_lang('Comment'); ?></td>
<td><textarea rows="3" cols="20" name="comment" wrap="virtual" style="width:300px;"></textarea></td>
</tr>
<tr>
<td valign="top">
<?php echo get_lang('Options'); ?>
</td>
<td>
- <input type="checkbox" name="unzip" value="1" onclick="check_unzip()"/> <?php echo get_lang('Uncompress'); ?><br/>
- <?php echo get_lang('UplWhatIfFileExists'); ?><br/>
&nbsp;&nbsp;&nbsp;<input type="radio" name="if_exists" value="nothing" title="<?php echo get_lang('UplDoNothingLong'); ?>" checked="checked"/> <?php echo get_lang('UplDoNothing'); ?><br/>
&nbsp;&nbsp;&nbsp;<input type="radio" name="if_exists" value="overwrite" title="<?php echo get_lang('UplOverwriteLong'); ?>"/> <?php echo get_lang('UplOverwrite'); ?><br/>
&nbsp;&nbsp;&nbsp;<input type="radio" name="if_exists" value="rename" title="<?php echo get_lang('UplRenameLong'); ?>"/> <?php echo get_lang('UplRename'); ?>
</td>
</tr>
</table>
<input type="submit" value="<?php echo get_lang('Ok'); ?>">
</form>
<!-- end upload form -->
<!-- so they can get back to the documents -->
<p><?php echo get_lang('Back'); ?> <?php echo get_lang('To'); ?> <a href="document.php?curdirpath=<?php echo $path; ?>"><?php echo get_lang('DocumentsOverview'); ?></a></p>
<?php
Display::display_footer();

47
main/upload/upload.php Normal file
View File

@@ -0,0 +1,47 @@
<?php
/* For licensing terms, see /license.txt */
use ChamiloSession as Session;
/**
* Action controller for the upload process. The display scripts (web forms) redirect
* the process here to do what needs to be done with each file.
*
* @package chamilo.upload
*
* @author Yannick Warnier <ywarnier@beeznest.org>
*/
require_once __DIR__.'/../inc/global.inc.php';
api_protect_course_script(true);
$toolFromSession = Session::read('my_tool');
// return to index if no tool is set
if (empty($toolFromSession)) {
header('location:index.php');
exit;
}
// check access permissions (edit permission is needed to add a document or a LP)
$is_allowed_to_edit = api_is_allowed_to_edit();
if (!$is_allowed_to_edit) {
api_not_allowed(true);
}
/**
* Redirect to the correct script to handle this type of upload.
*/
switch ($toolFromSession) {
case TOOL_LEARNPATH:
require 'upload.scorm.php';
break;
//the following cases need to be distinguished later on
case TOOL_DROPBOX:
case TOOL_STUDENTPUBLICATION:
case TOOL_DOCUMENT:
default:
//require 'upload.document.php';
break;
}

View File

@@ -0,0 +1,42 @@
<?php
/* For licensing terms, see /license.txt */
/**
* Process part of the SCORM sub-process for upload. This script MUST BE included by upload/index.php
* as it prepares most of the variables needed here.
*
* @package chamilo.upload
*
* @author Yannick Warnier <ywarnier@beeznest.org>
*/
$cwdir = getcwd();
require_once '../lp/lp_upload.php';
// Reinit current working directory as many functions in upload change it
chdir($cwdir);
if (api_get_setting('search_enabled') === 'true') {
require_once api_get_path(LIBRARY_PATH).'specific_fields_manager.lib.php';
$specific_fields = get_specific_field_list();
foreach ($specific_fields as $specific_field) {
$values = explode(',', trim($_POST[$specific_field['code']]));
if (!empty($values)) {
foreach ($values as $value) {
$value = trim($value);
if (!empty($value)) {
add_specific_field_value(
$specific_field['id'],
api_get_course_id(),
TOOL_LEARNPATH,
$oScorm->lp_id,
$value
);
}
}
}
}
}
header('location: ../lp/lp_controller.php?action=list&'.api_get_cidreq());
exit;

115
main/upload/upload_ppt.php Normal file
View File

@@ -0,0 +1,115 @@
<?php
/* For licensing terms, see /license.txt */
use Chamilo\CoreBundle\Component\Utils\ChamiloApi;
/**
* Action controller for the upload process. The display scripts (web forms) redirect
* the process here to do what needs to be done with each file.
*
* @package chamilo.upload
*
* @author Yannick Warnier <ywarnier@beeznest.org>
*/
require_once __DIR__.'/../inc/global.inc.php';
api_protect_course_script(true);
if (isset($_POST['convert'])) {
$cwdir = getcwd();
if (isset($_FILES['user_file'])) {
$allowed_extensions = ['odp', 'sxi', 'ppt', 'pps', 'sxd', 'pptx'];
if (in_array(
strtolower(pathinfo($_FILES['user_file']['name'], PATHINFO_EXTENSION)),
$allowed_extensions
)) {
require_once api_get_path(SYS_CODE_PATH).'lp/lp_upload.php';
if (isset($o_ppt) && $first_item_id != 0) {
if (api_get_setting('search_enabled') == 'true') {
require_once api_get_path(LIBRARY_PATH).'specific_fields_manager.lib.php';
$specific_fields = get_specific_field_list();
foreach ($specific_fields as $specific_field) {
$values = explode(',', trim($_POST[$specific_field['code']]));
if (!empty($values)) {
foreach ($values as $value) {
$value = trim($value);
if (!empty($value)) {
add_specific_field_value(
$specific_field['id'],
api_get_course_id(),
TOOL_LEARNPATH,
$o_ppt->lp_id,
$value
);
}
}
}
}
}
header('Location: ../lp/lp_controller.php?'.api_get_cidreq().'&lp_id='.$o_ppt->lp_id.'&action=view_item&id='.$first_item_id);
exit;
} else {
if (!empty($o_ppt->error)) {
$errorMessage = $o_ppt->error;
} else {
$errorMessage = get_lang('OogieUnknownError');
}
}
} else {
$errorMessage = get_lang('OogieBadExtension');
}
}
}
Event::event_access_tool(TOOL_UPLOAD);
// check access permissions (edit permission is needed to add a document or a LP)
$is_allowed_to_edit = api_is_allowed_to_edit();
if (!$is_allowed_to_edit) {
api_not_allowed(true);
}
$interbreadcrumb[] = ["url" => "../lp/lp_controller.php?action=list", "name" => get_lang("Doc")];
$nameTools = get_lang("OogieConversionPowerPoint");
Display::display_header($nameTools);
$message = get_lang("WelcomeOogieConverter");
if (!empty($errorMessage)) {
echo Display::return_message($errorMessage, 'warning', false);
}
$div_upload_limit = get_lang('UploadMaxSize').' : '.ini_get('post_max_size');
$form = new FormValidator('upload_ppt', 'POST', '?'.api_get_cidreq(), '');
$form->addElement('header', get_lang("WelcomeOogieSubtitle"));
$form->addElement('html', Display::return_message($message, 'info', false));
$form->addElement('file', 'user_file', [Display::return_icon('powerpoint_big.gif'), $div_upload_limit]);
$form->addElement('checkbox', 'take_slide_name', '', get_lang('TakeSlideName'));
$options = ChamiloApi::getDocumentConversionSizes();
$form->addElement('select', 'slide_size', get_lang('SlideSize'), $options);
if (api_get_setting('search_enabled') === 'true') {
require_once api_get_path(LIBRARY_PATH).'specific_fields_manager.lib.php';
$specific_fields = get_specific_field_list();
$form->addElement('checkbox', 'index_document', '', get_lang('SearchFeatureDoIndexDocument'));
$form->addSelectLanguage('language', get_lang('SearchFeatureDocumentLanguage'));
foreach ($specific_fields as $specific_field) {
$form->addElement('text', $specific_field['code'], $specific_field['name'].' : ');
}
}
$form->addButtonUpload(get_lang('ConvertToLP'), 'convert');
$form->addElement('hidden', 'ppt2lp', 'true');
$form->addProgress();
$size = api_get_setting('service_ppt2lp', 'size');
$defaults = [
'take_slide_name' => 'checked="checked"',
'index_document' => 'checked="checked"',
'slide_size' => $size,
];
$form->setDefaults($defaults);
// display the form
$form->display();
Display::display_footer();

190
main/upload/upload_word.php Normal file
View File

@@ -0,0 +1,190 @@
<?php
/* For licensing terms, see /license.txt */
/**
* Action controller for the upload process. The display scripts (web forms)
* redirect
* the process here to do what needs to be done with each file.
*
* @package chamilo.upload
*
* @author Yannick Warnier <ywarnier@beeznest.org>
*/
require_once __DIR__.'/../inc/global.inc.php';
api_protect_course_script(true);
$form_style = '<style>
.row {
width: 200px;
}
.convert_button{
background: url("'.Display::returnIconPath('learnpath.png').'") 0px 0px no-repeat;
padding: 2px 0px 2px 22px;
}
#dynamic_div_container{float:left;margin-right:10px;}
#dynamic_div_waiter_container{float:left;}
</style>';
$htmlHeadXtra[] = $form_style;
if (api_get_setting('search_enabled') == 'true') {
$specific_fields = get_specific_field_list();
}
if (isset($_POST['convert'])) {
$cwdir = getcwd();
if (isset($_FILES['user_file'])) {
$allowed_extensions = ['doc', 'docx', 'odt', 'txt', 'sxw', 'rtf'];
if (in_array(strtolower(pathinfo($_FILES['user_file']['name'], PATHINFO_EXTENSION)), $allowed_extensions)) {
require '../lp/lp_upload.php';
if (isset($o_doc) && $first_item_id != 0) {
// Search-related section
if (api_get_setting('search_enabled') == 'true') {
require_once api_get_path(LIBRARY_PATH).'specific_fields_manager.lib.php';
$specific_fields = get_specific_field_list();
foreach ($specific_fields as $specific_field) {
$values = explode(',', trim($_POST[$specific_field['code']]));
if (!empty($values)) {
foreach ($values as $value) {
$value = trim($value);
if (!empty($value)) {
add_specific_field_value(
$specific_field['id'],
api_get_course_id(),
TOOL_LEARNPATH,
$o_doc->lp_id,
$value
);
}
}
}
}
} //end of search-related section
header('Location: ../lp/lp_controller.php?'.api_get_cidreq().'&lp_id='.$o_doc->lp_id.'&action=view_item&id='.$first_item_id);
} else {
if (!empty($o_doc->error)) {
$errorMessage = $o_doc->error;
} else {
$errorMessage = get_lang('OogieUnknownError');
}
}
} else {
$errorMessage = get_lang('WoogieBadExtension');
}
}
}
Event::event_access_tool(TOOL_UPLOAD);
// check access permissions (edit permission is needed to add a document or a LP)
$is_allowed_to_edit = api_is_allowed_to_edit();
if (!$is_allowed_to_edit) {
api_not_allowed(true);
}
$interbreadcrumb[] = ["url" => "../lp/lp_controller.php?action=list", "name" => get_lang("Doc")];
$nameTools = get_lang("WoogieConversionPowerPoint");
Display::display_header($nameTools);
echo '<span style="color: #5577af; font-size: 16px; font-family: Arial; margin-left: 10px;">'.
get_lang("WelcomeWoogieSubtitle").'</span><br>';
$message = get_lang("WelcomeWoogieConverter");
echo '<br />';
$s_style = "border-width: 1px;
border-style: solid;
margin-left: 0;
margin-top: 10px;
margin-bottom: 0px;
min-height: 30px;
padding: 5px;
position: relative;
width: 500px;
background-color: #E5EDF9;
border-color: #4171B5;
color: #000;";
$s_style_error = "border-width: 1px;
border-style: solid;
margin-left: 0;
margin-top: 10px;
margin-bottom: 10px;
min-height: 30px;
padding: 5px;
position: relative;
width: 500px;
background-color: #FFD1D1;
border-color: #FF0000;
color: #000;";
echo '<div style="'.$s_style.'"><div style="float:left; margin-right:10px;">
<img src="'.Display::returnIconPath('message_normal.gif').'" alt="'.$alt_text.'" '.$attribute_list.' /></div>
<div style="margin-left: 43px">'.$message.'</div></div>';
if (!empty($errorMessage)) {
echo '<div style="'.$s_style_error.'"><div style="float:left; margin-right:10px;">
<img src="'.Display::returnIconPath('message_error.gif').'" alt="'.$alt_text.'" '.$attribute_list.' /></div>
<div style="margin-left: 43px">'.$errorMessage.'</div></div>';
}
$form = new FormValidator('update_course', 'POST', '', '', 'style="margin: 0;"');
// build the form
$form->addElement('html', '<br>');
$div_upload_limit = '&nbsp;&nbsp;'.get_lang('UploadMaxSize').' : '.ini_get('post_max_size');
$renderer = $form->defaultRenderer();
// set template for user_file element
$user_file_template =
<<<EOT
<div class="row" style="margin-top:10px;width:100%">
<!-- BEGIN required --><span class="form_required">*</span> <!-- END required -->{label}{element}$div_upload_limit
<!-- BEGIN error --><br /><span class="form_error">{error}</span><!-- END error -->
</div>
EOT;
$renderer->setElementTemplate($user_file_template, 'user_file');
// set template for other elements
$user_file_template =
<<<EOT
<div class="row" style="margin-top:10px;width:100%">
<!-- BEGIN required --><span class="form_required">*</span> <!-- END required -->{label}{element}
<!-- BEGIN error --><br /><span class="form_error">{error}</span><!-- END error -->
</div>
EOT;
$renderer->setCustomElementTemplate($user_file_template);
$form->addElement('file', 'user_file', Display::return_icon('word_big.gif'));
if (api_get_setting('search_enabled') === 'true') {
$form->addElement('checkbox', 'index_document', '', get_lang('SearchFeatureDoIndexDocument'));
$form->addElement('html', '<br />');
$form->addElement(
'html',
get_lang(
'SearchFeatureDocumentLanguage'
).': &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'.api_get_languages_combo()
);
$form->addElement('html', '<div class="sub-form">');
foreach ($specific_fields as $specific_field) {
$form->addElement('text', $specific_field['code'], $specific_field['name'].' : ');
}
$form->addElement('html', '</div>');
}
/*
* commented because SplitStepsPerChapter is not stable at all
* $form -> addElement ('radio', 'split_steps',null, get_lang('SplitStepsPerPage'),'per_page');
* $form -> addElement ('radio', 'split_steps',null, get_lang('SplitStepsPerChapter'),'per_chapter');
*/
$form->addElement('hidden', 'split_steps', 'per_page');
$form->addElement('submit', 'convert', get_lang('ConvertToLP'), 'class="convert_button"');
$form->addElement('hidden', 'woogie', 'true');
$form->addProgress();
$defaults = ['split_steps' => 'per_page', 'index_document' => 'checked="checked"'];
$form->setDefaults($defaults);
// display the form
$form->display();
Display::display_footer();