From 25ea459f4f336744aea3da04f394a85da668aaec Mon Sep 17 00:00:00 2001 From: "stephen@cubedesigners.com" Date: Tue, 15 Jan 2019 16:20:59 +0000 Subject: [PATCH] WIP #2498 @0.5 --- inc/ws/Metier/class.ws.book.parametres.php | 4 +- .../printing/class.ws.html5.compiler.php | 47 ++++++++++--------- l10n/en/main.lang.php | 2 + 3 files changed, 30 insertions(+), 23 deletions(-) diff --git a/inc/ws/Metier/class.ws.book.parametres.php b/inc/ws/Metier/class.ws.book.parametres.php index ebbe3b185..ba0202012 100644 --- a/inc/ws/Metier/class.ws.book.parametres.php +++ b/inc/ws/Metier/class.ws.book.parametres.php @@ -248,13 +248,15 @@ class wsBookParametres extends wsParametres // . // $this->fields['print'] = array('type' => 'boolean', 'default' => true, 'editable' => true, 'label' => __("Activer l'impression")); + $this->fields['printFullBrochure'] = array('type' => 'boolean', 'default' => true, 'editable' => true, 'label' => __("Autoriser l'impression de la brochure complète")); + $this->fields['printPageRange'] = array('type' => 'boolean', 'default' => false, 'editable' => true, 'label' => __("Activer l'option pour imprimer une plage de pages")); $this->fields['printMode'] = array('type' => 'combo', 'default' => 'vector', 'editable' => true, 'label' => __("Mode d'impression"), 'datas' => array(__('Bitmap') => 'bitmap', __('Vectoriel') => 'vector', __('PDF') => 'pdf')); $this->fields['printCoverWithMarks'] = array('type' => 'boolean', 'default' => true, 'editable' => true, 'label' => __("Imprimer les couvertures avec les pages marquées"), 'grade' => 3); $this->forms['print'] = array('label' => __('Impression'), - 'fieldsnames' => array('print', 'printMode', 'printCoverWithMarks')); + 'fieldsnames' => array('print', 'printFullBrochure', 'printPageRange', 'printMode', 'printCoverWithMarks')); $this->fields['search'] = array('type' => 'boolean', 'default' => true, 'editable' => true, 'label' => __('Activer le moteur de recherche')); diff --git a/inc/ws/Util/html5/printing/class.ws.html5.compiler.php b/inc/ws/Util/html5/printing/class.ws.html5.compiler.php index 171c6a8c9..fee62e377 100644 --- a/inc/ws/Util/html5/printing/class.ws.html5.compiler.php +++ b/inc/ws/Util/html5/printing/class.ws.html5.compiler.php @@ -180,14 +180,14 @@ class wsHTML5Compiler public $logtime = null; public $beginBody = array(); public $seoArticles = []; - public $securityPolicyWhitelist = ['*.google-analytics.com', '*.youtube.com', '*.ytimg.com']; + public $securityPolicyWhitelist = ['*.google-analytics.com', '*.youtube.com', '*.ytimg.com', '*.googletagmanager.com']; public $writeLinksData = false; public $content_lock = []; protected $_indexVars = null; public $_signature; /** - * @var wsHTML5Seo + * @var wsHTML5SeolinksData */ public $seo = null; @@ -493,7 +493,7 @@ class wsHTML5Compiler $this->writeExtras(); $this->log('Extras written'); $this->populateConfig(); - $this->writeCSS('data/style/style_%d.css', $linksCSS); + $this->writeCSS($linksCSS); $this->log('CSS written'); $this->writeIndex(); $this->log('Index written'); @@ -503,7 +503,7 @@ class wsHTML5Compiler } $this->writeJs(); $this->log('Js written'); - $this->vdir->sync($delete); + $this->vdir->sync($delete, $this); $this->log('Files Synced'); } @@ -600,25 +600,22 @@ class wsHTML5Compiler protected function _writeIndex($page) { - if (!isset($this->seo->pages[$page])) { return; } $seo = $this->seo->pages[$page]; $html = $seo->getHTML(); - $iv = $this->getIndexVars(); - - foreach ($iv as $k => $v) { - $html = str_replace($k, $v, $html); - } - if ($this->book->parametres->seoVersion) { $seo->writePage($html, $this->vdir); } if ($page == 1) { $seo->writePage($html, $this->vdir, 'index.html'); } + + if ($page % 10 == 0) { + $this->log('Written page ' . $page); + } } public function getIndexVars() @@ -774,6 +771,10 @@ class wsHTML5Compiler protected function writeIndex() { + $iv = $this->getIndexVars(); + foreach ($iv as $k => $v) { + $this->seo->html = str_replace($k, $v, $this->seo->html); + } if ($this->book->parametres->seoVersion) { foreach ($this->pages as $page => $infos) { $this->_writeIndex($page); @@ -1300,7 +1301,7 @@ class wsHTML5Compiler copy($tmp, $minimized); } - if (!file_exists($minimized)) { + if (!file_exists($minimized) || filesize($minimized) == 0) { die('An error occured while uglifying : ' . $uglify->output); } } @@ -1484,7 +1485,9 @@ class wsHTML5Compiler $this->_makeCover($docdir . 'html/t36-' . $infos['document_page'] . '.jpg'); } - $this->log('Copied image ' . $page); + if ($page % 10 == 0) { + $this->log('Copied image ' . $page); + } } @@ -1563,7 +1566,7 @@ class wsHTML5Compiler return $val ? 'true' : 'false'; } - protected function writeCSS($file, $links) + protected function writeCSS($links) { $res = array(); @@ -1610,11 +1613,13 @@ class wsHTML5Compiler $left = $w; + $centerOffset = 0; if ($this->book->parametres->correctCenter) { $centerOffset = 3; $left = ($cssWidth - $centerOffset) . 'px'; $res[] = '.doublePage._3d .page.left{left:-' . ($centerOffset + 1) . 'px !important;}'; } + $lessVariables['correct-center'] = ($centerOffset * -1); $res[] = '.doublePage._3d{left:' . $left . ';}'; $res[] = '#links.right{left:-' . $left . ';}'; @@ -1764,16 +1769,14 @@ class wsHTML5Compiler # ZoomPopup close button background $res[] = '.zoomPopupClose {background-color:' . wsHTML5::colorToCSS($this->theme->parametres->couleurB) . ';}'; + if ($this->book->parametres->textPopupStylesheet) { + $res[] = file_get_contents($this->wdir . '/' . $this->book->parametres->textPopupStylesheet); + } $this->_writeLess($lessVariables, $lessContents); - - $res = array_chunk($res, 3500); - foreach ($res as $k => $css) { - $this->stylesheets[] = 'data/style/style_' . $k . '.css'; - $this->vdir->file_put_contents(sprintf($file, $k), implode("\n", $css)); - $this->log('Write CSS ' . sprintf($file, $k)); - } - return count($res); + $this->stylesheets[] = 'data/style/style.css'; + $this->vdir->file_put_contents('data/style/style.css', implode("\n", $res)); + $this->log('Write CSS'); } protected function _writeLess($variables, $lessContents = '') diff --git a/l10n/en/main.lang.php b/l10n/en/main.lang.php index 71e62a5be..093ac11e5 100644 --- a/l10n/en/main.lang.php +++ b/l10n/en/main.lang.php @@ -647,6 +647,8 @@ let us know by writing to ', 'Activer le scroll automatique' => 'Enable automatic scrolling', 'Index' => 'Index', 'Activer l\'impression' => 'Enable printing ', + 'Autoriser l\'impression de la brochure complète' => 'Allow full brochure to be printed', + 'Activer l\'option pour imprimer une plage de pages' => 'Allow page ranges to be printed', 'Mode d\'impression' => 'Printing mode', 'Bitmap' => 'Bitmap', 'Vectoriel' => 'Vector', -- 2.39.5