From 0b441d3d8a28de4d8f201f604f733922aa6cc3b6 Mon Sep 17 00:00:00 2001 From: "vincent@cubedesigners.com" Date: Mon, 5 Sep 2011 10:03:10 +0000 Subject: [PATCH] --- inc/ws/Controlleur/class.ws.flash.php | 1282 +++++++++-------- .../class.ws.document.conversioninfos.php | 30 +- inc/ws/Metier/class.ws.document.php | 22 +- 3 files changed, 675 insertions(+), 659 deletions(-) diff --git a/inc/ws/Controlleur/class.ws.flash.php b/inc/ws/Controlleur/class.ws.flash.php index d9a59289d..d12254a27 100644 --- a/inc/ws/Controlleur/class.ws.flash.php +++ b/inc/ws/Controlleur/class.ws.flash.php @@ -1,645 +1,649 @@ con, $args); - - $droits = wsDroits::getDroits(); - $gateway->addAttribute('creation', $droits->creation ? '1' : '0'); - $gateway->addAttribute('revendeur', $droits->revendeur ? '1' : '0'); - $gateway->addAttribute('admin', $droits->admin ? '1' : '0'); - $gateway->addAttribute('grade', $core->user->ws_grade); - } - - public function saveConversionSettings() { - global $core; - $dao = new commonDAOUtilisateur($core->con); - $datas = array('resolution' => $this->args['resolution'], - 'objects' => $this->args['objects'], - 'method' => $this->args['method'], - 'quality' => $this->args['quality']); - $dao->sauveWSSettings($core->user->utilisateur_id, $datas); - } - - public function getConversionSettings() { - global $core; - $this->xml->addChild('resolution', $core->user->ws_settings['resolution']); - $this->xml->addChild('quality', $core->user->ws_settings['quality']); - $this->xml->addChild('method', $core->user->ws_settings['method']); - $this->xml->addChild('objects', $core->user->ws_settings['objects']); - } - - public function uploadDocument() { - cubePHP::neverStop(); - global $core; - if (!isset($_SESSION['conversionSession'])) { - $_SESSION['conversionSession'] = array(); - } - $dao = new wsDAODocument($core->con); - foreach ($_FILES as $varname => $infos) { - if ($infos['error']) { - continue; - } - // Initialisation du document - $data = array(); - $data['proprietaire'] = $core->user->utilisateur_id; - $data['pages'] = 0; - $data['version'] = 2; - $data['file'] = cubeFiles::tidyName($infos['name']); - $li = new wsDocumentLocalInfos($this); - $li->fileName = $this->args['fileName']; - $li->fileSize = $this->args['fileSize']; - $li->creationDate = $this->args['creationDate']; - $li->modificationDate = $this->args['modificationDate']; - $data['localInfos'] = $li; - $data['conversionInfos'] = new wsDocumentConversionInfos($this->args['resolution'], $this->args['method'], $this->args['quality'], $this->args['objects']); - $document = $dao->sauve($data); - $document->copyOriginalFromUpload($infos['tmp_name']); - $this->xml->addChild('document_id', $document->document_id); - $_SESSION['conversionSession'][$document->document_id] = 'all'; - $_SESSION['conversionSessionReload'] = false; - } - } - - public function addDocument() { - $_SESSION['conversionSession'] = array(); - $_SESSION['conversionSession'][$this->args['document_id']] = 'all'; - $_SESSION['conversionSessionReload'] = false; - } - - public function reload() { - global $core; - - if ($this->args['reloadDocs'] == '1') { - foreach ($this->args['documents'] as $document_id => $pages) { - $this->args['documents'][$document_id] = 'all'; - } - } - - $dao = new wsDAODocument($core->con); - $_SESSION['conversionSession'] = $this->args['documents']; - $_SESSION['conversionSessionReload'] = true; - foreach ($this->args['documents'] as $id => $pages) { - $doc = $dao->selectById($id); - $doc->conversionInfos->updatePages($pages, $this->args['resolution'], $this->args['quality'], $this->args['method'], $this->args['objects']); - $dao->updateFromObject($doc); - } - } - - public function processConversionSession() { - $_SESSION['sessionConversionGUID'] = $sessionConversionGUID = uniqid('conversion_', true); - $session = new wsConversionSession($sessionConversionGUID); - $session->reload = $_SESSION['conversionSessionReload']; - $session->setDocuments($_SESSION['conversionSession']); - $session->setBook($this->args['book_id']); - unset($_SESSION['conversionSession']); - unset($_SESSION['conversionSessionReload']); - $session->serialize(); - - $php = new cubeCommandLine('php'); - $php->setPath(CONVERTER_PATH); - $php->setArg('f', ROOT . '/index.php'); - $php->setManualArg('--'); - $php->setArg('user_email', $_SESSION['user_email']); - $php->setArg('user_password', $_SESSION['user_password']); - $php->setArg('sessionConversionGUID', $sessionConversionGUID); - $php->setArg('PATH_INFO', '/flash/processConversionSessionAsync'); - $php->setArg('HTTP_HOST', $_SERVER['HTTP_HOST']); - $php->setNohup(true); - $php->execute('exec'); - - $this->xml->addChild('command', html::escapeHTML($php->command)); - exit; - } - - public function processConversionSessionAsync() { - cubePHP::neverStop(); - try { - $conversion = wsConversionSession::openFromGUID($_REQUEST['sessionConversionGUID']); - $conversion->process(); - } catch (Exception $e) { - file_put_contents(CACHE . '/conversionExceptions.txt', print_r($e, true), FILE_APPEND); - } - $conversion->destroy(); - } - - public function getConversionSessionProgress() { - set_time_limit(1); - $session = wsConversionSession::openFromGUID($_SESSION['sessionConversionGUID']); - $p = $session->getProgress(); - $this->xml->addChild('progress', $p['progress']); - $this->xml->addChild('processedDoc', $p['processedDoc']); - $this->xml->addChild('totalDoc', $p['totalDoc']); - $this->xml->addChild('currentDoc', $p['currentDoc']); - $this->xml->addChild('currentDocPage', $p['currentDocPage']); - $this->xml->addChild('totalDocPage', $p['totalDocPage']); - } - - public function uploadThemeFile() { - foreach ($_FILES as $varname => $infos) { - if ($infos['error']) { - continue; - } - $fname = cubeFiles::tidyName($infos['name']); - $dest = '/' . $this->args['theme_id'] . '/' . $fname; - - if (!file_exists(WS_THEMES . '/' . $this->args['theme_id'])) { - mkdir(WS_THEMES . '/' . $this->args['theme_id'], 0755, true); - } - - move_uploaded_file($infos['tmp_name'], WS_THEMES . $dest); - $this->xml->addChild('file', $fname); - return; - } - } - - public function uploadLinkContent() { - foreach ($_FILES as $varname => $infos) { - if ($infos['error']) { - continue; - } - - if (isset($_POST['dir'])) { - $dir = trim($_POST['dir'], '/\\ '); - } else { - $dir = ''; - } - - if ($dir != '') { - $dir = $dir . '/'; - } - - $fname = cubeFiles::tidyName($infos['name']); - $dir = WS_BOOKS . '/working/' . $this->args['book_id'] . '/' . $dir; - if (!file_exists($dir)) { - mkdir($dir, 0777, true); - } - $dest = $dir . $fname; - move_uploaded_file($infos['tmp_name'], $dest); - if (in_array(strtolower(files::getExtension($dest)), array('flv', 'f4v', 'mp4'))) { - // convert uploaded file as webvideo (ogv and mp4) - wsTools::encodeWebVideos($dest, null, true, false); - } - $this->xml->addChild('file', $fname); - return; - } - } - - public function testDocuments() { - global $core; - - $toload = $this->xml->addChild('toLoad'); - $alreadyLoaded = $this->xml->addChild('alreadyLoaded'); - - $hash = array(); - - foreach ($this->args['fileName'] as $k => $name) { - $o = new wsDocumentLocalInfos(); - $o->fileName = $name; - $o->fileSize = intval($this->args['fileSize'][$k]); - $o->modificationDate = intval($this->args['modificationDate'][$k]); - $o->creationDate = intval($this->args['creationDate'][$k]); - - $hash[$k] = md5(serialize($o)); - } - - $in = array(); - foreach ($hash as $h) { - $in[] = "'" . $h . "'"; - } - - $sql = 'SELECT document_id,localHash FROM documents WHERE localHash'; - if (count($in) == 1) { - $sql .= ' = ' . implode(',', $in); - } else { - $sql .= ' IN (' . implode(',', $in) . ')'; - } - - $al = array(); - $r = $core->con->select($sql); - while ($r->fetch()) { - $k = array_search($r->localHash, $hash); - - if (!file_exists(WS_DOCS . '/' . $r->document_id . '/original.pdf')) { - continue; - } - - $al[$k] = true; - $f = $alreadyLoaded->addChild('file', $this->args['fileName'][$k]); - $f->addAttribute('document_id', $r->document_id); - } - - foreach ($this->args['fileName'] as $k => $name) { - if (!isset($al[$k])) { - $toload->addChild('file', $name); - } - } - } - - public function getPagesOfBook() { - global $core; - $dao = new wsDAOBook($core->con); - $book = $dao->selectById($this->args['book_id']); - $pages = $dao->getPagesOfBook($this->args['book_id']); - $p = $this->xml->addChild('pages'); - $docs = array(); - $defaultNum = array(); - foreach ($pages as $page => $info) { - $file = WS_DOCS . '/' . $info['document_id'] . '/p' . $info['document_page'] . '.jpg'; - if (!file_exists($file)) { - $dim = array(0, 0); - $info['resolution'] = 150; - $info['method'] = 1; - $info['objects'] = 1800; - $info['quality'] = 85; - } else { - $dim = getimagesize($file); - } - - - - $pa = $p->addChild('page'); - $pa->addAttribute('page', $page); - $pa->addAttribute('document_id', $info['document_id']); - $pa->addAttribute('document_page', $info['document_page']); - $pa->addAttribute('width', $dim[0]); - $pa->addAttribute('height', $dim[1]); - $pa->addAttribute('resolution', $info['resolution']); - $pa->addAttribute('quality', $info['quality']); - $pa->addAttribute('methode', $info['method']); - $pa->addAttribute('objects', $info['objects']); - $docs[] = $info['document_id']; - $defaultNum[] = $info['defaultNum']; - } - $docs = array_unique($docs); - $p->addAttribute('documents', implode(',', $docs)); - if (is_null($book->numerotation) || !$book->numerotation || $book->numerotation == 'null') { - $this->xml->addChild('numerotation', implode(',', $defaultNum)); - } else { - $this->xml->addChild('numerotation', $book->numerotation); - } - } - - public function getTheme() { - global $core; - $dao = new wsDAOTheme($core->con); - if (isset($this->args['theme_id'])) { - $theme = $dao->selectById($this->args['theme_id']); - } else { - $theme = $dao->getThemeOfBook($this->args['book_id']); - } - $this->_themeToXML($theme); - } - - public function saveTheme() { - global $core; - $dao = new wsDAOTheme($core->con); - $dao->sauve($this->args); - } - - public function getAllThemes() { - global $core; - - if (isset($this->args['book_id'])) { - $dao = new wsDAOBook($core->con); - $book = $dao->selectById($this->args['book_id']); - } else { - $this->args['book_id'] = 0; - } - - $dao = new wsDAOTheme($core->con); - $themes = $dao->getAllThemes($core->user, 'ORDER BY FIELD (theme_id,' . $this->args['book_id'] . ',1) DESC, theme_id DESC', true); - foreach ($themes as $theme) { - $t = $this->xml->addChild('theme'); - $t->addAttribute('id', $theme->theme_id); - $t->addAttribute('nom', $theme->nom); - if (isset($book) && $theme->theme_id == $book->theme) { - $t->addAttribute('selected', '1'); - $mine = true; - } else { - $mine = false; - } - if (wsDroits::revendeur() && wsDroits::creation()) { - $right = 'w'; - } else { - $right = 'r'; - } - $t->addAttribute('right', $right); - $t->addAttribute('proprietaire', $theme->proprietaire_nom); - $t->addAttribute('books', max(($theme->nbBooks) - ($mine ? 1 : 0), 0)); - } - } - - public function deleteTheme() { - global $core; - - $dao = new wsDAOTheme($core->con); - $dao->delete($this->args['theme_id']); - } - - public function renameTheme() { - global $core; - - $dao = new wsDAOTheme($core->con); - $dao->rename($this->args['theme_id'], $this->args['text']); - } - - public function duplicateTheme() { - global $core; - $dao = new wsDAOTheme($core->con); - $theme = $dao->duplicate($this->args['theme_id'], $core->user->utilisateur_id); - $this->xml->addChild('theme_id', $theme->theme_id); - if (isset($this->args['book_id'])) { - $dao = new wsDAOBook($core->con); - $data = array('book_id' => $this->args['book_id'], 'theme' => $theme->theme_id); - $dao->sauve($core->user->utilisateur_id, $data); - } - } - - public function setTheme() { - global $core; - $dao = new wsDAOBook($core->con); - $dao->setTheme($this->args['book_id'], $this->args['theme']); - } - - public function postThemeShot() { - file_put_contents(WS_THEMES . '/' . $this->args['theme_id'] . '.jpg', base64_decode($this->args['data'])); - } - - public function getAllIcones() { - global $core; - $dao = new wsDAOIcone($core->con); - $icones = $dao->selectAll('ORDER BY icone_id DESC'); - foreach ($icones as $icone) { - $i = $this->xml->addChild('icone'); - $i->addAttribute('id', $icone->icone_id); - $i->addAttribute('nom', $icone->nom); - $i->addAttribute('path', ICONS . $icone->icone_id . '.png'); - } - } - - protected function _themeToXML($theme) { - $t = $this->xml->addChild('theme'); - $t->addAttribute('theme_id', $theme->theme_id); - $t->addAttribute('icones_id', $theme->icones); - foreach ($theme->parametres as $k => $v) { - $t->addChild($k, $v); - } - } - - public function getThemeForms() { - global $core; - $dao = new wsDAOTheme($core->con); - $theme = $dao->selectById($this->args['theme_id']); - - foreach ($theme->parametres->getForms() as $name) { - $f = $this->xml->addChild('form', json_encode($theme->parametres->getForm($name))); - $f->addAttribute('name', $name); - } - } - - public function getFluidbookForms() { - global $core; - $dao = new wsDAOBook($core->con); - $book = $dao->selectById($this->args['book_id']); - foreach ($book->parametres->getForms() as $name) { - $f = $this->xml->addChild('form', html::escapeHTML(json_encode($book->parametres->getForm($name)))); - $f->addAttribute('name', $name); - } - } - - public function saveSettings() { - global $core; - $dao = new wsDAOBook($core->con); - $dao->setSettings($this->args['book_id'], $this->args['settings']); - } - - public function setChapters() { - global $core; - $dao = new wsDAOBook($core->con); - $dao->setChapters($this->args['book_id'], $this->args['chapters']); - } - - public function getChapters() { - global $core; - $dao = new wsDAOBook($core->con); - $book = $dao->selectById($this->args['book_id']); - $this->xml->addChild('chapters', html::escapeHTML(json_encode($book->chapters))); - } - - public function getLinks() { - global $core; - $dao = new wsDAOBook($core->con); - $book = $dao->selectById($this->args['book_id']); - - $pages = $dao->getPagesOfBook($this->args['book_id']); - $nb_pages = count($pages); - $this->xml->addChild('pages', $nb_pages); - $this->xml->addChild('numerotation', $book->numerotation); - - $daoDoc = new wsDAODocument($core->con); - $firstDoc = $daoDoc->selectById($pages[1]['document_id']); - $size = $firstDoc->generalInfos['size']; - $daoDoc->getLinksAndRulers($this->args['book_id'], $links, $rulers); - - $this->xml->addChild('width', $size[0]); - $this->xml->addChild('height', $size[1]); - $this->xml->addChild('links', html::escapeHTML(json_encode($links))); - $this->xml->addChild('rulers', json_encode($rulers)); - - $daoTheme = new wsDAOTheme($this->con); - $theme = $daoTheme->getThemeOfBook($this->args['book_id'], true); - - $specials = array('backgroundImage' => 'background', 'topBar' => 'topbar', 'afterSearch' => 'aftersearch'); - - foreach ($specials as $tparam => $sname) { - $this->_addSpecialInfos($theme, $tparam, $sname); - } - } - - protected function _addSpecialInfos($theme, $param, $specialName) { - if ($theme->parametres->$param != '') { - $themeRoot = WS_THEMES . '/' . $theme->theme_id . '/'; - $dim = getimagesize($themeRoot . $theme->parametres->$param); - $b = $this->xml->addChild($specialName); - $b->addChild('width', $dim[0]); - $b->addChild('height', $dim[1]); - $b->addChild('url', 'http://' . $_SERVER['HTTP_HOST'] . WEBROOT . '/fluidbook/themes/' . $theme->theme_id . '/' . $theme->parametres->$param); - } - } - - public function saveLinks() { - global $core; - - $comments = isset($this->args['comments']) ? $this->args['comments'] : 'Saved from editor'; - - $dao = new wsDAODocument($core->con); - $dao->setLinksAndRulers($this->args['book_id'], $this->args['links'], $this->args['rulers'], $comments, $core->user->utilisateur_id); - - $daoBook = new wsDAOBook($core->con); - $daoBook->setSpecialLinksAndRulers($this->args['book_id'], $this->args['specialLinks'], $this->args['specialRulers']); - - if (isset($this->args['getLinks'])) { - $this->getLinks(); - } - } - - public function formatSize($val) { - $str = files::size($val); - $str = str_replace('.', __(','), $str); - $str = str_replace('B', __('o'), $str); - return $str; - } - - public function getExtras() { - global $core; - $dao = new wsDAOBook($core->con); - $book = $dao->selectById($this->args['book_id']); - if ($book->extras != '') { - $tidy = cubeXML::tidy('' . $book->extras . ''); - $tidy = str_replace('', '', $tidy); - $tidy = str_replace('', '', $tidy); - $tidy = str_replace('', '', $tidy); - $tidy = trim($tidy); - $e = explode("\n", $tidy); - foreach ($e as $k => $v) { - if (substr($v, 0, 2) == ' ') { - $v = substr($v, 2); - } - $e[$k] = $v; - } - - $extras = implode("\n", $e); - } else { - $extras = ''; - } - - $this->xml->addChild('extras', $extras); - } - - public function saveExtras() { - global $core; - $dao = new wsDAOBook($core->con); - $res = $dao->setExtras($this->args['book_id'], $this->args['extras']); - $this->xml->addChild('ok', $res ? '1' : '0'); - } - - public function getBookInfos() { - global $core; - $dao = new wsDAOBook($core->con); - $book = $dao->selectById($this->args['book_id']); - $pages = $dao->getPagesOfBook($this->args['book_id']); - $daoDoc = new wsDAODocument($core->con); - $nb_pages = count($pages); - $this->xml->addChild('pages', $nb_pages); - $total_size = 0; - foreach ($pages as $page => $info) { - $file = WS_DOCS . '/' . $info['document_id'] . '/p' . $info['document_page'] . '.swf'; - $total_size += filesize($file); - } - $average_size = $total_size / $nb_pages; - $total = self::formatSize($total_size); - $average = self::formatSize($average_size); - $firstDoc = $daoDoc->selectById($pages[1]['document_id']); - $size = $firstDoc->generalInfos['size']; - $this->xml->addChild('width', $size[0]); - $this->xml->addChild('height', $size[1]); - $res = __('Nombre de pages') . ' : ' . "\n"; - $res .= $nb_pages . ' ' . __('pages') . "\n"; - $res .= "\n"; - $res .= __('Dimensions') . ' : ' . "\n"; - $res .= round($size[0], 3) . ' x ' . round($size[1], 3) . ' pts' . "\n"; - $res .= "\n"; - $res .= __('Taille totale des pages') . ' : ' . "\n"; - $res .= $total . "\n"; - $res .= "\n"; - $res .= __('Taille moyenne des pages') . ' : ' . "\n"; - $res .= $average . "\n"; - $res .= "\n"; - /* $res .= __('Taille du PDF') . ' : ' . "\n"; - $res .= '7898 Ko' . "\n"; - $res .= "\n"; - $res .= __('Qualité de conversion') . ' : ' . "\n"; - $res .= '150dpi (qualité 85%)' . "\n"; */ - $this->xml->addChild('infos', $res); - } - - public function getLangs() { - global $core; - if (isset($this->args['book_id'])) { - $dao = new wsDAOBook($core->con); - $book = $dao->selectById($this->args['book_id']); - $book->traductions = wsLang::checkTranslations($book->traductions); - if ($book->traductions != array()) { - $bookLang = $this->xml->addChild('book_lang', json_encode($book->traductions)); - } - } - - $dao = new wsDAOLang($core->con); - $langs = $dao->selectAll(); - foreach ($langs as $lang) { - $nom = cubeLang::getNameByCode($lang->lang_id, $core->user->lang); - $l = $this->xml->addChild('lang', json_encode($lang->traductions)); - $l->addAttribute('id', $lang->lang_id); - $l->addAttribute('nom', $nom); - if (isset($book) && $book->lang == $lang->lang_id) { - if (!isset($bookLang)) { - $l->addAttribute('selected', '1'); - } else { - $bookLang->addAttribute('id', $lang->lang_id); - $bookLang->addAttribute('nom', $nom . ' (' . __('modifié') . ')'); - $bookLang->addAttribute('selected', '1'); - } - } - } - } - - public function saveLang() { - global $core; - $dao = new wsDAOBook($core->con); - $dao->setLang($this->args['book_id'], $this->args['lang_id'], $this->args['traductions']); - } - - public function saveComposition() { - global $core; - $dao = new wsDAOBook($core->con); - $dao->setComposition($this->args['book_id'], json_decode($this->args['pages'])); - } - - public function getTexts() { - $this->xml->addChild('texts', json_encode($GLOBALS['__l10n'])); - } - - public function copyLinks() { - global $core; - $daoDocument = new wsDAODocument($core->con); - $daoDocument->copyLinks($this->args['fromDoc'], $this->args['toDoc']); - } - - public function compile() { - global $core; - wsSecureSWF::checkProtectedSWF(); - $dao = new wsDAOBook($core->con); - if (!$dao->isUpToDate($this->args['book_id'])) { - $log = $dao->compile($this->args['book_id'], 3); - $log = str_replace('&', '&', $log); - $log = str_replace('&', '&', $log); - // $this->xml->addChild('log', $log); - } - $book = $dao->selectById($this->args['book_id']); - $viewer = 'viewer'; - if (wsDroits::admin()) { - $viewer = 'vieweru'; - } - - $absoluteURL = 'http://' . $_SERVER['HTTP_HOST'] . '/' . $viewer . '/' . $book->book_id . '_' . $book->hash . '_' . TIME . '/'; - $this->xml->addChild('compiledBook', $absoluteURL . 'index.swf?base=' . $absoluteURL); - } + const CNAME = __CLASS__; + + public static function in($args) { + global $core; + $args = cubePage::getArgs($args); + $n = self::CNAME; + $gateway = new $n($core->con, $args); + + $droits = wsDroits::getDroits(); + $gateway->addAttribute('creation', $droits->creation ? '1' : '0'); + $gateway->addAttribute('revendeur', $droits->revendeur ? '1' : '0'); + $gateway->addAttribute('admin', $droits->admin ? '1' : '0'); + $gateway->addAttribute('grade', $core->user->ws_grade); + } + + public function saveConversionSettings() { + global $core; + $dao = new commonDAOUtilisateur($core->con); + $datas = array('resolution' => $this->args['resolution'], + 'objects' => $this->args['objects'], + 'method' => $this->args['method'], + 'quality' => $this->args['quality'], + 'version' => $this->args['version']); + $dao->sauveWSSettings($core->user->utilisateur_id, $datas); + } + + public function getConversionSettings() { + global $core; + $this->xml->addChild('resolution', $core->user->ws_settings['resolution']); + $this->xml->addChild('quality', $core->user->ws_settings['quality']); + $this->xml->addChild('method', $core->user->ws_settings['method']); + $this->xml->addChild('objects', $core->user->ws_settings['objects']); + $this->xml->addChild('version', $core->user->ws_settings['version']); + } + + public function uploadDocument() { + cubePHP::neverStop(); + global $core; + if (!isset($_SESSION['conversionSession'])) { + $_SESSION['conversionSession'] = array(); + } + $dao = new wsDAODocument($core->con); + foreach ($_FILES as $varname => $infos) { + if ($infos['error']) { + continue; + } + // Initialisation du document + $data = array(); + $data['proprietaire'] = $core->user->utilisateur_id; + $data['pages'] = 0; + $data['version'] = 2; + $data['file'] = cubeFiles::tidyName($infos['name']); + $li = new wsDocumentLocalInfos($this); + $li->fileName = $this->args['fileName']; + $li->fileSize = $this->args['fileSize']; + $li->creationDate = $this->args['creationDate']; + $li->modificationDate = $this->args['modificationDate']; + $data['localInfos'] = $li; + $data['conversionInfos'] = new wsDocumentConversionInfos($this->args['resolution'], $this->args['method'], $this->args['quality'], $this->args['objects'], $this->args['version']); + $document = $dao->sauve($data); + $document->copyOriginalFromUpload($infos['tmp_name']); + $this->xml->addChild('document_id', $document->document_id); + $_SESSION['conversionSession'][$document->document_id] = 'all'; + $_SESSION['conversionSessionReload'] = false; + } + } + + public function addDocument() { + $_SESSION['conversionSession'] = array(); + $_SESSION['conversionSession'][$this->args['document_id']] = 'all'; + $_SESSION['conversionSessionReload'] = false; + } + + public function reload() { + global $core; + + if ($this->args['reloadDocs'] == '1') { + foreach ($this->args['documents'] as $document_id => $pages) { + $this->args['documents'][$document_id] = 'all'; + } + } + + $dao = new wsDAODocument($core->con); + $_SESSION['conversionSession'] = $this->args['documents']; + $_SESSION['conversionSessionReload'] = true; + foreach ($this->args['documents'] as $id => $pages) { + $doc = $dao->selectById($id); + $doc->conversionInfos->updatePages($pages, $this->args['resolution'], $this->args['quality'], $this->args['method'], $this->args['objects'], $this->args['version']); + $dao->updateFromObject($doc); + } + } + + public function processConversionSession() { + $_SESSION['sessionConversionGUID'] = $sessionConversionGUID = uniqid('conversion_', true); + $session = new wsConversionSession($sessionConversionGUID); + $session->reload = $_SESSION['conversionSessionReload']; + $session->setDocuments($_SESSION['conversionSession']); + $session->setBook($this->args['book_id']); + unset($_SESSION['conversionSession']); + unset($_SESSION['conversionSessionReload']); + $session->serialize(); + + $php = new cubeCommandLine('php'); + $php->setPath(CONVERTER_PATH); + $php->setArg('f', ROOT . '/index.php'); + $php->setManualArg('--'); + $php->setArg('user_email', $_SESSION['user_email']); + $php->setArg('user_password', $_SESSION['user_password']); + $php->setArg('sessionConversionGUID', $sessionConversionGUID); + $php->setArg('PATH_INFO', '/flash/processConversionSessionAsync'); + $php->setArg('HTTP_HOST', $_SERVER['HTTP_HOST']); + $php->setNohup(true); + $php->execute('exec'); + + $this->xml->addChild('command', html::escapeHTML($php->command)); + exit; + } + + public function processConversionSessionAsync() { + cubePHP::neverStop(); + try { + $conversion = wsConversionSession::openFromGUID($_REQUEST['sessionConversionGUID']); + $conversion->process(); + } catch (Exception $e) { + file_put_contents(CACHE . '/conversionExceptions.txt', print_r($e, true), FILE_APPEND); + } + $conversion->destroy(); + } + + public function getConversionSessionProgress() { + set_time_limit(1); + $session = wsConversionSession::openFromGUID($_SESSION['sessionConversionGUID']); + $p = $session->getProgress(); + $this->xml->addChild('progress', $p['progress']); + $this->xml->addChild('processedDoc', $p['processedDoc']); + $this->xml->addChild('totalDoc', $p['totalDoc']); + $this->xml->addChild('currentDoc', $p['currentDoc']); + $this->xml->addChild('currentDocPage', $p['currentDocPage']); + $this->xml->addChild('totalDocPage', $p['totalDocPage']); + } + + public function uploadThemeFile() { + foreach ($_FILES as $varname => $infos) { + if ($infos['error']) { + continue; + } + $fname = cubeFiles::tidyName($infos['name']); + $dest = '/' . $this->args['theme_id'] . '/' . $fname; + + if (!file_exists(WS_THEMES . '/' . $this->args['theme_id'])) { + mkdir(WS_THEMES . '/' . $this->args['theme_id'], 0755, true); + } + + move_uploaded_file($infos['tmp_name'], WS_THEMES . $dest); + $this->xml->addChild('file', $fname); + return; + } + } + + public function uploadLinkContent() { + foreach ($_FILES as $varname => $infos) { + if ($infos['error']) { + continue; + } + + if (isset($_POST['dir'])) { + $dir = trim($_POST['dir'], '/\\ '); + } else { + $dir = ''; + } + + if ($dir != '') { + $dir = $dir . '/'; + } + + $fname = cubeFiles::tidyName($infos['name']); + $dir = WS_BOOKS . '/working/' . $this->args['book_id'] . '/' . $dir; + if (!file_exists($dir)) { + mkdir($dir, 0777, true); + } + $dest = $dir . $fname; + move_uploaded_file($infos['tmp_name'], $dest); + if (in_array(strtolower(files::getExtension($dest)), array('flv', 'f4v', 'mp4'))) { + // convert uploaded file as webvideo (ogv and mp4) + wsTools::encodeWebVideos($dest, null, true, false); + } + $this->xml->addChild('file', $fname); + return; + } + } + + public function testDocuments() { + global $core; + + $toload = $this->xml->addChild('toLoad'); + $alreadyLoaded = $this->xml->addChild('alreadyLoaded'); + + $hash = array(); + + foreach ($this->args['fileName'] as $k => $name) { + $o = new wsDocumentLocalInfos(); + $o->fileName = $name; + $o->fileSize = intval($this->args['fileSize'][$k]); + $o->modificationDate = intval($this->args['modificationDate'][$k]); + $o->creationDate = intval($this->args['creationDate'][$k]); + + $hash[$k] = md5(serialize($o)); + } + + $in = array(); + foreach ($hash as $h) { + $in[] = "'" . $h . "'"; + } + + $sql = 'SELECT document_id,localHash FROM documents WHERE localHash'; + if (count($in) == 1) { + $sql .= ' = ' . implode(',', $in); + } else { + $sql .= ' IN (' . implode(',', $in) . ')'; + } + + $al = array(); + $r = $core->con->select($sql); + while ($r->fetch()) { + $k = array_search($r->localHash, $hash); + + if (!file_exists(WS_DOCS . '/' . $r->document_id . '/original.pdf')) { + continue; + } + + $al[$k] = true; + $f = $alreadyLoaded->addChild('file', $this->args['fileName'][$k]); + $f->addAttribute('document_id', $r->document_id); + } + + foreach ($this->args['fileName'] as $k => $name) { + if (!isset($al[$k])) { + $toload->addChild('file', $name); + } + } + } + + public function getPagesOfBook() { + global $core; + $dao = new wsDAOBook($core->con); + $book = $dao->selectById($this->args['book_id']); + $pages = $dao->getPagesOfBook($this->args['book_id']); + $p = $this->xml->addChild('pages'); + $docs = array(); + $defaultNum = array(); + foreach ($pages as $page => $info) { + $file = WS_DOCS . '/' . $info['document_id'] . '/p' . $info['document_page'] . '.jpg'; + if (!file_exists($file)) { + $dim = array(0, 0); + $info['resolution'] = 150; + $info['method'] = 1; + $info['objects'] = 1800; + $info['quality'] = 85; + $info['version']='stable'; + } else { + $dim = getimagesize($file); + } + + + + $pa = $p->addChild('page'); + $pa->addAttribute('page', $page); + $pa->addAttribute('document_id', $info['document_id']); + $pa->addAttribute('document_page', $info['document_page']); + $pa->addAttribute('width', $dim[0]); + $pa->addAttribute('height', $dim[1]); + $pa->addAttribute('resolution', $info['resolution']); + $pa->addAttribute('quality', $info['quality']); + $pa->addAttribute('methode', $info['method']); + $pa->addAttribute('objects', $info['objects']); + $pa->addAttribute('version', $info['version']); + $docs[] = $info['document_id']; + $defaultNum[] = $info['defaultNum']; + } + $docs = array_unique($docs); + $p->addAttribute('documents', implode(',', $docs)); + if (is_null($book->numerotation) || !$book->numerotation || $book->numerotation == 'null') { + $this->xml->addChild('numerotation', implode(',', $defaultNum)); + } else { + $this->xml->addChild('numerotation', $book->numerotation); + } + } + + public function getTheme() { + global $core; + $dao = new wsDAOTheme($core->con); + if (isset($this->args['theme_id'])) { + $theme = $dao->selectById($this->args['theme_id']); + } else { + $theme = $dao->getThemeOfBook($this->args['book_id']); + } + $this->_themeToXML($theme); + } + + public function saveTheme() { + global $core; + $dao = new wsDAOTheme($core->con); + $dao->sauve($this->args); + } + + public function getAllThemes() { + global $core; + + if (isset($this->args['book_id'])) { + $dao = new wsDAOBook($core->con); + $book = $dao->selectById($this->args['book_id']); + } else { + $this->args['book_id'] = 0; + } + + $dao = new wsDAOTheme($core->con); + $themes = $dao->getAllThemes($core->user, 'ORDER BY FIELD (theme_id,' . $this->args['book_id'] . ',1) DESC, theme_id DESC', true); + foreach ($themes as $theme) { + $t = $this->xml->addChild('theme'); + $t->addAttribute('id', $theme->theme_id); + $t->addAttribute('nom', $theme->nom); + if (isset($book) && $theme->theme_id == $book->theme) { + $t->addAttribute('selected', '1'); + $mine = true; + } else { + $mine = false; + } + if (wsDroits::revendeur() && wsDroits::creation()) { + $right = 'w'; + } else { + $right = 'r'; + } + $t->addAttribute('right', $right); + $t->addAttribute('proprietaire', $theme->proprietaire_nom); + $t->addAttribute('books', max(($theme->nbBooks) - ($mine ? 1 : 0), 0)); + } + } + + public function deleteTheme() { + global $core; + + $dao = new wsDAOTheme($core->con); + $dao->delete($this->args['theme_id']); + } + + public function renameTheme() { + global $core; + + $dao = new wsDAOTheme($core->con); + $dao->rename($this->args['theme_id'], $this->args['text']); + } + + public function duplicateTheme() { + global $core; + $dao = new wsDAOTheme($core->con); + $theme = $dao->duplicate($this->args['theme_id'], $core->user->utilisateur_id); + $this->xml->addChild('theme_id', $theme->theme_id); + if (isset($this->args['book_id'])) { + $dao = new wsDAOBook($core->con); + $data = array('book_id' => $this->args['book_id'], 'theme' => $theme->theme_id); + $dao->sauve($core->user->utilisateur_id, $data); + } + } + + public function setTheme() { + global $core; + $dao = new wsDAOBook($core->con); + $dao->setTheme($this->args['book_id'], $this->args['theme']); + } + + public function postThemeShot() { + file_put_contents(WS_THEMES . '/' . $this->args['theme_id'] . '.jpg', base64_decode($this->args['data'])); + } + + public function getAllIcones() { + global $core; + $dao = new wsDAOIcone($core->con); + $icones = $dao->selectAll('ORDER BY icone_id DESC'); + foreach ($icones as $icone) { + $i = $this->xml->addChild('icone'); + $i->addAttribute('id', $icone->icone_id); + $i->addAttribute('nom', $icone->nom); + $i->addAttribute('path', ICONS . $icone->icone_id . '.png'); + } + } + + protected function _themeToXML($theme) { + $t = $this->xml->addChild('theme'); + $t->addAttribute('theme_id', $theme->theme_id); + $t->addAttribute('icones_id', $theme->icones); + foreach ($theme->parametres as $k => $v) { + $t->addChild($k, $v); + } + } + + public function getThemeForms() { + global $core; + $dao = new wsDAOTheme($core->con); + $theme = $dao->selectById($this->args['theme_id']); + + foreach ($theme->parametres->getForms() as $name) { + $f = $this->xml->addChild('form', json_encode($theme->parametres->getForm($name))); + $f->addAttribute('name', $name); + } + } + + public function getFluidbookForms() { + global $core; + $dao = new wsDAOBook($core->con); + $book = $dao->selectById($this->args['book_id']); + foreach ($book->parametres->getForms() as $name) { + $f = $this->xml->addChild('form', html::escapeHTML(json_encode($book->parametres->getForm($name)))); + $f->addAttribute('name', $name); + } + } + + public function saveSettings() { + global $core; + $dao = new wsDAOBook($core->con); + $dao->setSettings($this->args['book_id'], $this->args['settings']); + } + + public function setChapters() { + global $core; + $dao = new wsDAOBook($core->con); + $dao->setChapters($this->args['book_id'], $this->args['chapters']); + } + + public function getChapters() { + global $core; + $dao = new wsDAOBook($core->con); + $book = $dao->selectById($this->args['book_id']); + $this->xml->addChild('chapters', html::escapeHTML(json_encode($book->chapters))); + } + + public function getLinks() { + global $core; + $dao = new wsDAOBook($core->con); + $book = $dao->selectById($this->args['book_id']); + + $pages = $dao->getPagesOfBook($this->args['book_id']); + $nb_pages = count($pages); + $this->xml->addChild('pages', $nb_pages); + $this->xml->addChild('numerotation', $book->numerotation); + + $daoDoc = new wsDAODocument($core->con); + $firstDoc = $daoDoc->selectById($pages[1]['document_id']); + $size = $firstDoc->generalInfos['size']; + $daoDoc->getLinksAndRulers($this->args['book_id'], $links, $rulers); + + $this->xml->addChild('width', $size[0]); + $this->xml->addChild('height', $size[1]); + $this->xml->addChild('links', html::escapeHTML(json_encode($links))); + $this->xml->addChild('rulers', json_encode($rulers)); + + $daoTheme = new wsDAOTheme($this->con); + $theme = $daoTheme->getThemeOfBook($this->args['book_id'], true); + + $specials = array('backgroundImage' => 'background', 'topBar' => 'topbar', 'afterSearch' => 'aftersearch'); + + foreach ($specials as $tparam => $sname) { + $this->_addSpecialInfos($theme, $tparam, $sname); + } + } + + protected function _addSpecialInfos($theme, $param, $specialName) { + if ($theme->parametres->$param != '') { + $themeRoot = WS_THEMES . '/' . $theme->theme_id . '/'; + $dim = getimagesize($themeRoot . $theme->parametres->$param); + $b = $this->xml->addChild($specialName); + $b->addChild('width', $dim[0]); + $b->addChild('height', $dim[1]); + $b->addChild('url', 'http://' . $_SERVER['HTTP_HOST'] . WEBROOT . '/fluidbook/themes/' . $theme->theme_id . '/' . $theme->parametres->$param); + } + } + + public function saveLinks() { + global $core; + + $comments = isset($this->args['comments']) ? $this->args['comments'] : 'Saved from editor'; + + $dao = new wsDAODocument($core->con); + $dao->setLinksAndRulers($this->args['book_id'], $this->args['links'], $this->args['rulers'], $comments, $core->user->utilisateur_id); + + $daoBook = new wsDAOBook($core->con); + $daoBook->setSpecialLinksAndRulers($this->args['book_id'], $this->args['specialLinks'], $this->args['specialRulers']); + + if (isset($this->args['getLinks'])) { + $this->getLinks(); + } + } + + public function formatSize($val) { + $str = files::size($val); + $str = str_replace('.', __(','), $str); + $str = str_replace('B', __('o'), $str); + return $str; + } + + public function getExtras() { + global $core; + $dao = new wsDAOBook($core->con); + $book = $dao->selectById($this->args['book_id']); + if ($book->extras != '') { + $tidy = cubeXML::tidy('' . $book->extras . ''); + $tidy = str_replace('', '', $tidy); + $tidy = str_replace('', '', $tidy); + $tidy = str_replace('', '', $tidy); + $tidy = trim($tidy); + $e = explode("\n", $tidy); + foreach ($e as $k => $v) { + if (substr($v, 0, 2) == ' ') { + $v = substr($v, 2); + } + $e[$k] = $v; + } + + $extras = implode("\n", $e); + } else { + $extras = ''; + } + + $this->xml->addChild('extras', $extras); + } + + public function saveExtras() { + global $core; + $dao = new wsDAOBook($core->con); + $res = $dao->setExtras($this->args['book_id'], $this->args['extras']); + $this->xml->addChild('ok', $res ? '1' : '0'); + } + + public function getBookInfos() { + global $core; + $dao = new wsDAOBook($core->con); + $book = $dao->selectById($this->args['book_id']); + $pages = $dao->getPagesOfBook($this->args['book_id']); + $daoDoc = new wsDAODocument($core->con); + $nb_pages = count($pages); + $this->xml->addChild('pages', $nb_pages); + $total_size = 0; + foreach ($pages as $page => $info) { + $file = WS_DOCS . '/' . $info['document_id'] . '/p' . $info['document_page'] . '.swf'; + $total_size += filesize($file); + } + $average_size = $total_size / $nb_pages; + $total = self::formatSize($total_size); + $average = self::formatSize($average_size); + $firstDoc = $daoDoc->selectById($pages[1]['document_id']); + $size = $firstDoc->generalInfos['size']; + $this->xml->addChild('width', $size[0]); + $this->xml->addChild('height', $size[1]); + $res = __('Nombre de pages') . ' : ' . "\n"; + $res .= $nb_pages . ' ' . __('pages') . "\n"; + $res .= "\n"; + $res .= __('Dimensions') . ' : ' . "\n"; + $res .= round($size[0], 3) . ' x ' . round($size[1], 3) . ' pts' . "\n"; + $res .= "\n"; + $res .= __('Taille totale des pages') . ' : ' . "\n"; + $res .= $total . "\n"; + $res .= "\n"; + $res .= __('Taille moyenne des pages') . ' : ' . "\n"; + $res .= $average . "\n"; + $res .= "\n"; + /* $res .= __('Taille du PDF') . ' : ' . "\n"; + $res .= '7898 Ko' . "\n"; + $res .= "\n"; + $res .= __('Qualité de conversion') . ' : ' . "\n"; + $res .= '150dpi (qualité 85%)' . "\n"; */ + $this->xml->addChild('infos', $res); + } + + public function getLangs() { + global $core; + if (isset($this->args['book_id'])) { + $dao = new wsDAOBook($core->con); + $book = $dao->selectById($this->args['book_id']); + $book->traductions = wsLang::checkTranslations($book->traductions); + if ($book->traductions != array()) { + $bookLang = $this->xml->addChild('book_lang', json_encode($book->traductions)); + } + } + + $dao = new wsDAOLang($core->con); + $langs = $dao->selectAll(); + foreach ($langs as $lang) { + $nom = cubeLang::getNameByCode($lang->lang_id, $core->user->lang); + $l = $this->xml->addChild('lang', json_encode($lang->traductions)); + $l->addAttribute('id', $lang->lang_id); + $l->addAttribute('nom', $nom); + if (isset($book) && $book->lang == $lang->lang_id) { + if (!isset($bookLang)) { + $l->addAttribute('selected', '1'); + } else { + $bookLang->addAttribute('id', $lang->lang_id); + $bookLang->addAttribute('nom', $nom . ' (' . __('modifié') . ')'); + $bookLang->addAttribute('selected', '1'); + } + } + } + } + + public function saveLang() { + global $core; + $dao = new wsDAOBook($core->con); + $dao->setLang($this->args['book_id'], $this->args['lang_id'], $this->args['traductions']); + } + + public function saveComposition() { + global $core; + $dao = new wsDAOBook($core->con); + $dao->setComposition($this->args['book_id'], json_decode($this->args['pages'])); + } + + public function getTexts() { + $this->xml->addChild('texts', json_encode($GLOBALS['__l10n'])); + } + + public function copyLinks() { + global $core; + $daoDocument = new wsDAODocument($core->con); + $daoDocument->copyLinks($this->args['fromDoc'], $this->args['toDoc']); + } + + public function compile() { + global $core; + wsSecureSWF::checkProtectedSWF(); + $dao = new wsDAOBook($core->con); + if (!$dao->isUpToDate($this->args['book_id'])) { + $log = $dao->compile($this->args['book_id'], 3); + $log = str_replace('&', '&', $log); + $log = str_replace('&', '&', $log); + // $this->xml->addChild('log', $log); + } + $book = $dao->selectById($this->args['book_id']); + $viewer = 'viewer'; + if (wsDroits::admin()) { + $viewer = 'vieweru'; + } + + $absoluteURL = 'http://' . $_SERVER['HTTP_HOST'] . '/' . $viewer . '/' . $book->book_id . '_' . $book->hash . '_' . TIME . '/'; + $this->xml->addChild('compiledBook', $absoluteURL . 'index.swf?base=' . $absoluteURL); + } } diff --git a/inc/ws/Metier/class.ws.document.conversioninfos.php b/inc/ws/Metier/class.ws.document.conversioninfos.php index 76876afbd..3f5409a2f 100644 --- a/inc/ws/Metier/class.ws.document.conversioninfos.php +++ b/inc/ws/Metier/class.ws.document.conversioninfos.php @@ -1,48 +1,46 @@ resolution = $resolution; $this->method = $method; $this->quality = $quality; $this->objects = $objects; + $this->version = $version; $this->pages = array(); } - public function setPageNumber($n) - { + public function setPageNumber($n) { // Set defaults - for($i = 1;$i <= $n;$i++) { + for ($i = 1; $i <= $n; $i++) { if (!isset($this->pages[$i])) { - $this->pages[$i] = new wsDocumentConversionInfos($this->resolution, $this->method, $this->quality, $this->objects); + $this->pages[$i] = new wsDocumentConversionInfos($this->resolution, $this->method, $this->quality, $this->objects, $this->version); } } } - public function updatePages($pages, $resolution, $quality, $method, $objects) - { + public function updatePages($pages, $resolution, $quality, $method, $objects, $version) { if ($pages == 'all') { $pages = array_keys($this->pages); } - foreach($pages as $page) { - $this->updatePage($page, $resolution, $quality, $method, $objects); + foreach ($pages as $page) { + $this->updatePage($page, $resolution, $quality, $method, $objects, $version); } } - public function updatePage($page, $resolution, $quality, $method, $objects) - { + public function updatePage($page, $resolution, $quality, $method, $objects, $version) { if (!isset($this->pages[$page])) { - $this->pages[$page] = new wsDocumentConversionInfos($resolution, $quality, $method, $objects); + $this->pages[$page] = new wsDocumentConversionInfos($resolution, $quality, $method, $objects, $version); } else { if ($resolution != 'default') { $this->pages[$page]->resolution = $resolution; @@ -56,8 +54,12 @@ class wsDocumentConversionInfos { if ($objects != 'default') { $this->pages[$page]->objects = $objects; } + if ($version != 'default') { + $this->pages[$page]->version = $version; + } } } + } ?> \ No newline at end of file diff --git a/inc/ws/Metier/class.ws.document.php b/inc/ws/Metier/class.ws.document.php index f16fa8fb2..bb997180a 100644 --- a/inc/ws/Metier/class.ws.document.php +++ b/inc/ws/Metier/class.ws.document.php @@ -500,7 +500,7 @@ class wsDocument extends cubeMetier { return $this->autocrop || $this->manualcrop || $this->autocut || $this->manualcut; } - public function makeSWFFiles($page, $resolution = null, $quality = null, $storeAllChars = null, $maxObjects = null, $method = null) { + public function makeSWFFiles($page, $resolution = null, $quality = null, $storeAllChars = null, $maxObjects = null, $method = null, $version=null) { $conversionSettings = $this->conversionInfos->pages[$page]; if (is_null($storeAllChars)) { $storeAllChars = true; @@ -517,17 +517,21 @@ class wsDocument extends cubeMetier { if (is_null($maxObjects)) { $maxObjects = $conversionSettings->objects; } + if (is_null($version)) { + $version = isset($conversionSettings->version)?$conversionSettings->version:'stable'; + } if ($maxObjects <= 1) { $method = self::POLY2BITMAP; } + // Pour les fichiers croppés, on utilise la méthode flatten qui ne prends // pas en compte les objets hors de la box if ($this->isCropped()) { // $method = max($method, self::FLATTEN); } - $out = $this->pdf2swf($page, $resolution, $quality, $storeAllChars, $method); + $out = $this->pdf2swf($page, $resolution, $quality, $storeAllChars, $method, 'p', $version); if ($method < self::BARBARE_PNM) { // Analyse de la sortie pour détecter des typos manquantes $overflow = false; @@ -561,7 +565,7 @@ class wsDocument extends cubeMetier { return; } $nextMethod = $method + 1; - return $this->makeSWFFiles($page, $resolution, $quality, $storeAllChars, $maxObjects, $nextMethod); + return $this->makeSWFFiles($page, $resolution, $quality, $storeAllChars, $maxObjects, $nextMethod, $version); } } } @@ -613,7 +617,7 @@ class wsDocument extends cubeMetier { * @param integer $method * @return */ - protected function pdf2swf($page, $resolution = 150, $quality = 90, $storeAllChars = true, $method = 0, $prefix = 'p') { + protected function pdf2swf($page, $resolution = 150, $quality = 90, $storeAllChars = true, $method = 0, $prefix = 'p', $version='stable') { /* -h , --help Print short help message and exit -V , --version Print version info and exit @@ -691,7 +695,14 @@ class wsDocument extends cubeMetier { } if (!in_array($method, array(self::BARBARE_PNM, self::BARBARE_GS))) { - $pdf2swf = new cubeCommandLine('pdf2swf', null, true); + + if (in_array($version, array('stable', 'latest'))) { + $program = '/usr/local/swftools/' . $version . '/bin/pdf2swf'; + } else { + $program = 'pdf2swf'; + } + + $pdf2swf = new cubeCommandLine($program, null, true); $pdf2swf->setPath(CONVERTER_PATH); $pdf2swf->setArg('p', $page); @@ -731,7 +742,6 @@ class wsDocument extends cubeMetier { $pdf2swf->setArg('set jpegquality', $quality); $pdf2swf->setArg('set disablelinks'); $pdf2swf->setArg('set dots'); - $pdf2swf->setManualArg('-vvv'); $pdf2swf->setArg(null, $this->cropped); $pdf2swf->setArg('output', $this->out . $prefix . '%.swf'); $pdf2swf->execute(); -- 2.39.5