From 3e52bb47e83257ce12ceaaff0518dede0ff0d142 Mon Sep 17 00:00:00 2001 From: "vincent@cubedesigners.com" Date: Thu, 1 Aug 2013 17:03:05 +0000 Subject: [PATCH] --- .../Metier/class.extranet.document.php | 2 +- inc/ws/Controlleur/class.ws.ajax.php | 17 +++++-- inc/ws/Controlleur/class.ws.services.php | 44 ++++++++++++------- inc/ws/Metier/class.ws.document.php | 38 +++++++--------- inc/ws/Util/class.ws.exporter.php | 41 +++++++++++------ .../html5/app/class.ws.html5.app.compiler.php | 14 +++++- inc/ws/Util/html5/class.ws.html5.compiler.php | 17 ++++--- .../Util/packager/class.ws.packager.html.php | 9 +++- inc/ws/Util/packager/class.ws.packager.php | 4 +- 9 files changed, 120 insertions(+), 66 deletions(-) diff --git a/inc/extranet/Metier/class.extranet.document.php b/inc/extranet/Metier/class.extranet.document.php index c3067cd2a..742d721e9 100644 --- a/inc/extranet/Metier/class.extranet.document.php +++ b/inc/extranet/Metier/class.extranet.document.php @@ -144,7 +144,7 @@ abstract class extranetDocument extends cubeMetier { $pdf->Cell(30, $space, $ttcf . ' euros', 0, 1, 'R'); if (isset($notes)) { - $pdf->setXY(8, 275); + $pdf->setXY(8, 268); $pdf->setTextColor(0, 0, 0); $pdf->setFont('Helvetica', '', 8); $pdf->Cell(195, 0, self::escape($notes), 0, 1, 'R'); diff --git a/inc/ws/Controlleur/class.ws.ajax.php b/inc/ws/Controlleur/class.ws.ajax.php index 29577b3ba..4ea08f36a 100644 --- a/inc/ws/Controlleur/class.ws.ajax.php +++ b/inc/ws/Controlleur/class.ws.ajax.php @@ -876,8 +876,13 @@ class wsAjax extends cubeAjax { } public static function exportbookExe($args, &$x) { + fb($_POST); + + $dest = array('dir' => null, 'file' => null); + $dest = array_merge($dest, $_POST['destination']); + $exporter = new wsExporter(); - $exporter->export($_POST['book_id'], $x, $_POST['action'], $_POST['version'], $_POST['destination']['dir'], $_POST['destination']['file']); + $exporter->export($_POST['book_id'], $x, $_POST['action'], $_POST['version'], $dest['dir'], $dest['file']); $x->addClosePopup(); } @@ -1117,12 +1122,15 @@ class wsAjax extends cubeAjax { protected static function cleanCachesCollection($id) { $os = array('ios', 'android'); $files = array('json', 'update'); + $resolutions = array(150, 300); foreach ($os as $_os) { foreach ($files as $f) { - $ff = WS_COLLECTIONS . '/ws/' . $id . '.' . $_os . '.' . $f; - if (file_exists($ff)) { - unlink($ff); + foreach ($resolutions as $r) { + $ff = WS_COLLECTIONS . '/ws/' . $id . '.' . $_os . '.' . $r . '.' . $f; + if (file_exists($ff)) { + unlink($ff); + } } } } @@ -1143,4 +1151,5 @@ class wsAjax extends cubeAjax { } } + ?> \ No newline at end of file diff --git a/inc/ws/Controlleur/class.ws.services.php b/inc/ws/Controlleur/class.ws.services.php index 7ed417d59..171a57898 100644 --- a/inc/ws/Controlleur/class.ws.services.php +++ b/inc/ws/Controlleur/class.ws.services.php @@ -554,13 +554,14 @@ class wsServices extends cubeFlashGateway { global $core; $id = $this->callArgs[0]; $os = $this->callArgs[1]; - $local = (isset($this->callArgs[2])) ? $this->callArgs[2] : null; + $resolution = $this->callArgs[2]; + $local = (isset($this->callArgs[3])) ? $this->callArgs[3] : null; $this->outputXML = false; header('Content-type: application/json'); - $cache = WS_COLLECTIONS . '/ws/' . $id . '.' . $os . '.json'; - $update = WS_COLLECTIONS . '/ws/' . $id . '.' . $os . '.update'; + $cache = WS_COLLECTIONS . '/ws/' . $id . '.' . $os . '.' . $resolution . '.json'; + $update = WS_COLLECTIONS . '/ws/' . $id . '.' . $os . '.' . $resolution . '.update'; if (file_exists($update) && filemtime(__FILE__) > filemtime($update)) { unlink($update); @@ -626,7 +627,7 @@ class wsServices extends cubeFlashGateway { } $d = array('id' => $id, 'langs' => $langs, 'langnames' => $langsnames, 'time' => $version, 'datas' => $composition, 'couvertures' => $couvertures, 'traductions' => $traductions, 'contents' => $collection->contents); - $d = array_merge($d, $this->_getManifest($publications, '/fluidbook/collections/versions/' . $id . '/' . $version . '/' . $os, $books)); + $d = array_merge($d, $this->_getManifest($publications, '/fluidbook/collections/versions/' . $id . '/' . $version . '/' . $os, $books, $resolution)); $dao = new wsDAOCollection($core->con); $col = $dao->selectById($id); @@ -651,7 +652,7 @@ class wsServices extends cubeFlashGateway { exit; } - protected function _getManifest($publications, $dir, $books) { + protected function _getManifest($publications, $dir, $books, $resolution) { global $core; $res = array(); $res['manifest'] = array('assetRoot' => 'http://workshop.fluidbook.com' . $dir . '/', 'autoDownload' => true); @@ -671,7 +672,9 @@ class wsServices extends cubeFlashGateway { $book = $books[$p]; $theme = $daoTheme->selectById($book->theme); $orders = $this->_getBundles($book); - $reg = $this->_getRegExpManifest($r, $book, $theme); + $regexp = $this->_getRegExpManifest($r, $book, $theme, $resolution); + $reg = $regexp['reg']; + $exclude = $regexp['exclude']; $b = array(); @@ -680,6 +683,13 @@ class wsServices extends cubeFlashGateway { continue; } $path = str_replace($removeFromRelative, '', $k); + + foreach ($exclude as $e) { + if (preg_match('|' . $e . '|', $path)) { + continue 2; + } + } + $order = $this->_inFirstManifest($path, $orders, $reg); if (!isset($b[$order])) { @@ -707,30 +717,30 @@ class wsServices extends cubeFlashGateway { return $res; } - protected function _getRegExpManifest($r, $book, $theme) { + protected function _getRegExpManifest($r, $book, $theme, $resolution) { $reg = array(); $reg['loading'] = array('^' . $r . 'style/(.*).css$', '^' . $r . 'index.html$', '^' . $r . 'data/style/(.*)$', '^' . $r . 'data/(.*).js$', '^' . $r . 'data/images/' . $theme->parametres->logoLoader . '$', '^' . $r . 'style/fonts/(.*).ttf$'); $reg['extras'] = array('^' . $r . 'data/links/(.*)$', '^' . $r . 'data/(.*).pdf$', '^' . $r . 'cover.jpg$'); $reg['thumbnails'] = array('^' . $r . 'data/thumbnails/p(\d+).jpg$'); for ($i = 1; $i <= $book->parametres->pages; $i++) { $var = 'content_' . $i; - $reg[$var] = array('^' . $r . 'data/background/150/t' . $i . '.jpg$', '^' . $r . 'data/contents/p' . $i . '.svg$'); + $reg[$var] = array('^' . $r . 'data/background/\d+/t' . $i . '.jpg$', '^' . $r . 'data/contents/p' . $i . '.svg$'); } $reg['urgents'] = array('^' . $r . 'images/(.*)$', '^' . $r . 'data/images/(.*)$'); - return $reg; + $exclude = array(); + if ($resolution == 150) { + $er = 300; + } else { + $er = 150; + } + $exclude[] = '^' . $r . 'data/background/' . $er . '/t\d+.jpg$'; + return array('reg' => $reg, 'exclude' => $exclude); } protected function _inFirstManifest($p, $orders, $reg) { - - foreach ($orders as $list) { foreach ($reg[$list] as $v) { if (preg_match('|' . $v . '|', $p)) { - fb($p); - if ($p == '11461/data/background/150/t25.jpg') { - fb($reg[$list]); - fb($v); - } return $list; } } @@ -739,7 +749,7 @@ class wsServices extends cubeFlashGateway { } protected function _getBundles($book) { - $res = array(0 => 'loading', 200001 => 'extras', 20000 => 'thumbnails', 1 => 'urgents'); + $res = array(0 => 'loading', 20001 => 'extras', 20000 => 'thumbnails', 1 => 'urgents'); for ($i = 1; $i <= $book->parametres->pages; $i++) { $k = 2 + $i; $res[$k] = 'content_' . $i; diff --git a/inc/ws/Metier/class.ws.document.php b/inc/ws/Metier/class.ws.document.php index d24dff580..044e0cd80 100644 --- a/inc/ws/Metier/class.ws.document.php +++ b/inc/ws/Metier/class.ws.document.php @@ -457,6 +457,9 @@ class wsDocument extends cubeMetier { if (is_null($in)) { $in = $this->cropped; } + + $tmp = cubeFiles::tempnam(); + $antialiasing = $antialiasing ? 'yes' : 'no'; $freetype = $texts ? 'yes' : 'no'; $resolution = $resolution; @@ -466,24 +469,30 @@ class wsDocument extends cubeMetier { $pdftoppm->setArg('f', $page); $pdftoppm->setArg('l', $page); - $pdftoppm->setArg('-cropbox'); $pdftoppm->setArg('-freetype ' . $freetype); - $pdftoppm->setArg('-jpeg'); + $pdftoppm->setArg('-singlefile'); $pdftoppm->setArg('-aa ' . $antialiasing); $pdftoppm->setArg('-aaVector ' . $antialiasing); $pdftoppm->setArg('r', $resolution); $pdftoppm->setArg(null, $in); - $pdftoppm->setArg(null, $this->out . 'ppm'); + $pdftoppm->setArg(null, $tmp); $pdftoppm->execute(); $this->addToLog($pdftoppm, true, $page); + $tmp.='.ppm'; + $jpegfile = $this->out . $prefix . $page . '.jpg'; - $ppmjpgfile = $this->out . 'ppm-' . cubeMath::fill($page, strlen((string) $this->pages)) . '.jpg'; - if (file_exists($ppmjpgfile)) { - rename($ppmjpgfile, $jpegfile); - $this->addToLog('Move ' . $ppmjpgfile . ' to ' . $jpegfile, true, $page); + + if (file_exists($tmp)) { + $pnmtojpeg = new cubeCommandLine('pnmtojpeg', $jpegfile, false); + $pnmtojpeg->setArg('-quality ' . $quality); + $pnmtojpeg->setArg(null, $tmp); + $pnmtojpeg->execute(); + $this->addToLog($pnmtojpeg, false, $page); + + unlink($tmp); } } @@ -563,19 +572,16 @@ class wsDocument extends cubeMetier { public function makeHTML5Files($page) { // Then make HD background shots - $resolutions = array(150 => 75, 36 => 80); + $resolutions = array(300 => 85, 150 => 85, 36 => 85); foreach ($resolutions as $r => $q) { $this->makeShotPNM($page, 'html/h' . $r . '-', $r, $q, 4, null, false); $this->makeShotPNM($page, 'html/t' . $r . '-', $r, $q, 4, null, true); } - $this->makeSVGFile($page); } public function makeSVGFile($page) { - $testFile = $this->out . '/html/s' . $page . '.svg'; $svgFile = $this->out . '/html/p' . $page . '.svg'; - //$svgSimplified = $this->out . '/html/s' . $page . '.svg'; $svgOpt = $this->out . '/html/o' . $page . '.svg'; $pdftocairo = new cubeCommandLine('pdftocairo'); @@ -589,17 +595,7 @@ class wsDocument extends cubeMetier { $pdftocairo->execute(); $this->addToLog($pdftocairo, true, $page); - /*$pdf2svg = new cubeCommandLine('pdf2svg'); - $pdf2svg->setPath(CONVERTER_PATH); - $pdf2svg->setArg(null, $this->cropped); - $pdf2svg->setArg(null, $testFile); - $pdf2svg->setArg(null, $page); - $pdf2svg->execute(); - $this->addToLog($pdf2svg, true, $page); - $this->_cleanSVG($testFile);*/ - $this->_cleanSVG($svgFile); - } protected function _cleanSVG($svgFile) { diff --git a/inc/ws/Util/class.ws.exporter.php b/inc/ws/Util/class.ws.exporter.php index a48974ec3..577b38486 100644 --- a/inc/ws/Util/class.ws.exporter.php +++ b/inc/ws/Util/class.ws.exporter.php @@ -54,22 +54,31 @@ class wsExporter { // splashs $splashs = array('320x480' => 'Default~iphone', '640x960' => 'Default@2x~iphone', '1024x748' => 'Default-Landscape~ipad', '768x1004' => 'Default-Portrait~ipad', '2048x1496' => 'Default-Landscape@2x~ipad', '1536x2008' => 'Default-Portrait@2x~ipad', '640x1136' => 'Default-568h@2x~iphone'); - $d = WS_COLLECTIONS . '/resources/' . $collection->collection_id . '/' . $os . '/splash/'; - if (!file_exists($d)) { - mkdir($d, 0777, true); - } + $langs = array(); + + foreach ($langs as $l) { + $src = $compiler->wdir . '/' . $collection->theme['splash_' . $l]; + if (!file_exists($src)) { + continue; + } - $src = $compiler->wdir . '/' . $collection->theme['splash']; - foreach ($splashs as $size => $name) { - list($width, $height) = explode('x', $size); + $d = WS_COLLECTIONS . '/resources/' . $collection->collection_id . '/' . $os . '/splash/' . $l . '.lproj/'; + if (!file_exists($d)) { + mkdir($d, 0777, true); + } - $dest = $d . $name . '.png'; - if (!$this->_testFile($src, $dest)) { - $it = new cubeImageTools(); - $it->loadImage($src); - $it->resize($width, $height, 'crop', false, 'C', 'M', 'transparent'); - $it->output('png', $dest); + foreach ($splashs as $size => $name) { + list($width, $height) = explode('x', $size); + + $dest = $d . $name . '.png'; + + if (!$this->_testFile($src, $dest)) { + $it = new cubeImageTools(); + $it->loadImage($src); + $it->resize($width, $height, 'crop', false, 'C', 'M', 'transparent'); + $it->output('png', $dest); + } } } @@ -178,7 +187,7 @@ class wsExporter { $d = '/' . $this->destinationDir; $packager = new wsPackagerPhonegap($this->book_id, $d, true, false, $this->version); - $packager->home=true; + $packager->home = true; return $packager->makePackage(false); } @@ -264,6 +273,7 @@ class wsExporter { $commandes = array( 'set ftp:passive-mode ' . $passive, + 'set ssl:verify-certificate no', 'mkdir -p ' . $u['dir'] ); @@ -286,6 +296,9 @@ class wsExporter { $lftp->setArg('e', implode(';', $commandes)); $lftp->setArg(null, $u['host']); $lftp->execute(); + + fb($lftp->commande); + fb($lftp->output); } protected function _rsync($src, $dest, $erase = false, $chown = null) { diff --git a/inc/ws/Util/html5/app/class.ws.html5.app.compiler.php b/inc/ws/Util/html5/app/class.ws.html5.app.compiler.php index ec42321b3..280048217 100644 --- a/inc/ws/Util/html5/app/class.ws.html5.app.compiler.php +++ b/inc/ws/Util/html5/app/class.ws.html5.app.compiler.php @@ -144,7 +144,8 @@ class wsHTML5AppCompiler { $c[] = '.mview{background-color:' . $menuColor->toCSS() . ';color:' . $textColor->toCSS() . ';}'; # Topbar - $top = $menuColor->toCSS(); + $menu = $top = $menuColor->toCSS(); + $text = $textColor->toCSS(); $bottom = $menuMultiply->toCSS(); $border = $menuMultiply2->setAlpha(0.6)->toCSS(); @@ -160,8 +161,15 @@ class wsHTML5AppCompiler { $caption.='#bar,.mview{color:' . $textColor->toCSS() . '}'; $caption.=".mview .caption a{ border:1px solid $border; + color:$text; }"; + $svg = array('interface-back-arrow'); + foreach ($svg as $icon) { + wsTools::colorizeAndRasterizeIcon(1, $icon, $text, $this->vdir . '/images/', 4, $w, $h, true); + } + $textColor->toCSS(); + $caption.="#bar{border-bottom:1px solid " . $border . "}"; $c[] = $caption; @@ -170,6 +178,7 @@ class wsHTML5AppCompiler { $bottom = $menuMultiply->setAlpha(0.5)->toCSS(); $border = $menuMultiply2->setAlpha(0.5)->toCSS(); + $c[] = '.mview{background-color:' . $menu . ';}'; $c[] = ".mview li{ background-image: -moz-linear-gradient(top, $top 0%, $bottom 100%); /* FF3.6+ */ background-image: -webkit-linear-gradient(top, $top 0%,$bottom 100%); /* Chrome10+,Safari5.1+ */ @@ -177,7 +186,10 @@ class wsHTML5AppCompiler { background-image: -ms-linear-gradient(top, $top 0%,$bottom 100%); /* IE10+ */ background-image: linear-gradient(top bottom, $top 0%,$bottom 100%); /* W3C */ border-bottom:1px solid $border; + color: $text; }"; + + $c[] = '.mview li a{color:' . $text . ';}'; file_put_contents($this->vdir . '/data/app.css', implode("\n", $c)); } diff --git a/inc/ws/Util/html5/class.ws.html5.compiler.php b/inc/ws/Util/html5/class.ws.html5.compiler.php index 83438b1d6..003f645b2 100644 --- a/inc/ws/Util/html5/class.ws.html5.compiler.php +++ b/inc/ws/Util/html5/class.ws.html5.compiler.php @@ -17,7 +17,8 @@ class wsHTML5Compiler { } } - protected static $resolutions = array(150); + protected static $resolutions = array(150, 300); + protected $maxRes = 300; protected static $uaPrefixes = array('-moz-', '-webkit-', '-o-', '-ms-', ''); public $jsFiles = array( 'js/libs/fix/ios-orientation.js', @@ -827,6 +828,7 @@ class wsHTML5Compiler { $this->config->videoFormats = $this->getVideosFormats(false); $this->config->htmlmultimedia = $this->htmlmultimedia; $this->config->phonegap = $this->phonegap; + $this->config->retinaResolution = $this->maxRes; if ($this->home) { $this->config->home = '%apphome%'; } @@ -916,8 +918,12 @@ class wsHTML5Compiler { $this->copy($svg, $this->vdir . '/data/contents/p' . $page . '.svg'); } + foreach (self::$resolutions as $r) { - $this->copy(WS_DOCS . '/' . $infos['document_id'] . '/html/' . $srcPrefix . $r . '-' . $infos['document_page'] . '.jpg', $this->vdir . '/data/background/' . $r . '/' . $this->backgroundsPrefix . $page . '.jpg'); + $ok = $this->copy(WS_DOCS . '/' . $infos['document_id'] . '/html/' . $srcPrefix . $r . '-' . $infos['document_page'] . '.jpg', $this->vdir . '/data/background/' . $r . '/' . $this->backgroundsPrefix . $page . '.jpg'); + if (!$ok && $r = 300) { + $this->maxRes = 150; + } } $this->copy(WS_DOCS . '/' . $infos['document_id'] . '/p' . $infos['document_page'] . '.jpg', $this->vdir . '/data/thumbnails/p' . $page . '.jpg'); @@ -954,17 +960,18 @@ class wsHTML5Compiler { protected function copy($s, $t) { if (!file_exists($s)) { fb($s . ' dont exists'); - return; + return false; } if (file_exists($t) && filemtime($t) >= filemtime($s) && filesize($s) == filesize($t)) { - return; + return true; } if (!file_exists(dirname($t))) { mkdir(dirname($t), 0777, true); } - copy($s, $t); + $res=copy($s, $t); touch($t, filemtime($s)); + return true; } protected function writeCSS($file, $links) { diff --git a/inc/ws/Util/packager/class.ws.packager.html.php b/inc/ws/Util/packager/class.ws.packager.html.php index 152bc0d65..290380ebb 100644 --- a/inc/ws/Util/packager/class.ws.packager.html.php +++ b/inc/ws/Util/packager/class.ws.packager.html.php @@ -37,7 +37,9 @@ class wsPackagerHTML extends wsPackager { $this->copyOtherFiles($others); - mkdir($this->vdir . '/pages/', 0777, true); + if (!file_exists($this->vdir . '/pages')) { + mkdir($this->vdir . '/pages/', 0777, true); + } $ga = ''; if ($this->book->parametres->googleAnalyticsCustom) { @@ -184,7 +186,9 @@ class wsPackagerHTML extends wsPackager { $this->daoBook->compile($this->book_id, 'html5'); $dest = $this->vdir . 'm'; - mkdir($dest, 0777, true); + if (!file_exists($dest)) { + mkdir($dest, 0777, true); + } $cp = new cubeCommandLine('cp'); $cp->setPath(CONVERTER_PATH); @@ -194,6 +198,7 @@ class wsPackagerHTML extends wsPackager { $cp->setArg(null, $dest); $cp->execute(); + $filesToAdd = array(); if ($this->book->parametres->mobileServerConfig) { $filesToAdd = array('.htaccess', 'web.config'); } diff --git a/inc/ws/Util/packager/class.ws.packager.php b/inc/ws/Util/packager/class.ws.packager.php index 398c5c306..f96592959 100644 --- a/inc/ws/Util/packager/class.ws.packager.php +++ b/inc/ws/Util/packager/class.ws.packager.php @@ -185,7 +185,9 @@ class wsPackager { $this->vdir = $this->dir . $this->version . '/'; } $this->cleanVdir(); - mkdir($this->vdir . '/data', 0777, true); + if (!file_exists($this->vdir . '/data')) { + mkdir($this->vdir . '/data', 0777, true); + } } protected function cleanVdir() { -- 2.39.5