From d8859bceea63e196d87b79a074c03d0c2494d0a5 Mon Sep 17 00:00:00 2001 From: "vincent@cubedesigners.com" Date: Wed, 18 Jan 2017 12:05:46 +0000 Subject: [PATCH] wip #1079 @3 --- inc/ws/Util/html5/class.ws.html5.compiler.php | 61 ++++++++++++++++--- inc/ws/Util/html5/class.ws.html5.links.php | 41 +++++++++---- 2 files changed, 83 insertions(+), 19 deletions(-) diff --git a/inc/ws/Util/html5/class.ws.html5.compiler.php b/inc/ws/Util/html5/class.ws.html5.compiler.php index 3b5760a73..5a0473bd4 100644 --- a/inc/ws/Util/html5/class.ws.html5.compiler.php +++ b/inc/ws/Util/html5/class.ws.html5.compiler.php @@ -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 .= '' . "\n"; $this->writeScorm(); } + if (count($this->specialJsFiles)) { + $script .= '' . "\n"; + } foreach ($this->pluginJs as $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{'; diff --git a/inc/ws/Util/html5/class.ws.html5.links.php b/inc/ws/Util/html5/class.ws.html5.links.php index a83f26234..3cb824a0d 100644 --- a/inc/ws/Util/html5/class.ws.html5.links.php +++ b/inc/ws/Util/html5/class.ws.html5.links.php @@ -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() { -- 2.39.5