From fa5e39c945f2fbf6b3fc8e872ed6dbc0cd0befba Mon Sep 17 00:00:00 2001 From: "vincent@cubedesigners.com" Date: Mon, 12 Nov 2012 11:29:20 +0000 Subject: [PATCH] --- inc/ws/Controlleur/class.ws.url.php | 34 ++++++++++- inc/ws/DAO/class.ws.dao.book.php | 8 ++- inc/ws/Util/html5/class.ws.html5.compiler.php | 2 - .../packager/class.ws.packager.phonegap.php | 61 ++++++++++++++++--- inc/ws/prepend.php | 2 + 5 files changed, 95 insertions(+), 12 deletions(-) diff --git a/inc/ws/Controlleur/class.ws.url.php b/inc/ws/Controlleur/class.ws.url.php index 515cd1655..653257fd5 100644 --- a/inc/ws/Controlleur/class.ws.url.php +++ b/inc/ws/Controlleur/class.ws.url.php @@ -243,7 +243,7 @@ class wsUrl { array('version' => 'viewerh', 'title' => __('Version HTML5'), 'icon' => cubeMedia::image(IMG . '/html5.png')), array('version' => 'vieweru', 'title' => __('Version Flash') . ' (' . __('debuggage') . ')', 'icon' => cubeMedia::image(IMG . '/flashbug.png')), array('version' => 'viewerhu', 'title' => __('Version HTML5') . ' (' . __('debuggage') . ')', 'icon' => cubeMedia::image(IMG . '/html5bug.png')), - array('version' => 'viewerhu', 'title' => __('Widget HTML5'), 'icon' => cubeMedia::image(IMG . '/html5bug.png'), 'file' => 'widget.html', 'pattern' => '$1_$2_$3'), + //array('version' => 'viewerhu', 'title' => __('Widget HTML5'), 'icon' => cubeMedia::image(IMG . '/html5bug.png'), 'file' => 'widget.html', 'pattern' => '$1_$2_$3'), array('version' => 'viewer1', 'title' => __('Version 1'), 'icon' => cubeMedia::image(IMG . '/flash.png')) ); } @@ -713,6 +713,31 @@ html{height:100%}' . "\n"; self::commonHTML5Viewer($book_id, $hash, 'u'); } + public static function viewerha($args) { + global $core; + + commonDroits::min(5); + $args = cubePage::getArgs($args); + if (!isset($args[1])) { + $args[1] = ''; + } + + $dao = new wsDAOBook($core->con); + $e = explode('_', $args[0]); + $dao->compileTemp($e[0], 'ha', WS_BOOKS . '/html5a/' . $e[0]); + $time = time(); + + if (count($e) == 2 || $e[2] < $time - 20) { + $e[2] = $time; + http::redirect(SITE_PATH . 'viewerha/' . implode('_', $e) . '/' . $args[1]); + exit; + } + + $book_id = $e[0]; + $hash = $e[1]; + self::commonHTML5Viewer($book_id, $hash, 'a'); + } + public static function viewerht($args) { commonDroits::min(5); $args = cubePage::getArgs($args); @@ -738,12 +763,17 @@ html{height:100%}' . "\n"; $dao = new wsDAOBook($core->con); + if ($version == 'a') { + $version = ''; + $dir = 'a'; + } + $book = $dao->selectById($book_id); if ($hash != 'bcf26f9cf4a795ec00b9a44f42750d58' && $book->hash != $hash) { commonDroits::error(); } - echo file_get_contents(WS_BOOKS . '/html5/' . $book_id . '/index' . $version . '.html'); + echo file_get_contents(WS_BOOKS . '/html5' . $dir . '/' . $book_id . '/index' . $version . '.html'); exit; } diff --git a/inc/ws/DAO/class.ws.dao.book.php b/inc/ws/DAO/class.ws.dao.book.php index 117fd70c3..5558af0e3 100644 --- a/inc/ws/DAO/class.ws.dao.book.php +++ b/inc/ws/DAO/class.ws.dao.book.php @@ -792,6 +792,13 @@ class wsDAOBook extends commonDAO { $pages = $this->getPagesOfBook($book_id); } + public function compileTemp($book_id, $version, $dir) { + if ($version == 'ha') { + $packager = new wsPackagerPhonegap($book_id, $dir, true, false, 'android'); + $packager->makePackage(false); + } + } + public function compile($book_id, $version = 'all', $complete = false, $force = false) { if (is_null($book_id) || !$book_id) { return; @@ -809,7 +816,6 @@ class wsDAOBook extends commonDAO { $html5 = true; } - $book = $this->selectById($book_id); $pages = $this->getPagesOfBook($book_id); diff --git a/inc/ws/Util/html5/class.ws.html5.compiler.php b/inc/ws/Util/html5/class.ws.html5.compiler.php index 4953f50ec..dfff4ae2d 100644 --- a/inc/ws/Util/html5/class.ws.html5.compiler.php +++ b/inc/ws/Util/html5/class.ws.html5.compiler.php @@ -123,8 +123,6 @@ class wsHTML5Compiler { function __construct($book_id, $version = 'stable', $phonegap = false, $dir = null) { global $core; - $this->videoPath = $videoPath; - $this->makeResources = $resources; if ($version == 'stable') { $this->assets = WS_COMPILE_ASSETS . '/_html5prod'; wsMaintenance::updateHTML5Sources(array(), false); diff --git a/inc/ws/Util/packager/class.ws.packager.phonegap.php b/inc/ws/Util/packager/class.ws.packager.phonegap.php index 665688f3c..d6afc211f 100644 --- a/inc/ws/Util/packager/class.ws.packager.phonegap.php +++ b/inc/ws/Util/packager/class.ws.packager.phonegap.php @@ -26,12 +26,50 @@ class wsPackagerPhonegap extends wsPackager { if ($this->makeResources) { - $this->resources = $this->vdir . '/Resources'; - $this->makeResources(); + + if ($this->os == 'ios') { + $this->resources = $this->vdir . '/Resources'; + $this->makeIOSResources(); + } elseif ($this->os == 'android') { + $this->resources = $this->vdir . '/Resources'; + $this->makeAndroidResources(); + } + } + } + + protected function makeAndroidResources() { + $icons = array('drawable' => 96, + 'drawable-hdpi' => 72, + 'drawable-ldpi' => 36, + 'drawable-mdpi' => 48, + 'drawable-xhdpi' => 96 + ); + + $splashs = array('drawable' => 'x', + 'drawable-hdpi' => 'x', + 'drawable-ldpi' => 'x', + 'drawable-mdpi' => 'x', + 'drawable-xhdpi' => 'x'); + + foreach ($icons as $dir => $size) { + $d = $this->resources . '/' . $dir; + if (!file_exists($d)) { + mkdir($d, 0777, true); + } + $list($w, $h) = explode('x', $size); + $this->_makeIcon($w, $h, 'splash', $d); + } + + foreach ($splashs as $dir => $size) { + $d = $this->resources . '/' . $dir; + if (!file_exists($d)) { + mkdir($d, 0777, true); + } + $this->_makeSplash($size, 'splash', $d); } } - protected function makeResources() { + protected function makeIOSResources() { $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'); $icons = array(57 => 'icon', 72 => 'icon-72', 114 => 'icon@2x', 144 => 'icon-72@2x'); @@ -51,27 +89,36 @@ class wsPackagerPhonegap extends wsPackager { } } - protected function _makeSplash($width, $height, $name) { + protected function _makeSplash($width, $height, $name, $dir = null) { $im = imagecreatetruecolor($width, $height); // Draw Background $back = imagecolorhexallocate($im, $this->theme->parametres->backgroundColor); imagefill($im, 0, 0, $back); // Draw image + + if (is_null($dir)) { + $dir = $this->resources . '/splash'; + } + $this->_drawBackImage($im, $width, $height); - imagepng($im, $this->resources . '/splash/' . $name . '.png'); + imagepng($im, $dir . '/' . $name . '.png'); } - protected function _makeIcon($size, $name) { + protected function _makeIcon($size, $name, $dir = null) { if ($this->theme->parametres->favicon != '') { $base = $this->themeRoot . '/' . $this->theme->parametres->favicon; } else { $base = WS_COMPILE_ASSETS . '/_ico/phonegap.png'; } + if (is_null($dir)) { + $dir = $this->resources . '/icons'; + } + $it = new imageTools(); $it->loadImage($base); $it->resize($size, $size, 'ratio'); - $it->output('png', $this->resources . '/icons/' . $name . '.png'); + $it->output('png', $dir . '/' . $name . '.png'); } protected function _drawBackImage($im, $width, $height) { diff --git a/inc/ws/prepend.php b/inc/ws/prepend.php index 0e6ea5844..c34e389b4 100644 --- a/inc/ws/prepend.php +++ b/inc/ws/prepend.php @@ -12,6 +12,8 @@ $core->url->register('viewerp', 'viewerp', '^viewerp/(.*)$', array('wsUrl', 'vie $core->url->register('viewerh', 'viewerh', '^viewerh/(.*)$', array('wsUrl', 'viewerh')); $core->url->register('viewerhu', 'viewerhu', '^viewerhu/(.*)$', array('wsUrl', 'viewerhu')); $core->url->register('viewerht', 'viewerht', '^viewerht/(.*)$', array('wsUrl', 'viewerht')); +$core->url->register('viewerha', 'viewerha', '^viewerha/(.*)$', array('wsUrl', 'viewerha')); +$core->url->register('viewerhi', 'viewerhi', '^viewerhi/(.*)$', array('wsUrl', 'viewerhi')); if (DEV) { $tools = ROOT . '/../inc/tools/'; -- 2.39.5