Upgrade 1-11.38

This commit is contained in:
xesmyd
2026-03-30 14:10:30 +02:00
parent f2a7e6d1fc
commit ac648ef29d
24665 changed files with 69682 additions and 2205004 deletions
+49 -55
View File
@@ -5,11 +5,7 @@
use Chamilo\CoreBundle\Component\Editor\Connector;
use Chamilo\CoreBundle\Component\Filesystem\Data;
use Ddeboer\DataImport\Writer\CsvWriter;
use Ddeboer\DataImport\Writer\ExcelWriter;
use MediaAlchemyst\Alchemyst;
use MediaAlchemyst\DriversContainer;
use Neutron\TemporaryFilesystem\Manager;
use Neutron\TemporaryFilesystem\TemporaryFilesystem;
use Symfony\Component\Filesystem\Filesystem;
/**
@@ -77,14 +73,19 @@ class Export
{
$filePath = api_get_path(SYS_ARCHIVE_PATH).uniqid('').'.xlsx';
$file = new \SplFileObject($filePath, 'w');
$writer = new ExcelWriter($file);
@$writer->prepare();
foreach ($data as $row) {
@$writer->writeItem($row);
$excel = @new \PhpOffice\PhpSpreadsheet\Spreadsheet();
$row = 1;
foreach ($data as $item) {
$values = array_values($item);
$count = count($values);
for ($i = 0; $i < $count; $i++) {
@$excel->getActiveSheet()->setCellValueByColumnAndRow($i + 1, $row, $values[$i]);
}
$row++;
}
@$writer->finish();
$writer = \PhpOffice\PhpSpreadsheet\IOFactory::createWriter($excel, 'Xlsx');
$writer->save($filePath);
DocumentManager::file_send_for_download($filePath, true, $filename.'.xlsx');
exit;
@@ -102,9 +103,8 @@ class Export
$filePath = api_get_path(SYS_ARCHIVE_PATH).uniqid('').'.xlsx';
$file = new \SplFileObject($filePath, 'w');
$excel = @new PHPExcel();
$excel = @new \PhpOffice\PhpSpreadsheet\Spreadsheet();
$type = 'Excel2007';
$sheet = null;
$row = 1;
$prependHeaderRow = false;
@@ -125,7 +125,7 @@ class Export
$headers = array_keys($item);
for ($i = 0; $i < $count; $i++) {
@$excel->getActiveSheet()->setCellValueByColumnAndRow($i, $row, $headers[$i]);
@$excel->getActiveSheet()->setCellValueByColumnAndRow($i + 1, $row, $headers[$i]);
}
$row++;
}
@@ -136,9 +136,9 @@ class Export
if (false !== strpos($values[$i], '[comment]')) {
list($txtValue, $txtComment) = explode('[comment]', $values[$i]);
}
@$excel->getActiveSheet()->setCellValueByColumnAndRow($i, $row, $txtValue);
@$excel->getActiveSheet()->setCellValueByColumnAndRow($i + 1, $row, $txtValue);
if (!empty($txtComment)) {
$columnLetter = PHPExcel_Cell::stringFromColumnIndex($i);
$columnLetter = \PhpOffice\PhpSpreadsheet\Cell\Coordinate::stringFromColumnIndex($i + 1);
$coordinate = $columnLetter.$row;
@$excel->getActiveSheet()->getComment($coordinate)->getText()->createTextRun($txtComment);
}
@@ -146,7 +146,7 @@ class Export
$row++;
}
$writer = \PHPExcel_IOFactory::createWriter($excel, $type);
$writer = \PhpOffice\PhpSpreadsheet\IOFactory::createWriter($excel, 'Xlsx');
$writer->save($file->getPathname());
DocumentManager::file_send_for_download($filePath, true, $filename.'.xlsx');
@@ -370,51 +370,45 @@ class Export
return false;
}
if (!empty($html)) {
$fs = new Filesystem();
$paths = [
'root_sys' => api_get_path(SYS_PATH),
'path.temp' => api_get_path(SYS_ARCHIVE_PATH),
];
$connector = new Connector();
if (empty($html)) {
return false;
}
$drivers = new DriversContainer();
$drivers['configuration'] = [
'unoconv.binaries' => $unoconv,
'unoconv.timeout' => 60,
];
$fs = new Filesystem();
$paths = [
'root_sys' => api_get_path(SYS_PATH),
'path.temp' => api_get_path(SYS_ARCHIVE_PATH),
];
$connector = new Connector();
$tempFilesystem = TemporaryFilesystem::create();
$manager = new Manager($tempFilesystem, $fs);
$alchemyst = new Alchemyst($drivers, $manager);
$dataFileSystem = new Data($paths, $fs, $connector, $unoconv);
$content = $dataFileSystem->convertRelativeToAbsoluteUrl($html);
// convertRelativeToAbsoluteUrl returns a simple_html_dom object; cast to string explicitly
$content = (string) $content;
$dataFileSystem = new Data($paths, $fs, $connector, $alchemyst);
$content = $dataFileSystem->convertRelativeToAbsoluteUrl($html);
$filePath = $dataFileSystem->putContentInTempFile(
$content,
api_replace_dangerous_char($name),
'html'
);
$safeName = api_replace_dangerous_char($name);
$filePath = $dataFileSystem->putContentInTempFile($content, $safeName, 'html');
$try = true;
if (empty($filePath)) {
error_log("htmlToOdt: failed to create temp file for '$name'");
while ($try) {
try {
$convertedFile = $dataFileSystem->transcode(
$filePath,
$format
);
return false;
}
$try = false;
DocumentManager::file_send_for_download(
$convertedFile,
false,
$name.'.'.$format
);
} catch (Exception $e) {
// error_log($e->getMessage());
}
try {
$convertedFile = $dataFileSystem->transcode($filePath, $format);
if ($convertedFile) {
DocumentManager::file_send_for_download(
$convertedFile,
true,
$name.'.'.$format
);
} else {
error_log("htmlToOdt: transcode failed for '$name'");
}
} catch (Exception $e) {
error_log("htmlToOdt: exception during transcode for '$name': ".$e->getMessage());
}
}
}