use Cubist\Backpack\Magic\Fields\SelectFromArray;
use Cubist\Backpack\Magic\Fields\Text;
use Cubist\Backpack\Magic\Models\CubistMagicAbstractModel;
+use Cubist\Util\Files\Files;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Support\Facades\Auth;
use function Symfony\Component\String\s;
public function compile($path)
{
$data = $this->getPageData();
+
+ $path = Files::emptyDir($path);
+
if ($data->type === 'scorm_multilang') {
return $this->compileSCORMMultilang($data, $path);
}
$user = backpack_user();
$ws->login($user->email, $user->api_token);
- $first = true;
$langs = [];
foreach ($data->publications as $publication) {
$fbid = $publication['fluidbook'];
$langs[] = $metadata->lang;
$dir = $path . '/' . $metadata->lang;
$ws->installBook($fbid, $dir, 'scorm', 3);
- if ($first) {
- $first = false;
- copy($dir . '/imsmanifest.xml', $path . '/imsmanifest.xml');
- }
- unlink($dir . '/imsmanifest.xml');
}
if (in_array('en', $langs)) {
$default = $langs[0];
}
+ foreach ($langs as $lang) {
+ $manifest = $path . '/' . $lang . '/imsmanifest.xml';
+ if ($lang === $default) {
+ rename($manifest, $path . '/imsmanifest.xml');
+ } else {
+ unlink($manifest);
+ }
+ }
+
$redirectionScript = "<html>
<head></head>
<body>
}
var locale=guessPreferedLanguage(" . json_encode($langs) . ",'" . $default . "');
-window.location=\"./ + locale + /index.html\";
+window.location='./' + locale + '/index.html';
</script>
</body>
</html>";
- file_put_contents($path.'/index.html',$redirectionScript);
+ file_put_contents($path . '/index.html', $redirectionScript);
}
}