From: vincent@cubedesigners.com Date: Wed, 2 Sep 2020 14:38:12 +0000 (+0000) Subject: wip #3828 @1 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=58660eeeb7f44d84e9c55a21af364cc7a1a10435;p=cubeextranet.git wip #3828 @1 --- diff --git a/inc/ws/Metier/class.ws.book.parametres.php b/inc/ws/Metier/class.ws.book.parametres.php index d146ad8c2..eee54246b 100644 --- a/inc/ws/Metier/class.ws.book.parametres.php +++ b/inc/ws/Metier/class.ws.book.parametres.php @@ -451,8 +451,8 @@ class wsBookParametres extends wsParametres $this->fields['product_zoom_references'] = array('type' => 'freefile', 'default' => '', 'editable' => true, 'label' => __('Références produits'), 'grade' => 3, 'fileFilter' => $basketFilter, 'hint' => __('Fichier contenant les références produits'), 'dir' => 'commerce'); $this->fields['product_zoom_buttons_order'] = ['type' => 'combo', 'datas' => [__('De la droite vers la gauche') => 'right', __('De la gauche vers la droite') => 'left'], 'editable' => true, 'grade' => 3, 'default' => 'right', 'label' => __('Order des boutons')]; - $icons = [__('Aucune') => 'none', __('Partage') => 'nav-share', __('Ecran') => 'icon-site', __('Télécharger') => 'nav-download', 'PDF' => 'icon-pdf', 'Video' => 'icon-video', __('Lien') => 'icon-link', __('Code') => 'icon-code', __('QR code') => 'icon-qr', __('Article') => 'icon-article']; - $actions = [__('Ouvrir un lien') => 'link', __('Copier un contenu') => 'copy', __('Vidéo') => 'video']; + $icons = [__('Aucune') => 'none', __('Partage') => 'nav-share', __('Ecran') => 'icon-site', __('Télécharger') => 'nav-download', 'PDF' => 'icon-pdf', 'Video' => 'icon-video', __('Lien') => 'icon-link', __('Code') => 'icon-code', __('QR code') => 'icon-qr', __('Article') => 'icon-article', __('Panier') => 'nav-basket', __('Panier 2') => 'nav-basket-1']; + $actions = [__('Ouvrir un lien') => 'link', __('Copier un contenu') => 'copy', __('Vidéo') => 'video', __('Ajouter au panier') => 'addtocart']; $f = []; for ($i = 1; $i <= 3; $i++) { $this->fields['product_zoom_label_' . $i] = ['type' => 'text', 'label' => __('Label du bouton') . ' ' . $i, 'default' => '', 'editable' => true, 'grade' => 3]; @@ -495,7 +495,7 @@ class wsBookParametres extends wsParametres $this->fields['articlesShare'] = ['type' => 'boolean', 'default' => true, 'editable' => true, 'label' => __('Activer le partage'), 'grade' => 3]; $this->fields['articlesStyle'] = ['type' => 'combo', 'default' => true, 'editable' => true, 'label' => __('Style'), 'grade' => 3, 'datas' => ['Défaut' => 'default', 'Atlantic' => 'atlantic', 'Harmonie Mutuelle' => 'harmonie-mutuelle', 'Business Immo' => 'business-immo']]; - $this->forms['articles'] = ['label' => __('Articles'), 'fieldsnames' => ['articlesFile', 'articlesImages', '|', 'articlesShare', '|', 'articlesStyle', 'articlesFont']]; + $this->forms['articles'] = ['label' => __('Articles'), 'fieldsnames' => ['articlesFile', 'articlesImages', '|', 'articlesShare', '|', 'articlesStyle', 'articlesFont']]; //. $this->fields['externalArchives'] = array('type' => 'freefile', 'default' => '', 'editable' => true, @@ -536,6 +536,7 @@ class wsBookParametres extends wsParametres 'Wesco Ventes' => 'com.fluidbook.player.basket.custom.wesco.WescoBasketManager', 'Atlantic Download' => 'com.fluidbook.player.basket.custom.atlantic.AtlanticDownloadBasketManager', 'Remarkable' => 'Remarkable', + 'Mopec' => 'Mopec', 'Zoom + lien produit (déprécié, utiliser la fonctionnalité "Zoom produits")' => 'ZoomProductLink', ), 'grade' => 5); diff --git a/inc/ws/Util/class.ws.exporter.php b/inc/ws/Util/class.ws.exporter.php index be29a55c2..a6431e53d 100644 --- a/inc/ws/Util/class.ws.exporter.php +++ b/inc/ws/Util/class.ws.exporter.php @@ -3,548 +3,551 @@ class wsExporter { - public $book_id; - public $dao; - public $book; - public $action; - public $metaAction; - public $origVersion; - public $origAction; - public $version; - public $destinationDir; - public $destinationFile; - public $x; - public $ftpPassiveMode = false; - - const VINCENT = "paris.cubedesigners.com"; - - public function exportCollection($collectionId, $os) - { - global $core; - - - $ctrl = isset($_GET['ctrl']) && $_GET['ctrl'] == 'true'; - $alt = isset($_GET['alt']) && $_GET['alt'] == 'true'; - - $run = CubeIT_Mobile_Phonegap::RUN_SYNC; - $resetApp = false; - if ($ctrl) { - $resetApp = true; - $run = CubeIT_Mobile_Phonegap::RUN_RUN; - if ($alt) { - $run = CubeIT_Mobile_Phonegap::RUN_CREATE; - } - } - - $compiler = new wsHTML5AppCompiler($collectionId); - $dir = $compiler->compile($os, 'collection', $resetApp); - - $collection = $compiler->collection; - $d = str_replace('.', '/', $collection->settings['namespace']); - $dest = $d . '/www/'; - - $phonegap = CubeIT_Mobile_Phonegap::create($os); - $phonegap->setName($collection->nom); - $phonegap->setId($collection->settings['namespace']); - $phonegap->setAuthor('Fluidbook', 'contact@fluidbook.com', 'https://www.fluidbook.com'); - $phonegap->setVersion($collection->settings['version']); - $phonegap->setBuild($collection->settings['build']); - if ($os == 'android') { - $phonegap->setLicenseKey($collection->settings['license_key']); - $phonegap->setExpansion($collection->settings['android_storage'] !== 'apk'); - } - $phonegap->setNamespace($collection->settings['namespace']); - $phonegap->setActivity($collection->settings['activity']); - - $appNames = array(); - - foreach ($compiler->langs as $l) { - $src = $compiler->wdir . '/' . $collection->theme['splash_' . $l]; - $phonegap->setSplash($src, $l); - $phonegap->setIcon($compiler->wdir . '/' . $collection->theme['icon'], $l); - $appNames[$l] = $collection->contents[$l]['titrehome']; - } - $phonegap->setAppName($appNames); - $phonegap->setWWWDirectory($dir); - if ($os == 'ios') { - $phonegap->setDistantCompiler(self::VINCENT, 'vincent', 'atacama', '/Users/vincent/Phonegap/Projects/' . $d, '/mnt/macbox/Phonegap/Projects/' . $d, 22022, SSH_KEY); - } else if ($os == 'android') { - $manifestType = isset($collection->settings['offline']) ? 'Offline' : 'Online'; - if (!$phonegap->getExpansion()) { - $manifestType .= 'Standalone'; - } - $phonegap->setManifest(WS_COMPILE_ASSETS . '/_html5app/_android/AndroidManifest' . $manifestType . '.xml'); - $phonegap->setMain(WS_COMPILE_ASSETS . '/_html5app/_android/Main' . $manifestType . '.java'); - $phonegap->setMainDir(WS_COMPILE_ASSETS . '/_html5app/_android/'); - - if ($phonegap->getExpansion()) { - $phonegap->addLibrary(array('from' => WS_COMPILE_ASSETS . '/_html5app/_android/lib', 'to' => '/app/src/main/java')); - } else { - $phonegap->addLibrary(array('from' => WS_COMPILE_ASSETS . '/_html5app/_android/lib/com/fluidbook', 'to' => '/app/src/main/java/com/fluidbook')); - } - $phonegap->addLibrary(array('from' => WS_COMPILE_ASSETS . '/_html5app/_android/fluidbook-dependencies', 'to' => '/fluidbook-dependencies')); - $phonegap->addLibrary(array('from' => WS_COMPILE_ASSETS . '/_html5app/_android/res', 'to' => '/app/src/main/res')); - - $phonegap->setDistantCompiler(self::VINCENT, 'Vincent', 's77vpo*wu5', 'h:/Phonegap/Projects/' . $d, '/mnt/vincent/cygdrive/h/Phonegap/Projects/' . $d, 22322, SSH_KEY); - $phonegap->setSourceVariables(array('background' => '0xff' . $collection->settings['couleurD'], - 'orientation' => $collection->settings['orientation']) - ); - $phonegap->fileDistantReplaceContents('// PLUGIN GRADLE EXTENSIONS START' . "\r\n" . '// PLUGIN GRADLE EXTENSIONS END', - '// PLUGIN GRADLE EXTENSIONS START' . "\r\n" . 'apply from: "fluidbook-dependencies/catalogues-fluidbook.gradle"' . "\r\n" . '// PLUGIN GRADLE EXTENSIONS END', - 'platforms/android/build.gradle'); - $phonegap->fileDistantReplaceContents('// PLUGIN GRADLE EXTENSIONS START' . "\n" . '// PLUGIN GRADLE EXTENSIONS END', - '// PLUGIN GRADLE EXTENSIONS START' . "\n" . 'apply from: "fluidbook-dependencies/catalogues-fluidbook.gradle"' . "\n" . '// PLUGIN GRADLE EXTENSIONS END', - 'platforms/android/build.gradle'); - } - - $phonegap->setPreference('show-splash-screen-spinner', false); - $phonegap->setPreference('auto-hide-splash-screen', false); - $phonegap->setPreference('ios-statusbarstyle', CubeIT_Mobile_Phonegap::BARSTYLE_TRANSLUCENT); - $phonegap->setPreference('iosPersistentFileLocation', 'Library'); - $phonegap->setPreference('EnableViewportScale', true); - $phonegap->addFeatures(array( - CubeIT_Mobile_Phonegap::FEATURE_CONNECTION, - CubeIT_Mobile_Phonegap::FEATURE_DEVICE, - CubeIT_Mobile_Phonegap::FEATURE_FILE, - CubeIT_Mobile_Phonegap::FEATURE_FILETRANSFER, - CubeIT_Mobile_Phonegap::FEATURE_STORAGE, - CubeIT_Mobile_Phonegap::FEATURE_NOTIFICATION_DIALOG, - CubeIT_Mobile_Phonegap::FEATURE_INAPPBROWSER, - CubeIT_Mobile_Phonegap::FEATURE_SPLASHSCREEN, - CubeIT_Mobile_Phonegap::FEATURE_GLOBALIZATION, - //CubeIT_Mobile_Phonegap::FEATURE_PUSHNOTIFICATION, - CubeIT_Mobile_Phonegap::FEATURE_DEBUG - ) - ); - if ($os == 'ios') { - $phonegap->addFeature(CubeIT_Mobile_Phonegap::FEATURE_EXTERNALFILEUTIL); - $phonegap->addFeature(CubeIT_Mobile_Phonegap::FEATURE_STATUSBAR); - //$phonegap->addFeature(CubeIT_Mobile_Phonegap_IOS::FEATURE_WKWEBVIEW); - } else if ($os == 'android') { - $phonegap->addFeature(CubeIT_Mobile_Phonegap::FEATURE_WEBINTENT); - } - - - $allpub = $compiler->books; - - if (isset($collection->settings['offline']) && $collection->settings['offline']) { - $p = $compiler->getPublishedVersionPath($os, $collection->settings['version']); - if ($p) { - $phonegap->addAdditionalSource('publications', $p); - - $exs = explode("\n", $collection->settings['offline_exclude']); - foreach ($exs as $e) { - $e = trim($e); - if ($e == '') { - continue; - } - - if (stristr($e, '$id$')) { - foreach ($allpub as $i) { - $phonegap->addExclude('"' . str_replace('$id$', $i, $e) . '"'); - } - } else { - $phonegap->addExclude('"' . $e . '"'); - } - } - - $add = explode("\n", $collection->settings['offline_syncs']); - foreach ($add as $a) { - $a = trim($a); - if ($a == '' || substr($a, 0, 1) == '#' || substr($a, 0, 1) == ';') { - continue; - } - list($to, $source) = explode(':', $a); - $phonegap->addAdditionalSource('publications' . '/' . $to, $p . $source); - } - } - } - - $phonegap->run($run); - } - - /** - * - * @param string $os - * @param wsHTML5AppCompiler $compiler - */ - protected function _collectionAssets($os, $compiler) - { - if ($os == 'ios') { - $this->_collectionAssetsIOS($os, $compiler); - } else if ($os == 'android') { - $this->_collectionAssetsAndroid($os, $compiler); - } - } - - protected function _collectionAssetsAndroid($os, $compiler) - { - $collection = $compiler->collection; - $src = $compiler->wdir . '/' . $collection->theme['icon']; - } - - protected function _collectionAssetsIOS($os, $compiler) - { - $collection = $compiler->collection; - $src = $compiler->wdir . '/' . $collection->theme['icon']; - // icones - $icons = array(57 => 'icon', 72 => 'icon-72', 114 => 'icon@2x', 144 => 'icon-72@2x'); - $d = WS_COLLECTIONS . '/resources/' . $collection->collection_id . '/' . $os . '/icons/'; - if (!file_exists($d)) { - mkdir($d, 0777, true); - } - foreach ($icons as $s => $n) { - - $dest = $d . $n . '.png'; - if (!$this->_testFile($src, $dest)) { - wsPackagerPhonegap::__makeIcon($src, $dest, $s); - } - } - - // 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'); - - $langs = $compiler->langs; - - foreach ($langs as $l) { - $src = $compiler->wdir . '/' . $collection->theme['splash_' . $l]; - if (!file_exists($src)) { - continue; - } - - $d = WS_COLLECTIONS . '/resources/' . $collection->collection_id . '/' . $os . '/splash/' . $l . '.lproj/'; - if (!file_exists($d)) { - mkdir($d, 0777, true); - } - - - 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); - } - } - } - - - // Transfert - $this->_rsync(WS_COLLECTIONS . '/resources/' . $collection->collection_id . '/' . $os, "/mnt/macbox" . $this->_iosProjectDir($collection->settings['namespace']) . '/' . CubeIT_Text::str2URL($collection->nom) . '/Resources', false); - } - - protected function _testFile($ref, $dest) - { - if (!file_exists($dest)) { - return false; - } - if (filemtime($ref) > filemtime($dest)) { - return false; - } - return true; - } - - protected function _createProject($os, $name, $ns) - { - if ($os == 'ios') { - $dir = $this->_iosProjectDir($ns); - $sdir = '/mnt/macbox' . $dir; - if (!file_exists($sdir)) { - `sudo /usr/local/bin/remountmac`; - mkdir($sdir, 0777, true); - $cl = new CubeIT_CommandLine('/Phonegap/Cordova/bin/create'); - $cl->setArg(null, $dir); - $cl->setArg(null, $ns); - $cl->setArg(null, CubeIT_Text::str2URL($name)); - $cl->setSSH(self::VINCENT, 'vincent', '', 22022); - $cl->execute(); - // Install plugins - $this->_iosPlugin($dir, 'PushPlugin'); - $this->_iosPlugin($dir, 'ExternalFileUtil'); - } - } elseif ($os == 'android') { - - } - } - - protected function _iosProjectDir($ns) - { - return '/Phonegap/Projects/' . str_replace('.', '/', $ns); - } - - protected function _iosPlugin($dir, $plugin) - { - // git@github.com:phonegap-build/PushPlugin.git - $cl = new CubeIT_CommandLine('/usr/local/bin/plugman'); - $cl->setManualArg(' --platform ios'); - $cl->setManualArg(' --project ' . $dir); - $cl->setManualArg(' --plugin /Phonegap/Plugins/' . $plugin); - $cl->setSSH(self::VINCENT, 'vincent', '', 22022); - $cl->execute(); - } - - public function export($book_id, &$x, $action = 'download', $version = 'online', $destinationDir = null, $destinationFile = null) - { - global $core; - set_time_limit(0); - - if (is_null($destinationDir)) { - $destinationDir = ''; - } - if (is_null($destinationFile)) { - $destinationFile = ''; - } - - $this->origVersion = $version; - $this->origAction = $action; - - $this->book_id = $book_id; - $this->x = $x; - - $this->dao = new wsDAOBook($core->con); - $this->book = $this->dao->selectById($this->book_id); - - $this->action = $action; - $e = explode('_', $this->action, 2); - $this->metaAction = $e[0]; - if (count($e) > 1) { - $this->action = $e[1]; - } - - $this->version = $this->_getVersion($version); - $this->destinationDir = ltrim(trim($destinationDir), '/'); - $this->destinationFile = str_replace('/', '-', trim($destinationFile)); - - $this->_saveDestination(); - - if ($this->metaAction == 'download') { - $this->_download(); - } else if ($this->metaAction == 'phonegap') { - $this->_phonegap(); - } else if ($this->metaAction == 'install') { - $this->_install(); - } else if ($this->metaAction == 'phonegapcollection') { - $this->_phonegapcollection(); - } - } - - protected function _haveToZip() - { - $yes = array('win-exe', 'mac-exe', 'win-cd'); - return in_array($this->version, $yes); - } - - protected function _phonegapcollection() - { - $d = '/' . $this->destinationDir; - - $packager = new wsPackagerPhonegap($this->book_id, $d, true, false, $this->version); - $packager->home = true; - $packager->book->parametres->mobileVideosPath = ''; - - return $packager->makePackage(false); - } - - protected function _killFtp($book_id) - { - $kill = 'pkill -f "^lftp(.*)' . $book_id . '"'; - `$kill`; - } - - protected function _install() - { - $this->_killFtp($this->book_id); - - $p = wsPackager::package($this->book_id, $this->version, $this->_haveToZip(), false); - - if (strpos($p, '/fluidbook') == 0) { - $p = ROOT . $p; - } - - - if ($this->action == 'references') { - //$root = 'fluidbook@www.fluidbook.com:/home/fluidbook/www/references/'; - $root = '/mnt/sshfs/fluidbook/home/fluidbook/www/references/'; - $rootURL = 'https://www.fluidbook.com/references/'; - } else if ($this->action == 'hosting') { - $root = '/mnt/sshfs/fluidbook/data/fluidbook/hosting/'; - $rootURL = 'https://hosting.fluidbook.com/'; - } else if ($this->action == 'ftp') { - $root = 'ftp://'; - $rootURL = null; - } - - if ($this->destinationFile) { - $pathd = $root . $this->destinationDir; - $path = $pathd . '/' . $this->destinationFile; - } else { - $path = $root . $this->destinationDir; - } - - if (stristr($path, 'ftp://')) { - $this->_killFtp($this->book_id); - $this->_lftp($p, $path, $this->ftpPassiveMode); - } else { - $this->_rsync($p, $path); - } - - if (!is_null($rootURL)) { - $url = $rootURL . $this->destinationDir; - if($this->x) { + public $book_id; + public $dao; + public $book; + public $action; + public $metaAction; + public $origVersion; + public $origAction; + public $version; + public $destinationDir; + public $destinationFile; + public $x; + public $ftpPassiveMode = false; + + const VINCENT = "paris.cubedesigners.com"; + + public function exportCollection($collectionId, $os) + { + global $core; + + + $ctrl = isset($_GET['ctrl']) && $_GET['ctrl'] == 'true'; + $alt = isset($_GET['alt']) && $_GET['alt'] == 'true'; + + $run = CubeIT_Mobile_Phonegap::RUN_SYNC; + $resetApp = false; + if ($ctrl) { + $resetApp = true; + $run = CubeIT_Mobile_Phonegap::RUN_RUN; + if ($alt) { + $run = CubeIT_Mobile_Phonegap::RUN_CREATE; + } + } + + $compiler = new wsHTML5AppCompiler($collectionId); + $dir = $compiler->compile($os, 'collection', $resetApp); + + $collection = $compiler->collection; + $d = str_replace('.', '/', $collection->settings['namespace']); + $dest = $d . '/www/'; + + $phonegap = CubeIT_Mobile_Phonegap::create($os); + $phonegap->setName($collection->nom); + $phonegap->setId($collection->settings['namespace']); + $phonegap->setAuthor('Fluidbook', 'contact@fluidbook.com', 'https://www.fluidbook.com'); + $phonegap->setVersion($collection->settings['version']); + $phonegap->setBuild($collection->settings['build']); + if ($os == 'android') { + $phonegap->setLicenseKey($collection->settings['license_key']); + $phonegap->setExpansion($collection->settings['android_storage'] !== 'apk'); + } + $phonegap->setNamespace($collection->settings['namespace']); + $phonegap->setActivity($collection->settings['activity']); + + $appNames = array(); + + foreach ($compiler->langs as $l) { + $src = $compiler->wdir . '/' . $collection->theme['splash_' . $l]; + $phonegap->setSplash($src, $l); + $phonegap->setIcon($compiler->wdir . '/' . $collection->theme['icon'], $l); + $appNames[$l] = $collection->contents[$l]['titrehome']; + } + $phonegap->setAppName($appNames); + $phonegap->setWWWDirectory($dir); + if ($os == 'ios') { + $phonegap->setDistantCompiler(self::VINCENT, 'vincent', 'atacama', '/Users/vincent/Phonegap/Projects/' . $d, '/mnt/macbox/Phonegap/Projects/' . $d, 22022, SSH_KEY); + } else if ($os == 'android') { + $manifestType = isset($collection->settings['offline']) ? 'Offline' : 'Online'; + if (!$phonegap->getExpansion()) { + $manifestType .= 'Standalone'; + } + $phonegap->setManifest(WS_COMPILE_ASSETS . '/_html5app/_android/AndroidManifest' . $manifestType . '.xml'); + $phonegap->setMain(WS_COMPILE_ASSETS . '/_html5app/_android/Main' . $manifestType . '.java'); + $phonegap->setMainDir(WS_COMPILE_ASSETS . '/_html5app/_android/'); + + if ($phonegap->getExpansion()) { + $phonegap->addLibrary(array('from' => WS_COMPILE_ASSETS . '/_html5app/_android/lib', 'to' => '/app/src/main/java')); + } else { + $phonegap->addLibrary(array('from' => WS_COMPILE_ASSETS . '/_html5app/_android/lib/com/fluidbook', 'to' => '/app/src/main/java/com/fluidbook')); + } + $phonegap->addLibrary(array('from' => WS_COMPILE_ASSETS . '/_html5app/_android/fluidbook-dependencies', 'to' => '/fluidbook-dependencies')); + $phonegap->addLibrary(array('from' => WS_COMPILE_ASSETS . '/_html5app/_android/res', 'to' => '/app/src/main/res')); + + $phonegap->setDistantCompiler(self::VINCENT, 'Vincent', 's77vpo*wu5', 'h:/Phonegap/Projects/' . $d, '/mnt/vincent/cygdrive/h/Phonegap/Projects/' . $d, 22322, SSH_KEY); + $phonegap->setSourceVariables(array('background' => '0xff' . $collection->settings['couleurD'], + 'orientation' => $collection->settings['orientation']) + ); + $phonegap->fileDistantReplaceContents('// PLUGIN GRADLE EXTENSIONS START' . "\r\n" . '// PLUGIN GRADLE EXTENSIONS END', + '// PLUGIN GRADLE EXTENSIONS START' . "\r\n" . 'apply from: "fluidbook-dependencies/catalogues-fluidbook.gradle"' . "\r\n" . '// PLUGIN GRADLE EXTENSIONS END', + 'platforms/android/build.gradle'); + $phonegap->fileDistantReplaceContents('// PLUGIN GRADLE EXTENSIONS START' . "\n" . '// PLUGIN GRADLE EXTENSIONS END', + '// PLUGIN GRADLE EXTENSIONS START' . "\n" . 'apply from: "fluidbook-dependencies/catalogues-fluidbook.gradle"' . "\n" . '// PLUGIN GRADLE EXTENSIONS END', + 'platforms/android/build.gradle'); + } + + $phonegap->setPreference('show-splash-screen-spinner', false); + $phonegap->setPreference('auto-hide-splash-screen', false); + $phonegap->setPreference('ios-statusbarstyle', CubeIT_Mobile_Phonegap::BARSTYLE_TRANSLUCENT); + $phonegap->setPreference('iosPersistentFileLocation', 'Library'); + $phonegap->setPreference('EnableViewportScale', true); + $phonegap->addFeatures(array( + CubeIT_Mobile_Phonegap::FEATURE_CONNECTION, + CubeIT_Mobile_Phonegap::FEATURE_DEVICE, + CubeIT_Mobile_Phonegap::FEATURE_FILE, + CubeIT_Mobile_Phonegap::FEATURE_FILETRANSFER, + CubeIT_Mobile_Phonegap::FEATURE_STORAGE, + CubeIT_Mobile_Phonegap::FEATURE_NOTIFICATION_DIALOG, + CubeIT_Mobile_Phonegap::FEATURE_INAPPBROWSER, + CubeIT_Mobile_Phonegap::FEATURE_SPLASHSCREEN, + CubeIT_Mobile_Phonegap::FEATURE_GLOBALIZATION, + //CubeIT_Mobile_Phonegap::FEATURE_PUSHNOTIFICATION, + CubeIT_Mobile_Phonegap::FEATURE_DEBUG + ) + ); + if ($os == 'ios') { + $phonegap->addFeature(CubeIT_Mobile_Phonegap::FEATURE_EXTERNALFILEUTIL); + $phonegap->addFeature(CubeIT_Mobile_Phonegap::FEATURE_STATUSBAR); + //$phonegap->addFeature(CubeIT_Mobile_Phonegap_IOS::FEATURE_WKWEBVIEW); + } else if ($os == 'android') { + $phonegap->addFeature(CubeIT_Mobile_Phonegap::FEATURE_WEBINTENT); + } + + + $allpub = $compiler->books; + + if (isset($collection->settings['offline']) && $collection->settings['offline']) { + $p = $compiler->getPublishedVersionPath($os, $collection->settings['version']); + if ($p) { + $phonegap->addAdditionalSource('publications', $p); + + $exs = explode("\n", $collection->settings['offline_exclude']); + foreach ($exs as $e) { + $e = trim($e); + if ($e == '') { + continue; + } + + if (stristr($e, '$id$')) { + foreach ($allpub as $i) { + $phonegap->addExclude('"' . str_replace('$id$', $i, $e) . '"'); + } + } else { + $phonegap->addExclude('"' . $e . '"'); + } + } + + $add = explode("\n", $collection->settings['offline_syncs']); + foreach ($add as $a) { + $a = trim($a); + if ($a == '' || substr($a, 0, 1) == '#' || substr($a, 0, 1) == ';') { + continue; + } + list($to, $source) = explode(':', $a); + $phonegap->addAdditionalSource('publications' . '/' . $to, $p . $source); + } + } + } + + $phonegap->run($run); + } + + /** + * + * @param string $os + * @param wsHTML5AppCompiler $compiler + */ + protected function _collectionAssets($os, $compiler) + { + if ($os == 'ios') { + $this->_collectionAssetsIOS($os, $compiler); + } else if ($os == 'android') { + $this->_collectionAssetsAndroid($os, $compiler); + } + } + + protected function _collectionAssetsAndroid($os, $compiler) + { + $collection = $compiler->collection; + $src = $compiler->wdir . '/' . $collection->theme['icon']; + } + + protected function _collectionAssetsIOS($os, $compiler) + { + $collection = $compiler->collection; + $src = $compiler->wdir . '/' . $collection->theme['icon']; + // icones + $icons = array(57 => 'icon', 72 => 'icon-72', 114 => 'icon@2x', 144 => 'icon-72@2x'); + $d = WS_COLLECTIONS . '/resources/' . $collection->collection_id . '/' . $os . '/icons/'; + if (!file_exists($d)) { + mkdir($d, 0777, true); + } + foreach ($icons as $s => $n) { + + $dest = $d . $n . '.png'; + if (!$this->_testFile($src, $dest)) { + wsPackagerPhonegap::__makeIcon($src, $dest, $s); + } + } + + // 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'); + + $langs = $compiler->langs; + + foreach ($langs as $l) { + $src = $compiler->wdir . '/' . $collection->theme['splash_' . $l]; + if (!file_exists($src)) { + continue; + } + + $d = WS_COLLECTIONS . '/resources/' . $collection->collection_id . '/' . $os . '/splash/' . $l . '.lproj/'; + if (!file_exists($d)) { + mkdir($d, 0777, true); + } + + + 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); + } + } + } + + + // Transfert + $this->_rsync(WS_COLLECTIONS . '/resources/' . $collection->collection_id . '/' . $os, "/mnt/macbox" . $this->_iosProjectDir($collection->settings['namespace']) . '/' . CubeIT_Text::str2URL($collection->nom) . '/Resources', false); + } + + protected function _testFile($ref, $dest) + { + if (!file_exists($dest)) { + return false; + } + if (filemtime($ref) > filemtime($dest)) { + return false; + } + return true; + } + + protected function _createProject($os, $name, $ns) + { + if ($os == 'ios') { + $dir = $this->_iosProjectDir($ns); + $sdir = '/mnt/macbox' . $dir; + if (!file_exists($sdir)) { + `sudo /usr/local/bin/remountmac`; + mkdir($sdir, 0777, true); + $cl = new CubeIT_CommandLine('/Phonegap/Cordova/bin/create'); + $cl->setArg(null, $dir); + $cl->setArg(null, $ns); + $cl->setArg(null, CubeIT_Text::str2URL($name)); + $cl->setSSH(self::VINCENT, 'vincent', '', 22022); + $cl->execute(); + // Install plugins + $this->_iosPlugin($dir, 'PushPlugin'); + $this->_iosPlugin($dir, 'ExternalFileUtil'); + } + } elseif ($os == 'android') { + + } + } + + protected function _iosProjectDir($ns) + { + return '/Phonegap/Projects/' . str_replace('.', '/', $ns); + } + + protected function _iosPlugin($dir, $plugin) + { + // git@github.com:phonegap-build/PushPlugin.git + $cl = new CubeIT_CommandLine('/usr/local/bin/plugman'); + $cl->setManualArg(' --platform ios'); + $cl->setManualArg(' --project ' . $dir); + $cl->setManualArg(' --plugin /Phonegap/Plugins/' . $plugin); + $cl->setSSH(self::VINCENT, 'vincent', '', 22022); + $cl->execute(); + } + + public function export($book_id, &$x, $action = 'download', $version = 'online', $destinationDir = null, $destinationFile = null) + { + global $core; + set_time_limit(0); + + if (is_null($destinationDir)) { + $destinationDir = ''; + } + if (is_null($destinationFile)) { + $destinationFile = ''; + } + + $this->origVersion = $version; + $this->origAction = $action; + + $this->book_id = $book_id; + $this->x = $x; + + $this->dao = new wsDAOBook($core->con); + $this->book = $this->dao->selectById($this->book_id); + + $this->action = $action; + $e = explode('_', $this->action, 2); + $this->metaAction = $e[0]; + if (count($e) > 1) { + $this->action = $e[1]; + } + + $this->version = $this->_getVersion($version); + $this->destinationDir = ltrim(trim($destinationDir), '/'); + $this->destinationFile = str_replace('/', '-', trim($destinationFile)); + + $this->_saveDestination(); + + if ($this->metaAction == 'download') { + $this->_download(); + } else if ($this->metaAction == 'phonegap') { + $this->_phonegap(); + } else if ($this->metaAction == 'install') { + $this->_install(); + } else if ($this->metaAction == 'phonegapcollection') { + $this->_phonegapcollection(); + } + } + + protected function _haveToZip() + { + $yes = array('win-exe', 'mac-exe', 'win-cd'); + return in_array($this->version, $yes); + } + + protected function _phonegapcollection() + { + $d = '/' . $this->destinationDir; + + $packager = new wsPackagerPhonegap($this->book_id, $d, true, false, $this->version); + $packager->home = true; + $packager->book->parametres->mobileVideosPath = ''; + + return $packager->makePackage(false); + } + + protected function _killFtp($book_id) + { + $kill = 'pkill -f "^lftp(.*)' . $book_id . '"'; + `$kill`; + } + + protected function _install() + { + $this->_killFtp($this->book_id); + + $p = wsPackager::package($this->book_id, $this->version, $this->_haveToZip(), false); + + if (strpos($p, '/fluidbook') == 0) { + $p = ROOT . $p; + } + + + if ($this->action == 'references') { + //$root = 'fluidbook@www.fluidbook.com:/home/fluidbook/www/references/'; + $root = '/mnt/sshfs/fluidbook/home/fluidbook/www/references/'; + $rootURL = 'https://www.fluidbook.com/references/'; + } else if ($this->action == 'hosting') { + $root = '/mnt/sshfs/fluidbook/data/fluidbook/hosting/'; + $rootURL = 'https://hosting.fluidbook.com/'; + } else if ($this->action == 'ftp') { + $root = 'ftp://'; + $rootURL = null; + } + + if ($this->destinationFile) { + $pathd = $root . $this->destinationDir; + $path = $pathd . '/' . $this->destinationFile; + } else { + $path = $root . $this->destinationDir; + } + + if (stristr($path, 'ftp://')) { + $this->_killFtp($this->book_id); + $this->_lftp($p, $path, $this->ftpPassiveMode); + } else { + $this->_rsync($p, $path); + } + + if (!is_null($rootURL)) { + $url = $rootURL . $this->destinationDir; + if ($this->x) { $this->x->addTruePopup($url . '/'); } - } - } - - protected function _phonegap() - { - $os = $this->action; - - if ($this->destinationDir == '') { - return; - } - - $packager = new wsPackagerPhonegap($this->book_id, null, true, false, $os); - $packager->cleanOnDestruct = false; - $package = $packager->makePackage(false); - - $this->_transfertPhonegap($os, $package, $this->destinationDir); - } - - protected function _transfertPhonegap($os, $package, $destination) - { - if ($os == 'android') { - `sudo /usr/local/bin/remountvincent`; - $this->_rsync($package, '/mnt/vincent/cygdrive/h/Works/Phonegap/Projects/' . $destination, true); - } else if ($os == 'ios') { - `sudo /usr/local/bin/remountmac`; - $this->_rsync($package, '/mnt/macbox/Phonegap/Projects/' . $destination, true); - } - } - - protected function _lftp($src, $dest, $passive = false, $erase = false) - { - set_time_limit(0); - $u = parse_url($dest); - - $file = is_file($src); - if ($file) { - $e = explode('/', $u['path']); - $u['file'] = array_pop($e); - $u['dir'] = implode('/', $e); - } else { - $u['dir'] = $u['path']; - } - if ($u['dir'] == '') { - $u['dir'] = '/'; - } - - $passive = $passive ? 'on' : 'off'; - - if (!isset($u['port'])) { - $u['port'] = '21'; - } - - $commandes = array( - 'set ftp:ssl-allow false', - 'mkdir -p ' . $u['dir'] - ); - - if ($file) { - $commandes[] = 'put -O ' . $u['dir'] . ' ' . $src . ' -o ' . $u['file']; - } else { - $commandes[] = 'lcd ' . $src; - $commandes[] = 'cd ' . $u['dir']; - if ($erase) { - $commandes[] = 'mirror -Rve'; - } else { - $commandes[] = 'mirror -Rv'; - } - } - - if (!file_exists($src)) { - return; - } - - $lftp = new CubeIT_CommandLine('lftp'); - $lftp->setArg('u', $u['user'] . ',' . $u['pass']); - $lftp->setArg('p', $u['port']); - $lftp->setArg('e', implode(';', $commandes)); - $lftp->setArg(null, $u['host']); - $lftp->execute(); - $lftp->debug(); - } - - protected function _rsync($src, $dest, $erase = false, $chown = null) - { - set_time_limit(0); - /*if (is_file($src)) { - $dir = dirname($dest); - if (!file_exists($dir)) { - mkdir($dir, 0777, true); - } - copy($src, $dest); - if (!is_null($chown)) { - `chown $chown $dest`; - } - return; - }*/ - - $cl = new CubeIT_CommandLine_Rsync($src, $dest, $erase); - $cl->setProg('/usr/bin/rsync'); - $cl->execute(); - if (!is_null($chown)) { - `chown -R $chown $dest`; - } - } - - protected function _download() - { - $r = wsPackager::package($this->book_id, $this->version); - $this->x->addRedirection($r); - } - - protected function _getVersion($version) - { - if ($version == 'v2') { - return 'html'; - } else if ($version == 'online') { - if ($this->book->parametres->version == '1') { - return 'v1'; - } elseif ($this->book->parametres->version == '2') { - return 'html'; - } - } - return $version; - } - - protected function _saveDestination() - { - $datas = $this->book->exportdatas; - if ($datas == '') { - $datas = array(); - } else { - $datas = json_decode($datas, true); - } - if (!isset($datas[$this->origAction])) { - $datas[$this->origAction] = array(); - } - - $d = array(); - if ($this->destinationDir) { - $d['dir'] = $this->destinationDir; - } - if ($this->destinationFile) { - $d['file'] = $this->destinationFile; - } - - $datas[$this->origAction][$this->origVersion] = $d; - - $this->dao->saveExportDatas($this->book_id, $datas); - } + } + } + + protected function _phonegap() + { + $os = $this->action; + + if ($this->destinationDir == '') { + return; + } + + $packager = new wsPackagerPhonegap($this->book_id, null, true, false, $os); + $packager->cleanOnDestruct = false; + $package = $packager->makePackage(false); + + $this->_transfertPhonegap($os, $package, $this->destinationDir); + } + + protected function _transfertPhonegap($os, $package, $destination) + { + if ($os == 'android') { + `sudo /usr/local/bin/remountvincent`; + $this->_rsync($package, '/mnt/vincent/cygdrive/h/Works/Phonegap/Projects/' . $destination, true); + } else if ($os == 'ios') { + `sudo /usr/local/bin/remountmac`; + $this->_rsync($package, '/mnt/macbox/Phonegap/Projects/' . $destination, true); + } + } + + protected function _lftp($src, $dest, $passive = false, $erase = false) + { + set_time_limit(0); + $u = parse_url($dest); + + $file = is_file($src); + if ($file) { + $e = explode('/', $u['path']); + $u['file'] = array_pop($e); + $u['dir'] = implode('/', $e); + } else { + $u['dir'] = $u['path']; + } + if ($u['dir'] == '') { + $u['dir'] = '/'; + } + + $passive = $passive ? 'on' : 'off'; + + if (!isset($u['port'])) { + $u['port'] = '21'; + } + + $commandes = array( + //'set ftp:passive-mode ' . $passive, + 'set ftp:ssl-allow false', + 'mkdir -p ' . $u['dir'] + ); + + + if ($file) { + $commandes[] = 'put -O ' . $u['dir'] . ' ' . $src . ' -o ' . $u['file']; + } else { + $commandes[] = 'lcd ' . $src; + $commandes[] = 'cd ' . $u['dir']; + if ($erase) { + $commandes[] = 'mirror -Rve'; + } else { + $commandes[] = 'mirror -Rv'; + } + } + + if (!file_exists($src)) { + return; + } + + $lftp = new CubeIT_CommandLine('lftp'); + $lftp->setArg('u', $u['user'] . ',' . $u['pass']); + $lftp->setArg('p', $u['port']); + $lftp->setArg('e', implode(';', $commandes)); + $lftp->setArg(null, $u['host']); + $lftp->execute(); + $lftp->debug(); + + } + + protected function _rsync($src, $dest, $erase = false, $chown = null) + { + set_time_limit(0); + /*if (is_file($src)) { + $dir = dirname($dest); + if (!file_exists($dir)) { + mkdir($dir, 0777, true); + } + copy($src, $dest); + if (!is_null($chown)) { + `chown $chown $dest`; + } + return; + }*/ + + $cl = new CubeIT_CommandLine_Rsync($src, $dest, $erase); + $cl->setProg('/usr/bin/rsync'); + $cl->execute(); + if (!is_null($chown)) { + `chown -R $chown $dest`; + } + } + + protected function _download() + { + $r = wsPackager::package($this->book_id, $this->version); + $this->x->addRedirection($r); + } + + protected function _getVersion($version) + { + if ($version == 'v2') { + return 'html'; + } else if ($version == 'online') { + if ($this->book->parametres->version == '1') { + return 'v1'; + } elseif ($this->book->parametres->version == '2') { + return 'html'; + } + } + return $version; + } + + protected function _saveDestination() + { + $datas = $this->book->exportdatas; + if ($datas == '') { + $datas = array(); + } else { + $datas = json_decode($datas, true); + } + if (!isset($datas[$this->origAction])) { + $datas[$this->origAction] = array(); + } + + $d = array(); + if ($this->destinationDir) { + $d['dir'] = $this->destinationDir; + } + if ($this->destinationFile) { + $d['file'] = $this->destinationFile; + } + + $datas[$this->origAction][$this->origVersion] = $d; + + $this->dao->saveExportDatas($this->book_id, $datas); + } } diff --git a/inc/ws/Util/html5/master/class.ws.html5.compiler.php b/inc/ws/Util/html5/master/class.ws.html5.compiler.php index f2ad47d26..6d7bfdb41 100644 --- a/inc/ws/Util/html5/master/class.ws.html5.compiler.php +++ b/inc/ws/Util/html5/master/class.ws.html5.compiler.php @@ -418,6 +418,11 @@ class wsHTML5Compiler $this->addJsLib('cookie', 'js/libs/jquery/jquery.cookie.js'); $this->addJsLib('remarkable', 'js/libs/fluidbook/cart/fluidbook.cart.remarkable.js'); break; + case 'Mopec': + $this->addJsLib('parsley', 'js/libs/parsley.min.js'); + $this->addJsLib('cookie', 'js/libs/jquery/jquery.cookie.js'); + $this->addJsLib('mopec', 'js/libs/fluidbook/cart/fluidbook.cart.mopec.js'); + break; default: break; }