From e48a4eb23ad6244db03272bde31883e2ddf20526 Mon Sep 17 00:00:00 2001 From: "vincent@cubedesigners.com" Date: Tue, 18 Aug 2015 18:01:20 +0000 Subject: [PATCH] HTML5 priority when flash not installed on the user browser --- fluidbook/compile/_js/fluidbook.js | 11 +++++++++++ fluidbook/compile/_zinc/send.bat | 2 +- fluidbook/compile/index.html | 7 +++++++ inc/ws/Metier/class.ws.book.parametres.php | 6 ++++-- inc/ws/Util/packager/class.ws.packager.html.php | 7 ++++++- 5 files changed, 29 insertions(+), 4 deletions(-) diff --git a/fluidbook/compile/_js/fluidbook.js b/fluidbook/compile/_js/fluidbook.js index de4fa2298..943ca6245 100644 --- a/fluidbook/compile/_js/fluidbook.js +++ b/fluidbook/compile/_js/fluidbook.js @@ -20,6 +20,17 @@ function getWmode() { } } +function supportHTML5Version() { + var prefixes = 'transform WebkitTransform MozTransform OTransform msTransform'.split(' '); + var div = document.createElement('div'); + for (var i = 0; i < prefixes.length; i++) { + if (div && div.style[prefixes[i]] !== undefined) { + return true; + } + } + return false; +} + function getLocation() { return window.location.toString(); } diff --git a/fluidbook/compile/_zinc/send.bat b/fluidbook/compile/_zinc/send.bat index 451b9db32..51436f91b 100644 --- a/fluidbook/compile/_zinc/send.bat +++ b/fluidbook/compile/_zinc/send.bat @@ -1,5 +1,5 @@ @echo off rm Fluidbook.app.zip -"C:\Program Files (x86)\7-Zip\7z.exe" a -tzip Fluidbook.app.zip Fluidbook.app +"C:\Program Files\7-Zip\7z.exe" a -tzip Fluidbook.app.zip Fluidbook.app "H:\Applications\PortableApps\PuTTYPortable\App\putty\pscp.exe" "Fluidbook.exe" extranet@extranet.cubedesigners.com:/home/extranet/www/fluidbook/compile/ "H:\Applications\PortableApps\PuTTYPortable\App\putty\pscp.exe" "Fluidbook.app.zip" extranet@extranet.cubedesigners.com:/home/extranet/www/fluidbook/compile/ \ No newline at end of file diff --git a/fluidbook/compile/index.html b/fluidbook/compile/index.html index 29b2d6ffd..4614abffa 100644 --- a/fluidbook/compile/index.html +++ b/fluidbook/compile/index.html @@ -26,11 +26,18 @@ INDEX_EXT = '$index_ext'; var backgroundColor = "$bgcolor"; function redirect() { + + if (isMobile() || $alwaysHTML5) { $redirectMobile } else if (isBadMobile()) { $redirectPDF } else { + if ($html5priority && supportHTML5Version() && !swfobject.hasFlashPlayerVersion("$flashversion")) { + $redirectMobile + return; + } + document.getElementById('fluidbook').style.opacity = 1; swfobject.embedSWF("$pathToIndex?junk=$junk", "fluidbook", "100%", "100%", "$flashversion", "", getFlashvars($junk, $fv), { "allowScriptAccess": "always", diff --git a/inc/ws/Metier/class.ws.book.parametres.php b/inc/ws/Metier/class.ws.book.parametres.php index 4799e2260..52b06c46d 100644 --- a/inc/ws/Metier/class.ws.book.parametres.php +++ b/inc/ws/Metier/class.ws.book.parametres.php @@ -291,12 +291,14 @@ class wsBookParametres extends wsParametres { $this->forms['offline'] = array('label' => __('Version offline'), 'fieldsnames' => array('offlineTitle', 'offlineLink')); - $this->fields['alwaysHTML5'] = array('type' => 'boolean', 'default' => 'false', 'editable' => true, 'label' => __('Toujours utiliser la version HTML5'), 'grade' => 3); + $this->fields['alwaysHTML5'] = array('type' => 'boolean', 'default' => 'true', 'editable' => true, 'label' => __('Toujours utiliser la version HTML5'), 'grade' => 3); $this->fields['mobileVersion'] = array('type' => 'combo', 'default' => 'html5-images', 'editable' => true, 'label' => __('Version mobile'), 'grade' => 3, 'datas' => array(__('Rediriger vers le PDF') => 'pdf', __('Version HTML5') => 'html5', __("Version HTML5 en images") => 'html5-images') ); + $this->fields['html5priority'] = array('type' => 'boolean', 'default' => 'true', 'editable' => true, 'label' => __("Si flash n'est pas installé, rediriger vers la version HTML5"), 'grade' => 3); + $this->fields['navOrderH'] = array('type' => 'textarea', 'default' => '', 'editable' => true, 'label' => __('Ordre des icônes dans la nav') . ' (' . __('Si différente') . ')', 'grade' => 3); @@ -330,7 +332,7 @@ class wsBookParametres extends wsParametres { $this->fields['mobileIgnoreBackgroundLinks'] = array('type' => 'boolean', 'default' => false, 'editable' => true, 'label' => __('Ignorer les liens de background')); $this->forms['mobile'] = array('label' => __('Version mobile'), - 'fieldsnames' => array('alwaysHTML5', 'mobileLVersion', 'mobileVersion', 'mobileNavigationType', '|', 'mobileNavScale', '|', 'mobileTransitions', 'mobileTransitionDuration', '|', 'navOrderH', '|', 'mobileIconVector', 'mobileServerConfig', 'mobilePlugins', '|', 'mobileVideosPath', '|', 'mobileExtraXSpace', '|', 'mobileIgnoreBackgroundLinks')); + 'fieldsnames' => array('alwaysHTML5', 'html5priority', 'mobileLVersion', 'mobileVersion', 'mobileNavigationType', '|', 'mobileNavScale', '|', 'mobileTransitions', 'mobileTransitionDuration', '|', 'navOrderH', '|', 'mobileIconVector', 'mobileServerConfig', 'mobilePlugins', '|', 'mobileVideosPath', '|', 'mobileExtraXSpace', '|', 'mobileIgnoreBackgroundLinks')); $this->fields['phonegapId'] = array('type' => 'text', 'default' => 'com.fluidbook.phonegap.$id', 'editable' => true, 'label' => __("Identifiant de l'identifiant"), 'grade' => 5, 'hint' => __('De la forme') . ' com.fluidbook.phonegap.xxxxx'); $this->fields['phonegapVersion'] = array('type' => 'text', 'default' => '1.0.0', 'editable' => true, 'label' => __("Version de l'application"), 'grade' => 5, 'hint' => __('De la forme') . ' 1.2.3'); diff --git a/inc/ws/Util/packager/class.ws.packager.html.php b/inc/ws/Util/packager/class.ws.packager.html.php index 3f47e7ccf..9d48b49ad 100644 --- a/inc/ws/Util/packager/class.ws.packager.html.php +++ b/inc/ws/Util/packager/class.ws.packager.html.php @@ -109,6 +109,11 @@ class wsPackagerHTML extends wsPackager { $alwaysHTML5 = 'false'; } + if (!isset($this->book->parametres->html5priority)) { + $this->book->parametres->html5priority = true; + } + $html5priority = CubeIT_Util_Bool::boolval($this->book->parametres->html5priority, false, true); + // Stuffs to replace in html $toReplace = array('lang' => strtolower($this->book->lang), 'ga' => $ga, @@ -123,10 +128,10 @@ class wsPackagerHTML extends wsPackager { 'flashversion' => $this->getMinFlashVersion(), 'fv' => json_encode($this->getFlashvars()), 'alwaysHTML5' => $alwaysHTML5, + 'html5priority' => $html5priority, 'keywords' => $keywords, 'allowNetworking' => $this->_allowNeworking); - $this->origHTML = $this->book->parametres->htmlPrepend . file_get_contents($this->vdir . '/index.html'); unlink($this->vdir . '/index.html'); $this->origHTML = $this->replaceHTML($toReplace); -- 2.39.5