$db->book_collection->nom('varchar', 64, false);\r
$db->book_collection->datas('text', 0, false);\r
$db->book_collection->theme('text', 0, false);\r
+ $db->book_collection->settings('text', 0, false);\r
$db->book_collection->proprietaire('integer', 0, false);\r
// Clés\r
$db->book_collection->primary('pk_book_collection', 'collection_id');\r
define('MXMLC_PATH_3', '/usr/local/flex_sdk_3.6/bin/mxmlc');\r
define('AS3_SOURCES', '/home/as/sources/as/as3');\r
define('AS3_FLUIDBOOK_SOURCES', '/home/as/sources/fluidbook');\r
-define('PHONEGAP_PLUGINS','/home/as/sources/phonegap-plugins');\r
+define('PHONEGAP_PLUGINS', '/home/as/sources/phonegap-plugins');\r
\r
define('MONITOR_PERFS', true);\r
\r
define('WS_STATS', 'http://stats.fluidbook.com/');\r
define('WS_FILES', ROOT . '/fluidbook');\r
define('WS_BOOKS', WS_FILES . '/books');\r
+define('WS_COLLECTIONS', WS_FILES . '/collections');\r
define('WS_DOCS', WS_FILES . '/docs');\r
define('WS_ICONS', WS_FILES . '/icones');\r
define('WS_THEMES', WS_FILES . '/themes');\r
\r
define('JS_PATH', WEBROOT . '/js');\r
define('JS', JS_PATH);\r
-define('MINIMIZE_JS',false);\r
+define('MINIMIZE_JS', false);\r
\r
define('JOURNEE', 8);\r
define('TAUX_JOURNALIER', 500);\r
return $res;\r
}\r
\r
+ public static function exportCollection($args, &$x) {\r
+ $id = $args[1];\r
+ $os = $args[2];\r
+\r
+ $exporter = new wsExporter();\r
+ $exporter->exportCollection($id, $os);\r
+ }\r
+\r
}\r
\r
?>
\ No newline at end of file
\r
$res.='<h3>' . __('Paramètres avancés') . '</h3>';\r
$res.='<table class="max">';\r
- $res.='<tr><td class="min nowrap">' . __('Version phonegap') . '</td><td>' . form::combo(array('settings[phonegap]','phonegap'), $phonegapVersions, $collection->settings['phonegap']) . '</td></tr>';\r
+ $res.='<tr><td class="min nowrap">' . __('Version phonegap') . '</td><td>' . form::combo(array('settings[phonegap]', 'phonegap'), $phonegapVersions, $collection->settings['phonegap']) . '</td></tr>';\r
+ $res.='<tr><td class="min nowrap">' . __('Identifiant de l\'application') . '</td><td>' . form::field(array('settings[namespace]', 'namespace'), 64, 64, $collection->settings['namespace']) . '</td></tr>';\r
$res.='</table>';\r
\r
\r
$res.='<h3>' . __('Versions') . '</h3>';\r
\r
\r
+ $res.='<h3>' . __('Export') . '</h3>';\r
+ $res.='<a href="#" class="right ajax" rel="exportCollection/' . $collection->collection_id . '/android">' . $core->typo->Ajouter(__('Exporter pour Android')) . '</a> <a href="#" class="right ajax" rel="exportCollection/' . $collection->collection_id . '/ios">' . $core->typo->Ajouter(__('Exporter pour iOS')) . '</a>';\r
+\r
return $res;\r
}\r
\r
$__autoload['wsSecureSWF'] = dirname(__FILE__) . '/class.ws.secure.swf.php';\r
$__autoload['wsTools'] = dirname(__FILE__) . '/class.ws.tools.php';\r
$__autoload['wsHTML5Compiler'] = dirname(__FILE__) . '/html5/class.ws.html5.compiler.php';\r
+$__autoload['wsHTML5AppCompiler'] = dirname(__FILE__) . '/html5/app/class.ws.html5.app.compiler.php';\r
$__autoload['wsHTML5CompilerDev'] = dirname(__FILE__) . '/html5/class.ws.html5.compiler.php';\r
$__autoload['wsHTML5Link'] = dirname(__FILE__) . '/html5/class.ws.html5.links.php';\r
$__autoload['wsPDFFontExtractor'] = dirname(__FILE__) . '/fontextractor/class.ws.pdf.fontextractor.php';\r
public $destinationFile;
public $x;
+ public function exportCollection($collectionId, $os) {
+ global $core;
+ $compiler = new wsHTML5AppCompiler($collectionId, $os, 'collection');
+ $dir = $compiler->compile();
+
+ $collection = $compiler->collection;
+ $d = str_replace('.', '/', $collection->settings['namespace']);
+ $dest = $d . '/www/';
+
+ $this->_createProject($os, $collection->nom, $collection->settings['namespace']);
+ $this->_transfertPhonegap($os, $dir, $dest);
+ }
+
+ protected function _createProject($os, $name, $ns) {
+ if ($os == 'ios') {
+
+ $dir = '/Phonegap/Projects/' . str_replace('.', '/', $ns);
+ $sdir = '/mnt/macbox' . $dir;
+ if (file_exists($sdir)) {
+ return;
+ }
+ `sudo /usr/local/bin/remountmac`;
+ mkdir($sdir, 0777, true);
+ $cl = new CubeIT_CommandLine('/Phonegap/Cordova/bin/create');
+ $cl->setArg('shared');
+ $cl->setArg(null, $dir);
+ $cl->setArg(null, $ns);
+ $cl->setArg(null, CubeIT_Text::str2URL($name));
+ $cl->setSSH('paris.cubedesigners.com', 'vincent', 'iquique', 22022);
+ $cl->execute();
+ } elseif ($os == 'android') {
+
+ }
+ }
+
public function export($book_id, &$x, $action = 'download', $version = 'online', $destinationDir = null, $destinationFile = null) {
global $core;
$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) {
$cp->setArg(null, rtrim($dest, '/') . '/');
$cp->execute();
- fb($cp->commande);
- fb($cp->output);
-
if (!is_null($chown)) {
`chown -R $chown $dest`;
}
--- /dev/null
+<?php
+
+class wsHTML5AppCompiler {
+
+ public $collectionId, $collection;
+ public $assets;
+ public $dir, $vdir, $wdir, $sdir;
+ public $os;
+ public $phonegapVersion;
+
+ public function __construct($collectionId, $os, $phonegapVersion = 'latest') {
+
+ global $core;
+
+ $this->collectionId = $collectionId;
+ $dao = new wsDAOCollection($core->con);
+ $this->collection = $dao->selectById($this->collectionId);
+
+ if ($phonegapVersion == 'collection') {
+ $phonegapVersion = $this->collection->settings['phonegap'];
+ }
+
+ $this->phonegapVersion = wsHTML5Compiler::getPhonegapVersion($phonegapVersion);
+ $this->os = $os;
+
+ $this->vdir = $this->dir = WS_COLLECTIONS . '/app/' . $this->collectionId . '/';
+ $this->wdir = WS_COLLECTIONS . '/working/' . $this->collectionId;
+ $this->sdir = WS_COMPILE_ASSETS . '/_html5app/';
+ }
+
+ protected function copy($s, $t) {
+ if (!file_exists($s)) {
+ return;
+ }
+ if (file_exists($t) && filemtime($t) >= filemtime($s) && filesize($s) == filesize($t)) {
+ return;
+ }
+ if (!file_exists(dirname($t))) {
+ mkdir(dirname($t), 0777, true);
+ }
+
+ copy($s, $t);
+ touch($t, filemtime($s));
+ }
+
+ protected function copyRecursive($source, $dest) {
+ if (is_dir($source)) {
+ $iterator = new RecursiveIteratorIterator(
+ new RecursiveDirectoryIterator($source, RecursiveDirectoryIterator::SKIP_DOTS), RecursiveIteratorIterator::SELF_FIRST
+ );
+
+ foreach ($iterator as $file) {
+ if ($file->isDir()) {
+ $dirtocreate = $dest . DIRECTORY_SEPARATOR . $iterator->getSubPathName();
+ if (!file_exists($dirtocreate)) {
+ mkdir($dirtocreate, 0777, true);
+ }
+ } else {
+ $this->copy($file, $dest . DIRECTORY_SEPARATOR . $iterator->getSubPathName());
+ }
+ }
+ } else {
+ $this->copy($source, $dest);
+ }
+ }
+
+ function compile() {
+ $this->copyRecursive($this->sdir, $this->vdir);
+
+ $this->writeStyle();
+ $this->writeScript();
+ $this->writeIndex();
+
+ return $this->vdir;
+ }
+
+ function writeScript() {
+ $config = array();
+ $config['id'] = $this->collectionId;
+
+ $this->copy(WS_COMPILE_ASSETS . '/_html5/js/libs/phonegap/' . $this->phonegapVersion . '/cordova-' . $this->os . '.js', $this->vdir . '/js/cordova.js');
+ file_put_contents($this->vdir . '/js/app.js', 'DATAS = ' . CubeIT_Util_Json::encode($config) . ';');
+ }
+
+ function writeIndex() {
+
+ }
+
+ function writeStyle() {
+ $c = array();
+ $c[] = 'body{background-image:url("data/images/' . $this->collection->theme['back'] . '");}';
+ file_put_contents($this->vdir . '/data/app.css', implode("\n", $c));
+ }
+
+}
+
+?>
function __construct($book_id, $version = 'stable', $phonegap = false, $phonegapVersion = 'latest', $dir = null, $standalone = false) {
global $core;
- $this->phonegapVersion = $this->getPhonegapVersion($phonegapVersion);
+ $this->phonegapVersion = self::getPhonegapVersion($phonegapVersion);
if ($version == 'stable') {
$this->assets = WS_COMPILE_ASSETS . '/_html5prod';
$this->config = cubeObject::merge($this->book->parametres->toStandardObject(), $this->theme->parametres->toStandardObject());
}
- public function getPhonegapVersion($v) {
+ public static function getPhonegapVersion($v) {
if ($v != 'latest') {
return $v;
}