]> _ Git - cubeextranet.git/commitdiff
(no commit message)
authorvincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Tue, 10 May 2011 18:10:58 +0000 (18:10 +0000)
committervincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Tue, 10 May 2011 18:10:58 +0000 (18:10 +0000)
inc/ws/Controlleur/class.ws.flash.php

index eb2f3232785a22191cb5c9b9ed401a162bfc577c..af4f95792904163417187364ec1ad8a21be49558 100644 (file)
@@ -1,22 +1,22 @@
 <?php\r
+\r
 class wsFlash extends cubeFlashGateway {\r
        const CNAME = __CLASS__;\r
-       public static function in($args)\r
-       {\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('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
-       {\r
+       public function saveConversionSettings() {\r
                global $core;\r
                $dao = new commonDAOUtilisateur($core->con);\r
                $datas = array('resolution' => $this->args['resolution'],\r
@@ -26,8 +26,7 @@ class wsFlash extends cubeFlashGateway {
                $dao->sauveWSSettings($core->user->utilisateur_id, $datas);\r
        }\r
 \r
-       public function getConversionSettings()\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
@@ -35,15 +34,14 @@ class wsFlash extends cubeFlashGateway {
                $this->xml->addChild('objects', $core->user->ws_settings['objects']);\r
        }\r
 \r
-       public function uploadDocument()\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
+               foreach ($_FILES as $varname => $infos) {\r
                        if ($infos['error']) {\r
                                continue;\r
                        }\r
@@ -68,19 +66,17 @@ class wsFlash extends cubeFlashGateway {
                }\r
        }\r
 \r
-       public function addDocument()\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
-       {\r
+       public function reload() {\r
                global $core;\r
 \r
                if ($this->args['reloadDocs'] == '1') {\r
-                       foreach($this->args['documents'] as $document_id => $pages) {\r
+                       foreach ($this->args['documents'] as $document_id => $pages) {\r
                                $this->args['documents'][$document_id] = 'all';\r
                        }\r
                }\r
@@ -88,15 +84,14 @@ class wsFlash extends cubeFlashGateway {
                $dao = new wsDAODocument($core->con);\r
                $_SESSION['conversionSession'] = $this->args['documents'];\r
                $_SESSION['conversionSessionReload'] = true;\r
-               foreach($this->args['documents'] as $id => $pages) {\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
-       {\r
+       public function processConversionSession() {\r
                $_SESSION['sessionConversionGUID'] = $sessionConversionGUID = uniqid('conversion_', true);\r
                $session = new wsConversionSession($sessionConversionGUID);\r
                $session->reload = $_SESSION['conversionSessionReload'];\r
@@ -122,21 +117,18 @@ class wsFlash extends cubeFlashGateway {
                exit;\r
        }\r
 \r
-       public function processConversionSessionAsync()\r
-       {\r
+       public function processConversionSessionAsync() {\r
                cubePHP::neverStop();\r
                try {\r
                        $conversion = wsConversionSession::openFromGUID($_REQUEST['sessionConversionGUID']);\r
                        $conversion->process();\r
-               }\r
-               catch(Exception $e) {\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
-       {\r
+       public function getConversionSessionProgress() {\r
                set_time_limit(1);\r
                $session = wsConversionSession::openFromGUID($_SESSION['sessionConversionGUID']);\r
                $p = $session->getProgress();\r
@@ -148,9 +140,8 @@ class wsFlash extends cubeFlashGateway {
                $this->xml->addChild('totalDocPage', $p['totalDocPage']);\r
        }\r
 \r
-       public function uploadThemeFile()\r
-       {\r
-               foreach($_FILES as $varname => $infos) {\r
+       public function uploadThemeFile() {\r
+               foreach ($_FILES as $varname => $infos) {\r
                        if ($infos['error']) {\r
                                continue;\r
                        }\r
@@ -167,14 +158,13 @@ class wsFlash extends cubeFlashGateway {
                }\r
        }\r
 \r
-       public function uploadLinkContent()\r
-       {\r
-               foreach($_FILES as $varname => $infos) {\r
+       public function uploadLinkContent() {\r
+               foreach ($_FILES as $varname => $infos) {\r
                        if ($infos['error']) {\r
                                continue;\r
                        }\r
                        $fname = cubeFiles::tidyName($infos['name']);\r
-                       $dir = WS_BOOKS . '/working/' . $this->args['book_id'] . '/' ;\r
+                       $dir = WS_BOOKS . '/working/' . $this->args['book_id'] . '/';\r
                        if (!file_exists($dir)) {\r
                                mkdir($dir, 0777, true);\r
                        }\r
@@ -185,8 +175,7 @@ class wsFlash extends cubeFlashGateway {
                }\r
        }\r
 \r
-       public function testDocuments()\r
-       {\r
+       public function testDocuments() {\r
                global $core;\r
 \r
                $toload = $this->xml->addChild('toLoad');\r
@@ -194,7 +183,7 @@ class wsFlash extends cubeFlashGateway {
 \r
                $hash = array();\r
 \r
-               foreach($this->args['fileName'] as $k => $name) {\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
@@ -205,7 +194,7 @@ class wsFlash extends cubeFlashGateway {
                }\r
 \r
                $in = array();\r
-               foreach($hash as $h) {\r
+               foreach ($hash as $h) {\r
                        $in[] = "'" . $h . "'";\r
                }\r
 \r
@@ -230,15 +219,14 @@ class wsFlash extends cubeFlashGateway {
                        $f->addAttribute('document_id', $r->document_id);\r
                }\r
 \r
-               foreach($this->args['fileName'] as $k => $name) {\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
-       {\r
+       public function getPagesOfBook() {\r
                global $core;\r
                $dao = new wsDAOBook($core->con);\r
                $book = $dao->selectById($this->args['book_id']);\r
@@ -246,7 +234,7 @@ class wsFlash extends cubeFlashGateway {
                $p = $this->xml->addChild('pages');\r
                $docs = array();\r
                $defaultNum = array();\r
-               foreach($pages as $page => $info) {\r
+               foreach ($pages as $page => $info) {\r
                        $file = WS_DOCS . '/' . $info['document_id'] . '/p' . $info['document_page'] . '.jpg';\r
                        if (!file_exists($file)) {\r
                                continue;\r
@@ -275,8 +263,7 @@ class wsFlash extends cubeFlashGateway {
                }\r
        }\r
 \r
-       public function getTheme()\r
-       {\r
+       public function getTheme() {\r
                global $core;\r
                $dao = new wsDAOTheme($core->con);\r
                if (isset($this->args['theme_id'])) {\r
@@ -287,15 +274,13 @@ class wsFlash extends cubeFlashGateway {
                $this->_themeToXML($theme);\r
        }\r
 \r
-       public function saveTheme()\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
-       {\r
+       public function getAllThemes() {\r
                global $core;\r
 \r
                if (isset($this->args['book_id'])) {\r
@@ -307,7 +292,7 @@ class wsFlash extends cubeFlashGateway {
 \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
+               foreach ($themes as $theme) {\r
                        $t = $this->xml->addChild('theme');\r
                        $t->addAttribute('id', $theme->theme_id);\r
                        $t->addAttribute('nom', $theme->nom);\r
@@ -324,28 +309,25 @@ class wsFlash extends cubeFlashGateway {
                        }\r
                        $t->addAttribute('right', $right);\r
                        $t->addAttribute('proprietaire', $theme->proprietaire_nom);\r
-                       $t->addAttribute('books', max(($theme->nbBooks) - ($mine?1:0), 0));\r
+                       $t->addAttribute('books', max(($theme->nbBooks) - ($mine ? 1 : 0), 0));\r
                }\r
        }\r
 \r
-       public function deleteTheme()\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
-       {\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
-       {\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
@@ -357,24 +339,21 @@ class wsFlash extends cubeFlashGateway {
                }\r
        }\r
 \r
-       public function setTheme()\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
-       {\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
-       {\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
+               foreach ($icones as $icone) {\r
                        $i = $this->xml->addChild('icone');\r
                        $i->addAttribute('id', $icone->icone_id);\r
                        $i->addAttribute('nom', $icone->nom);\r
@@ -382,63 +361,56 @@ class wsFlash extends cubeFlashGateway {
                }\r
        }\r
 \r
-       protected function _themeToXML($theme)\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
+               foreach ($theme->parametres as $k => $v) {\r
                        $t->addChild($k, $v);\r
                }\r
        }\r
 \r
-       public function getThemeForms()\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
+               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
-       {\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
+               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
-       {\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
-       {\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
-       {\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
-       {\r
+       public function getLinks() {\r
                global $core;\r
                $dao = new wsDAOBook($core->con);\r
                $book = $dao->selectById($this->args['book_id']);\r
@@ -451,34 +423,47 @@ class wsFlash extends cubeFlashGateway {
                $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
+               $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
+               if ($theme->parametres->backgroundImage != '' && in_array($theme->parametres->repeat, array(2, 3))) {\r
+                       $themeRoot = WS_THEMES . '/' . $theme->theme_id . '/' . $theme->parametres->backgroundImage;\r
+                       $dim = getimagesize($themeRoot);\r
+                       $b = $this->xml->addChild('background');\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->backgroundImage);\r
+               }\r
        }\r
 \r
-       public function saveLinks()\r
-       {\r
+       public function saveLinks() {\r
                global $core;\r
                $dao = new wsDAODocument($core->con);\r
                $dao->setLinksAndRulers($this->args['book_id'], $this->args['links'], $this->args['rulers']);\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
-       {\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
-       {\r
+       public function getExtras() {\r
                global $core;\r
                $dao = new wsDAOBook($core->con);\r
                $book = $dao->selectById($this->args['book_id']);\r
@@ -489,7 +474,7 @@ class wsFlash extends cubeFlashGateway {
                        $tidy = str_replace('<?xml version="1.0"?>', '', $tidy);\r
                        $tidy = trim($tidy);\r
                        $e = explode("\n", $tidy);\r
-                       foreach($e as $k => $v) {\r
+                       foreach ($e as $k => $v) {\r
                                if (substr($v, 0, 2) == '  ') {\r
                                        $v = substr($v, 2);\r
                                }\r
@@ -504,16 +489,14 @@ class wsFlash extends cubeFlashGateway {
                $this->xml->addChild('extras', $extras);\r
        }\r
 \r
-       public function saveExtras()\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
+               $this->xml->addChild('ok', $res ? '1' : '0');\r
        }\r
 \r
-       public function getBookInfos()\r
-       {\r
+       public function getBookInfos() {\r
                global $core;\r
                $dao = new wsDAOBook($core->con);\r
                $book = $dao->selectById($this->args['book_id']);\r
@@ -522,7 +505,7 @@ class wsFlash extends cubeFlashGateway {
                $nb_pages = count($pages);\r
                $this->xml->addChild('pages', $nb_pages);\r
                $total_size = 0;\r
-               foreach($pages as $page => $info) {\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
@@ -545,16 +528,15 @@ class wsFlash extends cubeFlashGateway {
                $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
+               /* $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
-       {\r
+       public function getLangs() {\r
                global $core;\r
                if (isset($this->args['book_id'])) {\r
                        $dao = new wsDAOBook($core->con);\r
@@ -567,7 +549,7 @@ class wsFlash extends cubeFlashGateway {
 \r
                $dao = new wsDAOLang($core->con);\r
                $langs = $dao->selectAll();\r
-               foreach($langs as $lang) {\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
@@ -584,34 +566,29 @@ class wsFlash extends cubeFlashGateway {
                }\r
        }\r
 \r
-       public function saveLang()\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
-       {\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
-       {\r
+       public function getTexts() {\r
                $this->xml->addChild('texts', json_encode($GLOBALS['__l10n']));\r
        }\r
 \r
-       public function copyLinks()\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
-       {\r
+       public function compile() {\r
                global $core;\r
                wsSecureSWF::checkProtectedSWF();\r
                $dao = new wsDAOBook($core->con);\r
@@ -630,6 +607,7 @@ class wsFlash extends cubeFlashGateway {
                $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
 ?>
\ No newline at end of file