]> _ Git - cubeextranet.git/commitdiff
wip #1079 @3
authorvincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Wed, 18 Jan 2017 12:05:46 +0000 (12:05 +0000)
committervincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Wed, 18 Jan 2017 12:05:46 +0000 (12:05 +0000)
inc/ws/Util/html5/class.ws.html5.compiler.php
inc/ws/Util/html5/class.ws.html5.links.php

index 3b5760a73f2ca433804cf02d3f117d2d8c028a8a..5a0473bd4ae403ba6c16d0a80877b8f10c1ff5ff 100644 (file)
@@ -46,6 +46,7 @@ class wsHTML5Compiler {
                'js/libs/gal/gal.filesystem.js',
                'js/libs/fluidbook/forms/fluidbook.form.bulle.js',
                'js/libs/fluidbook/fluidbook.utils.js',
+               'js/libs/fluidbook/fluidbook.links.js',
                'js/libs/fluidbook/fluidbook.support.js',
                'js/libs/fluidbook/fluidbook.video.js',
                'js/libs/fluidbook/fluidbook.viewport.js',
@@ -70,6 +71,9 @@ class wsHTML5Compiler {
                'js/libs/fluidbook/views/fluidbook.index.js',
                'js/libs/fluidbook/fluidbook.js',
                'js/main.js');
+
+       public $specialJsFiles = array();
+
        public $debugJsFiles = array(
                'js/libs/Three.js',
                'data/search.index.js',
@@ -386,7 +390,6 @@ class wsHTML5Compiler {
                        return;
                }
 
-
                $cacheFile = $this->vdir . '/cache.appcache';
 
                if (file_exists($cacheFile)) {
@@ -500,6 +503,9 @@ class wsHTML5Compiler {
                        $script .= '<script type="text/javascript" charset="utf-8" src="data/scorm.js"></script>' . "\n";
                        $this->writeScorm();
                }
+               if (count($this->specialJsFiles)) {
+                       $script .= '<script type="text/javascript" charset="utf-8" src="data/special.js"></script>' . "\n";
+               }
                foreach ($this->pluginJs as $p) {
                        $script .= '<script type="text/javascript" charset="utf-8" src="' . $p . '"></script>' . "\n";
                }
@@ -699,6 +705,10 @@ class wsHTML5Compiler {
        protected function writeLinks() {
                global $core;
 
+               if ($this->book->parametres->customLinkClass == 'WescoSalesLink') {
+                       $this->specialJsFiles[] = 'js/libs/fluidbook/special/wescosales.js';
+               }
+
                $this->config->links = array();
                $this->config->clinks = array();
                $this->config->bookmarkGroups = array();
@@ -803,7 +813,9 @@ class wsHTML5Compiler {
                        $finals['scorm'][] = 'js/libs/scorm/apiwrapper.js';
                        $finals['scorm'][] = 'js/libs/scorm/scorm.js';
                }
-
+               if (count($this->specialJsFiles)) {
+                       $finals['special'] = $this->specialJsFiles;
+               }
                if ($this->widget) {
                        $finals['widget'] = $this->widgetJsFiles;
                }
@@ -814,11 +826,17 @@ class wsHTML5Compiler {
                        if (file_exists($minimized)) {
                                $mintime = filemtime($minimized);
                        }
+
                        $reminimize = false;
-                       foreach ($files as $file) {
-                               if (filemtime($this->assets . '/' . $file) > $mintime) {
-                                       $reminimize = true;
-                                       break;
+                       if ($jsfinal == 'special') {
+                               $reminimize = true;
+                       }
+                       if (!$reminimize) {
+                               foreach ($files as $file) {
+                                       if (filemtime($this->assets . '/' . $file) > $mintime) {
+                                               $reminimize = true;
+                                               break;
+                                       }
                                }
                        }
 
@@ -917,6 +935,35 @@ class wsHTML5Compiler {
                if ($this->config->phonegap) {
                        $this->config->manifest = $this->writeManifest();
                }
+
+               if ($this->config->basket) {
+                       if (file_exists($this->config->basketReferences)) {
+                               $referencesFile = $this->config->basketReferences;
+                       } else {
+                               $referencesFile = $this->wdir . '/commerce/' . $this->config->basketReferences;
+                       }
+
+                       if (file_exists($referencesFile)) {
+                               $ext = CubeIT_Files::getExtension($referencesFile);
+                               if ($ext == 'xlsx') {
+                                       include_once ROOT . '/inc/ZendFramework/PHPExcel/PHPExcel.php';
+                                       $objReader = PHPExcel_IOFactory::createReader('Excel2007');
+                                       $objPHPExcel = $objReader->load($referencesFile);
+
+
+                                       foreach ($objPHPExcel->getWorksheetIterator() as $worksheet) {
+                                               $title = $worksheet->getTitle();
+                                               if (strlen($title) == 2 && cubeCountry::getCountry($title)) {
+                                                       $title = cubeCountry::getCountry($title);
+                                               }
+
+                                               $worksheets[$title] = $worksheet->toArray(null, true, true);
+                                       }
+                                       $this->config->basketReferences = $worksheets;
+                               }
+                       }
+               }
+
                return 'var DATAS=' . json_encode($this->config) . ';' . "\n";
        }
 
@@ -1135,10 +1182,8 @@ class wsHTML5Compiler {
                $res[] = $search;
 
                // Background
-
                $res[] = $this->_cssBackground();
 
-
                // Archives
                // Header
                $header = 'header{';
index a83f26234cc0ff231b4ab88ab2d8d1bc3fc8f2e2..3cb824a0df8d8ad338c729c93e6bdd19353d87d4 100644 (file)
@@ -40,7 +40,7 @@ class wsHTML5Link {
         * @param integer $id
         * @param stdClass $init
         * @param wsHTML5Compiler $compiler
-        * @return \webLink|\mailLink|\internalLink|\videoLink|\videoPopupLink|\multimediaLink|null|\webVideoLink|\webVideoPopupLink|\actionLink|\basketLink|\colorLink|\imageLink|\fileLink|\htmlMultimediaLink
+        * @return \webLink|\mailLink|\internalLink|\videoLink|\videoPopupLink|\multimediaLink|null|\webVideoLink|\webVideoPopupLink|\actionLink|\basketLink|\colorLink|\imageLink|\fileLink|\htmlMultimediaLink|\normalLink
         */
        public static function getInstance($id, $init, &$compiler) {
                switch ($init['type']) {
@@ -58,17 +58,21 @@ class wsHTML5Link {
                                        return new videoPopupLink($id, $init, $compiler);
                                }
                        case 7:
-                               if ($compiler->book->parametres->customLinkClass == 'WescoLink') {
-                                       return new wescoLink($id, $init, $compiler);
-                               } else if ($compiler->book->parametres->customLinkClass == 'HaguenauManifLink') {
-                                       return new haguenauManifLink($id, $init, $compiler);
-                               } else if ($compiler->book->parametres->customLinkClass == 'FLFLink') {
-                                       return new flfLink($id, $init, $compiler);
-                               } else if ($compiler->book->parametres->customLinkClass == 'InpesPopinLink') {
-                                       return new inpesPopinLink($id, $init, $compiler);
-                               } else if ($compiler->book->parametres->customLinkClass == 'PierronLink') {
-                                       return new pierronLink($id, $init, $compiler);
+                               switch ($compiler->book->parametres->customLinkClass) {
+                                       case 'WescoLink':
+                                               return new wescoLink($id, $init, $compiler);
+                                       case 'HaguenauManifLink':
+                                               return new haguenauManifLink($id, $init, $compiler);
+                                       case 'FLFLink':
+                                               return new flfLink($id, $init, $compiler);
+                                       case 'InpesPopinLink':
+                                               return new inpesPopinLink($id, $init, $compiler);
+                                       case 'PierronLink':
+                                               return new pierronLink($id, $init, $compiler);
+                                       case 'WescoSalesLink':
+                                               return new wescoSalesLink($id, $init, $compiler);
                                }
+                               break;
                        case 8:
                        case 9:
                                return null;
@@ -84,6 +88,7 @@ class wsHTML5Link {
                                }
                                return new actionLink($id, $init, $compiler);
                        case 12:
+
                                return new basketLink($id, $init, $compiler);
                        case 13:
                                return null;
@@ -934,6 +939,20 @@ class pierronLink extends normalLink {
 
 }
 
+class wescoSalesLink extends normalLink {
+       public function getUrl() {
+               return '#';
+       }
+
+       public function getAdditionnalContent() {
+               return parent::getAdditionnalContent() . ' data-wescosales-ref="' . $this->to . '" ';
+       }
+
+       public function getTooltip() {
+               return 'Consulter les ventes de ce produit';
+       }
+}
+
 class inpesPopinLink extends htmlMultimediaLink {
 
        public function getHTMLContent() {