From 40e0a341bae44e986212cbc7209872e7f24a451a Mon Sep 17 00:00:00 2001 From: "vincent@cubedesigners.com" Date: Wed, 8 Apr 2015 17:23:00 +0000 Subject: [PATCH] Popup html link --- inc/ws/DAO/class.ws.dao.book.php | 51 +++---- inc/ws/Util/class.ws.links.php | 2 +- inc/ws/Util/html5/class.ws.html5.compiler.php | 140 +++++++++--------- inc/ws/Util/html5/class.ws.html5.links.php | 107 ++++++++----- .../Util/packager/class.ws.packager.html5.php | 100 ++++++------- 5 files changed, 211 insertions(+), 189 deletions(-) diff --git a/inc/ws/DAO/class.ws.dao.book.php b/inc/ws/DAO/class.ws.dao.book.php index e68f8ec5e..af7c9ff70 100644 --- a/inc/ws/DAO/class.ws.dao.book.php +++ b/inc/ws/DAO/class.ws.dao.book.php @@ -102,7 +102,7 @@ class wsDAOBook extends commonDAO { $mail->to = 'tech@fluidbook.com'; $mail->subject = '[Fluidbook Workshop] Fluidbook consulté via l\'url publique'; $mail->body = 'Le fluidbook suivant a été consulté ' . $m . ' fois (et ' . $r->demo_counter . ' au total) via l\'url publique : ' . "\r\n" . - 'Fluidbook # ' . $book_id . ' - ' . $r->nom; + 'Fluidbook # ' . $book_id . ' - ' . $r->nom; $mail->send(); } @@ -337,10 +337,10 @@ class wsDAOBook extends commonDAO { $num = ''; } $pages[$r->book_page] = array('document_id' => $r->document_id, - 'document_page' => $r->document_page, - 'version' => $r->version, - 'defaultNum' => $num, - 'nb_pages' => $r->doc_pages + 'document_page' => $r->document_page, + 'version' => $r->version, + 'defaultNum' => $num, + 'nb_pages' => $r->doc_pages ); if ($conversion) { @@ -494,12 +494,12 @@ class wsDAOBook extends commonDAO { } public function setChapters($book_id, $json) { - $chapters = json_decode($json, TRUE); + $chapters = json_decode($json, true); $res = array(); foreach ($chapters as $c) { $c['label'] = trim($c['label']); - $n = (string) $c['page']; + $n = (string)$c['page']; $c['label'] = trim(preg_replace('|\s+' . $n . '$|iu', '', $c['label'])); $res[] = $c; } @@ -529,7 +529,6 @@ class wsDAOBook extends commonDAO { } - $c1->links = $c->specialLinks = $links; $c1->rulers = $c->specialRulers = $rulers; $c1->update = $c->changedate = TIME; @@ -568,14 +567,14 @@ class wsDAOBook extends commonDAO { $chapters = $xml->xpath('//chapters'); foreach ($chapters as $ch) { $c = array(); - $c['label'] = (string) $ch->txt; + $c['label'] = (string)$ch->txt; - $p = intval((string) $ch->page); + $p = intval((string)$ch->page); if ($p <= 0) { continue; } $c['page'] = $n[$p]; - $c['level'] = intval((string) $ch->level); + $c['level'] = intval((string)$ch->level); $res[] = $c; } @@ -713,7 +712,7 @@ class wsDAOBook extends commonDAO { } public function isUpToDate($book, $version) { - $version = (string) $version; + $version = (string)$version; if ($version == '2') { if (!file_exists(WS_BOOKS . '/final/' . $book->book_id)) { return false; @@ -730,6 +729,7 @@ class wsDAOBook extends commonDAO { return false; } } else if ($version == 'html5') { + return false; // HTML5 $checks = array($book->changedate, cubeFiles::filemtimeRecursive(WS_BOOKS . '/working/' . $book->book_id), cubeFiles::filemtimeRecursive(WS_COMPILE_ASSETS . '/_html5'), cubeFiles::filemtimeRecursive(ROOT . '/inc/ws/Util/html5')); foreach ($checks as $check) { @@ -763,11 +763,11 @@ class wsDAOBook extends commonDAO { $tab = array(); $now = array(); while ($r->fetch()) { - $ref[$r->book_page] = array((int) $r->document_id, (int) $r->document_page); + $ref[$r->book_page] = array((int)$r->document_id, (int)$r->document_page); } $i = 1; foreach ($pages as $p) { - $now[$i] = array((int) $p->document_id, (int) $p->document_page); + $now[$i] = array((int)$p->document_id, (int)$p->document_page); $i++; } if ($now != $ref) { @@ -808,7 +808,7 @@ class wsDAOBook extends commonDAO { $dir = WS_BOOKS . '/index/' . $book->book_id; if ($book->parametres->ignoreSearchSeparators != '') { - $dir.='/' . sha1($book->parametres->ignoreSearchSeparators); + $dir .= '/' . sha1($book->parametres->ignoreSearchSeparators); } if (!file_exists($dir)) { mkdir($dir, 0777, true); @@ -1004,11 +1004,10 @@ class wsDAOBook extends commonDAO { } - $res = ''; if ($v1) { fb(time(), 'Compile V1'); - $res.=$this->compile1($book_id, $book, $pages); + $res .= $this->compile1($book_id, $book, $pages); $this->touchCompile($book_id, '1'); } if ($v2) { @@ -1018,7 +1017,7 @@ class wsDAOBook extends commonDAO { } if ($html5) { fb(time(), 'Compile HTML5'); - $res.=$this->compileHTML5($book_id, $book); + $res .= $this->compileHTML5($book_id, $book); $this->touchCompile($book_id, 'html5'); } if ($v1 || $v2) { @@ -1131,7 +1130,7 @@ class wsDAOBook extends commonDAO { $air = new cubeAIRCompiler($swf . '.swf', '/usr/local/flex/bin', $compilerDir, '2.0'); $air->setApplicationDatas('com.fluidbook' . $book_id, $book->parametres->title, $book->parametres->title, cubeText::str2URL($book->parametres->title), $book->lang); $air->setInitialWindow($book->parametres->title); - $res.=$air->compile(); + $res .= $air->compile(); return $res; } @@ -1160,9 +1159,9 @@ class wsDAOBook extends commonDAO { $signature = $daoSignature->selectById($book->parametres->signature); $exportSignature = array('main' => $signature->main, - 'mainLink' => $signature->mainLink, - 'partner' => $signature->partner, - 'partnerLink' => $signature->partnerLink); + 'mainLink' => $signature->mainLink, + 'partner' => $signature->partner, + 'partnerLink' => $signature->partnerLink); $index = ''; $textes = ''; @@ -1347,7 +1346,7 @@ class wsDAOBook extends commonDAO { $langNames[$mlang] = $n; $cn = cubeCountry::getCountryName($flag, $mlang); $countryNames[$mlang . '_' . $flag] = $cn; - $chars.=$n . $cn; + $chars .= $n . $cn; } $chars = preg_split('/(?item as $item) { - $ref = (string) $item['reference']; + $ref = (string)$item['reference']; if (isset($allref[$ref])) { continue; } @@ -1657,8 +1656,6 @@ class wsDAOBook extends commonDAO { } - - if ($book->parametres->pdfReplace) { $replace = WS_BOOKS . '/working/' . $book->book_id . '/' . $book->parametres->pdfReplace; if (file_exists($replace)) { @@ -1700,7 +1697,7 @@ class wsDAOBook extends commonDAO { $res = ''; for ($i = 0; $i < 8; $i++) { $j = rand(0, 61); - $res.=$this->base62($j); + $res .= $this->base62($j); } $r = $this->con->select('SELECT book_id FROM books WHERE cid=\'' . $res . '\''); if ($r->count() == 0) { diff --git a/inc/ws/Util/class.ws.links.php b/inc/ws/Util/class.ws.links.php index 8691c5b1a..82e373fef 100644 --- a/inc/ws/Util/class.ws.links.php +++ b/inc/ws/Util/class.ws.links.php @@ -210,7 +210,7 @@ class wsLinks { if (isset($tlinks[$infos['document_id']][$infos['document_page']])) { $l = $tlinks[$infos['document_id']][$infos['document_page']]; foreach ($l as $link) { - $link = (array) $link; + $link = (array)$link; $link['page'] = $p; $link['id'] = $i; if (!isset($link['rot'])) { diff --git a/inc/ws/Util/html5/class.ws.html5.compiler.php b/inc/ws/Util/html5/class.ws.html5.compiler.php index ccd735446..441d85015 100644 --- a/inc/ws/Util/html5/class.ws.html5.compiler.php +++ b/inc/ws/Util/html5/class.ws.html5.compiler.php @@ -91,7 +91,7 @@ class wsHTML5Compiler { 'js/widget.js' ); public $phonegapStandardPlugins = array('ios' => array('ExternalFileUtil'), - 'android' => array('webintent')); + 'android' => array('webintent')); public $pluginCSS = array(); public $pluginJs = array(); public $htmlmultimedia = array(); @@ -438,15 +438,15 @@ class wsHTML5Compiler { $signature = $daoSignature->selectById($this->book->parametres->signature); $exportSignature = array('main' => $signature->main, - 'mainLink' => $signature->mainLink, - 'partner' => $signature->partner, - 'partnerLink' => $signature->partnerLink); + 'mainLink' => $signature->mainLink, + 'partner' => $signature->partner, + 'partnerLink' => $signature->partnerLink); $credits = ''; if ($signature->partner != '') { $credits = '' . $signature->partner . ' '; } - $credits.='' . $signature->main . ''; + $credits .= '' . $signature->main . ''; $hiddenContents = implode("\n", $this->hiddenContents); @@ -479,9 +479,9 @@ class wsHTML5Compiler { $iscript = ''; if (count($this->htmlmultimedia)) { - $iscript.='' . "\n"; + $iscript .= '' . "\n"; } $script = ''; @@ -494,7 +494,7 @@ class wsHTML5Compiler { foreach ($this->pluginJs as $p) { $script .= '' . "\n"; } - $script.=$iscript; + $script .= $iscript; $description = ''; @@ -517,7 +517,7 @@ class wsHTML5Compiler { $dim = getimagesize($this->themeRoot . '/' . $this->theme->parametres->logoLoader); if ($dim !== false) { $this->copy($this->themeRoot . '/' . $this->theme->parametres->logoLoader, $this->vdir . '/data/images/' . $this->theme->parametres->logoLoader); - $splash.=''; + $splash .= ''; } } @@ -555,7 +555,7 @@ class wsHTML5Compiler { $uhtml = str_replace('', $$v, $uhtml); } - $script.="\n\t\t" . ''; + $script .= "\n\t\t" . ''; $vars = array('titre', 'credits', 'ga', 'style', 'script', 'print', 'hiddenContents', 'splash', 'message'); foreach ($vars as $v) { $thtml = str_replace('', $$v, $thtml); @@ -705,9 +705,9 @@ class wsHTML5Compiler { $cpages[$link->page] = ''; } if ($link instanceof contentLink) { - $cpages[$link->page].=$c; + $cpages[$link->page] .= $c; } else { - $pages[$link->page].=$c; + $pages[$link->page] .= $c; } if ($link->keep()) { @@ -744,7 +744,7 @@ class wsHTML5Compiler { return; } - $this->config->bookmarkGroups[] = array('page' => ($link['page'] ), 'nb' => $link['to'], 'name' => $link['extra']); + $this->config->bookmarkGroups[] = array('page' => ($link['page']), 'nb' => $link['to'], 'name' => $link['extra']); } protected function writeJs() { @@ -771,7 +771,7 @@ class wsHTML5Compiler { } if (!$reminimize) { - if (filemtime(__FILE__) > $mintime) { + if (filemtime(__FILE__) > $mintime || filemtime(__DIR__ . 'class.ws.html5.links.php') > $mintime) { $reminimize = true; } } @@ -779,8 +779,8 @@ class wsHTML5Compiler { if ($reminimize) { $js = ''; foreach ($files as $file) { - $js.=file_get_contents($this->assets . '/' . $file); - $js.="\n\n"; + $js .= file_get_contents($this->assets . '/' . $file); + $js .= "\n\n"; } $tmp = cubeFiles::tempnam(); file_put_contents($tmp, $js); @@ -889,14 +889,14 @@ class wsHTML5Compiler { $arrowsColor = $this->theme->parametres->arrowsColor; // Set the icon list with the color $icons = array('nav-bookmark' => $couleurI, 'nav-friend' => $couleurI, 'nav-help' => $couleurI, 'nav-index' => $couleurI, 'nav-sommaire' => $couleurI, - 'nav-zoomin' => $couleurI, 'nav-zoomout' => $couleurI, 'nav-fullscreen' => $couleurI, - 'interface-next' => $arrowsColor, 'interface-previous' => $arrowsColor, 'interface-search' => $couleurI, 'interface-back-arrow' => $subTextColor, 'interface-print' => $subTextColor, - 'interface-down' => $arrowsColor, 'interface-close' => $arrowsColor, - 'help-fingers' => $couleurI, 'help-mouse' => $couleurI, 'nav-home' => $couleurI, 'nav-archives' => $couleurI, 'nav-map' => $couleurI, - 'nav-tag' => $couleurI, 'nav-print' => $couleurI, 'nav-friend' => $couleurI, - 'share-facebook' => $couleurM, 'share-twitter' => $couleurM, 'share-email' => $couleurM, 'share-googleplus' => $couleurM, 'share-linkedin' => $couleurM, 'share-viadeo' => $couleurM, - 'bookmark-left-off' => $bookmarksDisabledColors, 'bookmark-left-on' => $bookmarksEnabledColors, - 'bookmark-right-off' => $bookmarksDisabledColors, 'bookmark-right-on' => $bookmarksEnabledColors + 'nav-zoomin' => $couleurI, 'nav-zoomout' => $couleurI, 'nav-fullscreen' => $couleurI, + 'interface-next' => $arrowsColor, 'interface-previous' => $arrowsColor, 'interface-search' => $couleurI, 'interface-back-arrow' => $subTextColor, 'interface-print' => $subTextColor, + 'interface-down' => $arrowsColor, 'interface-close' => $arrowsColor, + 'help-fingers' => $couleurI, 'help-mouse' => $couleurI, 'nav-home' => $couleurI, 'nav-archives' => $couleurI, 'nav-map' => $couleurI, + 'nav-tag' => $couleurI, 'nav-print' => $couleurI, 'nav-friend' => $couleurI, + 'share-facebook' => $couleurM, 'share-twitter' => $couleurM, 'share-email' => $couleurM, 'share-googleplus' => $couleurM, 'share-linkedin' => $couleurM, 'share-viadeo' => $couleurM, + 'bookmark-left-off' => $bookmarksDisabledColors, 'bookmark-left-on' => $bookmarksEnabledColors, + 'bookmark-right-off' => $bookmarksDisabledColors, 'bookmark-right-on' => $bookmarksEnabledColors ); $this->config->iconsDimensions = array(); @@ -959,8 +959,8 @@ class wsHTML5Compiler { $convert = new cubeCommandLine('composite'); $cmd = '-compose Multiply '; - $cmd.=$tmp . ' ' . $orig . ' '; - $cmd.=$this->vdir . '/cover.jpg'; + $cmd .= $tmp . ' ' . $orig . ' '; + $cmd .= $this->vdir . '/cover.jpg'; $convert->setManualArg($cmd); $convert->execute(); @@ -1035,36 +1035,36 @@ class wsHTML5Compiler { $br = '.background.r' . $r . '{'; if ($ratio != 1) { - $br.=self::writeCSSUA('transform', 'scale(' . $ratio . ')') . ';'; + $br .= self::writeCSSUA('transform', 'scale(' . $ratio . ')') . ';'; } - $br.='width:' . $wr . 'px;height:' . $hr . 'px;}'; + $br .= 'width:' . $wr . 'px;height:' . $hr . 'px;}'; $res[] = $br; } $texts = '.texts{' . self::writeCSSUA('transform-origin', 'top left') . ';'; - $texts.=self::writeCSSUA('transform', 'scale(' . round((1 / $this->multiply) * $cssScale * $this->cssSVGScale, 3) . ')') . ';'; - $texts.='width:' . ($wm / $this->cssSVGScale) . '; max-width:' . ($wm / $this->cssSVGScale) . ';'; - $texts.='height:' . ($hm / $this->cssSVGScale) . '; max-height:' . ($hm / $this->cssSVGScale) . ';'; - $texts.='}'; + $texts .= self::writeCSSUA('transform', 'scale(' . round((1 / $this->multiply) * $cssScale * $this->cssSVGScale, 3) . ')') . ';'; + $texts .= 'width:' . ($wm / $this->cssSVGScale) . '; max-width:' . ($wm / $this->cssSVGScale) . ';'; + $texts .= 'height:' . ($hm / $this->cssSVGScale) . '; max-height:' . ($hm / $this->cssSVGScale) . ';'; + $texts .= '}'; $res[] = $texts; // Theme $shade = '.page .shade{'; - $shade.='opacity:' . ($this->theme->parametres->shadeAlpha / 100) . ';'; - $shade.='}'; + $shade .= 'opacity:' . ($this->theme->parametres->shadeAlpha / 100) . ';'; + $shade .= '}'; $res[] = $shade; // Search field $searchColor = self::colorToCSS($this->theme->parametres->couleurS); $searchBackColor = self::colorToCSS($this->theme->parametres->searchFieldColor); $search = '#q{'; - $search.='color:' . $searchColor . ';'; - $search.='background-color:' . $searchBackColor . ';'; + $search .= 'color:' . $searchColor . ';'; + $search .= 'background-color:' . $searchBackColor . ';'; if ($this->theme->parametres->searchShadeAlpha > 0) { - $search.=self::writeCSSUA('box-shadow', '1px 1px 4px rgba(0,0,0,' . ($this->theme->parametres->searchShadeAlpha / 100) . ')') . ' inset;'; + $search .= self::writeCSSUA('box-shadow', '1px 1px 4px rgba(0,0,0,' . ($this->theme->parametres->searchShadeAlpha / 100) . ')') . ' inset;'; } - $search.='}'; - $search.='#searchHints,.hint{color:' . $searchColor . ';background-color:' . $searchBackColor . ';}'; - $search.='.hint:hover{color:' . $searchBackColor . ';background-color:' . $searchColor . ';}'; + $search .= '}'; + $search .= '#searchHints,.hint{color:' . $searchColor . ';background-color:' . $searchBackColor . ';}'; + $search .= '.hint:hover{color:' . $searchBackColor . ';background-color:' . $searchColor . ';}'; $res[] = $search; @@ -1076,15 +1076,15 @@ class wsHTML5Compiler { // Archives // Header $header = 'header{'; - $header.='height:' . $this->theme->parametres->menuHeight . 'px;'; - $header.='background-color:' . self::colorToCSS($this->theme->parametres->menuColor) . ';'; + $header .= 'height:' . $this->theme->parametres->menuHeight . 'px;'; + $header .= 'background-color:' . self::colorToCSS($this->theme->parametres->menuColor) . ';'; if ($this->theme->parametres->menuImage != '') { $this->copy($this->themeRoot . '/' . $this->theme->parametres->menuImage, $this->vdir . '/data/images/' . $this->theme->parametres->menuImage); - $header.='background-image:url(../images/' . $this->theme->parametres->menuImage . ');'; - $header.='background-repeat:no-repeat;'; - $header.='background-size:100% ' . $this->theme->parametres->menuHeight . 'px;'; + $header .= 'background-image:url(../images/' . $this->theme->parametres->menuImage . ');'; + $header .= 'background-repeat:no-repeat;'; + $header .= 'background-size:100% ' . $this->theme->parametres->menuHeight . 'px;'; } - $header.='}'; + $header .= '}'; $res[] = $header; //Icons @@ -1096,9 +1096,9 @@ class wsHTML5Compiler { if ($this->theme->parametres->logo) { $this->copy($this->themeRoot . '/' . $this->theme->parametres->logo, $this->vdir . '/data/images/' . $this->theme->parametres->logo); $dim = getimagesize($this->vdir . '/data/images/' . $this->theme->parametres->logo); - $logo.='background-image:url(../images/' . $this->theme->parametres->logo . ');width:' . $dim[0] . 'px;height:' . $dim[1] . 'px;'; + $logo .= 'background-image:url(../images/' . $this->theme->parametres->logo . ');width:' . $dim[0] . 'px;height:' . $dim[1] . 'px;'; } - $logo.='}'; + $logo .= '}'; $res[] = $logo; // Credits @@ -1141,8 +1141,8 @@ class wsHTML5Compiler { $res[] = '.mview{background-color:' . $menuColor->toCSS() . ';color:' . $menuTextColor . ';}'; # Inner View - $res[].='#innerView>div{background-color:' . $menuColor->toCSS() . ';color:' . $menuTextColor . ';}'; - $res[].='form input[type="text"],form input[type="email"]{background-color:' . self::colorToCSS($this->theme->parametres->subFieldColor) . ';color:' . self::colorToCSS($this->theme->parametres->subTextFieldColor) . ';}'; + $res[] .= '#innerView>div{background-color:' . $menuColor->toCSS() . ';color:' . $menuTextColor . ';}'; + $res[] .= 'form input[type="text"],form input[type="email"]{background-color:' . self::colorToCSS($this->theme->parametres->subFieldColor) . ';color:' . self::colorToCSS($this->theme->parametres->subTextFieldColor) . ';}'; // Archives if ($this->book->parametres->externalArchivesBack) { @@ -1163,7 +1163,7 @@ class wsHTML5Compiler { background-image: linear-gradient(top bottom, $top 0%,$bottom 100%); /* W3C */ }"; - $caption.=".mview .caption a{ + $caption .= ".mview .caption a{ border:1px solid $border; }"; $res[] = $caption; @@ -1202,21 +1202,21 @@ class wsHTML5Compiler { protected function _cssBackground() { $body = '#background,#splash{'; - $body.='background-color:#' . $this->theme->parametres->backgroundColor . ';'; + $body .= 'background-color:#' . $this->theme->parametres->backgroundColor . ';'; switch ($this->theme->parametres->repeat) { case wsTheme::REPEAT: - $body.='background-repeat:repeat;'; + $body .= 'background-repeat:repeat;'; break; case wsTheme::NONE: - $body.='background-repeat:no-repeat;'; + $body .= 'background-repeat:no-repeat;'; break; case wsTheme::RATIO: - $body.='background-repeat:no-repeat;'; - $body.='background-size:cover;'; + $body .= 'background-repeat:no-repeat;'; + $body .= 'background-size:cover;'; break; case wsTheme::STRETCH: - $body.='background-repeat:no-repeat;'; - $body.='background-size:100% 100%;'; + $body .= 'background-repeat:no-repeat;'; + $body .= 'background-size:100% 100%;'; break; } if ($this->theme->parametres->backgroundImage != '') { @@ -1227,36 +1227,36 @@ class wsHTML5Compiler { } $this->copy($this->themeRoot . '/' . $this->theme->parametres->backgroundImage, $this->vdir . '/data/images/' . $this->theme->parametres->backgroundImage); - $body.='background-image:url(../images/' . $this->theme->parametres->backgroundImage . ');'; - $body.='background-position:'; + $body .= 'background-image:url(../images/' . $this->theme->parametres->backgroundImage . ');'; + $body .= 'background-position:'; switch ($this->theme->parametres->backgroundVAlign) { case wsTheme::TOP: - $body.='top'; + $body .= 'top'; break; case wsTheme::MIDDLE: - $body.='center'; + $body .= 'center'; break; case wsTheme::BOTTOM: - $body.='bottom'; + $body .= 'bottom'; break; } - $body.=' '; + $body .= ' '; switch ($this->theme->parametres->backgroundHAlign) { case wsTheme::LEFT: - $body.='left'; + $body .= 'left'; break; case wsTheme::CENTER: - $body.='center'; + $body .= 'center'; break; case wsTheme::RIGHT: - $body.='right'; + $body .= 'right'; break; } - $body.=';'; + $body .= ';'; } - $body.='}'; + $body .= '}'; return $body; } diff --git a/inc/ws/Util/html5/class.ws.html5.links.php b/inc/ws/Util/html5/class.ws.html5.links.php index 30657f2af..929ccea85 100644 --- a/inc/ws/Util/html5/class.ws.html5.links.php +++ b/inc/ws/Util/html5/class.ws.html5.links.php @@ -26,6 +26,8 @@ class wsHTML5Link { public $id; public $rot; + protected $_init; + /** * * @var wsHTML5Compiler @@ -133,6 +135,7 @@ class wsHTML5Link { } public function __construct($id, $init, &$compiler) { + $this->_init = $init; foreach ($init as $k => $v) { $this->$k = $v; } @@ -194,6 +197,9 @@ class wsHTML5Link { public function unzipFile($file, $moveAssets = false) { $fdir = 'data/links/' . $file; $dir = $this->compiler->vdir . '/' . $fdir; + if (file_exists($dir) && is_file($dir)) { + unlink($dir); + } if (!file_exists($dir)) { mkdir($dir, 0777, true); } @@ -221,18 +227,18 @@ class wsHTML5Link { public function getCSSContainer() { if (!($this instanceof contentLink) && $this->page % 2 == 1) { $this->page--; - $this->left+=$this->compiler->width; + $this->left += $this->compiler->width; } $css = '#l_' . $this->id . '{'; - $css.='left:' . $this->left * $this->getCssScale() . 'px;top:' . $this->top * $this->getCssScale() . 'px;'; - $css.='width:' . $this->width * $this->getCssScale() . 'px;height:' . $this->height * $this->getCssScale() . 'px;'; + $css .= 'left:' . $this->left * $this->getCssScale() . 'px;top:' . $this->top * $this->getCssScale() . 'px;'; + $css .= 'width:' . $this->width * $this->getCssScale() . 'px;height:' . $this->height * $this->getCssScale() . 'px;'; if ($this->rot) { - $css.= wsHTML5Compiler::writeCSSUA('transform', 'rotate(' . $this->rot . 'deg)'); - $css.= wsHTML5Compiler::writeCSSUA('transform-origin', '0% 0%'); + $css .= wsHTML5Compiler::writeCSSUA('transform', 'rotate(' . $this->rot . 'deg)'); + $css .= wsHTML5Compiler::writeCSSUA('transform-origin', '0% 0%'); } - $css.=$this->getCSS(); - $css.='}'; + $css .= $this->getCSS(); + $css .= '}'; return $css; } @@ -309,6 +315,19 @@ class htmlMultimediaImage extends wsHTML5Link { } +class htmlMultimediaPopupLink extends htmlMultimediaPopupImage { + + public function getAdditionnalContent() { + $i = $this->_init; + $i['inline'] = true; + + $l = wsHTML5Link::getMultimediaInstance($this->id . '_content', $i, $this->compiler); + $markup = $l->getHTMLContainer(); + return ' data-multimedia="' . rawurlencode($markup) . '" '; + } +} + + class htmlMultimediaPopupImage extends normalLink { public function getURL() { @@ -424,19 +443,19 @@ class videoLink extends wsHTML5Link { $res = '
book_id . '/' . $basename . '.jpg'; $dim = getimagesize($path); - $res.='data-width="' . $dim[0] . '" data-height="' . $dim[1] . '" '; - } - $res.=' data-autoplay="' . $autoplay . '"'; - $res.=' data-controls="' . $controls . '"'; - $res.=' data-loop="' . $loop . '"'; - $res.=' data-sound="' . $sound . '"'; - $res.=' data-name="' . $basename . '"'; - $res.='>
'; + $res .= 'data-width="' . $dim[0] . '" data-height="' . $dim[1] . '" '; + } + $res .= ' data-autoplay="' . $autoplay . '"'; + $res .= ' data-controls="' . $controls . '"'; + $res .= ' data-loop="' . $loop . '"'; + $res .= ' data-sound="' . $sound . '"'; + $res .= ' data-name="' . $basename . '"'; + $res .= '>'; return $res; } @@ -574,6 +593,8 @@ class htmlMultimediaLink extends wsHTML5Link { public function getHTMLContent() { if ($this->_content == '') { $ext = files::getExtension($this->alternative); + fb($this->alternative); + fb($ext); if ($ext == 'oam') { $d = $this->unzipFile($this->alternative, true); $this->_config = $this->getConfigOAM($d['dir']); @@ -585,6 +606,7 @@ class htmlMultimediaLink extends wsHTML5Link { } elseif ($ext == 'html') { $fdir = 'data/links'; $dir = $this->compiler->vdir . '/' . $fdir; + $d = array('fdir' => $fdir, 'dir' => $dir); if (!file_exists($d['dir'])) { fb($d['dir']); @@ -595,12 +617,14 @@ class htmlMultimediaLink extends wsHTML5Link { $this->copyExternalFile($d['dir'] . '/' . $this->alternative); } + fb($this->_config); + $w = $this->width * $this->getCssScale(); $h = $this->height * $this->getCssScale(); if ($this->_config['html']) { $this->_url = $d['fdir'] . '/' . $this->_config['html']; if ($this->extra) { - $this->_url.='?' . $this->extra; + $this->_url .= '?' . $this->extra; } $iw = $this->_config['width']; @@ -643,14 +667,14 @@ class htmlMultimediaLink extends wsHTML5Link { public function getCSSContainer() { if (!($this instanceof contentLink) && $this->page % 2 == 1) { $this->page--; - $this->left+=$this->compiler->width; + $this->left += $this->compiler->width; } $css = '#l_' . $this->id . '{'; - $css.='left:' . $this->left * $this->getCssScale() . 'px;top:' . $this->top * $this->getCssScale() . 'px;'; - $css.='width:' . $this->_config['width'] . 'px;height:' . $this->_config['height'] . 'px;'; - $css.=$this->getCSS(); - $css.='}'; + $css .= 'left:' . $this->left * $this->getCssScale() . 'px;top:' . $this->top * $this->getCssScale() . 'px;'; + $css .= 'width:' . $this->_config['width'] . 'px;height:' . $this->_config['height'] . 'px;'; + $css .= $this->getCSS(); + $css .= '}'; return $css; } @@ -659,7 +683,7 @@ class htmlMultimediaLink extends wsHTML5Link { $sy = ($this->height / ($this->_config['height'])) * $this->getCssScale(); $res = wsHTML5Compiler::writeCSSUA('transform', 'scale(' . $sx . ',' . $sy . ')'); - $res.= wsHTML5Compiler::writeCSSUA('transform-origin', '0% 0%'); + $res .= wsHTML5Compiler::writeCSSUA('transform-origin', '0% 0%'); if (!$this->_config['html']) { return ''; @@ -674,7 +698,8 @@ class htmlMultimediaLink extends wsHTML5Link { } else { $r = array('html' => false, 'inject' => array(file_get_contents($d . '/init.js')), 'injectcss' => array('multimedia.css'), 'injectjs' => array('multimedia.js')); } - return array_merge($res, $r); + $res = array_merge($res, $r); + return $res; } public function getConfigHTML($d, $html) { @@ -686,7 +711,7 @@ class htmlMultimediaLink extends wsHTML5Link { public function getConfigOAM($d) { $x = simplexml_load_file($d . '/config.xml'); - $config = (string) $x->oamfile['src']; + $config = (string)$x->oamfile['src']; $config = str_replace('/Assets', '', $d . '/' . $config); $x = simplexml_load_file($config, 'SimpleXMLElement', LIBXML_NOCDATA); $c = CubeIT_Util_Xml::toObject($x); @@ -738,23 +763,23 @@ class audioLink extends wsHTML5Link { public function getCSSContainer() { $css = parent::getCSSContainer(); $css .= '#l_' . $this->id . ' audio{'; - $css.='width:' . round($this->width * $this->getCssScale()) . 'px;'; - $css.='height:' . round($this->height * $this->getCssScale()) . 'px;'; - $css.='display:block;'; - $css.='}'; + $css .= 'width:' . round($this->width * $this->getCssScale()) . 'px;'; + $css .= 'height:' . round($this->height * $this->getCssScale()) . 'px;'; + $css .= 'display:block;'; + $css .= '}'; return $css; } public static function makeAudioTag($linkDatas, $w = null, $h = null, $compiler = null) { $res = ''; + $res .= ' src="' . wsHTML5Link::getUniversalLocation($linkDatas->to) . '"'; + $res .= '>'; return $res; } @@ -797,18 +822,18 @@ class inpesPopinLink extends htmlMultimediaLink { public function getCSSContainer() { if (!($this instanceof contentLink) && $this->page % 2 == 1) { $this->page--; - $this->left+=$this->compiler->width; + $this->left += $this->compiler->width; } $css = '#l_' . $this->id . '{'; - $css.='left:' . $this->left * $this->getCssScale() . 'px;top:' . $this->top * $this->getCssScale() . 'px;'; - $css.='width:' . $this->width * $this->getCssScale() . 'px;height:' . $this->height * $this->getCssScale() . 'px;'; + $css .= 'left:' . $this->left * $this->getCssScale() . 'px;top:' . $this->top * $this->getCssScale() . 'px;'; + $css .= 'width:' . $this->width * $this->getCssScale() . 'px;height:' . $this->height * $this->getCssScale() . 'px;'; if ($this->rot) { - $css.= wsHTML5Compiler::writeCSSUA('transform', 'rotate(' . $this->rot . 'deg)'); - $css.= wsHTML5Compiler::writeCSSUA('transform-origin', '0% 0%'); + $css .= wsHTML5Compiler::writeCSSUA('transform', 'rotate(' . $this->rot . 'deg)'); + $css .= wsHTML5Compiler::writeCSSUA('transform-origin', '0% 0%'); } - $css.=$this->getCSS(); - $css.='}'; + $css .= $this->getCSS(); + $css .= '}'; return $css; } @@ -824,7 +849,7 @@ class inpesPopinLink extends htmlMultimediaLink { public function getAdditionnalContent() { $res = parent::getAdditionnalContent(); - $res.=' data-src="' . $this->_url . '" data-width="900" data-height="650"'; + $res .= ' data-src="' . $this->_url . '" data-width="900" data-height="650"'; return $res; } diff --git a/inc/ws/Util/packager/class.ws.packager.html5.php b/inc/ws/Util/packager/class.ws.packager.html5.php index 3defc0aa6..12644be5a 100644 --- a/inc/ws/Util/packager/class.ws.packager.html5.php +++ b/inc/ws/Util/packager/class.ws.packager.html5.php @@ -108,10 +108,10 @@ class wsPackagerHTML5 extends wsPackager { $arrowsColor = '#' . $this->theme->parametres->arrowsColor; // Set the icon list with the color $icons = array('nav-bookmark' => $couleurI, 'nav-friend' => $couleurI, 'nav-help' => $couleurI, 'nav-index' => $couleurI, 'nav-sommaire' => $couleurI, - 'next' => $arrowsColor, 'previous' => $arrowsColor, 'search' => $couleurI); + 'next' => $arrowsColor, 'previous' => $arrowsColor, 'search' => $couleurI); foreach ($icons as $icon => $color) { - wsTools::colorizeAndRasterizeIcon($this->theme->parametres->iconSet, $icon, $color, $this->vdir . '/data/images/',4, $w, $h); + wsTools::colorizeAndRasterizeIcon($this->theme->parametres->iconSet, $icon, $color, $this->vdir . '/data/images/', 4, $w, $h); $res[] = '#icon-' . $icon . '{width:' . $w . 'px;height:' . $h . 'px;background-image:url(data/images/' . $icon . '.svg), url(data/images/' . $icon . '.png);background-repeat:no-repeat;background-size:' . $w . 'px ' . $h . 'px}'; } return $res; @@ -156,9 +156,9 @@ class wsPackagerHTML5 extends wsPackager { $res = '
'; foreach ($line['groups'] as $group) { - $res.=$this->writeGroup($group); + $res .= $this->writeGroup($group); } - $res.='
'; + $res .= ''; return $res; } @@ -196,9 +196,9 @@ class wsPackagerHTML5 extends wsPackager { $res = '
'; foreach ($group['spans'] as $span) { - $res.=$this->writeSpan($span); + $res .= $this->writeSpan($span); } - $res.='
'; + $res .= ''; return $res; } @@ -231,86 +231,86 @@ class wsPackagerHTML5 extends wsPackager { $br = '.background.r' . $r . '{'; if ($ratio != 1) { - $br.=$this->writeCSSUA('transform', 'scale(' . $ratio . ')') . ';'; + $br .= $this->writeCSSUA('transform', 'scale(' . $ratio . ')') . ';'; } - $br.='width:' . $wr . 'px;height:' . $hr . 'px;}'; + $br .= 'width:' . $wr . 'px;height:' . $hr . 'px;}'; $res[] = $br; } $res[] = '.doublePage,#pages,.landscape #shadow.double{width:' . $w2 . ';max-width:' . $w2 . ';height:' . $h . ';max-height:' . $h . '}'; $res[] = '.landscape #shadow.single.right{left: ' . $w . ';}'; $res[] = '.landscape .page.right{left:' . $w . '}'; $texts = '.texts{' . $this->writeCSSUA('transform-origin', 'top left') . ';'; - $texts.=$this->writeCSSUA('transform', 'scale(' . (1 / $this->multiply) . ')') . ';'; - $texts.='width:' . $wm . '; max-width:' . $wm . ';'; - $texts.='height:' . $hm . '; max-height:' . $hm . ';'; - $texts.='}'; + $texts .= $this->writeCSSUA('transform', 'scale(' . (1 / $this->multiply) . ')') . ';'; + $texts .= 'width:' . $wm . '; max-width:' . $wm . ';'; + $texts .= 'height:' . $hm . '; max-height:' . $hm . ';'; + $texts .= '}'; $res[] = $texts; // Theme // Background $body = '#main{'; - $body.='background-color:#' . $this->theme->parametres->backgroundColor . ';'; + $body .= 'background-color:#' . $this->theme->parametres->backgroundColor . ';'; switch ($this->theme->parametres->repeat) { case wsTheme::REPEAT: - $body.='background-repeat:repeat;'; + $body .= 'background-repeat:repeat;'; break; case wsTheme::NONE: - $body.='background-repeat:no-repeat;'; + $body .= 'background-repeat:no-repeat;'; break; case wsTheme::RATIO: - $body.='background-repeat:no-repeat;'; + $body .= 'background-repeat:no-repeat;'; break; case wsTheme::STRETCH: - $body.='background-repeat:no-repeat;'; - $body.='background-size:100% 100%;'; + $body .= 'background-repeat:no-repeat;'; + $body .= 'background-size:100% 100%;'; break; } if ($this->theme->parametres->backgroundImage != '') { copy($this->themeRoot . '/' . $this->theme->parametres->backgroundImage, $this->vdir . '/data/images/' . $this->theme->parametres->backgroundImage); - $body.='background-image:url(../images/' . $this->theme->parametres->backgroundImage . ');'; - $body.='background-position:'; + $body .= 'background-image:url(../images/' . $this->theme->parametres->backgroundImage . ');'; + $body .= 'background-position:'; switch ($this->theme->parametres->backgroundVAlign) { case wsTheme::TOP: - $body.='top'; + $body .= 'top'; break; case wsTheme::MIDDLE: - $body.='center'; + $body .= 'center'; break; case wsTheme::BOTTOM: - $body.='bottom'; + $body .= 'bottom'; break; } - $body.=' '; + $body .= ' '; switch ($this->theme->parametres->backgroundHAlign) { case wsTheme::LEFT: - $body.='left'; + $body .= 'left'; break; case wsTheme::CENTER: - $body.='center'; + $body .= 'center'; break; case wsTheme::RIGHT: - $body.='right'; + $body .= 'right'; break; } - $body.=';'; + $body .= ';'; } - $body.='}'; + $body .= '}'; $res[] = $body; // Header $header = '#header{'; - $header.='height:' . $this->theme->parametres->menuHeight . 'px;'; - $header.='background-color:' . self::colorToCSS($this->theme->parametres->menuColor) . ';'; + $header .= 'height:' . $this->theme->parametres->menuHeight . 'px;'; + $header .= 'background-color:' . self::colorToCSS($this->theme->parametres->menuColor) . ';'; if ($this->theme->parametres->menuImage != '') { copy($this->themeRoot . '/' . $this->theme->parametres->menuImage, $this->vdir . '/data/images/' . $this->theme->parametres->menuImage); - $header.='background-image:url(../images/' . $this->theme->parametres->menuImage . ');'; - $header.='background-repeat:no-repeat;'; - $header.='background-size:100% ' . $this->theme->parametres->menuHeight . 'px;'; + $header .= 'background-image:url(../images/' . $this->theme->parametres->menuImage . ');'; + $header .= 'background-repeat:no-repeat;'; + $header .= 'background-size:100% ' . $this->theme->parametres->menuHeight . 'px;'; } - $header.='}'; + $header .= '}'; $res[] = $header; //Icons @@ -321,9 +321,9 @@ class wsPackagerHTML5 extends wsPackager { if ($this->theme->parametres->logo) { copy($this->themeRoot . '/' . $this->theme->parametres->logo, $this->vdir . '/data/images/' . $this->theme->parametres->logo); $dim = getimagesize($this->vdir . '/data/images/' . $this->theme->parametres->logo); - $logo.='background-image:url(../images/' . $this->theme->parametres->logo . ');width:' . $dim[0] . 'px;height:' . $dim[1] . 'px;'; + $logo .= 'background-image:url(../images/' . $this->theme->parametres->logo . ');width:' . $dim[0] . 'px;height:' . $dim[1] . 'px;'; } - $logo.='}'; + $logo .= '}'; $res[] = $logo; // Credits @@ -363,15 +363,15 @@ class wsPackagerHTML5 extends wsPackager { } foreach ($this->cssRotation as $rotation => $index) { - $rotation*= - 1; + $rotation *= -1; $to = 'transform-origin:left top;'; $css = '.r' . $index . '{'; - $css.=self::writeCSSUA('transform', 'rotate(' . $rotation . 'deg)') . ';'; - $css.=self::writeCSSUA('transform-origin', 'left top'); - $css.='}'; + $css .= self::writeCSSUA('transform', 'rotate(' . $rotation . 'deg)') . ';'; + $css .= self::writeCSSUA('transform-origin', 'left top'); + $css .= '}'; $res[] = $css; } @@ -401,9 +401,9 @@ class wsPackagerHTML5 extends wsPackager { $res[] = $this->addGroup($group, $document_id); } return array('x' => $this->normalizeFloatValue($line['x']), - 'y' => $this->normalizeFloatValue($line['y']), - 'rotation' => $this->getCSSRotation($this->normalizeFloatValue($line['rotation'], 0)), - "groups" => $res); + 'y' => $this->normalizeFloatValue($line['y']), + 'rotation' => $this->getCSSRotation($this->normalizeFloatValue($line['rotation'], 0)), + "groups" => $res); } protected function addGroup($group, $document_id) { @@ -438,7 +438,7 @@ class wsPackagerHTML5 extends wsPackager { protected function addSpan($span, $document_id) { - $text = (string) $span; + $text = (string)$span; if ($text == '') { return false; } @@ -510,7 +510,7 @@ class wsPackagerHTML5 extends wsPackager { } protected function getIndex($value, &$tab) { - $value = (string) $value; + $value = (string)$value; if (isset($tab[$value])) { return $tab[$value]; } @@ -519,9 +519,9 @@ class wsPackagerHTML5 extends wsPackager { return $res; } - protected function normalizeFloatValue($value, $round=3) { + protected function normalizeFloatValue($value, $round = 3) { $value = str_replace(',', '.', $value); - $value = (float) $value; + $value = (float)$value; $value = round($value, $round); return $value; } @@ -546,7 +546,7 @@ class wsPackagerHTML5 extends wsPackager { } public function __destruct() { - + } public static function colorToCSS($color) { @@ -563,7 +563,7 @@ class wsPackagerHTML5 extends wsPackager { $hex = substr($color, $k * 2, 2); $$name = intval($hex, 16); } - $alpha/=255; + $alpha /= 255; if ($alpha == 0) { return 'transparent'; } elseif ($alpha == 1) { -- 2.39.5