]> _ Git - cubeextranet.git/commitdiff
wip #2277 @2
authorvincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Tue, 23 Oct 2018 12:15:48 +0000 (12:15 +0000)
committervincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Tue, 23 Oct 2018 12:15:48 +0000 (12:15 +0000)
inc/ws/Util/html5/master/class.ws.html5.compiler.php
inc/ws/Util/html5/master/class.ws.html5.links.php

index 6ac9b6727716c276e88e2074f6ab4240027c5b0d..e7262e81d4d9e4a4c62708202c4b4f81511d89c7 100644 (file)
@@ -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);
index 833fa0e80ab44087c2c4a51a8209ff948f69fc18..7fc37d151a753d25266da2c4ea8a630559c89f6f 100644 (file)
@@ -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;
                }