From aa8caaa2adb4781264cffeecf1d826aca61793d5 Mon Sep 17 00:00:00 2001 From: "vincent@cubedesigners.com" Date: Tue, 7 May 2019 14:32:25 +0000 Subject: [PATCH] #2687 --- inc/ws/Controlleur/class.ws.url.php | 4340 ++++++++++---------- inc/ws/Metier/class.ws.book.parametres.php | 6 +- 2 files changed, 2177 insertions(+), 2169 deletions(-) diff --git a/inc/ws/Controlleur/class.ws.url.php b/inc/ws/Controlleur/class.ws.url.php index f19b1c8be..09bd52dc5 100644 --- a/inc/ws/Controlleur/class.ws.url.php +++ b/inc/ws/Controlleur/class.ws.url.php @@ -3,2174 +3,2178 @@ class wsUrl { - public static function publications($args) - { - global $core; - - if (isset($args[1])) { - $_SESSION['q'] = $args[1]; - } - - $settings = $core->user->getSettings('books'); - - $shortcuts = array(); - if (wsDroits::creation()) { - $shortcuts[] = '' . $core->typo->Ajouter(__('Créer une nouvelle publication')) . ''; - } - - $filtres = array(); - if (wsDroits::revendeur(false)) { - $filtres[] = new commonFiltre(__('Status'), 'status_book', $settings['filtres']); - } - if (wsDroits::admin()) { - $filtres[] = new commonFiltre(__('Administrateur'), 'admin_book', $settings['filtres']); - $filtres[] = new commonFiltre(__('Revendeur'), 'revendeur_book', $settings['filtres']); - } - $res = commonPage::barre($filtres, 'filtreBooks', 'books', $shortcuts, wsDroits::creation()); - $res .= commonPage::tMain(null, wsDroits::creation()); - $res .= commonPage::bh(); - $res .= '
'; - $res .= self::listeBooks(); - $res .= '
'; - $res .= commonPage::bf(); - $res .= commonPage::bMain(); - return $res; - } - - public static function listeBooks($dashboard = null, $settings = null) - { - global $core; - cubePage::truePopup(); - cubePage::autocomplete(); - cubePage::contextMenu(); - - $droits = wsDroits::getDroits(); - - commonDroits::min(1); - $settings = is_null($settings) ? $core->user->getSettings('books') : $settings; - $change = is_null($dashboard) ? 'Books' : 'Dashboard/' . $dashboard; - $dao = new wsDAOBook($core->con); - $context_download_id = is_null($dashboard) ? 'contextDownloadBook' : 'contextDashboard_Download' . $dashboard; - $context_status_id = is_null($dashboard) ? 'contextStatusBook' : 'contextDashboard_Status' . $dashboard; - $context_view_id = is_null($dashboard) ? 'contextViewBook' : 'contextView_Status' . $dashboard; - - if (isset($settings['search']) && !is_null($settings['search'])) { - $dao->setSearch($settings['search']); - } - $dao->setFiltres($settings['filtres']); - $liste = $dao->getListe($settings['orderby'], $settings['sens'], $settings['limit'], $core->user); - - $res = ''; - - - $res .= self::contextBookStatus($context_status_id); - $res .= self::contextBookView($context_view_id); - - $res .= ''; - $res .= ''; - $res .= ''; - $res .= ''; - $res .= ''; - $res .= ''; - if ($droits->admin) { - $res .= ''; - } - if ($droits->revendeur) { - $res .= ''; - } else { - $res .= ''; - } - if ($droits->admin) { - $res .= ''; - } - if ($droits->revendeur) { - $res .= ''; - $res .= ''; - } - $res .= str_repeat('', 5); - $res .= ''; - $i = 0; - - $btVoir = '
' . __('voir') . ''; - $btEdit = '
' . __('éditer') . ''; - $btStats = '
' . __('stats') . ''; - $btDownload = '
' . __('télécharger') . ''; - if ($droits->creation) { - $btDel = '
' . __('suppr.') . ''; - } - - foreach ($liste as $id => $book) { - $odd = cubeMath::isOdd($i) ? ' class="odd"' : ''; - $res .= ''; - $res .= ''; - $res .= ''; - $res .= ''; - $res .= ''; - $res .= ''; - if ($droits->admin) { - $res .= ''; - } - - if ($droits->revendeur) { - $p = str_replace(" (", '
', html::escapeHTML($book->proprietaire)); - $p = str_replace(')', '', $p); - $res .= ''; - } else { - $res .= ''; - } - if ($droits->admin) { - $res .= ''; - } - if ($droits->revendeur) { - if ($droits->admin || $book->status < 1) { - $p = ''; - if (!is_null($book->projet)) { - $p = ' ' . cubeMedia::silk('arrow_right.png') . ''; - } - $res .= ''; - } else { - $res .= ''; - } - $res .= ''; - } - if ($book->version > 1 || $droits->admin) { - $types = []; - if (!$book->parametres->alwaysHTML5) { - $types[] = 'flash'; - $defaultPlayer = 'viewer'; - } else { - $defaultPlayer = 'viewerh'; - } - if ($book->parametres->mobileVersion != 'pdf') { - $types[] = 'html5'; - } - if ($book->parametres->scorm_enable) { - $types[] = 'scorm'; - } - - - $res .= ''; - $res .= ''; - } else { - $res .= ''; - } - $res .= ''; - if ($book->version > 1) { - if ($droits->admin) { - $res .= ''; - } else { - $res .= self::contextBookDownload($context_download_id, $droits, $book); - $res .= ''; - } - } else { - $res .= ''; - } - if ($droits->creation && $book->status < 0) { - $res .= ''; - } else { - $res .= ''; - } - $res .= ''; - $i++; - } - - if (!isset($settings['search']) || is_null($settings['search'])) { - $odd = cubeMath::isOdd($i) ? ' class="odd"' : ''; - $res .= ''; - } - $res .= '
' . commonUrl::orderby('#', 'book_id', $settings, 'sort' . $change) . '' . commonUrl::orderby(__('Titre de la publication'), 'nom', $settings, 'sort' . $change) . '' . commonUrl::orderby(__('Date'), 'date', $settings, 'sort' . $change) . '' . commonUrl::orderby(__(''), 'lang', $settings, 'sort' . $change) . '' . __('Pages') . '' . commonUrl::orderby('C', 'demo_counter', $settings, 'sort' . $change, __('Compteur de démos')) . '' . commonUrl::orderby(__('Proprietaire'), 'proprietaire_nom', $settings, 'sort' . $change) . '' . commonUrl::orderby(__('Proprietaire'), 'proprietaire_utilisateur', $settings, 'sort' . $change) . '' . commonUrl::orderby(__('Facturation'), 'facturable', $settings, 'sort' . $change) . '' . commonUrl::orderby(__('Status'), 'status', $settings, 'sort' . $change) . '' . __('V') . '
' . $book->book_id . '' . html::escapeHTML($book->nom) . '' . date('Y-m-d', $book->date) . '' . mb_strtoupper($book->lang) . '' . $book->parametres->pages . '' . $book->demo_counter . '' . $p . '' . html::escapeHTML($book->proprietaire_utilisateur) . '' . html::escapeHTML($book->facturable) . '' . $core->books_status[$book->status] . '' . $p . '' . $core->books_status[1] . '' . $book->version . '' . $btVoir . '' . $btEdit . '' . $btStats . '' . $btDownload . '' . $btDownload . '' . $btDel . '
'; - $res .= commonPage::pager($settings['page'], $dao->count($core->user), $settings['par_page'], 'page' . $change . '/%d'); - $res .= commonUrl::formParPage('parPage' . $change, $settings['par_page'], __('publications'), false); - $res .= '
'; - return $res; - } - - public static function collections() - { - global $core; - - if (isset($args[1])) { - $_SESSION['q'] = $args[1]; - } - - $settings = $core->user->getSettings('collections'); - $shortcuts = array(); - if (wsDroits::creation()) { - $shortcuts[] = '' . $core->typo->Ajouter(__('Créer une nouvelle collection')) . ''; - } - - $filtres = array(); - - $res = commonPage::barre($filtres, 'filtreCollections', 'collections', $shortcuts); - $res .= commonPage::tMain(null); - $res .= commonPage::bh(); - $res .= '
'; - $res .= self::listeCollections(); - $res .= '
'; - $res .= commonPage::bf(); - $res .= commonPage::bMain(); - return $res; - } - - public static function collection($args) - { - global $core; - commonDroits::min(1); - cubePage::ui('Sortable'); - cubePage::autocomplete(); - - $dao = new wsDAOCollection($core->con); - $collection = $dao->selectById($args[1]); - - $shortcuts = array(); - - $res = commonPage::barre(null, null, null, $shortcuts); - $res .= commonPage::tMain(); - $res .= commonPage::bh(); - $res .= '
'; - $res .= self::collectionEdit($collection); - $res .= '
'; - $res .= commonPage::bf(); - $res .= commonPage::bMain(); - return $res; - } - - public static function collectionEdit($collection) - { - global $core; - - $res = '

