1 | <?php |
||
2 | /* For licensing terms, see /license.txt */ |
||
3 | |||
4 | use Chamilo\CourseBundle\Component\CourseCopy\CourseArchiver; |
||
5 | |||
6 | class Cc13ExportConvert |
||
7 | { |
||
8 | public static function export($objCourse) |
||
9 | { |
||
10 | $permDirs = api_get_permissions_for_new_directories(); |
||
11 | $backupDirectory = CourseArchiver::getBackupDir(); |
||
12 | |||
13 | // Create a temp directory |
||
14 | $backupDir = $backupDirectory.'CourseCC13Archiver_'.api_get_unique_id(); |
||
15 | |||
16 | if (mkdir($backupDir, $permDirs, true)) { |
||
17 | $converted = Cc13Convert::convert($backupDirectory, $backupDir, $objCourse); |
||
18 | if ($converted) { |
||
19 | $imsccFileName = self::createImscc($backupDir, $objCourse); |
||
20 | |||
21 | return $imsccFileName; |
||
22 | } |
||
23 | } |
||
24 | |||
25 | return false; |
||
26 | } |
||
27 | |||
28 | public static function createImscc($backupDir, $objCourse) |
||
29 | { |
||
30 | $backupDirectory = CourseArchiver::getBackupDir(); |
||
31 | |||
32 | $date = new \DateTime(api_get_local_time()); |
||
33 | |||
34 | $imsccFileName = $objCourse->info['code'].'_'.$date->format('Ymd-His').'.imscc'; |
||
35 | $imsccFilePath = $backupDirectory.$imsccFileName; |
||
36 | |||
37 | // Zip the course-contents |
||
38 | $zip = new \PclZip($imsccFilePath); |
||
39 | $zip->create($backupDir, PCLZIP_OPT_REMOVE_PATH, $backupDir); |
||
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
40 | |||
41 | // Remove the temp-dir. |
||
42 | rmdirr($backupDir); |
||
43 | |||
44 | return $imsccFileName; |
||
45 | } |
||
46 | } |
||
47 |