From c8f7c92c80bdbc67b0fe7b59d0a9bc694c08c475 Mon Sep 17 00:00:00 2001 From: "vincent@cubedesigners.com" Date: Wed, 23 Mar 2016 10:46:52 +0000 Subject: [PATCH] #scorm Add extranet fields to customize manifest and enable scorm features Append scorm files when packaging --- inc/ws/Metier/class.ws.book.parametres.php | 9 +++++++ inc/ws/Util/html5/class.ws.html5.compiler.php | 25 ++++++++++++++++--- inc/ws/Util/packager/class.ws.packager.php | 11 +++++++- 3 files changed, 40 insertions(+), 5 deletions(-) diff --git a/inc/ws/Metier/class.ws.book.parametres.php b/inc/ws/Metier/class.ws.book.parametres.php index 113f453eb..6caa26892 100644 --- a/inc/ws/Metier/class.ws.book.parametres.php +++ b/inc/ws/Metier/class.ws.book.parametres.php @@ -407,6 +407,15 @@ class wsBookParametres extends wsParametres { $this->fields['redirectDemo'] = array('type' => 'text', 'default' => '', 'editable' => true, 'label' => __('Rediriger le lien de démo vers'), 'grade' => 5); $this->forms['demo'] = array('label' => __('Lien de démo'), 'fieldsnames' => array('disableDemo', 'redirectDemo')); + + + $this->fields['scorm_enable'] = array('type' => 'boolean', 'default' => false, 'editable' => true, 'label' => __('Activer SCORM'), 'grade' => 5); + $this->fields['scorm_id'] = array('type' => 'text', 'default' => 'MFMCTE091mobile', 'editable' => true, 'label' => __('Identifiant SCORM'), 'grade' => 5); + $this->fields['scorm_org'] = array('type' => 'text', 'default' => 'ACME-ORG-1350650111249', 'editable' => true, 'label' => __('Organisation SCORM'), 'grade' => 5); + $this->fields['scorm_title'] = array('type' => 'text', 'default' => '', 'editable' => true, 'label' => __('Titre SCORM'), 'grade' => 5, 'hint' => __('Laisser vide pour utiliser le titre de la publication')); + + $this->forms['scorm'] = array('label' => __('SCORM'), + 'fieldsnames' => array('scorm_enable', 'scorm_id', 'scorm_org', 'scorm_title')); } } diff --git a/inc/ws/Util/html5/class.ws.html5.compiler.php b/inc/ws/Util/html5/class.ws.html5.compiler.php index 81a9c11d8..3b8e2a704 100644 --- a/inc/ws/Util/html5/class.ws.html5.compiler.php +++ b/inc/ws/Util/html5/class.ws.html5.compiler.php @@ -494,9 +494,9 @@ class wsHTML5Compiler { $script = ''; $script .= '' . "\n"; $script .= '' . "\n"; - if ($this->book->parametres->search) { - //$script .= '' . "\n"; - //$script .= '' . "\n"; + if ($this->book->parametres->scorm_enable) { + $script .= '' . "\n"; + $this->writeScorm(); } foreach ($this->pluginJs as $p) { $script .= '' . "\n"; @@ -587,6 +587,18 @@ class wsHTML5Compiler { } } + protected function writeScorm() { + $manifest = file_get_contents($this->assets . '/_imsmanifest.xml'); + if (!$this->book->parametres->scorm_title) { + $this->book->parametres->scorm_title = $this->book->parametres->title; + } + $vars = array('scorm_id', 'scorm_org', 'scorm_title'); + foreach ($vars as $v) { + $manifest = str_replace('$' . $v, $this->book->parametres->$v, $manifest); + } + file_put_contents($this->vdir . '/imsmanifest.xml', $manifest); + } + protected function writePrint() { if (!$this->book->parametres->print && !$this->book->parametres->pdf) { @@ -758,11 +770,16 @@ class wsHTML5Compiler { $config = $this->writeConfig(); file_put_contents($this->vdir . '/data/datas.js', $config); $finals = array('fluidbook' => $this->jsFiles); + if ($this->book->parametres->scorm_enable) { + $finals['scorm'] = array(); + $finals['scorm'][] = 'js/libs/scorm/apiwrapper.js'; + $finals['scorm'][] = 'js/libs/scorm/scorm.js'; + } + if ($this->widget) { $finals['widget'] = $this->widgetJsFiles; } - foreach ($finals as $jsfinal => $files) { $mintime = 0; $minimized = $this->assets . '/js/' . $jsfinal . '-min.js'; diff --git a/inc/ws/Util/packager/class.ws.packager.php b/inc/ws/Util/packager/class.ws.packager.php index 7788191ad..b7d6c4587 100644 --- a/inc/ws/Util/packager/class.ws.packager.php +++ b/inc/ws/Util/packager/class.ws.packager.php @@ -166,8 +166,9 @@ class wsPackager { $rename = true; } + $zip = new cubeCommandLine('zip'); - $zip->cd($this->vdir); + $zip->cd($this->getFinalPackageDir()); $zip->setArg(null, $zipfile); $zip->setArg('0'); $zip->setArg('r'); @@ -185,6 +186,14 @@ class wsPackager { return $url; } + public function getFinalPackageDir() { + $dir = $this->vdir; + if ($this->book->parametres->alwaysHTML5) { + $dir .= '/m/'; + } + return $dir; + } + protected function initTempDir() { if (is_null($this->vdir)) { $this->vdir = $this->dir . $this->version . '/'; -- 2.39.5