From: vincent@cubedesigners.com Date: Mon, 8 Nov 2021 21:09:17 +0000 (+0000) Subject: wip #4866 @2 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=7644ffee1e87b4cc67418f8b74dee351914f9e92;p=cubeextranet.git wip #4866 @2 --- diff --git a/inc/ws/Metier/class.ws.book.parametres.php b/inc/ws/Metier/class.ws.book.parametres.php index 1053f3d9c..bec01fa88 100644 --- a/inc/ws/Metier/class.ws.book.parametres.php +++ b/inc/ws/Metier/class.ws.book.parametres.php @@ -300,7 +300,7 @@ class wsBookParametres extends wsParametres $this->fields['dynamicBackgroundColor'] = ['type' => 'textarea', 'default' => '', 'editable' => true, 'label' => 'Couleur de fond dynamique', 'grade' => 3]; $this->forms['3d_mode'] = array('label' => __('Options de visualisation'), - 'fieldsnames' => array('mobileNavigationType', '|', 'mobileTransitions', 'mobileTransitionDuration', '|', 'forceWhiteBackground', 'rasterizePages', 'vectorPages', 'visualisationMode', 'antialiasReading', 'correctCenter', 'pagesBaseAngle', 'centerBook', '|', 'extraXSpace', 'mobileExtraXSpace', 'extraYSpace', '|', 'viewMode', '|', 'dynamicBackgroundColor', '|', 'svgToCanvasUpscale','textsThickness','textsThicknessPages', '|', 'imageFormat', 'maxResolution', 'JPEGQuality')); + 'fieldsnames' => array('mobileNavigationType', '|', 'mobileTransitions', 'mobileTransitionDuration', '|', 'forceWhiteBackground', 'rasterizePages', 'vectorPages', 'visualisationMode', 'antialiasReading', 'correctCenter', 'pagesBaseAngle', 'centerBook', '|', 'extraXSpace', 'mobileExtraXSpace', 'extraYSpace', '|', 'viewMode', '|', 'dynamicBackgroundColor', '|', 'svgToCanvasUpscale', 'textsThickness', 'textsThicknessPages', '|', 'imageFormat', 'maxResolution', 'JPEGQuality')); $this->fields['rasterizeOnSafari'] = array('type' => 'boolean', 'default' => false, 'editable' => true, 'label' => __('Ecraser les pages pour Safari (Mac OS)'), 'grade' => 1); $this->forms['performances'] = ['label' => __('Performances'), @@ -460,8 +460,9 @@ class wsBookParametres extends wsParametres $this->fields['tagcommander_prod'] = ['type' => 'boolean', 'default' => true, 'editable' => true, 'label' => 'Production', 'grade' => 3]; $this->fields['tagcommander_plan'] = ['type' => 'freefile', 'default' => '', 'editable' => true, 'label' => 'Plan de taggage "Tag commander"', 'grade' => 3]; $this->fields['tagcommander_default_vars'] = ['type' => 'textarea', 'default' => '', 'editable' => true, 'label' => 'Variables par défaut', 'grade' => 3]; + $this->fields['anchorsAliases'] = ['type' => 'text', 'default' => '', 'editable' => true, 'label' => __('Alias des ancres')]; $this->forms['stats'] = array('label' => __('Statistiques avancées'), - 'fieldsnames' => array('stats_score', 'stats_exclude_ip', '|', 'relay_url_params', '|', 'gtag_additional_code', '|', 'googleAnalyticsCustom', 'statsCustom', '|', 'xiti', 'xiti_page', '|', 'tagcommander_id', 'tagcommander_prod', 'tagcommander_plan', 'tagcommander_default_vars')); + 'fieldsnames' => array('tagcommander_id', 'tagcommander_prod', 'tagcommander_plan', 'tagcommander_default_vars', 'anchorsAliases', '|', 'stats_score', 'stats_exclude_ip', '|', 'relay_url_params', '|', 'gtag_additional_code', '|', 'googleAnalyticsCustom', 'statsCustom', '|', 'xiti', 'xiti_page')); $this->fields['displayChaptersPopup'] = array('type' => 'boolean', 'default' => true, 'editable' => true, 'label' => __('Always display chapters in a popup'), 'grade' => 1); $this->fields['displayChaptersIcon'] = array('type' => 'boolean', 'default' => true, 'editable' => true, 'label' => __("Affiche l'icône du sommaire"), 'grade' => 1); @@ -529,6 +530,7 @@ class wsBookParametres extends wsParametres $this->fields['linkTooltipMaxWidth'] = array('type' => 'integer', 'default' => 140, 'editable' => true, 'label' => __('Largeur max des infobulles des liens de type "infobulle"')); $this->fields['openLinkAtStartup'] = ['type' => 'text', 'default' => '', 'editable' => true, 'label' => __('Déclencher un lien à l\'ouverture du fluidbook')]; + $this->fields['mobileIgnoreBackgroundLinks'] = array('type' => 'boolean', 'default' => false, 'editable' => true, 'label' => __('Ignorer les liens de background')); $this->forms['links'] = array('label' => __('Liens'), 'fieldsnames' => array('permanentLinks', 'mobileLinksRevealAnim', 'linkBlinkTime', 'linkBlinkRepetition', '|', 'openLinkAtStartup', '|', 'customLinkClass', 'ignoreLinksTypes', 'mobileIgnoreBackgroundLinks', 'linkTooltipManager', 'linkCornerSize', 'linkTooltipMaxWidth', '|', 'linkTracker', 'linkTrackerRegexp', '|', 'linkFilePrefix')); diff --git a/inc/ws/Util/class.ws.util.php b/inc/ws/Util/class.ws.util.php index 6b97fd336..78a78fbbc 100644 --- a/inc/ws/Util/class.ws.util.php +++ b/inc/ws/Util/class.ws.util.php @@ -31,7 +31,7 @@ class wsUtil return array(); } - $cacheFile = $cacheBase . sha1($excelFile . '/' . filemtime($excelFile).'/'.$assoc); + $cacheFile = $cacheBase . sha1($excelFile . '/' . filemtime($excelFile) . '/' . $assoc); if (!$force && file_exists($cacheFile) && filemtime($cacheFile) > filemtime($excelFile)) { $worksheets = json_decode(file_get_contents($cacheFile), true); @@ -45,12 +45,11 @@ class wsUtil $objPHPExcel = $objReader->load($excelFile); - foreach ($objPHPExcel->getWorksheetIterator() as $worksheet) { if ($worksheet->getSheetState() != PHPExcel_Worksheet::SHEETSTATE_VISIBLE) { continue; } - $title = $worksheet->getTitle(); + $title = trim($worksheet->getTitle()); if (strlen($title) == 2 && cubeCountry::getCountry($title)) { $title = cubeCountry::getCountry($title); @@ -83,35 +82,53 @@ class wsUtil public static function excelToArrayKeyVars($excelFile, $reader = 'Excel2007', $skipEmptyId = false) { + global $core; + + $e = explode('#', $excelFile); + $excelFile = $e[0]; + $worksheets = self::excelToArray($excelFile, false, $reader); + + if (isset($e[1])) { + $sheetName = trim($e[1]); + } + + + if (isset($sheetName, $worksheets[$sheetName])) { + $worksheet = $worksheets[$sheetName]; + } else { + $worksheet = array_unshift($worksheets); + } + $res = []; - foreach ($worksheets as $worksheet) { - foreach ($worksheet as $i => $line) { - if ($i === 0) { - $vars = []; - foreach ($line as $j => $varname) { - if ($j === 0) { - continue; - } - $vars[$j] = $varname; - } - } else { - $r = []; - foreach ($vars as $j => $varname) { - $r[$varname] = trim($line[$j]); + foreach ($worksheet as $i => $line) { + if ($i === 0) { + $vars = []; + foreach ($line as $j => $varname) { + if ($j === 0) { + continue; } - $id = trim($line[0]); - if ($id === '') { - if ($skipEmptyId) { - continue; - } - $id = $i; + $vars[$j] = $varname; + } + } else { + if (trim(implode('', $line)) == '') { + continue; + } + $r = []; + foreach ($vars as $j => $varname) { + $r[$varname] = trim($line[$j]); + } + $id = trim($line[0]); + if ($id === '') { + if ($skipEmptyId) { + continue; } - $res[$id] = $r; + $id = $i; } + $res[$id] = $r; } - break; } + return $res; } @@ -355,7 +372,7 @@ class wsUtil if ($book->parametres->pdfReplace) { - $replace = $book->getAssetDir().$book->parametres->pdfReplace; + $replace = $book->getAssetDir() . $book->parametres->pdfReplace; if (file_exists($replace) && filesize($replace) > 0) { if (!file_exists($normalPDF) || filemtime($normalPDF) < filemtime($replace) || filesize($normalPDF) != filesize($replace)) { self::copy($replace, $normalPDF); 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 be5675122..8c7587281 100644 --- a/inc/ws/Util/html5/master/class.ws.html5.compiler.php +++ b/inc/ws/Util/html5/master/class.ws.html5.compiler.php @@ -894,9 +894,9 @@ class wsHTML5Compiler $this->addSlideshowLibrary(false); $this->addSlideshowLibrary(true); } - $this->writeStats(); - $this->writeSecure(); + $this->log('Copied assets'); + $this->writeSecure(); $this->loadPlugins(); $this->log('Plugins loaded'); $this->writeImages(); @@ -906,6 +906,8 @@ class wsHTML5Compiler $this->log('Articles written'); $linksCSS = $this->writeLinks(); $this->log('Links written'); + $this->writeStats(); + $this->log('Stats written'); $this->writeLangs(); $this->log('Langs written'); $this->writeSEO(); @@ -939,6 +941,7 @@ class wsHTML5Compiler protected function writeStats() { + global $core; if ($this->book->parametres->tagcommander_id) { $id = $this->book->parametres->tagcommander_id; if (!$this->book->parametres->tagcommander_prod) { @@ -953,9 +956,8 @@ class wsHTML5Compiler $this->book->parametres->statsCustom .= ''; $this->book->parametres->statsCustom .= ''; - if ($this->book->parametres->tagcommander_plan) { - $plan = wsUtil::excelToArrayKeyVars($this->wdir . '/' . $this->book->parametres->tagcommander_plan); + $plan = wsUtil::excelToArrayKeyVars($this->_wdirOrAbsolute($this->book->parametres->tagcommander_plan)); $fixedplan = []; foreach ($plan as $k => $v) { $e = explode('#', $k); @@ -963,7 +965,7 @@ class wsHTML5Compiler $k = $e[1]; } - $fixedplan[trim($k, '#/')] = $v; + $fixedplan[$this->_labelToPage($k)] = $v; } $this->config->tagcommander_plan = $fixedplan; } @@ -981,9 +983,42 @@ j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src= '; + + } } + + protected function _wdirOrAbsolute($path) + { + $e = explode('#', $path); + if (file_exists($e[0])) { + return $path; + } + return $this->wdir . $path; + + } + + protected function _labelToPage($k) + { + global $core; + $k = trim($k, '#/'); + $k = str_replace('page/page', 'page', $k); + + if (preg_match('/^page\/(\d+)$/', $k, $matches)) { + return $k; + } + + if (preg_match('/^page\/(.+)$/', $k, $matches)) { + $matches[1]=CubeIT_Util_Text::removeAccents($matches[1]); + $matches[1]=mb_strtolower($matches[1]); + if (isset($this->pageLabels[$matches[1]])) { + return 'page/' . $this->pageLabels[$matches[1]]; + } + } + return $k; + } + protected function writeSecure() { if ($this->book->parametres->secureClientSidePassword !== '') { @@ -1798,10 +1833,14 @@ height="0" width="0" style="display:none;visibility:hidden"> $pagesOfCustomLinks = []; $hiddenLinks = []; + $anchorExists = []; $linksCopy = $links; foreach ($linksCopy as $k => $linkData) { + if ($linkData['type'] == 26 || $linkData == 40) { + $anchorExists[$linkData['to']] = $linkData; + } if ($linkData['type'] == 35 || $linkData['type'] == 15 || $linkData['type'] == 39) { $linkData = wsLinks::decryptLink($linkData); $animations = contentLink::parseAnimations($linkData['image_rollover']); @@ -1874,6 +1913,41 @@ height="0" width="0" style="display:none;visibility:hidden"> } } + if ($this->book->parametres->anchorsAliases && file_exists($this->book->parametres->anchorsAliases)) { + $aliases = []; + $anchors = []; + $lines = CubeIT_Util_Text::explodeNewLines(file_get_contents($this->book->parametres->anchorsAliases)); + foreach ($lines as $line) { + $e = explode("\t", $line); + $from = trim($e[0]); + $to = trim($e[1]); + $aliases[$from] = $to; + if (is_numeric($to) && !isset($anchorExists[$from])) { + $anchor = [ + 'page' => $to, + 'top' => 0, + 'left' => 0, + 'width' => 100, + 'height' => 100, + 'type' => 26, + 'to' => $from, + 'uid' => wsHTML5Link::generateUID() + ]; + $anchorExists[$from] = $anchor; + $links[] = $anchor; + } else { + if (!isset($anchorExists[$from]) && isset($anchorExists[$to])) { + $anchor = $anchorExists[$to]; + $anchor['to'] = $from; + $anchor['uid'] = wsHTML5Link::generateUID(); + $anchorExists[$from] = $anchor; + $links[] = $anchor; + } + } + } + } + + $this->config->pagesOfCustomLinks = $pagesOfCustomLinks; $i = 1; @@ -1956,6 +2030,7 @@ height="0" width="0" style="display:none;visibility:hidden"> } } + $allpages = range(0, $this->book->parametres->pages + 1); if ($this->book->parametres->themeEnableAfterSearch) { $allpages[] = 'aftersearch'; 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 8f4b02b0f..68dc938f5 100644 --- a/inc/ws/Util/html5/master/class.ws.html5.links.php +++ b/inc/ws/Util/html5/master/class.ws.html5.links.php @@ -274,6 +274,11 @@ class wsHTML5Link } + public static function generateUID() + { + return dechex(rand(0, pow(16, 10))); + } + public function getSurface() { return $this->width * $this->height;