]> _ Git - cubeextranet.git/commitdiff
(no commit message)
authorvincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Thu, 1 Aug 2013 17:03:05 +0000 (17:03 +0000)
committervincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Thu, 1 Aug 2013 17:03:05 +0000 (17:03 +0000)
inc/extranet/Metier/class.extranet.document.php
inc/ws/Controlleur/class.ws.ajax.php
inc/ws/Controlleur/class.ws.services.php
inc/ws/Metier/class.ws.document.php
inc/ws/Util/class.ws.exporter.php
inc/ws/Util/html5/app/class.ws.html5.app.compiler.php
inc/ws/Util/html5/class.ws.html5.compiler.php
inc/ws/Util/packager/class.ws.packager.html.php
inc/ws/Util/packager/class.ws.packager.php

index c3067cd2ad84485b0a4069bdbc342d3eaef9bdea..742d721e9a974585b71b7461afb9f3c7594847a2 100644 (file)
@@ -144,7 +144,7 @@ abstract class extranetDocument extends cubeMetier {
                $pdf->Cell(30, $space, $ttcf . ' euros', 0, 1, 'R');\r
 \r
                if (isset($notes)) {\r
-                       $pdf->setXY(8, 275);\r
+                       $pdf->setXY(8, 268);\r
                        $pdf->setTextColor(0, 0, 0);\r
                        $pdf->setFont('Helvetica', '', 8);\r
                        $pdf->Cell(195, 0, self::escape($notes), 0, 1, 'R');\r
index 29577b3bac4cc60f66343c1e136a2a32a36f55f2..4ea08f36a97f94d38e381c702a0ab28027016215 100644 (file)
@@ -876,8 +876,13 @@ class wsAjax extends cubeAjax {
        }\r
 \r
        public static function exportbookExe($args, &$x) {\r
+               fb($_POST);\r
+\r
+               $dest = array('dir' => null, 'file' => null);\r
+               $dest = array_merge($dest, $_POST['destination']);\r
+\r
                $exporter = new wsExporter();\r
-               $exporter->export($_POST['book_id'], $x, $_POST['action'], $_POST['version'], $_POST['destination']['dir'], $_POST['destination']['file']);\r
+               $exporter->export($_POST['book_id'], $x, $_POST['action'], $_POST['version'], $dest['dir'], $dest['file']);\r
 \r
                $x->addClosePopup();\r
        }\r
@@ -1117,12 +1122,15 @@ class wsAjax extends cubeAjax {
        protected static function cleanCachesCollection($id) {\r
                $os = array('ios', 'android');\r
                $files = array('json', 'update');\r
+               $resolutions = array(150, 300);\r
 \r
                foreach ($os as $_os) {\r
                        foreach ($files as $f) {\r
-                               $ff = WS_COLLECTIONS . '/ws/' . $id . '.' . $_os . '.' . $f;\r
-                               if (file_exists($ff)) {\r
-                                       unlink($ff);\r
+                               foreach ($resolutions as $r) {\r
+                                       $ff = WS_COLLECTIONS . '/ws/' . $id . '.' . $_os . '.' . $r . '.' . $f;\r
+                                       if (file_exists($ff)) {\r
+                                               unlink($ff);\r
+                                       }\r
                                }\r
                        }\r
                }\r
@@ -1143,4 +1151,5 @@ class wsAjax extends cubeAjax {
        }\r
 \r
 }\r
+\r
 ?>
\ No newline at end of file
index 7ed417d59d76046c4ab2b9da8827165f3159e7aa..171a5789818a9903be6420a9ebf2e3b325c0de8e 100644 (file)
@@ -554,13 +554,14 @@ class wsServices extends cubeFlashGateway {
                global $core;\r
                $id = $this->callArgs[0];\r
                $os = $this->callArgs[1];\r
-               $local = (isset($this->callArgs[2])) ? $this->callArgs[2] : null;\r
+               $resolution = $this->callArgs[2];\r
+               $local = (isset($this->callArgs[3])) ? $this->callArgs[3] : null;\r
 \r
                $this->outputXML = false;\r
                header('Content-type: application/json');\r
 \r
-               $cache = WS_COLLECTIONS . '/ws/' . $id . '.' . $os . '.json';\r
-               $update = WS_COLLECTIONS . '/ws/' . $id . '.' . $os . '.update';\r
+               $cache = WS_COLLECTIONS . '/ws/' . $id . '.' . $os . '.' . $resolution . '.json';\r
+               $update = WS_COLLECTIONS . '/ws/' . $id . '.' . $os . '.' . $resolution . '.update';\r
 \r
                if (file_exists($update) && filemtime(__FILE__) > filemtime($update)) {\r
                        unlink($update);\r
@@ -626,7 +627,7 @@ class wsServices extends cubeFlashGateway {
                        }\r
 \r
                        $d = array('id' => $id, 'langs' => $langs, 'langnames' => $langsnames, 'time' => $version, 'datas' => $composition, 'couvertures' => $couvertures, 'traductions' => $traductions, 'contents' => $collection->contents);\r
-                       $d = array_merge($d, $this->_getManifest($publications, '/fluidbook/collections/versions/' . $id . '/' . $version . '/' . $os, $books));\r
+                       $d = array_merge($d, $this->_getManifest($publications, '/fluidbook/collections/versions/' . $id . '/' . $version . '/' . $os, $books, $resolution));\r
 \r
                        $dao = new wsDAOCollection($core->con);\r
                        $col = $dao->selectById($id);\r
@@ -651,7 +652,7 @@ class wsServices extends cubeFlashGateway {
                exit;\r
        }\r
 \r
-       protected function _getManifest($publications, $dir, $books) {\r
+       protected function _getManifest($publications, $dir, $books, $resolution) {\r
                global $core;\r
                $res = array();\r
                $res['manifest'] = array('assetRoot' => 'http://workshop.fluidbook.com' . $dir . '/', 'autoDownload' => true);\r
@@ -671,7 +672,9 @@ class wsServices extends cubeFlashGateway {
                        $book = $books[$p];\r
                        $theme = $daoTheme->selectById($book->theme);\r
                        $orders = $this->_getBundles($book);\r
-                       $reg = $this->_getRegExpManifest($r, $book, $theme);\r
+                       $regexp = $this->_getRegExpManifest($r, $book, $theme, $resolution);\r
+                       $reg = $regexp['reg'];\r
+                       $exclude = $regexp['exclude'];\r
 \r
                        $b = array();\r
 \r
@@ -680,6 +683,13 @@ class wsServices extends cubeFlashGateway {
                                        continue;\r
                                }\r
                                $path = str_replace($removeFromRelative, '', $k);\r
+\r
+                               foreach ($exclude as $e) {\r
+                                       if (preg_match('|' . $e . '|', $path)) {\r
+                                               continue 2;\r
+                                       }\r
+                               }\r
+\r
                                $order = $this->_inFirstManifest($path, $orders, $reg);\r
 \r
                                if (!isset($b[$order])) {\r
@@ -707,30 +717,30 @@ class wsServices extends cubeFlashGateway {
                return $res;\r
        }\r
 \r
-       protected function _getRegExpManifest($r, $book, $theme) {\r
+       protected function _getRegExpManifest($r, $book, $theme, $resolution) {\r
                $reg = array();\r
                $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$');\r
                $reg['extras'] = array('^' . $r . 'data/links/(.*)$', '^' . $r . 'data/(.*).pdf$', '^' . $r . 'cover.jpg$');\r
                $reg['thumbnails'] = array('^' . $r . 'data/thumbnails/p(\d+).jpg$');\r
                for ($i = 1; $i <= $book->parametres->pages; $i++) {\r
                        $var = 'content_' . $i;\r
-                       $reg[$var] = array('^' . $r . 'data/background/150/t' . $i . '.jpg$', '^' . $r . 'data/contents/p' . $i . '.svg$');\r
+                       $reg[$var] = array('^' . $r . 'data/background/\d+/t' . $i . '.jpg$', '^' . $r . 'data/contents/p' . $i . '.svg$');\r
                }\r
                $reg['urgents'] = array('^' . $r . 'images/(.*)$', '^' . $r . 'data/images/(.*)$');\r
-               return $reg;\r
+               $exclude = array();\r
+               if ($resolution == 150) {\r
+                       $er = 300;\r
+               } else {\r
+                       $er = 150;\r
+               }\r
+               $exclude[] = '^' . $r . 'data/background/' . $er . '/t\d+.jpg$';\r
+               return array('reg' => $reg, 'exclude' => $exclude);\r
        }\r
 \r
        protected function _inFirstManifest($p, $orders, $reg) {\r
-\r
-\r
                foreach ($orders as $list) {\r
                        foreach ($reg[$list] as $v) {\r
                                if (preg_match('|' . $v . '|', $p)) {\r
-                                       fb($p);\r
-                                       if ($p == '11461/data/background/150/t25.jpg') {\r
-                                               fb($reg[$list]);\r
-                                               fb($v);\r
-                                       }\r
                                        return $list;\r
                                }\r
                        }\r
@@ -739,7 +749,7 @@ class wsServices extends cubeFlashGateway {
        }\r
 \r
        protected function _getBundles($book) {\r
-               $res = array(0 => 'loading', 200001 => 'extras', 20000 => 'thumbnails', 1 => 'urgents');\r
+               $res = array(0 => 'loading', 20001 => 'extras', 20000 => 'thumbnails', 1 => 'urgents');\r
                for ($i = 1; $i <= $book->parametres->pages; $i++) {\r
                        $k = 2 + $i;\r
                        $res[$k] = 'content_' . $i;\r
index d24dff580f8ee0af2a7b3fdd659b4943f29a05be..044e0cd805b9363c67ef0550fb761471be78b210 100644 (file)
@@ -457,6 +457,9 @@ class wsDocument extends cubeMetier {
                if (is_null($in)) {\r
                        $in = $this->cropped;\r
                }\r
+\r
+               $tmp = cubeFiles::tempnam();\r
+\r
                $antialiasing = $antialiasing ? 'yes' : 'no';\r
                $freetype = $texts ? 'yes' : 'no';\r
                $resolution = $resolution;\r
@@ -466,24 +469,30 @@ class wsDocument extends cubeMetier {
 \r
                $pdftoppm->setArg('f', $page);\r
                $pdftoppm->setArg('l', $page);\r
-\r
                $pdftoppm->setArg('-cropbox');\r
                $pdftoppm->setArg('-freetype ' . $freetype);\r
-               $pdftoppm->setArg('-jpeg');\r
+               $pdftoppm->setArg('-singlefile');\r
                $pdftoppm->setArg('-aa ' . $antialiasing);\r
                $pdftoppm->setArg('-aaVector ' . $antialiasing);\r
                $pdftoppm->setArg('r', $resolution);\r
                $pdftoppm->setArg(null, $in);\r
-               $pdftoppm->setArg(null, $this->out . 'ppm');\r
+               $pdftoppm->setArg(null, $tmp);\r
                $pdftoppm->execute();\r
                $this->addToLog($pdftoppm, true, $page);\r
 \r
+               $tmp.='.ppm';\r
+\r
                $jpegfile = $this->out . $prefix . $page . '.jpg';\r
 \r
-               $ppmjpgfile = $this->out . 'ppm-' . cubeMath::fill($page, strlen((string) $this->pages)) . '.jpg';\r
-               if (file_exists($ppmjpgfile)) {\r
-                       rename($ppmjpgfile, $jpegfile);\r
-                       $this->addToLog('Move ' . $ppmjpgfile . ' to ' . $jpegfile, true, $page);\r
+\r
+               if (file_exists($tmp)) {\r
+                       $pnmtojpeg = new cubeCommandLine('pnmtojpeg', $jpegfile, false);\r
+                       $pnmtojpeg->setArg('-quality ' . $quality);\r
+                       $pnmtojpeg->setArg(null, $tmp);\r
+                       $pnmtojpeg->execute();\r
+                       $this->addToLog($pnmtojpeg, false, $page);\r
+\r
+                       unlink($tmp);\r
                }\r
        }\r
 \r
@@ -563,19 +572,16 @@ class wsDocument extends cubeMetier {
 \r
        public function makeHTML5Files($page) {\r
                // Then make HD background shots\r
-               $resolutions = array(150 => 75, 36 => 80);\r
+               $resolutions = array(300 => 85, 150 => 85, 36 => 85);\r
                foreach ($resolutions as $r => $q) {\r
                        $this->makeShotPNM($page, 'html/h' . $r . '-', $r, $q, 4, null, false);\r
                        $this->makeShotPNM($page, 'html/t' . $r . '-', $r, $q, 4, null, true);\r
                }\r
-\r
                $this->makeSVGFile($page);\r
        }\r
 \r
        public function makeSVGFile($page) {\r
-               $testFile = $this->out . '/html/s' . $page . '.svg';\r
                $svgFile = $this->out . '/html/p' . $page . '.svg';\r
-               //$svgSimplified = $this->out . '/html/s' . $page . '.svg';\r
                $svgOpt = $this->out . '/html/o' . $page . '.svg';\r
 \r
                $pdftocairo = new cubeCommandLine('pdftocairo');\r
@@ -589,17 +595,7 @@ class wsDocument extends cubeMetier {
                $pdftocairo->execute();\r
                $this->addToLog($pdftocairo, true, $page);\r
 \r
-               /*$pdf2svg = new cubeCommandLine('pdf2svg');\r
-               $pdf2svg->setPath(CONVERTER_PATH);\r
-               $pdf2svg->setArg(null, $this->cropped);\r
-               $pdf2svg->setArg(null, $testFile);\r
-               $pdf2svg->setArg(null, $page);\r
-               $pdf2svg->execute();\r
-               $this->addToLog($pdf2svg, true, $page);\r
-               $this->_cleanSVG($testFile);*/\r
-\r
                $this->_cleanSVG($svgFile);\r
-               \r
        }\r
 \r
        protected function _cleanSVG($svgFile) {\r
index a48974ec3e599cf82c83f111de31112729e4c942..577b38486a09cbc8b23cee7f6d821220efbcb469 100644 (file)
@@ -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) {
index ec42321b36a46b7e39f0438e4e8d905cb436f57e..280048217afd2109efbe9a1e367a739f67e0eb9e 100644 (file)
@@ -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));
        }
 
index 83438b1d6dcbe7cb95362ec4c4d56add5e41e5c2..003f645b21e11d5443c03e911894a8d53341fd6c 100644 (file)
@@ -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) {
index 152bc0d6578ed98c9132a3c2ce78a61af2ea6054..290380ebb0ca37f15845fe87ff67fb70a780b310 100644 (file)
@@ -37,7 +37,9 @@ class wsPackagerHTML extends wsPackager {
 \r
                $this->copyOtherFiles($others);\r
 \r
-               mkdir($this->vdir . '/pages/', 0777, true);\r
+               if (!file_exists($this->vdir . '/pages')) {\r
+                       mkdir($this->vdir . '/pages/', 0777, true);\r
+               }\r
 \r
                $ga = '';\r
                if ($this->book->parametres->googleAnalyticsCustom) {\r
@@ -184,7 +186,9 @@ class wsPackagerHTML extends wsPackager {
                $this->daoBook->compile($this->book_id, 'html5');\r
 \r
                $dest = $this->vdir . 'm';\r
-               mkdir($dest, 0777, true);\r
+               if (!file_exists($dest)) {\r
+                       mkdir($dest, 0777, true);\r
+               }\r
 \r
                $cp = new cubeCommandLine('cp');\r
                $cp->setPath(CONVERTER_PATH);\r
@@ -194,6 +198,7 @@ class wsPackagerHTML extends wsPackager {
                $cp->setArg(null, $dest);\r
                $cp->execute();\r
 \r
+               $filesToAdd = array();\r
                if ($this->book->parametres->mobileServerConfig) {\r
                        $filesToAdd = array('.htaccess', 'web.config');\r
                }\r
index 398c5c3061a953526d71fe5d984fac0f21dc3081..f96592959f3cc53fea1809be2518294aeac43bbd 100644 (file)
@@ -185,7 +185,9 @@ class wsPackager {
                        $this->vdir = $this->dir . $this->version . '/';\r
                }\r
                $this->cleanVdir();\r
-               mkdir($this->vdir . '/data', 0777, true);\r
+               if (!file_exists($this->vdir . '/data')) {\r
+                       mkdir($this->vdir . '/data', 0777, true);\r
+               }\r
        }\r
 \r
        protected function cleanVdir() {\r