Gestion de la collection « ' . $collection->nom . ' » # ' . $collection->collection_id . '

'; - $res .= '
'; - $res .= ''; - $res .= ''; - $res .= ''; - $res .= '
#' . form::hidden('collection_id', $collection->collection_id) . $collection->collection_id . '
' . __('Nom de la collection') . '' . form::field('nom', 20, 64, $collection->nom) . '
'; - $res .= '

' . __('Composition') . '

'; - $res .= '' . $core->typo->Ajouter(__('Nouveau groupe')) . '

'; - $res .= ''; - - $contents = $collection->contents; - $theme = $collection->theme; - - foreach ($langs as $l) { - $e = explode('_', $l); - $slang = $e[0]; - if (!isset($contents[$l]) && isset($contents[$slang])) { - $contents[$l] = $contents[$slang]; - } - - $files = ['splash', 'ad']; - foreach ($files as $file) { - if (!isset($theme[$file . '_' . $l]) && isset($theme[$file . '_' . $slang])) { - $theme[$file . '_' . $l] = $theme[$file . '_' . $slang]; - } - } - - $res .= '

' . __('Contenus') . ' [' . $l . ']

'; - $res .= ''; - $res .= ''; - $res .= ''; - $res .= ''; - //'splash' => - $res .= ''; - $res .= ''; - $res .= ''; - $res .= '
' . __('Titre') . '' . form::field(array('contents[' . $l . '][titre]', 'contents_' . $l . '_titre'), 64, 64, $contents[$l]['titre']) . '
' . __("Titre sur l'écran d'accueil") . '' . form::field(array('contents[' . $l . '][titrehome]', 'contents_' . $l . '_titrehome'), 64, 64, $contents[$l]['titrehome']) . '
' . __('A propos') . '' . form::textarea(array('contents[' . $l . '][apropos]', 'contents_' . $l . '_apropos'), 60, 10, $contents[$l]['apropos']) . '
' . __('Ecran de lancement') . ' (2048x2048px)' . form::hidden(array('theme[splash_' . $l . ']', 'splash_' . $l), $theme['splash_' . $l]) . self::viewCollectionFile($theme['splash_' . $l], $collection->collection_id) . '
' . __('Panneau publicité') . '' . form::hidden(array('theme[ad_' . $l . ']', 'ad_' . $l), $theme['ad_' . $l]) . self::viewCollectionFile($theme['ad_' . $l], $collection->collection_id) . '
' . __('Lien publicité') . '' . form::field(array('contents[' . $l . '][adlink]', 'adlink_' . $l), 64, 64, $contents[$l]['adlink']) . '
'; - } - - $res .= '

