array('version' => 'viewerh', 'title' => __('Version HTML5'), 'icon' => cubeMedia::image(IMG . '/html5.png')),\r
array('version' => 'vieweru', 'title' => __('Version Flash') . ' (' . __('debuggage') . ')', 'icon' => cubeMedia::image(IMG . '/flashbug.png')),\r
array('version' => 'viewerhu', 'title' => __('Version HTML5') . ' (' . __('debuggage') . ')', 'icon' => cubeMedia::image(IMG . '/html5bug.png')),\r
- array('version' => 'viewerhu', 'title' => __('Widget HTML5'), 'icon' => cubeMedia::image(IMG . '/html5bug.png'), 'file' => 'widget.html', 'pattern' => '$1_$2_$3'),\r
+ //array('version' => 'viewerhu', 'title' => __('Widget HTML5'), 'icon' => cubeMedia::image(IMG . '/html5bug.png'), 'file' => 'widget.html', 'pattern' => '$1_$2_$3'),\r
array('version' => 'viewer1', 'title' => __('Version 1'), 'icon' => cubeMedia::image(IMG . '/flash.png'))\r
);\r
}\r
self::commonHTML5Viewer($book_id, $hash, 'u');\r
}\r
\r
+ public static function viewerha($args) {\r
+ global $core;\r
+\r
+ commonDroits::min(5);\r
+ $args = cubePage::getArgs($args);\r
+ if (!isset($args[1])) {\r
+ $args[1] = '';\r
+ }\r
+\r
+ $dao = new wsDAOBook($core->con);\r
+ $e = explode('_', $args[0]);\r
+ $dao->compileTemp($e[0], 'ha', WS_BOOKS . '/html5a/' . $e[0]);\r
+ $time = time();\r
+\r
+ if (count($e) == 2 || $e[2] < $time - 20) {\r
+ $e[2] = $time;\r
+ http::redirect(SITE_PATH . 'viewerha/' . implode('_', $e) . '/' . $args[1]);\r
+ exit;\r
+ }\r
+\r
+ $book_id = $e[0];\r
+ $hash = $e[1];\r
+ self::commonHTML5Viewer($book_id, $hash, 'a');\r
+ }\r
+\r
public static function viewerht($args) {\r
commonDroits::min(5);\r
$args = cubePage::getArgs($args);\r
\r
$dao = new wsDAOBook($core->con);\r
\r
+ if ($version == 'a') {\r
+ $version = '';\r
+ $dir = 'a';\r
+ }\r
+\r
$book = $dao->selectById($book_id);\r
if ($hash != 'bcf26f9cf4a795ec00b9a44f42750d58' && $book->hash != $hash) {\r
commonDroits::error();\r
}\r
\r
- echo file_get_contents(WS_BOOKS . '/html5/' . $book_id . '/index' . $version . '.html');\r
+ echo file_get_contents(WS_BOOKS . '/html5' . $dir . '/' . $book_id . '/index' . $version . '.html');\r
exit;\r
}\r
\r
$pages = $this->getPagesOfBook($book_id);\r
}\r
\r
+ public function compileTemp($book_id, $version, $dir) {\r
+ if ($version == 'ha') {\r
+ $packager = new wsPackagerPhonegap($book_id, $dir, true, false, 'android');\r
+ $packager->makePackage(false);\r
+ }\r
+ }\r
+\r
public function compile($book_id, $version = 'all', $complete = false, $force = false) {\r
if (is_null($book_id) || !$book_id) {\r
return;\r
$html5 = true;\r
}\r
\r
-\r
$book = $this->selectById($book_id);\r
$pages = $this->getPagesOfBook($book_id);\r
\r
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);
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');
}
}
- 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) {
$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/';