<?php\r
\r
class wsFlash extends cubeFlashGateway {\r
- const CNAME = __CLASS__;\r
-\r
- public static function in($args) {\r
- global $core;\r
- $args = cubePage::getArgs($args);\r
- $n = self::CNAME;\r
- $gateway = new $n($core->con, $args);\r
-\r
- $droits = wsDroits::getDroits();\r
- $gateway->addAttribute('creation', $droits->creation ? '1' : '0');\r
- $gateway->addAttribute('revendeur', $droits->revendeur ? '1' : '0');\r
- $gateway->addAttribute('admin', $droits->admin ? '1' : '0');\r
- $gateway->addAttribute('grade', $core->user->ws_grade);\r
- }\r
-\r
- public function saveConversionSettings() {\r
- global $core;\r
- $dao = new commonDAOUtilisateur($core->con);\r
- $datas = array('resolution' => $this->args['resolution'],\r
- 'objects' => $this->args['objects'],\r
- 'method' => $this->args['method'],\r
- 'quality' => $this->args['quality']);\r
- $dao->sauveWSSettings($core->user->utilisateur_id, $datas);\r
- }\r
-\r
- public function getConversionSettings() {\r
- global $core;\r
- $this->xml->addChild('resolution', $core->user->ws_settings['resolution']);\r
- $this->xml->addChild('quality', $core->user->ws_settings['quality']);\r
- $this->xml->addChild('method', $core->user->ws_settings['method']);\r
- $this->xml->addChild('objects', $core->user->ws_settings['objects']);\r
- }\r
-\r
- public function uploadDocument() {\r
- cubePHP::neverStop();\r
- global $core;\r
- if (!isset($_SESSION['conversionSession'])) {\r
- $_SESSION['conversionSession'] = array();\r
- }\r
- $dao = new wsDAODocument($core->con);\r
- foreach ($_FILES as $varname => $infos) {\r
- if ($infos['error']) {\r
- continue;\r
- }\r
- // Initialisation du document\r
- $data = array();\r
- $data['proprietaire'] = $core->user->utilisateur_id;\r
- $data['pages'] = 0;\r
- $data['version'] = 2;\r
- $data['file'] = cubeFiles::tidyName($infos['name']);\r
- $li = new wsDocumentLocalInfos($this);\r
- $li->fileName = $this->args['fileName'];\r
- $li->fileSize = $this->args['fileSize'];\r
- $li->creationDate = $this->args['creationDate'];\r
- $li->modificationDate = $this->args['modificationDate'];\r
- $data['localInfos'] = $li;\r
- $data['conversionInfos'] = new wsDocumentConversionInfos($this->args['resolution'], $this->args['method'], $this->args['quality'], $this->args['objects']);\r
- $document = $dao->sauve($data);\r
- $document->copyOriginalFromUpload($infos['tmp_name']);\r
- $this->xml->addChild('document_id', $document->document_id);\r
- $_SESSION['conversionSession'][$document->document_id] = 'all';\r
- $_SESSION['conversionSessionReload'] = false;\r
- }\r
- }\r
-\r
- public function addDocument() {\r
- $_SESSION['conversionSession'] = array();\r
- $_SESSION['conversionSession'][$this->args['document_id']] = 'all';\r
- $_SESSION['conversionSessionReload'] = false;\r
- }\r
-\r
- public function reload() {\r
- global $core;\r
-\r
- if ($this->args['reloadDocs'] == '1') {\r
- foreach ($this->args['documents'] as $document_id => $pages) {\r
- $this->args['documents'][$document_id] = 'all';\r
- }\r
- }\r
-\r
- $dao = new wsDAODocument($core->con);\r
- $_SESSION['conversionSession'] = $this->args['documents'];\r
- $_SESSION['conversionSessionReload'] = true;\r
- foreach ($this->args['documents'] as $id => $pages) {\r
- $doc = $dao->selectById($id);\r
- $doc->conversionInfos->updatePages($pages, $this->args['resolution'], $this->args['quality'], $this->args['method'], $this->args['objects']);\r
- $dao->updateFromObject($doc);\r
- }\r
- }\r
-\r
- public function processConversionSession() {\r
- $_SESSION['sessionConversionGUID'] = $sessionConversionGUID = uniqid('conversion_', true);\r
- $session = new wsConversionSession($sessionConversionGUID);\r
- $session->reload = $_SESSION['conversionSessionReload'];\r
- $session->setDocuments($_SESSION['conversionSession']);\r
- $session->setBook($this->args['book_id']);\r
- unset($_SESSION['conversionSession']);\r
- unset($_SESSION['conversionSessionReload']);\r
- $session->serialize();\r
-\r
- $php = new cubeCommandLine('php');\r
- $php->setPath(CONVERTER_PATH);\r
- $php->setArg('f', ROOT . '/index.php');\r
- $php->setManualArg('--');\r
- $php->setArg('user_email', $_SESSION['user_email']);\r
- $php->setArg('user_password', $_SESSION['user_password']);\r
- $php->setArg('sessionConversionGUID', $sessionConversionGUID);\r
- $php->setArg('PATH_INFO', '/flash/processConversionSessionAsync');\r
- $php->setArg('HTTP_HOST', $_SERVER['HTTP_HOST']);\r
- $php->setNohup(true);\r
- $php->execute('exec');\r
-\r
- $this->xml->addChild('command', html::escapeHTML($php->command));\r
- exit;\r
- }\r
-\r
- public function processConversionSessionAsync() {\r
- cubePHP::neverStop();\r
- try {\r
- $conversion = wsConversionSession::openFromGUID($_REQUEST['sessionConversionGUID']);\r
- $conversion->process();\r
- } catch (Exception $e) {\r
- file_put_contents(CACHE . '/conversionExceptions.txt', print_r($e, true), FILE_APPEND);\r
- }\r
- $conversion->destroy();\r
- }\r
-\r
- public function getConversionSessionProgress() {\r
- set_time_limit(1);\r
- $session = wsConversionSession::openFromGUID($_SESSION['sessionConversionGUID']);\r
- $p = $session->getProgress();\r
- $this->xml->addChild('progress', $p['progress']);\r
- $this->xml->addChild('processedDoc', $p['processedDoc']);\r
- $this->xml->addChild('totalDoc', $p['totalDoc']);\r
- $this->xml->addChild('currentDoc', $p['currentDoc']);\r
- $this->xml->addChild('currentDocPage', $p['currentDocPage']);\r
- $this->xml->addChild('totalDocPage', $p['totalDocPage']);\r
- }\r
-\r
- public function uploadThemeFile() {\r
- foreach ($_FILES as $varname => $infos) {\r
- if ($infos['error']) {\r
- continue;\r
- }\r
- $fname = cubeFiles::tidyName($infos['name']);\r
- $dest = '/' . $this->args['theme_id'] . '/' . $fname;\r
-\r
- if (!file_exists(WS_THEMES . '/' . $this->args['theme_id'])) {\r
- mkdir(WS_THEMES . '/' . $this->args['theme_id'], 0755, true);\r
- }\r
-\r
- move_uploaded_file($infos['tmp_name'], WS_THEMES . $dest);\r
- $this->xml->addChild('file', $fname);\r
- return;\r
- }\r
- }\r
-\r
- public function uploadLinkContent() {\r
- foreach ($_FILES as $varname => $infos) {\r
- if ($infos['error']) {\r
- continue;\r
- }\r
-\r
- if (isset($_POST['dir'])) {\r
- $dir = trim($_POST['dir'], '/\\ ');\r
- } else {\r
- $dir = '';\r
- }\r
-\r
- if ($dir != '') {\r
- $dir = $dir . '/';\r
- }\r
-\r
- $fname = cubeFiles::tidyName($infos['name']);\r
- $dir = WS_BOOKS . '/working/' . $this->args['book_id'] . '/' . $dir;\r
- if (!file_exists($dir)) {\r
- mkdir($dir, 0777, true);\r
- }\r
- $dest = $dir . $fname;\r
- move_uploaded_file($infos['tmp_name'], $dest);\r
- if (in_array(strtolower(files::getExtension($dest)), array('flv', 'f4v', 'mp4'))) {\r
- // convert uploaded file as webvideo (ogv and mp4)\r
- wsTools::encodeWebVideos($dest, null, true, false);\r
- }\r
- $this->xml->addChild('file', $fname);\r
- return;\r
- }\r
- }\r
-\r
- public function testDocuments() {\r
- global $core;\r
-\r
- $toload = $this->xml->addChild('toLoad');\r
- $alreadyLoaded = $this->xml->addChild('alreadyLoaded');\r
-\r
- $hash = array();\r
-\r
- foreach ($this->args['fileName'] as $k => $name) {\r
- $o = new wsDocumentLocalInfos();\r
- $o->fileName = $name;\r
- $o->fileSize = intval($this->args['fileSize'][$k]);\r
- $o->modificationDate = intval($this->args['modificationDate'][$k]);\r
- $o->creationDate = intval($this->args['creationDate'][$k]);\r
-\r
- $hash[$k] = md5(serialize($o));\r
- }\r
-\r
- $in = array();\r
- foreach ($hash as $h) {\r
- $in[] = "'" . $h . "'";\r
- }\r
-\r
- $sql = 'SELECT document_id,localHash FROM documents WHERE localHash';\r
- if (count($in) == 1) {\r
- $sql .= ' = ' . implode(',', $in);\r
- } else {\r
- $sql .= ' IN (' . implode(',', $in) . ')';\r
- }\r
-\r
- $al = array();\r
- $r = $core->con->select($sql);\r
- while ($r->fetch()) {\r
- $k = array_search($r->localHash, $hash);\r
-\r
- if (!file_exists(WS_DOCS . '/' . $r->document_id . '/original.pdf')) {\r
- continue;\r
- }\r
-\r
- $al[$k] = true;\r
- $f = $alreadyLoaded->addChild('file', $this->args['fileName'][$k]);\r
- $f->addAttribute('document_id', $r->document_id);\r
- }\r
-\r
- foreach ($this->args['fileName'] as $k => $name) {\r
- if (!isset($al[$k])) {\r
- $toload->addChild('file', $name);\r
- }\r
- }\r
- }\r
-\r
- public function getPagesOfBook() {\r
- global $core;\r
- $dao = new wsDAOBook($core->con);\r
- $book = $dao->selectById($this->args['book_id']);\r
- $pages = $dao->getPagesOfBook($this->args['book_id']);\r
- $p = $this->xml->addChild('pages');\r
- $docs = array();\r
- $defaultNum = array();\r
- foreach ($pages as $page => $info) {\r
- $file = WS_DOCS . '/' . $info['document_id'] . '/p' . $info['document_page'] . '.jpg';\r
- if (!file_exists($file)) {\r
- $dim = array(0, 0);\r
- $info['resolution'] = 150;\r
- $info['method'] = 1;\r
- $info['objects'] = 1800;\r
- $info['quality'] = 85;\r
- } else {\r
- $dim = getimagesize($file);\r
- }\r
-\r
-\r
-\r
- $pa = $p->addChild('page');\r
- $pa->addAttribute('page', $page);\r
- $pa->addAttribute('document_id', $info['document_id']);\r
- $pa->addAttribute('document_page', $info['document_page']);\r
- $pa->addAttribute('width', $dim[0]);\r
- $pa->addAttribute('height', $dim[1]);\r
- $pa->addAttribute('resolution', $info['resolution']);\r
- $pa->addAttribute('quality', $info['quality']);\r
- $pa->addAttribute('methode', $info['method']);\r
- $pa->addAttribute('objects', $info['objects']);\r
- $docs[] = $info['document_id'];\r
- $defaultNum[] = $info['defaultNum'];\r
- }\r
- $docs = array_unique($docs);\r
- $p->addAttribute('documents', implode(',', $docs));\r
- if (is_null($book->numerotation) || !$book->numerotation || $book->numerotation == 'null') {\r
- $this->xml->addChild('numerotation', implode(',', $defaultNum));\r
- } else {\r
- $this->xml->addChild('numerotation', $book->numerotation);\r
- }\r
- }\r
-\r
- public function getTheme() {\r
- global $core;\r
- $dao = new wsDAOTheme($core->con);\r
- if (isset($this->args['theme_id'])) {\r
- $theme = $dao->selectById($this->args['theme_id']);\r
- } else {\r
- $theme = $dao->getThemeOfBook($this->args['book_id']);\r
- }\r
- $this->_themeToXML($theme);\r
- }\r
-\r
- public function saveTheme() {\r
- global $core;\r
- $dao = new wsDAOTheme($core->con);\r
- $dao->sauve($this->args);\r
- }\r
-\r
- public function getAllThemes() {\r
- global $core;\r
-\r
- if (isset($this->args['book_id'])) {\r
- $dao = new wsDAOBook($core->con);\r
- $book = $dao->selectById($this->args['book_id']);\r
- } else {\r
- $this->args['book_id'] = 0;\r
- }\r
-\r
- $dao = new wsDAOTheme($core->con);\r
- $themes = $dao->getAllThemes($core->user, 'ORDER BY FIELD (theme_id,' . $this->args['book_id'] . ',1) DESC, theme_id DESC', true);\r
- foreach ($themes as $theme) {\r
- $t = $this->xml->addChild('theme');\r
- $t->addAttribute('id', $theme->theme_id);\r
- $t->addAttribute('nom', $theme->nom);\r
- if (isset($book) && $theme->theme_id == $book->theme) {\r
- $t->addAttribute('selected', '1');\r
- $mine = true;\r
- } else {\r
- $mine = false;\r
- }\r
- if (wsDroits::revendeur() && wsDroits::creation()) {\r
- $right = 'w';\r
- } else {\r
- $right = 'r';\r
- }\r
- $t->addAttribute('right', $right);\r
- $t->addAttribute('proprietaire', $theme->proprietaire_nom);\r
- $t->addAttribute('books', max(($theme->nbBooks) - ($mine ? 1 : 0), 0));\r
- }\r
- }\r
-\r
- public function deleteTheme() {\r
- global $core;\r
-\r
- $dao = new wsDAOTheme($core->con);\r
- $dao->delete($this->args['theme_id']);\r
- }\r
-\r
- public function renameTheme() {\r
- global $core;\r
-\r
- $dao = new wsDAOTheme($core->con);\r
- $dao->rename($this->args['theme_id'], $this->args['text']);\r
- }\r
-\r
- public function duplicateTheme() {\r
- global $core;\r
- $dao = new wsDAOTheme($core->con);\r
- $theme = $dao->duplicate($this->args['theme_id'], $core->user->utilisateur_id);\r
- $this->xml->addChild('theme_id', $theme->theme_id);\r
- if (isset($this->args['book_id'])) {\r
- $dao = new wsDAOBook($core->con);\r
- $data = array('book_id' => $this->args['book_id'], 'theme' => $theme->theme_id);\r
- $dao->sauve($core->user->utilisateur_id, $data);\r
- }\r
- }\r
-\r
- public function setTheme() {\r
- global $core;\r
- $dao = new wsDAOBook($core->con);\r
- $dao->setTheme($this->args['book_id'], $this->args['theme']);\r
- }\r
-\r
- public function postThemeShot() {\r
- file_put_contents(WS_THEMES . '/' . $this->args['theme_id'] . '.jpg', base64_decode($this->args['data']));\r
- }\r
-\r
- public function getAllIcones() {\r
- global $core;\r
- $dao = new wsDAOIcone($core->con);\r
- $icones = $dao->selectAll('ORDER BY icone_id DESC');\r
- foreach ($icones as $icone) {\r
- $i = $this->xml->addChild('icone');\r
- $i->addAttribute('id', $icone->icone_id);\r
- $i->addAttribute('nom', $icone->nom);\r
- $i->addAttribute('path', ICONS . $icone->icone_id . '.png');\r
- }\r
- }\r
-\r
- protected function _themeToXML($theme) {\r
- $t = $this->xml->addChild('theme');\r
- $t->addAttribute('theme_id', $theme->theme_id);\r
- $t->addAttribute('icones_id', $theme->icones);\r
- foreach ($theme->parametres as $k => $v) {\r
- $t->addChild($k, $v);\r
- }\r
- }\r
-\r
- public function getThemeForms() {\r
- global $core;\r
- $dao = new wsDAOTheme($core->con);\r
- $theme = $dao->selectById($this->args['theme_id']);\r
-\r
- foreach ($theme->parametres->getForms() as $name) {\r
- $f = $this->xml->addChild('form', json_encode($theme->parametres->getForm($name)));\r
- $f->addAttribute('name', $name);\r
- }\r
- }\r
-\r
- public function getFluidbookForms() {\r
- global $core;\r
- $dao = new wsDAOBook($core->con);\r
- $book = $dao->selectById($this->args['book_id']);\r
- foreach ($book->parametres->getForms() as $name) {\r
- $f = $this->xml->addChild('form', html::escapeHTML(json_encode($book->parametres->getForm($name))));\r
- $f->addAttribute('name', $name);\r
- }\r
- }\r
-\r
- public function saveSettings() {\r
- global $core;\r
- $dao = new wsDAOBook($core->con);\r
- $dao->setSettings($this->args['book_id'], $this->args['settings']);\r
- }\r
-\r
- public function setChapters() {\r
- global $core;\r
- $dao = new wsDAOBook($core->con);\r
- $dao->setChapters($this->args['book_id'], $this->args['chapters']);\r
- }\r
-\r
- public function getChapters() {\r
- global $core;\r
- $dao = new wsDAOBook($core->con);\r
- $book = $dao->selectById($this->args['book_id']);\r
- $this->xml->addChild('chapters', html::escapeHTML(json_encode($book->chapters)));\r
- }\r
-\r
- public function getLinks() {\r
- global $core;\r
- $dao = new wsDAOBook($core->con);\r
- $book = $dao->selectById($this->args['book_id']);\r
-\r
- $pages = $dao->getPagesOfBook($this->args['book_id']);\r
- $nb_pages = count($pages);\r
- $this->xml->addChild('pages', $nb_pages);\r
- $this->xml->addChild('numerotation', $book->numerotation);\r
-\r
- $daoDoc = new wsDAODocument($core->con);\r
- $firstDoc = $daoDoc->selectById($pages[1]['document_id']);\r
- $size = $firstDoc->generalInfos['size'];\r
- $daoDoc->getLinksAndRulers($this->args['book_id'], $links, $rulers);\r
-\r
- $this->xml->addChild('width', $size[0]);\r
- $this->xml->addChild('height', $size[1]);\r
- $this->xml->addChild('links', html::escapeHTML(json_encode($links)));\r
- $this->xml->addChild('rulers', json_encode($rulers));\r
-\r
- $daoTheme = new wsDAOTheme($this->con);\r
- $theme = $daoTheme->getThemeOfBook($this->args['book_id'], true);\r
-\r
- $specials = array('backgroundImage' => 'background', 'topBar' => 'topbar', 'afterSearch' => 'aftersearch');\r
-\r
- foreach ($specials as $tparam => $sname) {\r
- $this->_addSpecialInfos($theme, $tparam, $sname);\r
- }\r
- }\r
-\r
- protected function _addSpecialInfos($theme, $param, $specialName) {\r
- if ($theme->parametres->$param != '') {\r
- $themeRoot = WS_THEMES . '/' . $theme->theme_id . '/';\r
- $dim = getimagesize($themeRoot . $theme->parametres->$param);\r
- $b = $this->xml->addChild($specialName);\r
- $b->addChild('width', $dim[0]);\r
- $b->addChild('height', $dim[1]);\r
- $b->addChild('url', 'http://' . $_SERVER['HTTP_HOST'] . WEBROOT . '/fluidbook/themes/' . $theme->theme_id . '/' . $theme->parametres->$param);\r
- }\r
- }\r
-\r
- public function saveLinks() {\r
- global $core;\r
-\r
- $comments = isset($this->args['comments']) ? $this->args['comments'] : 'Saved from editor';\r
-\r
- $dao = new wsDAODocument($core->con);\r
- $dao->setLinksAndRulers($this->args['book_id'], $this->args['links'], $this->args['rulers'], $comments, $core->user->utilisateur_id);\r
-\r
- $daoBook = new wsDAOBook($core->con);\r
- $daoBook->setSpecialLinksAndRulers($this->args['book_id'], $this->args['specialLinks'], $this->args['specialRulers']);\r
-\r
- if (isset($this->args['getLinks'])) {\r
- $this->getLinks();\r
- }\r
- }\r
-\r
- public function formatSize($val) {\r
- $str = files::size($val);\r
- $str = str_replace('.', __(','), $str);\r
- $str = str_replace('B', __('o'), $str);\r
- return $str;\r
- }\r
-\r
- public function getExtras() {\r
- global $core;\r
- $dao = new wsDAOBook($core->con);\r
- $book = $dao->selectById($this->args['book_id']);\r
- if ($book->extras != '') {\r
- $tidy = cubeXML::tidy('<extras>' . $book->extras . '</extras>');\r
- $tidy = str_replace('<extras>', '', $tidy);\r
- $tidy = str_replace('</extras>', '', $tidy);\r
- $tidy = str_replace('<?xml version="1.0"?>', '', $tidy);\r
- $tidy = trim($tidy);\r
- $e = explode("\n", $tidy);\r
- foreach ($e as $k => $v) {\r
- if (substr($v, 0, 2) == ' ') {\r
- $v = substr($v, 2);\r
- }\r
- $e[$k] = $v;\r
- }\r
-\r
- $extras = implode("\n", $e);\r
- } else {\r
- $extras = '';\r
- }\r
-\r
- $this->xml->addChild('extras', $extras);\r
- }\r
-\r
- public function saveExtras() {\r
- global $core;\r
- $dao = new wsDAOBook($core->con);\r
- $res = $dao->setExtras($this->args['book_id'], $this->args['extras']);\r
- $this->xml->addChild('ok', $res ? '1' : '0');\r
- }\r
-\r
- public function getBookInfos() {\r
- global $core;\r
- $dao = new wsDAOBook($core->con);\r
- $book = $dao->selectById($this->args['book_id']);\r
- $pages = $dao->getPagesOfBook($this->args['book_id']);\r
- $daoDoc = new wsDAODocument($core->con);\r
- $nb_pages = count($pages);\r
- $this->xml->addChild('pages', $nb_pages);\r
- $total_size = 0;\r
- foreach ($pages as $page => $info) {\r
- $file = WS_DOCS . '/' . $info['document_id'] . '/p' . $info['document_page'] . '.swf';\r
- $total_size += filesize($file);\r
- }\r
- $average_size = $total_size / $nb_pages;\r
- $total = self::formatSize($total_size);\r
- $average = self::formatSize($average_size);\r
- $firstDoc = $daoDoc->selectById($pages[1]['document_id']);\r
- $size = $firstDoc->generalInfos['size'];\r
- $this->xml->addChild('width', $size[0]);\r
- $this->xml->addChild('height', $size[1]);\r
- $res = __('Nombre de pages') . ' : ' . "\n";\r
- $res .= $nb_pages . ' ' . __('pages') . "\n";\r
- $res .= "\n";\r
- $res .= __('Dimensions') . ' : ' . "\n";\r
- $res .= round($size[0], 3) . ' x ' . round($size[1], 3) . ' pts' . "\n";\r
- $res .= "\n";\r
- $res .= __('Taille totale des pages') . ' : ' . "\n";\r
- $res .= $total . "\n";\r
- $res .= "\n";\r
- $res .= __('Taille moyenne des pages') . ' : ' . "\n";\r
- $res .= $average . "\n";\r
- $res .= "\n";\r
- /* $res .= __('Taille du PDF') . ' : ' . "\n";\r
- $res .= '7898 Ko' . "\n";\r
- $res .= "\n";\r
- $res .= __('Qualité de conversion') . ' : ' . "\n";\r
- $res .= '150dpi (qualité 85%)' . "\n"; */\r
- $this->xml->addChild('infos', $res);\r
- }\r
-\r
- public function getLangs() {\r
- global $core;\r
- if (isset($this->args['book_id'])) {\r
- $dao = new wsDAOBook($core->con);\r
- $book = $dao->selectById($this->args['book_id']);\r
- $book->traductions = wsLang::checkTranslations($book->traductions);\r
- if ($book->traductions != array()) {\r
- $bookLang = $this->xml->addChild('book_lang', json_encode($book->traductions));\r
- }\r
- }\r
-\r
- $dao = new wsDAOLang($core->con);\r
- $langs = $dao->selectAll();\r
- foreach ($langs as $lang) {\r
- $nom = cubeLang::getNameByCode($lang->lang_id, $core->user->lang);\r
- $l = $this->xml->addChild('lang', json_encode($lang->traductions));\r
- $l->addAttribute('id', $lang->lang_id);\r
- $l->addAttribute('nom', $nom);\r
- if (isset($book) && $book->lang == $lang->lang_id) {\r
- if (!isset($bookLang)) {\r
- $l->addAttribute('selected', '1');\r
- } else {\r
- $bookLang->addAttribute('id', $lang->lang_id);\r
- $bookLang->addAttribute('nom', $nom . ' (' . __('modifié') . ')');\r
- $bookLang->addAttribute('selected', '1');\r
- }\r
- }\r
- }\r
- }\r
-\r
- public function saveLang() {\r
- global $core;\r
- $dao = new wsDAOBook($core->con);\r
- $dao->setLang($this->args['book_id'], $this->args['lang_id'], $this->args['traductions']);\r
- }\r
-\r
- public function saveComposition() {\r
- global $core;\r
- $dao = new wsDAOBook($core->con);\r
- $dao->setComposition($this->args['book_id'], json_decode($this->args['pages']));\r
- }\r
-\r
- public function getTexts() {\r
- $this->xml->addChild('texts', json_encode($GLOBALS['__l10n']));\r
- }\r
-\r
- public function copyLinks() {\r
- global $core;\r
- $daoDocument = new wsDAODocument($core->con);\r
- $daoDocument->copyLinks($this->args['fromDoc'], $this->args['toDoc']);\r
- }\r
-\r
- public function compile() {\r
- global $core;\r
- wsSecureSWF::checkProtectedSWF();\r
- $dao = new wsDAOBook($core->con);\r
- if (!$dao->isUpToDate($this->args['book_id'])) {\r
- $log = $dao->compile($this->args['book_id'], 3);\r
- $log = str_replace('&', '&', $log);\r
- $log = str_replace('&', '&', $log);\r
- // $this->xml->addChild('log', $log);\r
- }\r
- $book = $dao->selectById($this->args['book_id']);\r
- $viewer = 'viewer';\r
- if (wsDroits::admin()) {\r
- $viewer = 'vieweru';\r
- }\r
-\r
- $absoluteURL = 'http://' . $_SERVER['HTTP_HOST'] . '/' . $viewer . '/' . $book->book_id . '_' . $book->hash . '_' . TIME . '/';\r
- $this->xml->addChild('compiledBook', $absoluteURL . 'index.swf?base=' . $absoluteURL);\r
- }\r
+ const CNAME = __CLASS__;\r
+\r
+ public static function in($args) {\r
+ global $core;\r
+ $args = cubePage::getArgs($args);\r
+ $n = self::CNAME;\r
+ $gateway = new $n($core->con, $args);\r
+\r
+ $droits = wsDroits::getDroits();\r
+ $gateway->addAttribute('creation', $droits->creation ? '1' : '0');\r
+ $gateway->addAttribute('revendeur', $droits->revendeur ? '1' : '0');\r
+ $gateway->addAttribute('admin', $droits->admin ? '1' : '0');\r
+ $gateway->addAttribute('grade', $core->user->ws_grade);\r
+ }\r
+\r
+ public function saveConversionSettings() {\r
+ global $core;\r
+ $dao = new commonDAOUtilisateur($core->con);\r
+ $datas = array('resolution' => $this->args['resolution'],\r
+ 'objects' => $this->args['objects'],\r
+ 'method' => $this->args['method'],\r
+ 'quality' => $this->args['quality'],\r
+ 'version' => $this->args['version']);\r
+ $dao->sauveWSSettings($core->user->utilisateur_id, $datas);\r
+ }\r
+\r
+ public function getConversionSettings() {\r
+ global $core;\r
+ $this->xml->addChild('resolution', $core->user->ws_settings['resolution']);\r
+ $this->xml->addChild('quality', $core->user->ws_settings['quality']);\r
+ $this->xml->addChild('method', $core->user->ws_settings['method']);\r
+ $this->xml->addChild('objects', $core->user->ws_settings['objects']);\r
+ $this->xml->addChild('version', $core->user->ws_settings['version']);\r
+ }\r
+\r
+ public function uploadDocument() {\r
+ cubePHP::neverStop();\r
+ global $core;\r
+ if (!isset($_SESSION['conversionSession'])) {\r
+ $_SESSION['conversionSession'] = array();\r
+ }\r
+ $dao = new wsDAODocument($core->con);\r
+ foreach ($_FILES as $varname => $infos) {\r
+ if ($infos['error']) {\r
+ continue;\r
+ }\r
+ // Initialisation du document\r
+ $data = array();\r
+ $data['proprietaire'] = $core->user->utilisateur_id;\r
+ $data['pages'] = 0;\r
+ $data['version'] = 2;\r
+ $data['file'] = cubeFiles::tidyName($infos['name']);\r
+ $li = new wsDocumentLocalInfos($this);\r
+ $li->fileName = $this->args['fileName'];\r
+ $li->fileSize = $this->args['fileSize'];\r
+ $li->creationDate = $this->args['creationDate'];\r
+ $li->modificationDate = $this->args['modificationDate'];\r
+ $data['localInfos'] = $li;\r
+ $data['conversionInfos'] = new wsDocumentConversionInfos($this->args['resolution'], $this->args['method'], $this->args['quality'], $this->args['objects'], $this->args['version']);\r
+ $document = $dao->sauve($data);\r
+ $document->copyOriginalFromUpload($infos['tmp_name']);\r
+ $this->xml->addChild('document_id', $document->document_id);\r
+ $_SESSION['conversionSession'][$document->document_id] = 'all';\r
+ $_SESSION['conversionSessionReload'] = false;\r
+ }\r
+ }\r
+\r
+ public function addDocument() {\r
+ $_SESSION['conversionSession'] = array();\r
+ $_SESSION['conversionSession'][$this->args['document_id']] = 'all';\r
+ $_SESSION['conversionSessionReload'] = false;\r
+ }\r
+\r
+ public function reload() {\r
+ global $core;\r
+\r
+ if ($this->args['reloadDocs'] == '1') {\r
+ foreach ($this->args['documents'] as $document_id => $pages) {\r
+ $this->args['documents'][$document_id] = 'all';\r
+ }\r
+ }\r
+\r
+ $dao = new wsDAODocument($core->con);\r
+ $_SESSION['conversionSession'] = $this->args['documents'];\r
+ $_SESSION['conversionSessionReload'] = true;\r
+ foreach ($this->args['documents'] as $id => $pages) {\r
+ $doc = $dao->selectById($id);\r
+ $doc->conversionInfos->updatePages($pages, $this->args['resolution'], $this->args['quality'], $this->args['method'], $this->args['objects'], $this->args['version']);\r
+ $dao->updateFromObject($doc);\r
+ }\r
+ }\r
+\r
+ public function processConversionSession() {\r
+ $_SESSION['sessionConversionGUID'] = $sessionConversionGUID = uniqid('conversion_', true);\r
+ $session = new wsConversionSession($sessionConversionGUID);\r
+ $session->reload = $_SESSION['conversionSessionReload'];\r
+ $session->setDocuments($_SESSION['conversionSession']);\r
+ $session->setBook($this->args['book_id']);\r
+ unset($_SESSION['conversionSession']);\r
+ unset($_SESSION['conversionSessionReload']);\r
+ $session->serialize();\r
+\r
+ $php = new cubeCommandLine('php');\r
+ $php->setPath(CONVERTER_PATH);\r
+ $php->setArg('f', ROOT . '/index.php');\r
+ $php->setManualArg('--');\r
+ $php->setArg('user_email', $_SESSION['user_email']);\r
+ $php->setArg('user_password', $_SESSION['user_password']);\r
+ $php->setArg('sessionConversionGUID', $sessionConversionGUID);\r
+ $php->setArg('PATH_INFO', '/flash/processConversionSessionAsync');\r
+ $php->setArg('HTTP_HOST', $_SERVER['HTTP_HOST']);\r
+ $php->setNohup(true);\r
+ $php->execute('exec');\r
+\r
+ $this->xml->addChild('command', html::escapeHTML($php->command));\r
+ exit;\r
+ }\r
+\r
+ public function processConversionSessionAsync() {\r
+ cubePHP::neverStop();\r
+ try {\r
+ $conversion = wsConversionSession::openFromGUID($_REQUEST['sessionConversionGUID']);\r
+ $conversion->process();\r
+ } catch (Exception $e) {\r
+ file_put_contents(CACHE . '/conversionExceptions.txt', print_r($e, true), FILE_APPEND);\r
+ }\r
+ $conversion->destroy();\r
+ }\r
+\r
+ public function getConversionSessionProgress() {\r
+ set_time_limit(1);\r
+ $session = wsConversionSession::openFromGUID($_SESSION['sessionConversionGUID']);\r
+ $p = $session->getProgress();\r
+ $this->xml->addChild('progress', $p['progress']);\r
+ $this->xml->addChild('processedDoc', $p['processedDoc']);\r
+ $this->xml->addChild('totalDoc', $p['totalDoc']);\r
+ $this->xml->addChild('currentDoc', $p['currentDoc']);\r
+ $this->xml->addChild('currentDocPage', $p['currentDocPage']);\r
+ $this->xml->addChild('totalDocPage', $p['totalDocPage']);\r
+ }\r
+\r
+ public function uploadThemeFile() {\r
+ foreach ($_FILES as $varname => $infos) {\r
+ if ($infos['error']) {\r
+ continue;\r
+ }\r
+ $fname = cubeFiles::tidyName($infos['name']);\r
+ $dest = '/' . $this->args['theme_id'] . '/' . $fname;\r
+\r
+ if (!file_exists(WS_THEMES . '/' . $this->args['theme_id'])) {\r
+ mkdir(WS_THEMES . '/' . $this->args['theme_id'], 0755, true);\r
+ }\r
+\r
+ move_uploaded_file($infos['tmp_name'], WS_THEMES . $dest);\r
+ $this->xml->addChild('file', $fname);\r
+ return;\r
+ }\r
+ }\r
+\r
+ public function uploadLinkContent() {\r
+ foreach ($_FILES as $varname => $infos) {\r
+ if ($infos['error']) {\r
+ continue;\r
+ }\r
+\r
+ if (isset($_POST['dir'])) {\r
+ $dir = trim($_POST['dir'], '/\\ ');\r
+ } else {\r
+ $dir = '';\r
+ }\r
+\r
+ if ($dir != '') {\r
+ $dir = $dir . '/';\r
+ }\r
+\r
+ $fname = cubeFiles::tidyName($infos['name']);\r
+ $dir = WS_BOOKS . '/working/' . $this->args['book_id'] . '/' . $dir;\r
+ if (!file_exists($dir)) {\r
+ mkdir($dir, 0777, true);\r
+ }\r
+ $dest = $dir . $fname;\r
+ move_uploaded_file($infos['tmp_name'], $dest);\r
+ if (in_array(strtolower(files::getExtension($dest)), array('flv', 'f4v', 'mp4'))) {\r
+ // convert uploaded file as webvideo (ogv and mp4)\r
+ wsTools::encodeWebVideos($dest, null, true, false);\r
+ }\r
+ $this->xml->addChild('file', $fname);\r
+ return;\r
+ }\r
+ }\r
+\r
+ public function testDocuments() {\r
+ global $core;\r
+\r
+ $toload = $this->xml->addChild('toLoad');\r
+ $alreadyLoaded = $this->xml->addChild('alreadyLoaded');\r
+\r
+ $hash = array();\r
+\r
+ foreach ($this->args['fileName'] as $k => $name) {\r
+ $o = new wsDocumentLocalInfos();\r
+ $o->fileName = $name;\r
+ $o->fileSize = intval($this->args['fileSize'][$k]);\r
+ $o->modificationDate = intval($this->args['modificationDate'][$k]);\r
+ $o->creationDate = intval($this->args['creationDate'][$k]);\r
+\r
+ $hash[$k] = md5(serialize($o));\r
+ }\r
+\r
+ $in = array();\r
+ foreach ($hash as $h) {\r
+ $in[] = "'" . $h . "'";\r
+ }\r
+\r
+ $sql = 'SELECT document_id,localHash FROM documents WHERE localHash';\r
+ if (count($in) == 1) {\r
+ $sql .= ' = ' . implode(',', $in);\r
+ } else {\r
+ $sql .= ' IN (' . implode(',', $in) . ')';\r
+ }\r
+\r
+ $al = array();\r
+ $r = $core->con->select($sql);\r
+ while ($r->fetch()) {\r
+ $k = array_search($r->localHash, $hash);\r
+\r
+ if (!file_exists(WS_DOCS . '/' . $r->document_id . '/original.pdf')) {\r
+ continue;\r
+ }\r
+\r
+ $al[$k] = true;\r
+ $f = $alreadyLoaded->addChild('file', $this->args['fileName'][$k]);\r
+ $f->addAttribute('document_id', $r->document_id);\r
+ }\r
+\r
+ foreach ($this->args['fileName'] as $k => $name) {\r
+ if (!isset($al[$k])) {\r
+ $toload->addChild('file', $name);\r
+ }\r
+ }\r
+ }\r
+\r
+ public function getPagesOfBook() {\r
+ global $core;\r
+ $dao = new wsDAOBook($core->con);\r
+ $book = $dao->selectById($this->args['book_id']);\r
+ $pages = $dao->getPagesOfBook($this->args['book_id']);\r
+ $p = $this->xml->addChild('pages');\r
+ $docs = array();\r
+ $defaultNum = array();\r
+ foreach ($pages as $page => $info) {\r
+ $file = WS_DOCS . '/' . $info['document_id'] . '/p' . $info['document_page'] . '.jpg';\r
+ if (!file_exists($file)) {\r
+ $dim = array(0, 0);\r
+ $info['resolution'] = 150;\r
+ $info['method'] = 1;\r
+ $info['objects'] = 1800;\r
+ $info['quality'] = 85;\r
+ $info['version']='stable';\r
+ } else {\r
+ $dim = getimagesize($file);\r
+ }\r
+\r
+\r
+\r
+ $pa = $p->addChild('page');\r
+ $pa->addAttribute('page', $page);\r
+ $pa->addAttribute('document_id', $info['document_id']);\r
+ $pa->addAttribute('document_page', $info['document_page']);\r
+ $pa->addAttribute('width', $dim[0]);\r
+ $pa->addAttribute('height', $dim[1]);\r
+ $pa->addAttribute('resolution', $info['resolution']);\r
+ $pa->addAttribute('quality', $info['quality']);\r
+ $pa->addAttribute('methode', $info['method']);\r
+ $pa->addAttribute('objects', $info['objects']);\r
+ $pa->addAttribute('version', $info['version']);\r
+ $docs[] = $info['document_id'];\r
+ $defaultNum[] = $info['defaultNum'];\r
+ }\r
+ $docs = array_unique($docs);\r
+ $p->addAttribute('documents', implode(',', $docs));\r
+ if (is_null($book->numerotation) || !$book->numerotation || $book->numerotation == 'null') {\r
+ $this->xml->addChild('numerotation', implode(',', $defaultNum));\r
+ } else {\r
+ $this->xml->addChild('numerotation', $book->numerotation);\r
+ }\r
+ }\r
+\r
+ public function getTheme() {\r
+ global $core;\r
+ $dao = new wsDAOTheme($core->con);\r
+ if (isset($this->args['theme_id'])) {\r
+ $theme = $dao->selectById($this->args['theme_id']);\r
+ } else {\r
+ $theme = $dao->getThemeOfBook($this->args['book_id']);\r
+ }\r
+ $this->_themeToXML($theme);\r
+ }\r
+\r
+ public function saveTheme() {\r
+ global $core;\r
+ $dao = new wsDAOTheme($core->con);\r
+ $dao->sauve($this->args);\r
+ }\r
+\r
+ public function getAllThemes() {\r
+ global $core;\r
+\r
+ if (isset($this->args['book_id'])) {\r
+ $dao = new wsDAOBook($core->con);\r
+ $book = $dao->selectById($this->args['book_id']);\r
+ } else {\r
+ $this->args['book_id'] = 0;\r
+ }\r
+\r
+ $dao = new wsDAOTheme($core->con);\r
+ $themes = $dao->getAllThemes($core->user, 'ORDER BY FIELD (theme_id,' . $this->args['book_id'] . ',1) DESC, theme_id DESC', true);\r
+ foreach ($themes as $theme) {\r
+ $t = $this->xml->addChild('theme');\r
+ $t->addAttribute('id', $theme->theme_id);\r
+ $t->addAttribute('nom', $theme->nom);\r
+ if (isset($book) && $theme->theme_id == $book->theme) {\r
+ $t->addAttribute('selected', '1');\r
+ $mine = true;\r
+ } else {\r
+ $mine = false;\r
+ }\r
+ if (wsDroits::revendeur() && wsDroits::creation()) {\r
+ $right = 'w';\r
+ } else {\r
+ $right = 'r';\r
+ }\r
+ $t->addAttribute('right', $right);\r
+ $t->addAttribute('proprietaire', $theme->proprietaire_nom);\r
+ $t->addAttribute('books', max(($theme->nbBooks) - ($mine ? 1 : 0), 0));\r
+ }\r
+ }\r
+\r
+ public function deleteTheme() {\r
+ global $core;\r
+\r
+ $dao = new wsDAOTheme($core->con);\r
+ $dao->delete($this->args['theme_id']);\r
+ }\r
+\r
+ public function renameTheme() {\r
+ global $core;\r
+\r
+ $dao = new wsDAOTheme($core->con);\r
+ $dao->rename($this->args['theme_id'], $this->args['text']);\r
+ }\r
+\r
+ public function duplicateTheme() {\r
+ global $core;\r
+ $dao = new wsDAOTheme($core->con);\r
+ $theme = $dao->duplicate($this->args['theme_id'], $core->user->utilisateur_id);\r
+ $this->xml->addChild('theme_id', $theme->theme_id);\r
+ if (isset($this->args['book_id'])) {\r
+ $dao = new wsDAOBook($core->con);\r
+ $data = array('book_id' => $this->args['book_id'], 'theme' => $theme->theme_id);\r
+ $dao->sauve($core->user->utilisateur_id, $data);\r
+ }\r
+ }\r
+\r
+ public function setTheme() {\r
+ global $core;\r
+ $dao = new wsDAOBook($core->con);\r
+ $dao->setTheme($this->args['book_id'], $this->args['theme']);\r
+ }\r
+\r
+ public function postThemeShot() {\r
+ file_put_contents(WS_THEMES . '/' . $this->args['theme_id'] . '.jpg', base64_decode($this->args['data']));\r
+ }\r
+\r
+ public function getAllIcones() {\r
+ global $core;\r
+ $dao = new wsDAOIcone($core->con);\r
+ $icones = $dao->selectAll('ORDER BY icone_id DESC');\r
+ foreach ($icones as $icone) {\r
+ $i = $this->xml->addChild('icone');\r
+ $i->addAttribute('id', $icone->icone_id);\r
+ $i->addAttribute('nom', $icone->nom);\r
+ $i->addAttribute('path', ICONS . $icone->icone_id . '.png');\r
+ }\r
+ }\r
+\r
+ protected function _themeToXML($theme) {\r
+ $t = $this->xml->addChild('theme');\r
+ $t->addAttribute('theme_id', $theme->theme_id);\r
+ $t->addAttribute('icones_id', $theme->icones);\r
+ foreach ($theme->parametres as $k => $v) {\r
+ $t->addChild($k, $v);\r
+ }\r
+ }\r
+\r
+ public function getThemeForms() {\r
+ global $core;\r
+ $dao = new wsDAOTheme($core->con);\r
+ $theme = $dao->selectById($this->args['theme_id']);\r
+\r
+ foreach ($theme->parametres->getForms() as $name) {\r
+ $f = $this->xml->addChild('form', json_encode($theme->parametres->getForm($name)));\r
+ $f->addAttribute('name', $name);\r
+ }\r
+ }\r
+\r
+ public function getFluidbookForms() {\r
+ global $core;\r
+ $dao = new wsDAOBook($core->con);\r
+ $book = $dao->selectById($this->args['book_id']);\r
+ foreach ($book->parametres->getForms() as $name) {\r
+ $f = $this->xml->addChild('form', html::escapeHTML(json_encode($book->parametres->getForm($name))));\r
+ $f->addAttribute('name', $name);\r
+ }\r
+ }\r
+\r
+ public function saveSettings() {\r
+ global $core;\r
+ $dao = new wsDAOBook($core->con);\r
+ $dao->setSettings($this->args['book_id'], $this->args['settings']);\r
+ }\r
+\r
+ public function setChapters() {\r
+ global $core;\r
+ $dao = new wsDAOBook($core->con);\r
+ $dao->setChapters($this->args['book_id'], $this->args['chapters']);\r
+ }\r
+\r
+ public function getChapters() {\r
+ global $core;\r
+ $dao = new wsDAOBook($core->con);\r
+ $book = $dao->selectById($this->args['book_id']);\r
+ $this->xml->addChild('chapters', html::escapeHTML(json_encode($book->chapters)));\r
+ }\r
+\r
+ public function getLinks() {\r
+ global $core;\r
+ $dao = new wsDAOBook($core->con);\r
+ $book = $dao->selectById($this->args['book_id']);\r
+\r
+ $pages = $dao->getPagesOfBook($this->args['book_id']);\r
+ $nb_pages = count($pages);\r
+ $this->xml->addChild('pages', $nb_pages);\r
+ $this->xml->addChild('numerotation', $book->numerotation);\r
+\r
+ $daoDoc = new wsDAODocument($core->con);\r
+ $firstDoc = $daoDoc->selectById($pages[1]['document_id']);\r
+ $size = $firstDoc->generalInfos['size'];\r
+ $daoDoc->getLinksAndRulers($this->args['book_id'], $links, $rulers);\r
+\r
+ $this->xml->addChild('width', $size[0]);\r
+ $this->xml->addChild('height', $size[1]);\r
+ $this->xml->addChild('links', html::escapeHTML(json_encode($links)));\r
+ $this->xml->addChild('rulers', json_encode($rulers));\r
+\r
+ $daoTheme = new wsDAOTheme($this->con);\r
+ $theme = $daoTheme->getThemeOfBook($this->args['book_id'], true);\r
+\r
+ $specials = array('backgroundImage' => 'background', 'topBar' => 'topbar', 'afterSearch' => 'aftersearch');\r
+\r
+ foreach ($specials as $tparam => $sname) {\r
+ $this->_addSpecialInfos($theme, $tparam, $sname);\r
+ }\r
+ }\r
+\r
+ protected function _addSpecialInfos($theme, $param, $specialName) {\r
+ if ($theme->parametres->$param != '') {\r
+ $themeRoot = WS_THEMES . '/' . $theme->theme_id . '/';\r
+ $dim = getimagesize($themeRoot . $theme->parametres->$param);\r
+ $b = $this->xml->addChild($specialName);\r
+ $b->addChild('width', $dim[0]);\r
+ $b->addChild('height', $dim[1]);\r
+ $b->addChild('url', 'http://' . $_SERVER['HTTP_HOST'] . WEBROOT . '/fluidbook/themes/' . $theme->theme_id . '/' . $theme->parametres->$param);\r
+ }\r
+ }\r
+\r
+ public function saveLinks() {\r
+ global $core;\r
+\r
+ $comments = isset($this->args['comments']) ? $this->args['comments'] : 'Saved from editor';\r
+\r
+ $dao = new wsDAODocument($core->con);\r
+ $dao->setLinksAndRulers($this->args['book_id'], $this->args['links'], $this->args['rulers'], $comments, $core->user->utilisateur_id);\r
+\r
+ $daoBook = new wsDAOBook($core->con);\r
+ $daoBook->setSpecialLinksAndRulers($this->args['book_id'], $this->args['specialLinks'], $this->args['specialRulers']);\r
+\r
+ if (isset($this->args['getLinks'])) {\r
+ $this->getLinks();\r
+ }\r
+ }\r
+\r
+ public function formatSize($val) {\r
+ $str = files::size($val);\r
+ $str = str_replace('.', __(','), $str);\r
+ $str = str_replace('B', __('o'), $str);\r
+ return $str;\r
+ }\r
+\r
+ public function getExtras() {\r
+ global $core;\r
+ $dao = new wsDAOBook($core->con);\r
+ $book = $dao->selectById($this->args['book_id']);\r
+ if ($book->extras != '') {\r
+ $tidy = cubeXML::tidy('<extras>' . $book->extras . '</extras>');\r
+ $tidy = str_replace('<extras>', '', $tidy);\r
+ $tidy = str_replace('</extras>', '', $tidy);\r
+ $tidy = str_replace('<?xml version="1.0"?>', '', $tidy);\r
+ $tidy = trim($tidy);\r
+ $e = explode("\n", $tidy);\r
+ foreach ($e as $k => $v) {\r
+ if (substr($v, 0, 2) == ' ') {\r
+ $v = substr($v, 2);\r
+ }\r
+ $e[$k] = $v;\r
+ }\r
+\r
+ $extras = implode("\n", $e);\r
+ } else {\r
+ $extras = '';\r
+ }\r
+\r
+ $this->xml->addChild('extras', $extras);\r
+ }\r
+\r
+ public function saveExtras() {\r
+ global $core;\r
+ $dao = new wsDAOBook($core->con);\r
+ $res = $dao->setExtras($this->args['book_id'], $this->args['extras']);\r
+ $this->xml->addChild('ok', $res ? '1' : '0');\r
+ }\r
+\r
+ public function getBookInfos() {\r
+ global $core;\r
+ $dao = new wsDAOBook($core->con);\r
+ $book = $dao->selectById($this->args['book_id']);\r
+ $pages = $dao->getPagesOfBook($this->args['book_id']);\r
+ $daoDoc = new wsDAODocument($core->con);\r
+ $nb_pages = count($pages);\r
+ $this->xml->addChild('pages', $nb_pages);\r
+ $total_size = 0;\r
+ foreach ($pages as $page => $info) {\r
+ $file = WS_DOCS . '/' . $info['document_id'] . '/p' . $info['document_page'] . '.swf';\r
+ $total_size += filesize($file);\r
+ }\r
+ $average_size = $total_size / $nb_pages;\r
+ $total = self::formatSize($total_size);\r
+ $average = self::formatSize($average_size);\r
+ $firstDoc = $daoDoc->selectById($pages[1]['document_id']);\r
+ $size = $firstDoc->generalInfos['size'];\r
+ $this->xml->addChild('width', $size[0]);\r
+ $this->xml->addChild('height', $size[1]);\r
+ $res = __('Nombre de pages') . ' : ' . "\n";\r
+ $res .= $nb_pages . ' ' . __('pages') . "\n";\r
+ $res .= "\n";\r
+ $res .= __('Dimensions') . ' : ' . "\n";\r
+ $res .= round($size[0], 3) . ' x ' . round($size[1], 3) . ' pts' . "\n";\r
+ $res .= "\n";\r
+ $res .= __('Taille totale des pages') . ' : ' . "\n";\r
+ $res .= $total . "\n";\r
+ $res .= "\n";\r
+ $res .= __('Taille moyenne des pages') . ' : ' . "\n";\r
+ $res .= $average . "\n";\r
+ $res .= "\n";\r
+ /* $res .= __('Taille du PDF') . ' : ' . "\n";\r
+ $res .= '7898 Ko' . "\n";\r
+ $res .= "\n";\r
+ $res .= __('Qualité de conversion') . ' : ' . "\n";\r
+ $res .= '150dpi (qualité 85%)' . "\n"; */\r
+ $this->xml->addChild('infos', $res);\r
+ }\r
+\r
+ public function getLangs() {\r
+ global $core;\r
+ if (isset($this->args['book_id'])) {\r
+ $dao = new wsDAOBook($core->con);\r
+ $book = $dao->selectById($this->args['book_id']);\r
+ $book->traductions = wsLang::checkTranslations($book->traductions);\r
+ if ($book->traductions != array()) {\r
+ $bookLang = $this->xml->addChild('book_lang', json_encode($book->traductions));\r
+ }\r
+ }\r
+\r
+ $dao = new wsDAOLang($core->con);\r
+ $langs = $dao->selectAll();\r
+ foreach ($langs as $lang) {\r
+ $nom = cubeLang::getNameByCode($lang->lang_id, $core->user->lang);\r
+ $l = $this->xml->addChild('lang', json_encode($lang->traductions));\r
+ $l->addAttribute('id', $lang->lang_id);\r
+ $l->addAttribute('nom', $nom);\r
+ if (isset($book) && $book->lang == $lang->lang_id) {\r
+ if (!isset($bookLang)) {\r
+ $l->addAttribute('selected', '1');\r
+ } else {\r
+ $bookLang->addAttribute('id', $lang->lang_id);\r
+ $bookLang->addAttribute('nom', $nom . ' (' . __('modifié') . ')');\r
+ $bookLang->addAttribute('selected', '1');\r
+ }\r
+ }\r
+ }\r
+ }\r
+\r
+ public function saveLang() {\r
+ global $core;\r
+ $dao = new wsDAOBook($core->con);\r
+ $dao->setLang($this->args['book_id'], $this->args['lang_id'], $this->args['traductions']);\r
+ }\r
+\r
+ public function saveComposition() {\r
+ global $core;\r
+ $dao = new wsDAOBook($core->con);\r
+ $dao->setComposition($this->args['book_id'], json_decode($this->args['pages']));\r
+ }\r
+\r
+ public function getTexts() {\r
+ $this->xml->addChild('texts', json_encode($GLOBALS['__l10n']));\r
+ }\r
+\r
+ public function copyLinks() {\r
+ global $core;\r
+ $daoDocument = new wsDAODocument($core->con);\r
+ $daoDocument->copyLinks($this->args['fromDoc'], $this->args['toDoc']);\r
+ }\r
+\r
+ public function compile() {\r
+ global $core;\r
+ wsSecureSWF::checkProtectedSWF();\r
+ $dao = new wsDAOBook($core->con);\r
+ if (!$dao->isUpToDate($this->args['book_id'])) {\r
+ $log = $dao->compile($this->args['book_id'], 3);\r
+ $log = str_replace('&', '&', $log);\r
+ $log = str_replace('&', '&', $log);\r
+ // $this->xml->addChild('log', $log);\r
+ }\r
+ $book = $dao->selectById($this->args['book_id']);\r
+ $viewer = 'viewer';\r
+ if (wsDroits::admin()) {\r
+ $viewer = 'vieweru';\r
+ }\r
+\r
+ $absoluteURL = 'http://' . $_SERVER['HTTP_HOST'] . '/' . $viewer . '/' . $book->book_id . '_' . $book->hash . '_' . TIME . '/';\r
+ $this->xml->addChild('compiledBook', $absoluteURL . 'index.swf?base=' . $absoluteURL);\r
+ }\r
\r
}\r
\r