' . __('Paramètres avancés') . '

'; - $res .= ''; - $res .= ''; - $res .= ''; - $res .= ''; - $res .= ''; - $res .= ''; - $res .= ''; - $res .= ''; - $res .= ''; - $res .= ''; - $res .= ''; - $res .= ''; - $res .= ''; - $res .= '
' . __('Activity') . '' . form::field(array('settings[activity]', 'activity'), 20, 64, $collection->settings['activity']) . '
' . __('Build') . '' . form::field(array('settings[build]', 'build'), 10, 64, $collection->settings['build']) . '
' . __('Android License Key') . '' . form::textArea(array('settings[license_key]', 'license_key'), 50, 3, $collection->settings['license_key']) . '
' . __('Version') . '' . form::field(array('settings[version]', 'version'), 10, 64, $collection->settings['version']) . '
' . __('Orientation') . '' . form::combo(array('settings[orientation]', 'orientation'), array(__('Portrait et Paysage') => 'unspecified', __('Portrait') => 'portrait', __('Paysage') => 'landscape'), $collection->settings['orientation']) . '
' . __('Full offline') . '' . form::checkbox(array('settings[offline]', 'offline'), 1, $collection->settings['offline']) . '
' . __('Stockage publications') . ' (Android)' . form::combo(array('settings[android_storage]', 'android_storage'), array(__('Fichier expansion (.obb)') => 'expansion', __('Application (.apk)') => 'apk'), $collection->settings['android_storage']) . '
' . __('Identifiant de l\'application') . '' . form::field(array('settings[namespace]', 'namespace'), 64, 64, $collection->settings['namespace']) . '
' . __('Certificat APNS') . ' Dev (' . __('Fichier .pem') . ')
' . __('Certificat APNS') . ' Prod (' . __('Fichier .pem') . ')
' . __('Versions iOS') . '' . form::field(array('settings[v_ios]', 'namespace'), 64, 256, $collection->settings['v_ios']) . '
' . __('Versions Android') . '' . form::field(array('settings[v_android]', 'namespace'), 64, 256, $collection->settings['v_android']) . '
'; - - $res .= '

' . __('Applications offline') . '

'; - $res .= ''; - $res .= ''; - $res .= ''; - $res .= '
' . __("Filtres d'exclusion") . '' . form::textarea(array('settings[offline_exclude]', 'offline_exclude'), 30, 3, $collection->settings['offline_exclude']) . '
' . __("Synchronisations supplémentaires") . '' . form::textarea(array('settings[offline_syncs]', 'offline_syncs'), 30, 3, $collection->settings['offline_syncs']) . '
'; - - - if (!isset($collection->settings['perline']) || !$collection->settings['perline']) { - $collection->settings['perline'] = 3; - } - $res .= '

' . __('Thème') . '

'; - $res .= ''; - $images = array('back' => __('Image de fond'), 'etagere' => __("Image de l'étagère"), 'icon' => __("Icône de l'application") . ' (1024x1024px)'); - foreach ($images as $i => $label) { - $res .= ''; - } - $res .= ''; - $res .= ''; - $res .= ''; - $res .= ''; - $res .= ''; - $res .= ''; - $res .= ''; - $res .= ''; - $res .= ''; - - $res .= '
' . $label . '' . form::hidden(array('theme[' . $i . ']', 'theme_' . $i), $collection->theme[$i]) . self::viewCollectionFile($collection->theme[$i], $collection->collection_id) . '
' . __('Couleur principale') . '#' . form::field(array('settings[couleurA]', 'couleurA'), 6, 6, $collection->settings['couleurA']) . '
' . __('Couleur secondaire') . '#' . form::field(array('settings[couleurB]', 'couleurB'), 6, 6, $collection->settings['couleurB']) . '
' . __('Couleur des textes') . '#' . form::field(array('settings[couleurC]', 'couleurC'), 6, 6, $collection->settings['couleurC']) . '
' . __('Couleur des titres de publication') . '#' . form::field(array('settings[couleurE]', 'couleurC'), 6, 6, $collection->settings['couleurE']) . '
' . __('Couleur de fond') . '#' . form::field(array('settings[couleurD]', 'couleurD'), 6, 6, $collection->settings['couleurD']) . '
' . __('Nombre de publication par ligne') . '' . form::field(array('settings[perline]', 'perline'), 1, 1, $collection->settings['perline']) . '
' . __('Contenu HTML alternatif') . '' . form::textArea(array('settings[htmlalt]', 'htmlalt'), 100, 30, $collection->settings['htmlalt']) . '
' . __('HTML Head') . '' . form::textArea(array('settings[htmlhead]', 'htmlhead'), 100, 6, $collection->settings['htmlhead']) . '
' . __('Fichiers pour le contenu alternatif') . '' . form::hidden(array('theme[filesalt]', 'theme_' . $i), $collection->theme['filesalt']) . self::viewCollectionFile($collection->theme['filesalt'], $collection->collection_id) . '
'; - - $res .= '' . $core->typo->Ajouter(__('Enregistrer')) . ''; - $res .= '
'; - $res .= '

'; - $res .= '

' . __('Versions') . '

'; - $res .= '
'; - $res .= '' . $core->typo->Ajouter(__('Créer une version')) . '

