for ($i = 0; $i < sizeof($uploadedFiles); $i++) { $emptyUnits = array(); $file = $uploadedFiles[$i]; $pathParts = pathinfo($file['name']); if ($pathParts['extension'] == 'zip' && $unzipFlag == true) { $fileContents = $file->listContents(); sort($fileContents); //Check if it is a SCORM file if (in_array("imsmanifest.xml", $fileContents)) { $scormFolderName = EfrontFile::encode(eFront_basename($file['name'], '.zip')); $scormPath = $currentLesson->getDirectory() . $scormFolderName . '/'; is_dir($scormPath) or mkdir($scormPath, 0755); $file->rename($scormPath . $file['name'], true); $file->uncompress(false); $manifestFile = new EfrontFile($scormPath . 'imsmanifest.xml'); EfrontScorm::import($currentLesson, $manifestFile, $scormFolderName); } elseif (in_array("data.dat", $fileContents)) { $currentLesson->import($file); } else { $file->uncompress(); if ($values['uncompress_recursive']) { $unzipFlag = false; foreach ($fileContents as $additionalFile) { if (!is_dir($uploadDir . $additionalFile)) { //Add to the list of the uploaded files, all those that where extracted $uploadedFiles[] = new EfrontFile($uploadDir . $additionalFile); } else { //Assign folders to the $emptyUnits array, so that we can create the empty units hierarchy from them $emptyUnits[] = explode("/", trim($additionalFile, "/")); } }
//pr($scormFiles);exit; foreach ($scormFiles as $scormFile) { /* Imports scorm package to database */ $scormFolderName = EfrontFile::encode(basename($scormFile['name'], '.zip')); $scormPath = $currentLesson->getDirectory() . $scormFolderName . '/'; is_dir($scormPath) or mkdir($scormPath, 0755); //pr($scormPath.$scormFile['name']); //try { $scormFile->rename($scormPath . $scormFile['name'], true); //} catch (Exception $e) {pr($e);throw $e;} $fileList = $scormFile->uncompress(false); $scormFile->delete(); $total_fields = array(); $resources = array(); $manifestFile = new EfrontFile($scormPath . 'imsmanifest.xml'); EfrontScorm::import($currentLesson, $manifestFile, $scormFolderName, array('embed_type' => $values['embed_type'], 'popup_parameters' => $values['popup_parameters'], 'iframe_parameters' => $values['iframe_parameters'])); } eF_redirect("" . basename($_SERVER['PHP_SELF']) . "?ctg=scorm&message=" . urlencode(_SUCCESSFULLYIMPORTEDSCORMFILE) . "&message_type=success"); } catch (Exception $e) { $smarty->assign("T_EXCEPTION_TRACE", $e->getTraceAsString()); $message = $e->getMessage() . ' (' . $e->getCode() . ') <a href = "javascript:void(0)" onclick = "eF_js_showDivPopup(event, \'' . _ERRORDETAILS . '\', 2, \'error_details\')">' . _MOREINFO . '</a>'; $message_type = failure; } } $renderer = new HTML_QuickForm_Renderer_ArraySmarty($smarty); $renderer->setRequiredTemplate('{$html}{if $required} <span class = "formRequired">*</span> {/if}'); $renderer->setErrorTemplate('{$html}{if $error} <div class = "formError">{$error}</div> {/if}');