From d9152a6d279963197b32411667801522671c115c Mon Sep 17 00:00:00 2001 From: "vincent@cubedesigners.com" Date: Fri, 4 Jan 2019 19:39:14 +0000 Subject: [PATCH] fix #2438 @3 --- fluidbook/icones/15/interface.svg | 4 +-- inc/commons/class.common.ajax.php | 28 +++++++++++++------ inc/ws/Controlleur/class.ws.url.php | 20 ++++--------- inc/ws/DAO/class.ws.dao.book.php | 8 +++--- inc/ws/Metier/class.ws.book.parametres.php | 3 +- .../html5/3dflip/class.ws.html5.compiler.php | 18 ++++++------ .../html5/master/class.ws.html5.compiler.php | 21 ++++++++------ .../html5/master/class.ws.html5.links.php | 25 +++++++++++++---- .../Util/html5/master/class.ws.html5.seo.php | 19 +++++++++++-- index.php | 2 +- 10 files changed, 89 insertions(+), 59 deletions(-) diff --git a/fluidbook/icones/15/interface.svg b/fluidbook/icones/15/interface.svg index dbceb7ea4..419ed9b33 100644 --- a/fluidbook/icones/15/interface.svg +++ b/fluidbook/icones/15/interface.svg @@ -1,10 +1,10 @@ - - diff --git a/inc/commons/class.common.ajax.php b/inc/commons/class.common.ajax.php index af147addc..5a1277452 100644 --- a/inc/commons/class.common.ajax.php +++ b/inc/commons/class.common.ajax.php @@ -476,6 +476,7 @@ Mot de passe : $password"; { global $core; + $e = explode('.', $_FILES['file']['name']); $ext = array_pop($e); new PHPExcel(); @@ -483,23 +484,32 @@ Mot de passe : $password"; $phpexcel = $reader->load($_FILES['file']['tmp_name']); $sheet = $phpexcel->getSheet(0); $maxRow = $sheet->getHighestRow(0); - for ($i = 0; $i < $maxRow; $i++) { - + for ($i = 1; $i <= $maxRow; $i++) { $ref = trim($sheet->getCellByColumnAndRow(0, $i)); $url = trim($sheet->getCellByColumnAndRow(1, $i)->getOldCalculatedValue()); + + if ($ref == '') { + $ref = trim($sheet->getCellByColumnAndRow(0, $i)->getFormattedValue()); + } + if ($url == '') { + $url = trim($sheet->getCellByColumnAndRow(1, $i)->getFormattedValue()); + } + if ($url == '' || $ref == '') { continue; } + $fref = self::_formatWsReferenceRef($ref, $_POST['type']); + $furl = self::_formatWsReferenceUrl($url, $_POST['type']); + + $delete = "DELETE FROM wsref WHERE ref='" . $core->con->escape($fref) . "' AND type='" . $core->con->escape($_POST['type']) . "'"; + $core->con->execute($delete); + $c = $core->con->openCursor('wsref'); $c->type = $_POST['type']; - $c->ref = self::_formatWsReferenceRef($ref, $_POST['type']); - $c->url = self::_formatWsReferenceUrl($url, $_POST['type']); - try { - $c->insert(); - } catch (Exception $e) { - $c->update("WHERE ref='" . $core->con->escape($ref) . "' AND type='" . $core->con->escape($_POST['type']) . "'"); - } + $c->ref = $fref; + $c->url = $furl; + $c->insert(); } } diff --git a/inc/ws/Controlleur/class.ws.url.php b/inc/ws/Controlleur/class.ws.url.php index a9f8e945d..f19b1c8be 100644 --- a/inc/ws/Controlleur/class.ws.url.php +++ b/inc/ws/Controlleur/class.ws.url.php @@ -1105,15 +1105,15 @@ html{height:100%}' . "\n"; } } - $dao->compile($book_id, 'html5'); - $time = self::getHTML5CacheTime($book_id); - - if (count($e) == 2 /*|| $e[2] <= $time - 10*/) { + $time = TIME; + if (count($e) == 2) { $e[2] = $time; http::redirect(SITE_PATH . 'viewerh/' . implode('_', $e) . '/'); exit; } + $dao->compile($book_id, 'html5', false, false, false, null, false); + $book_id = $e[0]; $hash = $e[1]; self::commonHTML5Viewer($book_id, $hash); @@ -1149,7 +1149,7 @@ html{height:100%}' . "\n"; } $dao->compile($book_id, 'html5'); - $time = self::getHTML5CacheTime($book_id); + $time = TIME; if (count($e) == 2 || $e[2] <= $time - 10) { $e[2] = $time; @@ -1162,16 +1162,6 @@ html{height:100%}' . "\n"; self::commonHTML5Viewer($book_id, $hash, '', ['' => '']); } - - public static function getHTML5CacheTime($book_id) - { - $cacheFile = WS_BOOKS . '/html5/' . $book_id . '/cache.appcache'; - if (file_exists($cacheFile)) { - return filemtime($cacheFile); - } - return TIME; - } - public static function commonHTML5Viewer($book_id, $hash, $version = '', $replace = []) { global $core; diff --git a/inc/ws/DAO/class.ws.dao.book.php b/inc/ws/DAO/class.ws.dao.book.php index 21e334a53..c578ee547 100644 --- a/inc/ws/DAO/class.ws.dao.book.php +++ b/inc/ws/DAO/class.ws.dao.book.php @@ -1148,7 +1148,7 @@ class wsDAOBook extends commonDAO } } - public function compile($book_id, $version = 'all', $complete = false, $force = false, $dev = false, $book = null) + public function compile($book_id, $version = 'all', $complete = false, $force = false, $dev = false, $book = null, $delete = true) { if (is_null($book_id) || !$book_id) { return; @@ -1194,7 +1194,7 @@ class wsDAOBook extends commonDAO } if ($html5) { fb(time(), 'Compile HTML5'); - $res .= $this->compileHTML5($book_id, $book, $dev); + $res .= $this->compileHTML5($book_id, $book, $dev, $delete); $this->touchCompile($book_id, 'html5'); } if ($v1 || $v2) { @@ -1744,7 +1744,7 @@ class wsDAOBook extends commonDAO } } - public function compileHTML5($book_id, $book, $dev = false) + public function compileHTML5($book_id, $book, $dev = false, $delete = true) { $version = $book->parametres->mobileLVersion; if ($dev) { @@ -1752,7 +1752,7 @@ class wsDAOBook extends commonDAO } $htmlCompiler = wsHTML5::compilerFactory($book_id, $version, false, 'latest', null, false, false, false, $book); - $htmlCompiler->compile(); + $htmlCompiler->compile($delete); } /* public function indexPDF($book, $pages) { diff --git a/inc/ws/Metier/class.ws.book.parametres.php b/inc/ws/Metier/class.ws.book.parametres.php index 08993dded..d60307dab 100644 --- a/inc/ws/Metier/class.ws.book.parametres.php +++ b/inc/ws/Metier/class.ws.book.parametres.php @@ -391,8 +391,9 @@ class wsBookParametres extends wsParametres $this->fields['inlineSlideshowDuration'] = array('type' => 'float', 'default' => 7, 'editable' => true, 'label' => __('Temps d\'attente des diaporamas intégrés aux pages (s)')); $this->fields['textPopupStylesheet'] = ['type' => 'freefile', 'default' => '', 'editable' => true, 'label' => __('Feuille de style des popups de texte'), 'fileFilter' => $cssFilter]; $this->fields['textPopupWidth'] = ['type' => 'integer', 'default' => '600', 'editable' => true, 'label' => __('Largeur optimale des popups')]; + $this->fields['iframePopupMaxWidth'] = ['type' => 'integer', 'default' => '0', 'editable' => true, 'label' => __('Largeur maximale des popups iframe')]; $this->forms['multimedia'] = array('label' => __('Liens et multimédia'), - 'fieldsnames' => array('permanentLinks', 'linkBlinkTime', 'customLinkClass', 'ignoreLinksTypes', 'linkTooltipManager', 'linkCornerSize', 'linkTooltipMaxWidth', '|', 'linkTracker', 'linkTrackerRegexp', '|', 'linkFilePrefix', '|', 'linkMultimediaPerformanceMode', 'linkMultimediaQuality', '|', 'inlineSlideshowTransitionDuration', 'inlineSlideshowDuration', '|', 'videoReset', 'videoBigPlay', '|', 'brightcovePlayerId', 'brightcovePlayerSecret', '|', 'textPopupWidth', 'textPopupStylesheet')); + 'fieldsnames' => array('permanentLinks', 'linkBlinkTime', 'customLinkClass', 'ignoreLinksTypes', 'linkTooltipManager', 'linkCornerSize', 'linkTooltipMaxWidth', '|', 'linkTracker', 'linkTrackerRegexp', '|', 'linkFilePrefix', '|', 'linkMultimediaPerformanceMode', 'linkMultimediaQuality', '|', 'inlineSlideshowTransitionDuration', 'inlineSlideshowDuration', '|', 'videoReset', 'videoBigPlay', '|', 'brightcovePlayerId', 'brightcovePlayerSecret', '|', 'textPopupStylesheet', 'textPopupWidth', '|', 'iframePopupMaxWidth')); //. $this->fields['externalArchives'] = array('type' => 'freefile', 'default' => '', 'editable' => true, 'label' => __('Archives'), 'grade' => 3, 'fileFilter' => $imageFilter); diff --git a/inc/ws/Util/html5/3dflip/class.ws.html5.compiler.php b/inc/ws/Util/html5/3dflip/class.ws.html5.compiler.php index 7d2f90744..423a6a4aa 100644 --- a/inc/ws/Util/html5/3dflip/class.ws.html5.compiler.php +++ b/inc/ws/Util/html5/3dflip/class.ws.html5.compiler.php @@ -510,7 +510,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'); @@ -1581,7 +1581,7 @@ class wsHTML5Compiler return $val ? 'true' : 'false'; } - protected function writeCSS($file, $links) + protected function writeCSS($links) { $res = array(); @@ -1788,16 +1788,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/inc/ws/Util/html5/master/class.ws.html5.compiler.php b/inc/ws/Util/html5/master/class.ws.html5.compiler.php index c3f5d27f9..17baa2313 100644 --- a/inc/ws/Util/html5/master/class.ws.html5.compiler.php +++ b/inc/ws/Util/html5/master/class.ws.html5.compiler.php @@ -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); @@ -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); + } } 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 1946d631e..09a4c7364 100644 --- a/inc/ws/Util/html5/master/class.ws.html5.links.php +++ b/inc/ws/Util/html5/master/class.ws.html5.links.php @@ -87,7 +87,7 @@ class wsHTML5Link case 'AtlanticDownloadLink': return new atlanticDownloadLink($id, $init, $compiler); default : - return new customLink($id, $init, $compiler); + return customLink::getCustomInstance($id, $init, $compiler); } break; case 8: @@ -1567,12 +1567,22 @@ class haguenauManifLink extends internalLink class customLink extends wescoLink { - public function getURL() + public static function getCustomInstance($id, $init, &$compiler) + { + $e = explode(':', $init['to']); + if ($e[0] == '10doigts') { + $init['to'] = self::_getURL($init['to']); + return new iframePopupLink($id, $init, $compiler); + } + return new customLink($id, $init, $compiler); + } + + public static function _getURL($to) { global $core; - $e = explode(':', $this->to, 2); + $e = explode(':', $to, 2); if (!count($e) == 1) { - return 'https://workshop.fluidbook.com/services/wsref?ref=' . urlencode($this->to); + return 'https://workshop.fluidbook.com/services/wsref?ref=' . urlencode($to); } $type = trim($e[0]); $ref = trim($e[1]); @@ -1584,6 +1594,11 @@ class customLink extends wescoLink return 'https://workshop.fluidbook.com/services/wsref?ref=' . urlencode($type . '|' . $ref); } + public function getURL() + { + return self::_getURL($this->to); + } + public function getDefaultTooltip() { return 'click to open the link'; @@ -1868,7 +1883,7 @@ class iframePopupLink extends normalLink public function keep() { - return true; + return false; } } diff --git a/inc/ws/Util/html5/master/class.ws.html5.seo.php b/inc/ws/Util/html5/master/class.ws.html5.seo.php index c094021bb..f184c849e 100644 --- a/inc/ws/Util/html5/master/class.ws.html5.seo.php +++ b/inc/ws/Util/html5/master/class.ws.html5.seo.php @@ -7,6 +7,7 @@ class wsHTML5Seo */ public $compiler; public $pages; + public $html; protected $_nav = null; @@ -67,6 +68,8 @@ class wsHTML5Seo } } } + + $this->html = file_get_contents($this->compiler->assets . '/_index.html'); } public function getTextContent($infos) @@ -165,8 +168,7 @@ class wsHTML5SeoPage public function getHTML() { - $compiler = $this->_container->compiler; - $html = file_get_contents($this->_container->compiler->assets . '/_index.html'); + $html = $this->_container->html; $vars = ['description' => $this->description ? '' : '', 'keywords' => $this->keywords ? '' : '', @@ -241,6 +243,17 @@ class wsHTML5SeoPage } $html = str_replace('', $base, $html); - $vdir->file_put_contents($path, $html); + $dir = WS_BOOKS . '/seo/' . $this->_container->compiler->book_id . '/'; + if (!file_exists($dir)) { + mkdir($dir, 0777, true); + } + $file = $dir . $this->page . '.html'; + $hash = sha1($html); + $hashfile = $dir . $this->page . '.hash'; + if (!file_exists($hashfile) || file_get_contents($hashfile) != $hash) { + file_put_contents($file, $html); + file_put_contents($hashfile, $hash); + } + $vdir->copy($file, $path); } } \ No newline at end of file diff --git a/index.php b/index.php index 89185cb0b..d943374df 100644 --- a/index.php +++ b/index.php @@ -30,7 +30,7 @@ $standard = 'XHTML 1.0 Transitional'; echo $core->url->getDocument(); $buffer = ob_get_contents(); -cubePHP::set_memory('4G'); +cubePHP::set_memory('6G'); ob_clean(); echo cubePage::page($buffer, $js, $jsvar, $css, array(), 9, false, $meta, array(), $standard); -- 2.39.5