'; - $r = $core->con->select('SELECT * FROM book_collection_compile WHERE collection_id=\'' . $collection->collection_id . '\' ORDER BY compile_date DESC'); - - $v_ios = self::getSelectVersions($collection->settings['v_ios']); - $v_android = self::getSelectVersions($collection->settings['v_android']); - - - if (!$r->count()) { - $res .= __('Aucune version de la collection n\'a été crée'); - } else { - $res .= ''; - $res .= ''; - while ($r->fetch()) { - - if ($r->online_ios || $r->online_android) { - $del = ''; - } else { - $del = '
' . __('Effacer') . '
'; - } - - $pub_ios = form::combo('version[' . $r->compile_date . '][ios]', $v_ios, $r->online_ios); - $pub_android = form::combo('version[' . $r->compile_date . '][android]', $v_android, $r->online_android); - - $res .= ''; - } - $res .= '
' . __('Date') . 'iOSAndroid
' . date('Y-m-d H:i:s', $r->compile_date) . '' . $pub_ios . '' . $pub_android . '' . $del . '
'; - } - $res .= '' . $core->typo->Ajouter(__('Enregistrer')) . ''; - $res .= '
'; - $res .= '

'; - $res .= '

' . __('Notifications') . '

'; - $res .= '

' . __('Indiquez le texte de la notification à envoyer aux utilisateurs') . ' (' . __('Max 200 caractères') . ').
' . __('Laissez vide si vous souhaitez simplement afficher un badge') . '

'; - $res .= '
'; - $res .= form::hidden('collection', $collection->collection_id); - $res .= ''; - foreach ($langs as $lang) { - $res .= ''; - } - $res .= '' . $core->typo->Ajouter(__('Publier et notifier les utilisateurs')) . ''; - $res .= '
' . __('Notification') . '[' . $lang . ']' . form::textArea(array('notification[' . $lang . ']'), 60, 3) . '
'; - $res .= '
'; - $res .= '

' . __('Export') . '

'; - $res .= '' . $core->typo->Ajouter(__('Exporter pour Android')) . ' ' . $core->typo->Ajouter(__('Exporter pour iOS')) . ''; - - return $res; - } - - public static function viewCollectionFile($file, $collection_id) - { - $res = ''; - $res .= cubeMedia::tango('actions/document-save.png'); - $res .= ''; - return $res; - } - - public static function getSelectVersions($versions) - { - fb($versions); - $res = array('-----' => ''); - $e = explode(',', $versions); - - foreach ($e as $ee) { - $ee = trim($ee); - $res[$ee] = $ee; - } - return $res; - } - - public static function listeCollections($dashboard = null, $settings = null) - { - global $core; - - cubePage::truePopup(); - - $droits = wsDroits::getDroits(); - - commonDroits::min(3); - $settings = is_null($settings) ? $core->user->getSettings('collections') : $settings; - $change = is_null($dashboard) ? 'Collections' : 'Dashboard/' . $dashboard; - $dao = new wsDAOCollection($core->con); - if (isset($settings['search']) && !is_null($settings['search'])) { - $dao->setSearch($settings['search']); - } - $dao->setFiltres($settings['filtres']); - $liste = $dao->getListe($settings['orderby'], $settings['sens'], $settings['limit'], $core->user); - - $btVoir = '
' . __('voir') . ''; - $btEdit = '
' . __('éditer') . ''; - $btStats = '
' . __('stats') . ''; - $btDownload = '
' . __('télécharger') . ''; - if ($droits->creation) { - $btDel = '
' . __('suppr.') . ''; - } - - - $res = ''; - $res .= ''; - $res .= ''; - $res .= ''; - $res .= str_repeat('', 4); - $res .= ''; - - $i = 0; - foreach ($liste as $collection) { - $odd = cubeMath::isOdd($i) ? ' class="odd"' : ''; - $res .= ''; - $res .= ''; - $res .= ''; - if ($droits->revendeur) { - $p = str_replace(" (", '
', html::escapeHTML($collection->proprietaire_nom)); - $p = str_replace(')', '', $p); - $res .= ''; - } else { - $res .= ''; - } - - $res .= ''; - $res .= ''; - $res .= ''; - $res .= ''; - - $res .= ''; - - $i++; - } - - if (!isset($settings['search']) || is_null($settings['search'])) { - $odd = cubeMath::isOdd($i) ? ' class="odd"' : ''; - $res .= ''; - } - $res .= '
' . commonUrl::orderby('#', 'collection_id', $settings, 'sort' . $change) . '' . commonUrl::orderby(__('Nom de la collection'), 'nom', $settings, 'sort' . $change) . '' . commonUrl::orderby(__('Propriétaire'), 'proprietaire_nom', $settings, 'sort' . $change) . '
' . $collection->collection_id . '' . $collection->nom . '' . $p . '' . html::escapeHTML($collection->proprietaire_utilisateur) . '' . $btEdit . '
'; - $res .= commonPage::pager($settings['page'], $dao->count($core->user), $settings['par_page'], 'page' . $change . '/%d'); - $res .= commonUrl::formParPage('parPage' . $change, $settings['par_page'], __('collections'), false); - $res .= '
'; - - return $res; - } - - public static function getFluidbookVersions($select = false) - { - $droits = wsDroits::getDroits(); - - $chooseVersion = wsDroits::admin(); - - if ($chooseVersion) { - $default = ' - ' . __('Version par défaut'); - } else { - $default = ''; - } - - $versions = array(); - $versions['online'] = array('title' => __('Version online') . $default, 'icon' => cubeMedia::silk('page_world.png')); - $versions['scorm'] = array('title' => __('Version SCORM') . $default, 'icon' => cubeMedia::silk('page_world.png')); - if ($chooseVersion) { - $versions['v1'] = array('title' => __('Version online') . ' - V1', 'icon' => cubeMedia::silk('page_white_world.png')); - $versions['v2'] = array('title' => __('Version online') . ' - V2', 'icon' => cubeMedia::silk('page_white_world.png')); - } - $versions['win-exe'] = array('title' => __('Version offline') . ' - ' . __('Executable Windows') . ' (Flash)', 'icon' => cubeMedia::silk('application_view_tile.png')); - $versions['win-inss-html'] = array('title' => __('Version offline') . ' - ' . __('Executable Windows') . ' (HTML5)', 'icon' => cubeMedia::silk('application_view_tile.png')); - $versions['win-ins'] = array('title' => __('Version offline') . ' - ' . __('Installeur Auto-executable Windows') . ' (Flash)', 'icon' => cubeMedia::silk('application_view_tile.png')); - $versions['win-ins-html'] = array('title' => __('Version offline') . ' - ' . __('Installeur Auto-executable Windows') . ' (HTML5)', 'icon' => cubeMedia::silk('application_view_tile.png')); - $versions['mac-exe'] = array('title' => __('Version offline') . ' - ' . __('Exécutable Mac OS X') . ' (Flash)', 'icon' => cubeMedia::image(IMG . '/macos.png')); - $versions['mac-exe-html'] = array('title' => __('Version offline') . ' - ' . __('Exécutable Mac OS X') . ' (HTML)', 'icon' => cubeMedia::image(IMG . '/macos.png')); - $versions['win-cd'] = array('title' => __('Version offline') . ' - ' . __('CD-ROM') . ' / ' . __('Clé USB') . ' (Flash)', 'icon' => cubeMedia::silk('cd.png')); - $versions['win-cd-html'] = array('title' => __('Version offline') . ' - ' . __('CD-ROM') . ' / ' . __('Clé USB') . ' (HTML)', 'icon' => cubeMedia::silk('cd.png')); - - $versions['win-html'] = array('title' => __('Version offline') . ' - ' . __('HTML') . ' (' . __('Non adaptée à l\'installation sur un serveur web') . ')', 'icon' => cubeMedia::silk('cd.png')); - if ($droits->admin) { - $versions['phonegap'] = array('title' => __('Version offline') . ' - ' . __('Application mobile'), 'icon' => cubeMedia::image(IMG . '/phonegap.png')); - } - - if (!$select) { - return $versions; - } - - $res = array(); - foreach ($versions as $id => $d) { - $t = explode('-', $d['title'], 2); - $meta = trim($t[0]); - if (isset($t[1])) { - $title = trim($t[1]); - } else { - $title = $meta; - } - - if (!isset($res[$meta])) { - $res[$meta] = array(); - } - $res[$meta][$title] = $id; - } - return $res; - } - - public static function contextBookDownload($id, $droits, $book = null) - { - global $core; - - $versions = self::getFluidbookVersions(); - - if (null !== $book) { - $id .= '_' . $book->book_id; - } - - $res = '
'; - $res .= '
'; - return $res; - } - - public static function contextBookStatus($id) - { - global $core; - - if (wsDroits::admin()) { - $status = $core->books_status; - $status[2] = __('Facturé (associé à un projet)'); - } else { - $status = array(); - $status[-1] = $core->books_status[-1]; - $status[0] = $core->books_status[0]; - } - - $res = '
'; - $res .= '
'; - return $res; - } - - public static function contextBookView($id) - { - global $core; - - $viewers = array(array('type' => 'flash', 'version' => 'viewer', 'title' => __('Version Flash'), 'icon' => cubeMedia::image(IMG . '/flash.png')), - array('type' => 'html5', 'version' => 'viewerh', 'title' => __('Version HTML5'), 'icon' => cubeMedia::image(IMG . '/html5.png')), - array('type' => 'scorm', 'version' => 'viewers', 'title' => __('Version SCORM'), 'icon' => cubeMedia::image(IMG . '/html5.png')), - ); - - $res = '
'; - $res .= '
'; - return $res; - } - - public static function traductions($args) - { - global $core; - - commonDroits::min(5); - - if (count($args) < 2) { - $args[1] = 'fr'; - } - - $allLangs = cubeLang::getCodes($core->user->lang); - $allLangs['es-pr'] = 'Espagnol, Porto Rico'; - $existingLangs = array(); - - $dao = new wsDAOLang($core->con); - $langs = $dao->selectAll(); - foreach ($langs as $lang) { - if (!isset($allLangs[$lang->lang_id])) { - continue; - } - $existingLangs[$lang->lang_id] = $allLangs[$lang->lang_id]; - - unset($allLangs[$lang->lang_id]); - } - - $langs = array(__('Langues configurées') => array_flip($existingLangs), __('Autres langues') => array_flip($allLangs)); - - $res = commonPage::barre(); - $res .= commonPage::tMain(null, false); - - $res .= commonPage::bh(); - $res .= '
'; - $res .= ''; - $res .= ''; - $res .= '
' . __('Sélectionnez la langue à configurer') . ' : ' . form::combo('lang', $langs, $args[1]) . '
'; - $res .= '
'; - $res .= commonPage::bf(); - - $res .= '
'; - $res .= self::formLang($args[1]); - $res .= '
'; - $res .= commonPage::bMain(true); - - return $res; - } - - public static function formLang($lang_id) - { - commonDroits::min(5); - global $core; - $dao = new wsDAOLang($core->con); - $lang = $dao->selectById($lang_id); - - $res = commonPage::bh(); - $res .= ''; - $res .= ''; - $res .= '
' . __('Exporter au format Excel') . ''; - $res .= ' | ' . __('Exporter toutes les langues au format Excel') . ''; - $res .= '
'; - $res .= commonPage::bf(); - - $res .= '
'; - - $res .= commonPage::bh(); - $res .= ''; - $res .= ''; - $res .= ''; - $res .= ''; - $res .= ''; - $res .= '
' . __('Police de caractères') . ' : ' . form::hidden('lang', $lang_id) . form::combo('font', self::getFonts(), $lang->font) . '
' . __('Jeux de caractères') . ' : ' . form::combo('charset', self::getCharsets(), $lang->charset) . '
' . __("Langue de l'installeur") . ' : ' . form::combo('nsis', self::getNSISLangs(), $lang->nsis) . '
' . $core->typo->Ajouter('Valider') . '
'; - $res .= commonPage::bf(); - - $res .= commonPage::bh(); - $res .= cubeLang::translationForm(self::getTranslationSources(), $lang_id, null, 'liste', array(), '' . $core->typo->Ajouter(__('Enregistrer')) . '', $lang->traductions); - $res .= commonPage::bf(); - $res .= '
'; - return $res; - } - - public static function getTranslationSources() - { - return array(__('Version Flash') => PLAYER_SOURCES, __('Version HTML5') => WS_COMPILE_ASSETS . '/player/local', __('Compilateur HTML5') => ROOT . '/inc/ws/Util/html5', __('Application') => WS_COMPILE_ASSETS . '/_html5app'); - } - - public static function exportLangAsExcel($args) - { - global $core; - - $lang_id = $args[1]; - - $xls = new PHPExcel(); - $s = $xls->setActiveSheetIndex(0); - - $lang_name = self::exportLangAsSheet($s, $lang_id, 'en'); - - $xls->setActiveSheetIndex(0); - - ob_end_clean(); - files::registerMimeTypes(array('xlsx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet')); - cubeHTTP::forceDownload('Fluidbook_' . $lang_name . '.xlsx', false); - - $writer = new PHPExcel_Writer_Excel2007($xls); - $writer->save('php://output'); - - exit; - } - - public static function exportAllLangsAsExcel($args) - { - global $core; - - $xls = new PHPExcel(); - - $dao = new wsDAOLang($core->con); - $all = $dao->selectAll(); - - $i = 0; - foreach ($all as $l) { - try { - $s = $xls->getSheet($i); - } catch (Exception $e) { - $s = $xls->createSheet($i); - } - self::exportLangAsSheet($s, $l->lang_id, 'en'); - $i++; - } - - $xls->setActiveSheetIndex(0); - - ob_end_clean(); - files::registerMimeTypes(array('xlsx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet')); - cubeHTTP::forceDownload('Fluidbook_All_Languages.xlsx', false); - - $writer = new PHPExcel_Writer_Excel2007($xls); - $writer->save('php://output'); - exit; - } - - public static function exportLangAsSheet($s, $lang_id, $ref_id = 'en') - { - global $core; - $dao = new wsDAOLang($core->con); - - - $lang = $dao->selectById($lang_id); - $ref = $dao->selectById($ref_id); - - $lang_name = cubeLang::getNameByCode($lang_id, 'en'); - $ref_name = cubeLang::getNameByCode($ref_id, 'en'); - - $s->setTitle(cubeText::str2URL($lang_name)); - - $sources = []; - $ts = self::getTranslationSources(); - foreach ($ts as $item) { - $sources = array_merge($sources, $item); - } - - $tab = cubeLang::getTranslationsList(self::getTranslationSources(), array('php', 'as', 'js'), array(), $lang->traductions); - - $s->setCellValueByColumnAndRow(0, 1, 'ID', true); - $s->setCellValueByColumnAndRow(1, 1, $ref_name, true); - $s->setCellValueByColumnAndRow(2, 1, $lang_name, true); - - $j = 2; - foreach ($tab as $msgid => $msgstr) { - $s->setCellValueByColumnAndRow(0, $j, $msgid); - $s->setCellValueByColumnAndRow(1, $j, $ref->traductions[$msgid]); - $s->setCellValueByColumnAndRow(2, $j, $msgstr); - - if ($msgstr == '') { - $s->getStyleByColumnAndRow(2, $j)->getFill()->setFillType(PHPExcel_Style_Fill::FILL_SOLID); - $s->getStyleByColumnAndRow(2, $j)->getFill()->getStartColor()->setARGB('FFFFFF00'); - } - $j++; - } - - $s->getColumnDimensionByColumn(0)->setAutoSize(true); - $s->getColumnDimensionByColumn(1)->setAutoSize(true); - $s->getColumnDimensionByColumn(2)->setAutoSize(true); - - return $lang_name; - } - - public static function getFonts() - { - $formats = array('ttf', 'otf', 'TTF', 'OTF'); - - $dr = opendir(FONT_PATH); - $fonts = array('Arial (police système)' => "system"); - while ($file = readdir($dr)) { - if ($file == '.' || $file == '..' || !in_array(files::getExtension($file), $formats)) { - continue; - } - $fonts[$file] = $file; - } - return $fonts; - } - - protected static function getCharsets() - { - $sets = cubeFlexFontAsset::getSets(); - $res = array(); - foreach ($sets as $k => $v) { - $res[$k] = $k; - } - return $res; - } - - protected static function getNSISLangs() - { - $res = array(); - $dir = WS_FILES . '/nsislangs'; - $dr = opendir($dir); - while ($file = readdir($dr)) { - if ($file == '.' || $file == '..') { - continue; - } - $e = explode('.', $file); - $res[$e[0]] = $e[0]; - } - - ksort($res); - return $res; - } - - public static function editor($args) - { - commonDroits::min(1); - - global $core; - - $args = cubePage::getArgs($args); - $e = explode('_', $args[0]); - $book_id = $e[0]; - $hash = isset($e[1]) ? $e[1] : ''; - - - self::checkDocumentVersionOfBook($book_id); - - if ($book_id == 'new') { - $dao = new wsDAOBook($core->con); - $book = $dao->creeEmpty($core->user->utilisateur_id, $core->user->lang); - http::redirect(SITE_PATH . 'editor/' . $book->book_id . '_' . $book->hash); - } - - $res = ''; - $res .= '' . __('Edition de la publication') . ' #' . $args[0] . ''; - $res .= ''; - $res .= ''; - $res .= self::editComposition($book_id, $hash); - $res .= ''; - $res .= ''; - echo $res; - } - - /** - * wsUrl::restoreLinks() - * - * @param mixed $args - * @return - */ - public static function restoreLinks($args) - { - commonDroits::min(1); - - global $core; - - $args = cubePage::getArgs($args); - $book_id = $args[0]; - - - $dao = new wsDAODocument($core->con); - $updates = $dao->getLinksVersions($book_id); - krsort($updates); - - $res = ''; - $res .= '' . __('Restauration des liens de la publication') . ' #' . $args[0] . ''; - $res .= ''; - $res .= ''; - $res .= ''; - $res .= ''; - $res .= ''; - - echo $res; - } - - public static function exportLinksAsExcel($args) - { - global $core; - - cubePHP::neverStop(); - - $book_id = $args[1]; - $time = $args[2]; - - $dao = new wsDAODocument($core->con); - $dao->getLinksAndRulers($book_id, $links, $rulers, $time); - $xls = $dao->getLinksAsExcel($links, $rulers); - - ob_end_clean(); - files::registerMimeTypes(array('xlsx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet')); - cubeHTTP::forceDownload('links_' . $book_id . '_' . $time . '.xlsx', false); - - $writer = new PHPExcel_Writer_Excel2007($xls); - $writer->save('php://output'); - - exit; - } - - public static function editComposition($book_id, $hash) - { - - $fv = array(session_name() => session_id(), - 'book_id' => $book_id, - 'hash' => $hash, - 'url' => '/'); - - $mtime = filemtime(ROOT . '/swf/composer.swf'); - return cubeMedia::flash2(WEBROOT . '/swf/composer.swf?junk=' . $mtime, '100%', '100%', $fv, 'composerSwf', 'swfPanel', 10, '#d2d3c7', '', 'false', 'noscale', 'normal', array(), false, true, false); - } - - public static function stats($args) - { - global $core; - $bid = (isset($args[1])) ? $args[1] : null; - - list($bid, $hash) = explode('_', $bid); - - $r = $core->con->select('SELECT * FROM books WHERE book_id=\'' . $core->con->escape($bid) . '\' AND hash=\'' . $core->con->escape($hash) . '\''); - if (!$r->count()) { - return; - } - - $annee = (isset($args[2])) ? $args[2] : null; - $mois = (isset($args[3])) ? $args[3] : null; - return wsStats::display($bid . '_' . $hash, $annee, $mois); - } - - public static function viewerh($args) - { - global $core; - - $args = cubePage::getArgs($args); - - $e = explode('_', $args[0]); - - $book_id = $e[0]; - $hash = $e[1]; - - $dao = new wsDAOBook($core->con); - - $book = $dao->selectById($book_id); - if ($hash != 'bcf26f9cf4a795ec00b9a44f42750d58' && $book->hash != $hash) { - commonDroits::error(); - } - - if (!wsDroits::admin()) { - if ($book->parametres->redirectDemo != '') { - http::redirect($book->parametres->redirectDemo); - exit; - } - if ($book->parametres->disableDemo) { - commonDroits::error(); - } - } - - $time = TIME; - if (count($e) == 2) { - $e[2] = $time; - http::redirect(SITE_PATH . 'viewerh/' . implode('_', $e) . '/'); - exit; - } - - $dao->compile($book_id, 'html5', false, false, false, null, false); - - $book_id = $e[0]; - $hash = $e[1]; - self::commonHTML5Viewer($book_id, $hash); - } - - - public static function viewers($args) - { - global $core; - - $args = cubePage::getArgs($args); - - $e = explode('_', $args[0]); - - $book_id = $e[0]; - $hash = $e[1]; - - $dao = new wsDAOBook($core->con); - - $book = $dao->selectById($book_id); - if ($hash != 'bcf26f9cf4a795ec00b9a44f42750d58' && $book->hash != $hash) { - commonDroits::error(); - } - - if (!wsDroits::admin()) { - if ($book->parametres->redirectDemo != '') { - http::redirect($book->parametres->redirectDemo); - exit; - } - if ($book->parametres->disableDemo) { - commonDroits::error(); - } - } - - $dao->compile($book_id, 'html5'); - $time = TIME; - - if (count($e) == 2 || $e[2] <= $time - 10) { - $e[2] = $time; - http::redirect(SITE_PATH . 'viewers/' . implode('_', $e) . '/'); - exit; - } - - $book_id = $e[0]; - $hash = $e[1]; - self::commonHTML5Viewer($book_id, $hash, '', ['' => '']); - } - - public static function commonHTML5Viewer($book_id, $hash, $version = '', $replace = []) - { - global $core; - self::checkDocumentVersionOfBook($book_id); - - $dao = new wsDAOBook($core->con); - $dir = ''; - - $book = $dao->selectById($book_id); - if ($hash != 'bcf26f9cf4a795ec00b9a44f42750d58' && $book->hash != $hash) { - commonDroits::error(); - } - - if (!wsDroits::admin()) { - if ($book->parametres->redirectDemo != '') { - http::redirect($book->parametres->redirectDemo); - exit; - } - if ($book->parametres->disableDemo) { - commonDroits::error(); - } - } - - self::logReferer($book_id); - $html = file_get_contents(WS_BOOKS . '/html5' . $dir . '/' . $book_id . '/index' . $version . '.html'); - foreach ($replace as $from => $to) { - $html = str_replace($from, $to, $html); - } - echo $html; - exit; - } - - public static function viewer($args) - { - $args = cubePage::getArgs($args); - - $qs = ''; - if (isset($_SERVER['QUERY_STRING']) && !empty($_SERVER['QUERY_STRING'])) { - $qs = '?' . $_SERVER['QUERY_STRING']; - } - - $e = explode('_', $args[0]); - $newurl = null; - if (count($e) == 2 || $e[2] < TIME - 10) { - $e[2] = TIME; - http::redirect(SITE_PATH . 'viewer/' . implode('_', $e) . '/' . $qs); - exit; - } - - $book_id = $e[0]; - - $wmode = (isset($wmode) && $wmode != '') ? $wmode : 'default'; - - self::checkDocumentVersionOfBook($book_id); - wsSecureSWF::checkProtectedSWF(); - - echo self::commonViewer($book_id, $e[1], false, $wmode, $newurl); - } - - public static function commonViewer($book_id, $hash, $standalone = false, $wmode = 'default', $fps = false, $version = 2) - { - if (!defined('MINIMIZE_JS')) { - define('MINIMIZE_JS', false); - } - if (!defined('MINIMIZE_CSS')) { - define('MINIMIZE_CSS', false); - } - if (!defined('JQUERY')) { - define('JQUERY', false); - } - - global $core; - global $css; - global $js; - global $standard; - global $meta; - global $jsvar; - - if ($version == 2) { - $flashVersion = '10.0.22'; - } else { - $flashVersion = '8'; - } - - cubePage::swfobject(2); - - $dao = new wsDAOBook($core->con); - $book = $dao->selectById($book_id); - - if (!wsDroits::admin()) { - if ($book->parametres->redirectDemo != '') { - http::redirect($book->parametres->redirectDemo); - exit; - } - if ($book->parametres->disableDemo) { - commonDroits::error(); - } - } - - if ($hash != 'bcf26f9cf4a795ec00b9a44f42750d58' && $book->hash != $hash) { - commonDroits::error(); - } - - - if (is_null($core->user)) { - $dao->addDemoCount($book_id); - } - - $dao->compile($book_id, (string)$version); - - $daoTheme = new wsDAOTheme($core->con); - $theme = $daoTheme->selectById($book->theme, 'themes'); - - $webcompile = WEBROOT . '/fluidbook/compile/'; - - $standard = 'XHTML 1.0 Transitional'; - $css = $js = array(); - $css[] = $webcompile . 'style.css'; - $fv = $_GET; - if ($standalone) { - $fv['base'] = $_SERVER['REQUEST_URI']; - } - if ($fps) { - $fv['monitoring'] = '1'; - } - - if ($version == 1) { - $fv['id'] = $book_id; - $fv['mail'] = '0'; - $fv['onlineFlag'] = '1'; - $fv['loaderColor'] = $theme->parametres->loadingBackColor; - } - - $res = ''; - $res .= ''; - $res .= '' . $book->parametres->title . ''; - $res .= ''; - $res .= ''; - // Entêtes Facebook - $meta['og:title'] = ($book->parametres->facebook_title == '') ? $book->parametres->title : $book->parametres->facebook_title; - if ($book->parametres->facebook_description != '') { - $meta['og:description'] = $book->parametres->facebook_description; - } - $meta['og:image'] = 'https://workshop.fluidbook.com/services/facebook_thumbnail?id=' . $book->book_id . '&j=' . TIME; - - - $redirectPDF = 'window.location="data/document.pdf"'; - - if ($book->parametres->mobileVersion == 'pdf') { - $redirectMobile = $redirectPDF; - } else { - $redirectMobile = 'window.location="/viewerh/' . $book_id . '_' . $hash . '_' . TIME . '/";'; - } - - $alt = '
' . cubeMedia::image($webcompile . 'getflash.gif', 734, 409, '') . '
'; - - $res .= ''; - $res .= ''; - $res .= '
'; - $res .= "\n" . ''; - $js = array('fluidbook.js'); - $jsvar = array(); - - $gacodes = array(GA); - if ($book->parametres->googleAnalytics != '') { - $gacodes[] = $book->parametres->googleAnalytics; - } - $res .= cubePage::googleAnalytics($gacodes, false); - $res .= ''; - $res .= ''; - - self::logReferer($book_id); - - return $res; - } - - public static function logReferer($id) - { - - if (!isset($_SERVER['HTTP_REFERER']) || !$_SERVER['HTTP_REFERER']) { - $r = ''; - } else { - $r = $_SERVER['HTTP_REFERER']; - } - - fb($r, $id); - - global $core; - $rr = $core->con->select('SELECT * FROM books_referer WHERE book_id=\'' . $core->con->escape($id) . '\' AND referer=\'' . $core->con->escape($r) . '\''); - $c = $core->con->openCursor('books_referer'); - if (!$rr->count()) { - $c->book_id = $id; - $c->referer = $r; - $c->count = 1; - $c->insert(); - } else { - $rr->fetch(); - $c->count = $rr->count + 1; - $c->update('WHERE book_id=\'' . $core->con->escape($id) . '\' AND referer=\'' . $core->con->escape($r) . '\''); - } - } - - public static function statsxls($args) - { - $bid = (isset($args[1])) ? $args[1] : null; - $annee = (isset($args[2])) ? $args[2] : null; - $mois = (isset($args[3])) ? $args[3] : null; - wsStats::exportXLS($bid, $annee, $mois); - } - - public static function chooseExistingBook() - { - wsDroits::creation(true); - $res = '

a' . __("Si votre nouvelle publication a des paramètres en commun avec une publication existante, veuillez rechercher cette publication afin d'attribuer par défaut à votre nouvelle publication les paramètres de l'existante") . '

'; - $res .= '' . __('Rechercher une publication') . ' : ' . form::field('book_nom', 64, 1024) . form::hidden('book', '') . ''; - $res .= '' . __('Indiquez le titre de votre nouvelle publication') . '' . form::field('title', 64, 1024) . ''; - $res .= '