$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'),
$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);
$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'));
return array();\r
}\r
\r
- $cacheFile = $cacheBase . sha1($excelFile . '/' . filemtime($excelFile).'/'.$assoc);\r
+ $cacheFile = $cacheBase . sha1($excelFile . '/' . filemtime($excelFile) . '/' . $assoc);\r
\r
if (!$force && file_exists($cacheFile) && filemtime($cacheFile) > filemtime($excelFile)) {\r
$worksheets = json_decode(file_get_contents($cacheFile), true);\r
$objPHPExcel = $objReader->load($excelFile);\r
\r
\r
-\r
foreach ($objPHPExcel->getWorksheetIterator() as $worksheet) {\r
if ($worksheet->getSheetState() != PHPExcel_Worksheet::SHEETSTATE_VISIBLE) {\r
continue;\r
}\r
- $title = $worksheet->getTitle();\r
+ $title = trim($worksheet->getTitle());\r
\r
if (strlen($title) == 2 && cubeCountry::getCountry($title)) {\r
$title = cubeCountry::getCountry($title);\r
\r
public static function excelToArrayKeyVars($excelFile, $reader = 'Excel2007', $skipEmptyId = false)\r
{\r
+ global $core;\r
+\r
+ $e = explode('#', $excelFile);\r
+ $excelFile = $e[0];\r
+\r
$worksheets = self::excelToArray($excelFile, false, $reader);\r
+\r
+ if (isset($e[1])) {\r
+ $sheetName = trim($e[1]);\r
+ }\r
+\r
+\r
+ if (isset($sheetName, $worksheets[$sheetName])) {\r
+ $worksheet = $worksheets[$sheetName];\r
+ } else {\r
+ $worksheet = array_unshift($worksheets);\r
+ }\r
+\r
$res = [];\r
- foreach ($worksheets as $worksheet) {\r
- foreach ($worksheet as $i => $line) {\r
- if ($i === 0) {\r
- $vars = [];\r
- foreach ($line as $j => $varname) {\r
- if ($j === 0) {\r
- continue;\r
- }\r
- $vars[$j] = $varname;\r
- }\r
- } else {\r
- $r = [];\r
- foreach ($vars as $j => $varname) {\r
- $r[$varname] = trim($line[$j]);\r
+ foreach ($worksheet as $i => $line) {\r
+ if ($i === 0) {\r
+ $vars = [];\r
+ foreach ($line as $j => $varname) {\r
+ if ($j === 0) {\r
+ continue;\r
}\r
- $id = trim($line[0]);\r
- if ($id === '') {\r
- if ($skipEmptyId) {\r
- continue;\r
- }\r
- $id = $i;\r
+ $vars[$j] = $varname;\r
+ }\r
+ } else {\r
+ if (trim(implode('', $line)) == '') {\r
+ continue;\r
+ }\r
+ $r = [];\r
+ foreach ($vars as $j => $varname) {\r
+ $r[$varname] = trim($line[$j]);\r
+ }\r
+ $id = trim($line[0]);\r
+ if ($id === '') {\r
+ if ($skipEmptyId) {\r
+ continue;\r
}\r
- $res[$id] = $r;\r
+ $id = $i;\r
}\r
+ $res[$id] = $r;\r
}\r
- break;\r
}\r
+\r
return $res;\r
}\r
\r
\r
\r
if ($book->parametres->pdfReplace) {\r
- $replace = $book->getAssetDir().$book->parametres->pdfReplace;\r
+ $replace = $book->getAssetDir() . $book->parametres->pdfReplace;\r
if (file_exists($replace) && filesize($replace) > 0) {\r
if (!file_exists($normalPDF) || filemtime($normalPDF) < filemtime($replace) || filesize($normalPDF) != filesize($replace)) {\r
self::copy($replace, $normalPDF);\r
$this->addSlideshowLibrary(false);
$this->addSlideshowLibrary(true);
}
- $this->writeStats();
- $this->writeSecure();
+
$this->log('Copied assets');
+ $this->writeSecure();
$this->loadPlugins();
$this->log('Plugins loaded');
$this->writeImages();
$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();
protected function writeStats()
{
+ global $core;
if ($this->book->parametres->tagcommander_id) {
$id = $this->book->parametres->tagcommander_id;
if (!$this->book->parametres->tagcommander_prod) {
$this->book->parametres->statsCustom .= '<script src="//cdn.tagcommander.com/' . $id . '/tc_Multisite_Analytics.js"></script>';
$this->book->parametres->statsCustom .= '<script src="//cdn.tagcommander.com/' . $id . '/tc_Multisite_Medias.js"></script>';
-
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);
$k = $e[1];
}
- $fixedplan[trim($k, '#/')] = $v;
+ $fixedplan[$this->_labelToPage($k)] = $v;
}
$this->config->tagcommander_plan = $fixedplan;
}
<noscript><iframe src="https://www.googletagmanager.com/ns.html?id=' . $this->book->parametres->googleTagManager . '"
height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
<!-- End Google Tag Manager (noscript) -->';
+
+
}
}
+
+ 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 !== '') {
$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']);
}
}
+ 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;
}
}
+
$allpages = range(0, $this->book->parametres->pages + 1);
if ($this->book->parametres->themeEnableAfterSearch) {
$allpages[] = 'aftersearch';
}
+ public static function generateUID()
+ {
+ return dechex(rand(0, pow(16, 10)));
+ }
+
public function getSurface()
{
return $this->width * $this->height;