From 481ff27a9ad8e0bd9564122c494d3c93e024ce6c Mon Sep 17 00:00:00 2001 From: "vincent@cubedesigners.com" Date: Tue, 23 Oct 2018 12:15:48 +0000 Subject: [PATCH] wip #2277 @2 --- .../html5/master/class.ws.html5.compiler.php | 26 +++++++++++++++++++ .../html5/master/class.ws.html5.links.php | 3 +++ 2 files changed, 29 insertions(+) diff --git a/inc/ws/Util/html5/master/class.ws.html5.compiler.php b/inc/ws/Util/html5/master/class.ws.html5.compiler.php index 6ac9b6727..e7262e81d 100644 --- a/inc/ws/Util/html5/master/class.ws.html5.compiler.php +++ b/inc/ws/Util/html5/master/class.ws.html5.compiler.php @@ -163,6 +163,7 @@ class wsHTML5Compiler public $seoArticles = []; public $securityPolicyWhitelist = ['*.google-analytics.com', '*.youtube.com', '*.ytimg.com']; public $writeLinksData = false; + public $lock_contents = []; protected $_indexVars = null; public $_signature; @@ -800,6 +801,20 @@ class wsHTML5Compiler $this->seo = new wsHTML5Seo($this); } + public function addLockContents($page, $unlockConditions) + { + $unlockConditions = trim(CubeIT_Text::explodeNewLines($unlockConditions)); + $conditions = []; + foreach ($unlockConditions as $unlockCondition) { + $e = explode(',', $unlockCondition); + if (!isset($e[1])) { + $e[1] = 'click'; + } + $conditions[] = $e; + } + $this->lock_contents[] = ['page' => $page, 'unlockConditions' => $conditions]; + } + protected function writeScorm() { if ($this->book->parametres->scorm_version == '1.2') { @@ -1167,8 +1182,19 @@ class wsHTML5Compiler $this->copyLinkFile($link['to'], 'data/audiodescription/'); } + protected function beforeWriteConfig() + { + usort($this->lock_contents, function ($a, $b) { + return $a['page'] - $b['page']; + }); + + $this->config->lock_contents = $this->lock_contents; + } + protected function writeJs() { + $this->beforeWriteConfig(); + $config = $this->writeConfig(); $this->vdir->file_put_contents('data/datas.js', $config); $finals = array('fluidbook' => $this->jsFiles); diff --git a/inc/ws/Util/html5/master/class.ws.html5.links.php b/inc/ws/Util/html5/master/class.ws.html5.links.php index 833fa0e80..7fc37d151 100644 --- a/inc/ws/Util/html5/master/class.ws.html5.links.php +++ b/inc/ws/Util/html5/master/class.ws.html5.links.php @@ -170,6 +170,9 @@ class wsHTML5Link return new showLinkLink($id, $init, $compiler); case 33: return new zoomhdLink($id, $init, $compiler); + case 34: + $compiler->addLockContents($init['page'], $init['to']); + break; default: return null; } -- 2.39.5