From: vincent@cubedesigners.com Date: Tue, 10 May 2011 18:10:58 +0000 (+0000) Subject: (no commit message) X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=2c87f1c8aa40d09cf5f8dcc70eb258fcaf7c0d01;p=cubeextranet.git --- diff --git a/inc/ws/Controlleur/class.ws.flash.php b/inc/ws/Controlleur/class.ws.flash.php index eb2f32327..af4f95792 100644 --- a/inc/ws/Controlleur/class.ws.flash.php +++ b/inc/ws/Controlleur/class.ws.flash.php @@ -1,22 +1,22 @@ 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('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() - { + public function saveConversionSettings() { global $core; $dao = new commonDAOUtilisateur($core->con); $datas = array('resolution' => $this->args['resolution'], @@ -26,8 +26,7 @@ class wsFlash extends cubeFlashGateway { $dao->sauveWSSettings($core->user->utilisateur_id, $datas); } - public function getConversionSettings() - { + public function getConversionSettings() { global $core; $this->xml->addChild('resolution', $core->user->ws_settings['resolution']); $this->xml->addChild('quality', $core->user->ws_settings['quality']); @@ -35,15 +34,14 @@ class wsFlash extends cubeFlashGateway { $this->xml->addChild('objects', $core->user->ws_settings['objects']); } - public function uploadDocument() - { + public function uploadDocument() { cubePHP::neverStop(); global $core; if (!isset($_SESSION['conversionSession'])) { $_SESSION['conversionSession'] = array(); } $dao = new wsDAODocument($core->con); - foreach($_FILES as $varname => $infos) { + foreach ($_FILES as $varname => $infos) { if ($infos['error']) { continue; } @@ -68,19 +66,17 @@ class wsFlash extends cubeFlashGateway { } } - public function addDocument() - { + public function addDocument() { $_SESSION['conversionSession'] = array(); $_SESSION['conversionSession'][$this->args['document_id']] = 'all'; $_SESSION['conversionSessionReload'] = false; } - public function reload() - { + public function reload() { global $core; if ($this->args['reloadDocs'] == '1') { - foreach($this->args['documents'] as $document_id => $pages) { + foreach ($this->args['documents'] as $document_id => $pages) { $this->args['documents'][$document_id] = 'all'; } } @@ -88,15 +84,14 @@ class wsFlash extends cubeFlashGateway { $dao = new wsDAODocument($core->con); $_SESSION['conversionSession'] = $this->args['documents']; $_SESSION['conversionSessionReload'] = true; - foreach($this->args['documents'] as $id => $pages) { + 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() - { + public function processConversionSession() { $_SESSION['sessionConversionGUID'] = $sessionConversionGUID = uniqid('conversion_', true); $session = new wsConversionSession($sessionConversionGUID); $session->reload = $_SESSION['conversionSessionReload']; @@ -122,21 +117,18 @@ class wsFlash extends cubeFlashGateway { exit; } - public function processConversionSessionAsync() - { + public function processConversionSessionAsync() { cubePHP::neverStop(); try { $conversion = wsConversionSession::openFromGUID($_REQUEST['sessionConversionGUID']); $conversion->process(); - } - catch(Exception $e) { + } catch (Exception $e) { file_put_contents(CACHE . '/conversionExceptions.txt', print_r($e, true), FILE_APPEND); } $conversion->destroy(); } - public function getConversionSessionProgress() - { + public function getConversionSessionProgress() { set_time_limit(1); $session = wsConversionSession::openFromGUID($_SESSION['sessionConversionGUID']); $p = $session->getProgress(); @@ -148,9 +140,8 @@ class wsFlash extends cubeFlashGateway { $this->xml->addChild('totalDocPage', $p['totalDocPage']); } - public function uploadThemeFile() - { - foreach($_FILES as $varname => $infos) { + public function uploadThemeFile() { + foreach ($_FILES as $varname => $infos) { if ($infos['error']) { continue; } @@ -167,14 +158,13 @@ class wsFlash extends cubeFlashGateway { } } - public function uploadLinkContent() - { - foreach($_FILES as $varname => $infos) { + public function uploadLinkContent() { + foreach ($_FILES as $varname => $infos) { if ($infos['error']) { continue; } $fname = cubeFiles::tidyName($infos['name']); - $dir = WS_BOOKS . '/working/' . $this->args['book_id'] . '/' ; + $dir = WS_BOOKS . '/working/' . $this->args['book_id'] . '/'; if (!file_exists($dir)) { mkdir($dir, 0777, true); } @@ -185,8 +175,7 @@ class wsFlash extends cubeFlashGateway { } } - public function testDocuments() - { + public function testDocuments() { global $core; $toload = $this->xml->addChild('toLoad'); @@ -194,7 +183,7 @@ class wsFlash extends cubeFlashGateway { $hash = array(); - foreach($this->args['fileName'] as $k => $name) { + foreach ($this->args['fileName'] as $k => $name) { $o = new wsDocumentLocalInfos(); $o->fileName = $name; $o->fileSize = intval($this->args['fileSize'][$k]); @@ -205,7 +194,7 @@ class wsFlash extends cubeFlashGateway { } $in = array(); - foreach($hash as $h) { + foreach ($hash as $h) { $in[] = "'" . $h . "'"; } @@ -230,15 +219,14 @@ class wsFlash extends cubeFlashGateway { $f->addAttribute('document_id', $r->document_id); } - foreach($this->args['fileName'] as $k => $name) { + foreach ($this->args['fileName'] as $k => $name) { if (!isset($al[$k])) { $toload->addChild('file', $name); } } } - public function getPagesOfBook() - { + public function getPagesOfBook() { global $core; $dao = new wsDAOBook($core->con); $book = $dao->selectById($this->args['book_id']); @@ -246,7 +234,7 @@ class wsFlash extends cubeFlashGateway { $p = $this->xml->addChild('pages'); $docs = array(); $defaultNum = array(); - foreach($pages as $page => $info) { + foreach ($pages as $page => $info) { $file = WS_DOCS . '/' . $info['document_id'] . '/p' . $info['document_page'] . '.jpg'; if (!file_exists($file)) { continue; @@ -275,8 +263,7 @@ class wsFlash extends cubeFlashGateway { } } - public function getTheme() - { + public function getTheme() { global $core; $dao = new wsDAOTheme($core->con); if (isset($this->args['theme_id'])) { @@ -287,15 +274,13 @@ class wsFlash extends cubeFlashGateway { $this->_themeToXML($theme); } - public function saveTheme() - { + public function saveTheme() { global $core; $dao = new wsDAOTheme($core->con); $dao->sauve($this->args); } - public function getAllThemes() - { + public function getAllThemes() { global $core; if (isset($this->args['book_id'])) { @@ -307,7 +292,7 @@ class wsFlash extends cubeFlashGateway { $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) { + foreach ($themes as $theme) { $t = $this->xml->addChild('theme'); $t->addAttribute('id', $theme->theme_id); $t->addAttribute('nom', $theme->nom); @@ -324,28 +309,25 @@ class wsFlash extends cubeFlashGateway { } $t->addAttribute('right', $right); $t->addAttribute('proprietaire', $theme->proprietaire_nom); - $t->addAttribute('books', max(($theme->nbBooks) - ($mine?1:0), 0)); + $t->addAttribute('books', max(($theme->nbBooks) - ($mine ? 1 : 0), 0)); } } - public function deleteTheme() - { + public function deleteTheme() { global $core; $dao = new wsDAOTheme($core->con); $dao->delete($this->args['theme_id']); } - public function renameTheme() - { + public function renameTheme() { global $core; $dao = new wsDAOTheme($core->con); $dao->rename($this->args['theme_id'], $this->args['text']); } - public function duplicateTheme() - { + public function duplicateTheme() { global $core; $dao = new wsDAOTheme($core->con); $theme = $dao->duplicate($this->args['theme_id'], $core->user->utilisateur_id); @@ -357,24 +339,21 @@ class wsFlash extends cubeFlashGateway { } } - public function setTheme() - { + public function setTheme() { global $core; $dao = new wsDAOBook($core->con); $dao->setTheme($this->args['book_id'], $this->args['theme']); } - public function postThemeShot() - { + public function postThemeShot() { file_put_contents(WS_THEMES . '/' . $this->args['theme_id'] . '.jpg', base64_decode($this->args['data'])); } - public function getAllIcones() - { + public function getAllIcones() { global $core; $dao = new wsDAOIcone($core->con); $icones = $dao->selectAll('ORDER BY icone_id DESC'); - foreach($icones as $icone) { + foreach ($icones as $icone) { $i = $this->xml->addChild('icone'); $i->addAttribute('id', $icone->icone_id); $i->addAttribute('nom', $icone->nom); @@ -382,63 +361,56 @@ class wsFlash extends cubeFlashGateway { } } - protected function _themeToXML($theme) - { + 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) { + foreach ($theme->parametres as $k => $v) { $t->addChild($k, $v); } } - public function getThemeForms() - { + public function getThemeForms() { global $core; $dao = new wsDAOTheme($core->con); $theme = $dao->selectById($this->args['theme_id']); - foreach($theme->parametres->getForms() as $name) { + foreach ($theme->parametres->getForms() as $name) { $f = $this->xml->addChild('form', json_encode($theme->parametres->getForm($name))); $f->addAttribute('name', $name); } } - public function getFluidbookForms() - { + public function getFluidbookForms() { global $core; $dao = new wsDAOBook($core->con); $book = $dao->selectById($this->args['book_id']); - foreach($book->parametres->getForms() as $name) { + 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() - { + public function saveSettings() { global $core; $dao = new wsDAOBook($core->con); $dao->setSettings($this->args['book_id'], $this->args['settings']); } - public function setChapters() - { + public function setChapters() { global $core; $dao = new wsDAOBook($core->con); $dao->setChapters($this->args['book_id'], $this->args['chapters']); } - public function getChapters() - { + 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() - { + public function getLinks() { global $core; $dao = new wsDAOBook($core->con); $book = $dao->selectById($this->args['book_id']); @@ -451,34 +423,47 @@ class wsFlash extends cubeFlashGateway { $daoDoc = new wsDAODocument($core->con); $firstDoc = $daoDoc->selectById($pages[1]['document_id']); $size = $firstDoc->generalInfos['size']; - $daoDoc->getLinksAndRulers($this->args['book_id'], $links , $rulers); + $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); + + if ($theme->parametres->backgroundImage != '' && in_array($theme->parametres->repeat, array(2, 3))) { + $themeRoot = WS_THEMES . '/' . $theme->theme_id . '/' . $theme->parametres->backgroundImage; + $dim = getimagesize($themeRoot); + $b = $this->xml->addChild('background'); + $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->backgroundImage); + } } - public function saveLinks() - { + public function saveLinks() { global $core; $dao = new wsDAODocument($core->con); $dao->setLinksAndRulers($this->args['book_id'], $this->args['links'], $this->args['rulers']); + + $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) - { + public function formatSize($val) { $str = files::size($val); $str = str_replace('.', __(','), $str); $str = str_replace('B', __('o'), $str); return $str; } - public function getExtras() - { + public function getExtras() { global $core; $dao = new wsDAOBook($core->con); $book = $dao->selectById($this->args['book_id']); @@ -489,7 +474,7 @@ class wsFlash extends cubeFlashGateway { $tidy = str_replace('', '', $tidy); $tidy = trim($tidy); $e = explode("\n", $tidy); - foreach($e as $k => $v) { + foreach ($e as $k => $v) { if (substr($v, 0, 2) == ' ') { $v = substr($v, 2); } @@ -504,16 +489,14 @@ class wsFlash extends cubeFlashGateway { $this->xml->addChild('extras', $extras); } - public function saveExtras() - { + 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'); + $this->xml->addChild('ok', $res ? '1' : '0'); } - public function getBookInfos() - { + public function getBookInfos() { global $core; $dao = new wsDAOBook($core->con); $book = $dao->selectById($this->args['book_id']); @@ -522,7 +505,7 @@ class wsFlash extends cubeFlashGateway { $nb_pages = count($pages); $this->xml->addChild('pages', $nb_pages); $total_size = 0; - foreach($pages as $page => $info) { + foreach ($pages as $page => $info) { $file = WS_DOCS . '/' . $info['document_id'] . '/p' . $info['document_page'] . '.swf'; $total_size += filesize($file); } @@ -545,16 +528,15 @@ class wsFlash extends cubeFlashGateway { $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";*/ + /* $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() - { + public function getLangs() { global $core; if (isset($this->args['book_id'])) { $dao = new wsDAOBook($core->con); @@ -567,7 +549,7 @@ class wsFlash extends cubeFlashGateway { $dao = new wsDAOLang($core->con); $langs = $dao->selectAll(); - foreach($langs as $lang) { + 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); @@ -584,34 +566,29 @@ class wsFlash extends cubeFlashGateway { } } - public function saveLang() - { + 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() - { + public function saveComposition() { global $core; $dao = new wsDAOBook($core->con); $dao->setComposition($this->args['book_id'], json_decode($this->args['pages'])); } - public function getTexts() - { + public function getTexts() { $this->xml->addChild('texts', json_encode($GLOBALS['__l10n'])); } - public function copyLinks() - { + public function copyLinks() { global $core; $daoDocument = new wsDAODocument($core->con); $daoDocument->copyLinks($this->args['fromDoc'], $this->args['toDoc']); } - public function compile() - { + public function compile() { global $core; wsSecureSWF::checkProtectedSWF(); $dao = new wsDAOBook($core->con); @@ -630,6 +607,7 @@ class wsFlash extends cubeFlashGateway { $absoluteURL = 'http://' . $_SERVER['HTTP_HOST'] . '/' . $viewer . '/' . $book->book_id . '_' . $book->hash . '_' . TIME . '/'; $this->xml->addChild('compiledBook', $absoluteURL . 'index.swf?base=' . $absoluteURL); } + } ?> \ No newline at end of file