+++ /dev/null
-<?php\r
-\r
-class wsConversionSession {\r
- protected $documentsId = array();\r
- protected $documents = array();\r
- protected $guid;\r
- protected $progress = 0;\r
- protected $processing = false;\r
- protected $inited=false;\r
- protected $complete = false;\r
- protected $totalPages = null;\r
- protected $processedPages = 0;\r
-\r
- public function __construct($guid)\r
- {\r
- $this->guid = $guid;\r
- }\r
-\r
- public function setDocuments($documents)\r
- {\r
- $this->documentsId = $documents;\r
- }\r
-\r
- public function initDocuments()\r
- {\r
- global $core;\r
-\r
- $dao = new wsDAODocument($core->con);\r
- $this->documents = $dao->selectInList($this->documentsId);\r
- $this->totalPages = 0;\r
-\r
- foreach($this->documents as $doc) {\r
- $this->totalPages += $doc->getPagesNumber();\r
- }\r
- $inited=true;\r
- }\r
-\r
- public function process()\r
- {\r
- $this->processing = true;\r
- $this->initDocuments();\r
- $this->serialize();\r
-\r
- foreach($this->documents as $doc) {\r
- for($i = 1;$i <= $doc->generalInfos['pages'];$i++) {\r
- $doc->processOnePage($i);\r
- $this->processedPages++;\r
- $this->setProgress(($this->processedPages / $this->totalPages) * 100);\r
- }\r
- }\r
-\r
- $this->complete = true;\r
- $this->processing = false;\r
- $this->setProgress(100);\r
- }\r
-\r
- public function getProgress()\r
- {\r
- return $this->progress;\r
- }\r
-\r
- public function setProgress($i)\r
- {\r
- $this->progress = $i;\r
- $this->serialize();\r
- }\r
-\r
- public function getTotalPages()\r
- {\r
- return $this->totalPages;\r
- }\r
-\r
- public function getProcessedPages()\r
- {\r
- return $this->processedPages;\r
- }\r
-\r
- public function serialize()\r
- {\r
- file_put_contents(self::getCachePath($this->guid), serialize($this));\r
- }\r
-\r
- public function __destruct()\r
- {\r
- //$this->serialize();\r
- }\r
-\r
- public static function openFromGUID($guid)\r
- {\r
- $serializedObject = self::getCachePath($guid);\r
- if (file_exists($serializedObject)) {\r
- return unserialize(file_get_contents($serializedObject));\r
- } else {\r
- return new wsConversionSession($guid);\r
- }\r
- }\r
-\r
- public static function getCachePath($guid)\r
- {\r
- return CACHE . '/conversionSessions/' . $guid . '.obj';\r
- }\r
-}\r
-\r
-?>
\ No newline at end of file
+++ /dev/null
-<?php\r
-class wsDroits {\r
- public static function navigation()\r
- {\r
- global $core;\r
-\r
- $nav = array();\r
- $nav[__('Dashboard')] = 'dashboard';\r
- $nav[__('Publications')] = 'books';\r
- return $nav;\r
- }\r
-}\r
-\r
-?>
\ No newline at end of file
+++ /dev/null
-<?php\r
-class wsFlash extends cubeFlashGateway {\r
- const CNAME = __CLASS__;\r
- public static function in($args)\r
- {\r
- global $core;\r
- $args = cubePage::getArgs($args);\r
- $n = self::CNAME;\r
- $gateway = new $n($core->con, $args);\r
- }\r
-\r
- public function uploadDocument()\r
- {\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['file'] = $infos['name'];\r
- $li = new wsDocumentLocalInfos();\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
- $document = $dao->sauve($data);\r
- $document->copyOriginal($infos['tmp_name']);\r
- }\r
- $this->xml->addChild('document_id', $document->document_id);\r
- $_SESSION['conversionSession'][] = $document->document_id;\r
- }\r
-\r
- public function testDocuments()\r
- {\r
- $toload = $this->xml->addChild('toLoad');\r
- $alreadyLoaded = $this->xml->addChild('alreadyLoaded');\r
-\r
- foreach($this->args['fileName'] as $k => $name) {\r
- $toload->addChild('file', $name);\r
- }\r
- }\r
-\r
- public function getPagesOfBook()\r
- {\r
- global $core;\r
- $dao = new wsDAOBook($core->con);\r
- $pages = $dao->getPagesOfBook($this->args['book_id']);\r
- $p = $this->xml->addChild('pages');\r
- $docs = array();\r
- foreach($pages as $page => $info) {\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
- $docs[] = $info['document_id'];\r
- }\r
- $docs = array_unique($docs);\r
- $p->addAttribute('documents', implode(',', $docs));\r
- }\r
-\r
- public function processConversionSession()\r
- {\r
- $_SESSION['sessionConversionGUID'] = $sessionConversionGUID = uniqid('conversion_', true);\r
- $session = new wsConversionSession($sessionConversionGUID);\r
- $session->setDocuments($_SESSION['conversionSession']);\r
- unset($_SESSION['conversionSession']);\r
- $session->serialize();\r
-\r
- $http = new cubeHTTP($_SERVER['HTTP_HOST']);\r
- $http->setDataTimeout(1);\r
- try {\r
- $http->post('/flash/processConversionSessionAsync', array('user_email' => $_SESSION['user_email'], 'user_password' => $_SESSION['user_password'], 'sessionConversionGUID' => $sessionConversionGUID));\r
- }\r
- catch(Exception $e) {\r
- }\r
- }\r
-\r
- public function processConversionSessionAsync()\r
- {\r
- cubePHP::neverStop();\r
- $conversion = wsConversionSession::openFromGUID($_POST['sessionConversionGUID']);\r
- $conversion->process();\r
- }\r
-\r
- public function getConversionSessionProgress()\r
- {\r
- set_time_limit(1);\r
- $session = wsConversionSession::openFromGUID($_SESSION['sessionConversionGUID']);\r
- $this->xml->addChild('progress', $session->getProgress());\r
- $this->xml->addChild('totalPages',$session->getTotalPages());\r
- $this->xml->addChild('processedPages',$session->getProcessedPages());\r
- }\r
-}\r
-\r
-?>
\ No newline at end of file
+++ /dev/null
-<?php\r
-class wsUrl {\r
- public static function books($args)\r
- {\r
- global $core;\r
-\r
- $settings = $core->user->getSettings('books');\r
-\r
- $shortcuts = array();\r
- $shortcuts[] = '<a href="' . SITE_PATH . 'editbook/new">' . $core->typo->Ajouter(__('Créer une nouvelle publication')) . '</a>';\r
-\r
- $filtres = array();\r
- $filtres[] = new extranetFiltre(__('Status'), 'status_book', $settings['filtres']);\r
- $filtres[] = new extranetFiltre(__('Année'), 'annee_book', $settings['filtres']);\r
- $res = extranetPage::barre($filtres , 'filtreBooks', 'books', $shortcuts);\r
- $res .= extranetPage::tMain(null, true);\r
- $res .= extranetPage::bh();\r
- $res .= '<div id="listeBooks">';\r
- $res .= self::listeBooks();\r
- $res .= '</div>';\r
- $res .= extranetPage::bf();\r
- $res .= extranetPage::bMain();\r
- return $res;\r
- }\r
-\r
- public static function listeBooks($dashboard = null, $settings = null)\r
- {\r
- global $core;\r
- cubePage::truePopup();\r
- extranetDroits::min(1);\r
- $settings = is_null($settings)?$core->user->getSettings('books'):$settings;\r
- $change = is_null($dashboard)?'Books':'Dashboard/' . $dashboard;\r
- $dao = new wsDAOBook($core->con);\r
- if (isset($settings['search']) && !is_null($settings['search'])) {\r
- $dao->setSearch($settings['search']);\r
- }\r
- $dao->setFiltres($settings['filtres']);\r
- $liste = $dao->getListe($settings['orderby'], $settings['sens'], $settings['limit']);\r
-\r
- $res = '<table class="liste">';\r
- $res .= '<tr><th>' . extranetUrl::orderby('#', 'book_id', $settings, 'sort' . $change) . '</th>';\r
- $res .= '<th>' . extranetUrl::orderby(__('Titre de la publication'), 'nom', $settings, 'sort' . $change) . '</th>';\r
- $res .= '<th>' . extranetUrl::orderby(__(''), 'lang', $settings, 'sort' . $change) . '</th>';\r
- $res .= '<th>' . extranetUrl::orderby(__('Proprietaire'), 'proprietaire_nom', $settings, 'sort' . $change) . '</th>';\r
- $res .= '<th>' . extranetUrl::orderby(__('Facturation'), 'facturable', $settings, 'sort' . $change) . '</th>';\r
- $res .= '<th>' . extranetUrl::orderby(__('Status'), 'status', $settings, 'sort' . $change) . '</th>';\r
- $res .= '<th class="min"></th><th class="min"></th><th class="min"></th><th class="min"></th><th class="min"></th></tr>';\r
- $i = 0;\r
-\r
- foreach($liste as $id => $book) {\r
- $odd = cubeMath::isOdd($i)?' class="odd"':'';\r
- $res .= '<tr' . $odd . '>';\r
- $res .= '<td>' . $book->book_id . '</td>';\r
- $res .= '<td>' . $book->nom . '</td>';\r
- $res .= '<td>' . mb_strtoupper($book->lang) . '</td>';\r
- $res .= '<td>' . $book->proprietaire . '</td>';\r
- $f = $book->facturable;\r
- $res .= '<td>' . $f . '</td>';\r
- $res .= '<td>' . $core->books_status[$book->status] . '</td>';\r
- $res .= '<td class="bouton"><a href="' . SITE_PATH . 'voirbook/' . $book->book_id . '_' . $book->hash . '_' . TIME . '/" class="popupFS">' . cubeMedia::cssRollover($core->typo->Voir('voir', '', false)) . '</a></td>';\r
- $res .= '<td class="bouton"><a href="' . SITE_PATH . 'editbook/' . $book->book_id . '">' . cubeMedia::cssRollover($core->typo->Editer('éditer', '', false)) . '</a></td>';\r
- $res .= '<td class="bouton"><a href="' . SITE_PATH . 'supprimebook/' . $book->book_id . '">' . cubeMedia::cssRollover($core->typo->Stats('stats', '', false)) . '</a></td>';\r
- $res .= '<td class="bouton"><a href="' . SITE_PATH . 'supprimebook/' . $book->book_id . '">' . cubeMedia::cssRollover($core->typo->Telecharger('télécharger', '', false)) . '</a></td>';\r
- $res .= '<td class="bouton"><a href="#" rel="supprimeBook/' . $book->book_id . '" class="ajax" title="' . __('Êtes-vous certain de vouloir supprimer cette publication ?') . '">' . cubeMedia::cssRollover($core->typo->Supprimer('suppr.', '', false)) . '</a></td>';\r
- $res .= '</tr>';\r
- $i++;\r
- }\r
- if (!isset($settings['search']) || is_null($settings['search'])) {\r
- $odd = cubeMath::isOdd($i)?' class="odd"':'';\r
- $res .= '<tr' . $odd . '><td colspan="11">';\r
- $res .= extranetPage::pager($settings['page'], $dao->count() , $settings['par_page'], 'page' . $change . '/%d');\r
- $res .= extranetUrl::formParPage('parPage' . $change, $settings['par_page'], __('publications'), false);\r
- $res .= '</td></tr>';\r
- }\r
- $res .= '</table>';\r
- return $res;\r
- }\r
-\r
- public static function editbook($args)\r
- {\r
- global $core;\r
- $book_id = $args[1];\r
-\r
- if ($book_id == 'new') {\r
- $dao = new wsDAOBook($core->con);\r
- $book = $dao->creeEmpty($core->user->utilisateur_id);\r
- http::redirect(SITE_PATH . 'editbook/' . $book->book_id);\r
- }\r
-\r
- $step = isset($args[2])?$args[2]:1;\r
-\r
- $shortcuts = array();\r
-\r
- $steps = array();\r
- $steps[1] = __('Composition');\r
- $steps[2] = __('Personnalisation');\r
- $steps[3] = __('Paramètres');\r
- $steps[4] = __('Edition des liens');\r
- $steps[5] = __('Aperçu');\r
-\r
- foreach($steps as $s => $n) {\r
- $template = 'Step';\r
- if ($s == $step) {\r
- $class = 'step active';\r
- $ae = $as = '';\r
- } else {\r
- $class = 'step';\r
- $as = '<a href="' . SITE_PATH . 'editbook/' . $book_id . '/' . $s . '">';\r
- $ae = '</a>';\r
- }\r
-\r
- if ($s == count($steps)) {\r
- $template = 'Last' . $template;\r
- }\r
- $shortcuts[] = $as . $core->typo->$template($s . '. ' . $n, $class, -1) . $ae;\r
- }\r
-\r
- $res = extranetPage::barre(null , null, null, $shortcuts);\r
- $res .= extranetPage::tMain(null, true);\r
- $res .= extranetPage::bh();\r
- $res .= '<div id="listeBooks">';\r
- if ($step == 1) {\r
- $res .= self::editComposition($args);\r
- } elseif ($step == 2) {\r
- $res .= self::editTheme($args);\r
- } elseif ($step == 3) {\r
- $res .= self::editParametres($args);\r
- } elseif ($step == 4) {\r
- $res .= self::editLinks($args);\r
- } else {\r
- $res .= self::editApercu($args);\r
- }\r
- $res .= '</div>';\r
- $res .= extranetPage::bf();\r
- $res .= extranetPage::bMain();\r
- return $res;\r
- }\r
-\r
- public static function editComposition($args)\r
- {\r
- $fv = array(session_name() => session_id(),\r
- 'book_id' => $args[1],\r
- 'finishedText' => __('Transfert terminé'),\r
- 'loadingFileText' => __('Chargement du fichier'),\r
- 'totalText' => __('Total'),\r
- 'browseText' => __('Parcourir') . ' ...',\r
- 'titreUpload' => __('Sélectionnez un ou plusieurs document PDF sur votre ordinateur'),\r
- 'titreComposition' => __('Organisez le(s) document(s) pour composer votre fluidbook'));\r
- $res = cubeMedia::flash(WEBROOT . '/swf/composer.swf', '960', '100%', $fv, 'composerSwf', 'swfPanel', 9, '#ffffff', '', 'false', 'noscale', 'transparent');\r
- return $res;\r
- }\r
-\r
- public static function editTheme($args)\r
- {\r
- $fv = array(session_name() => session_id(),\r
- 'book_id' => $args[1]);\r
- $res = cubeMedia::flash(WEBROOT . '/swf/theme.swf', '960', '100%', $fv, 'composerSwf', 'swfPanel', 9, '#ffffff', '', 'false', 'noscale', 'transparent');\r
- return $res;\r
- }\r
-\r
- public static function editParametres($args)\r
- {\r
- }\r
-\r
- public static function editLinks($args)\r
- {\r
- $fv = array(session_name() => session_id(),\r
- 'book_id' => $args[1]);\r
- $res = cubeMedia::flash(WEBROOT . '/swf/links.swf', '960', '100%', $fv, 'composerSwf', 'swfPanel', 9, '#ffffff', '', 'false', 'noscale', 'transparent');\r
- return $res;\r
- }\r
-\r
- public static function editApercu($args)\r
- {\r
- }\r
-}\r
-\r
-?>
\ No newline at end of file
+++ /dev/null
-<?php\r
-class wsDAOBook extends extranetDAO {\r
- protected function singleton($r)\r
- {\r
- $book = new wsBook();\r
- $book->book_id = $r->book_id;\r
- $book->nom = $r->nom;\r
- $book->lang = $r->lang;\r
- $book->theme = $r->theme;\r
- $book->proprietaire = $r->proprietaire_nom;\r
- $book->proprietaire_id = $r->proprietaire_id;\r
- $book->facturable = $r->facturable;\r
- $book->facturable_id = $r->facturable_id;\r
- $book->hash = $r->hash;\r
- $book->compteur_visites = $r->compteur_visites;\r
- $book->status = $r->status;\r
- $book->date_status = $r->date_status;\r
- $book->date = $r->date;\r
- $book->pages = array();\r
-\r
- $p = unserialize($r->parametres);\r
- if (!$p) {\r
- $p = new wsBookParametres();\r
- }\r
- $book->parametres = $p;\r
-\r
- return $book;\r
- }\r
-\r
- protected function cree($r)\r
- {\r
- $book = new wsBook();\r
- $book->book_id = 'new';\r
- $book->nom = '';\r
- $book->lang = 0;\r
- $book->theme = 0;\r
- $book->proprietaire = '';\r
- $book->proprietaire_id = 0;\r
- $book->facturable = '';\r
- $book->facturable_id = 0;\r
- $book->hash = '';\r
- $book->compteur_visites = 20;\r
- $book->status = 0;\r
- $book->date_status = TIME;\r
- $book->date = TIME;\r
- $book->parametres = new wsBookParametres();\r
- $book->pages = array();\r
- return $book;\r
- }\r
-\r
- protected function getNextId()\r
- {\r
- $r = $this->con->select('SELECT MAX(book_id) AS book_id FROM books');\r
- return $r->book_id + 1;\r
- }\r
-\r
- public function selectById($book_id = null)\r
- {\r
- if (is_null($book_id)) {\r
- return $this->cree();\r
- }\r
- $sql = 'SELECT * FROM books_vue WHERE book_id=\'' . $this->con->escape($book_id) . '\' LIMIT 1';\r
- $r = $this->con->select('SELECT * FROM books_vue WHERE book_id=\'' . $this->con->escape($book_id) . '\' LIMIT 1');\r
- return $this->singleton($r);\r
- }\r
-\r
- public function sauve($createur, $data)\r
- {\r
- global $core;\r
-\r
- $c = $this->con->openCursor('books');\r
- $c->nom = $data['nom'];\r
- $c->lang = $data['lang'];\r
- $c->theme = $data['theme'];\r
- $c->proprietaire = $data['proprietaire'];\r
-\r
- if ($data['book_id'] == 'new' || $data['book_id'] == '') {\r
- $c->date = TIME;\r
- $c->hash = md5(rand(0, 1234567893));\r
- $c->compteur_visites = 20;\r
- $c->parametres = serialize(new wsParametres());\r
- $book_id = $c->book_id = $this->getNextId();\r
-\r
- $c->insert();\r
- } else {\r
- $book_id = $data['book_id'];\r
- $c->update('WHERE book_id=\'' . $this->con->escape($data['book_id']) . '\'');\r
- }\r
-\r
- return $this->selectById($book_id);\r
- }\r
-\r
- public function creeEmpty($createur)\r
- {\r
- $c = $this->con->openCursor('books');\r
- $c->proprietaire = $createur;\r
- $c->date = TIME;\r
- $c->hash = md5(rand(0, 1234567893));\r
- $c->compteur_visites = 20;\r
- $c->status = -1;\r
- $c->date_status = TIME;\r
- $c->parametres = serialize(new wsParametres());\r
- $book_id = $c->book_id = $this->getNextId();\r
- $c->insert();\r
- fb($book_id);\r
- return $this->selectById($book_id);\r
- }\r
-\r
- public function supprime($book_id)\r
- {\r
- return $this->con->execute('DELETE FROM books WHERE book_id=\'' . $this->con->escape($book_id) . '\'');\r
- }\r
-\r
- public function count()\r
- {\r
- $r = $this->con->select('SELECT COUNT(*) AS nb FROM books_vue WHERE ' . $this->makeWhereFromFiltres());\r
- return $r->nb;\r
- }\r
-\r
- public function getPagesOfBook($book_id)\r
- {\r
- $pages = array();\r
- $r = $this->con->select('SELECT * FROM book_pages WHERE book_id=\'' . $this->con->escape($book_id) . '\' ORDER BY book_page');\r
- while ($r->fetch()) {\r
- $pages[$r->book_page] = array('document_id' => $r->document_id, 'document_page' => $r->document_page);\r
- }\r
- return $pages;\r
- }\r
-\r
- public function appendDocument($book_id, $document_id)\r
- {\r
- $r = $core->con->select('SELECT MAX(book_page) AS book_page FROM books WHERE book_id=\'' . $core->con->escape($book_id) . '\'');\r
- $lastPage = $r->book_page;\r
- $this->insertDocument($book_id, $lastPage, $document_id);\r
- }\r
-\r
- public function removePage($book_id, $book_page)\r
- {\r
- // Supprime la page\r
- $core->con->execute('DELETE FROM book_pages WHERE book_page=\'' . $core->con->escape($book_page) . '\' AND book_id=\'' . $core->con->escape($book_id) . '\'');\r
- // Décale les pages suivantes vers le haut\r
- $this->decalePages($book_id, $book_page, -1);\r
- }\r
-\r
- public function insertPage($book_id, $after_page, $document_id, $document_page)\r
- {\r
- // Décale les pages vers le bas\r
- $this->decalePages($book_id, $after_page, 1);\r
- // Insère la page\r
- $c = $core->con->openCursor('book_pages');\r
- $c->book_id = $book_id;\r
- $c->book_page = $after_page + 1;\r
- $c->document_id = $document_id;\r
- $c->document_page = $document_page;\r
- $c->insert();\r
- }\r
-\r
- public function insertDocument($book_id, $after_page, $document_id)\r
- {\r
- // Obtiens le nombre de pages\r
- $r = $core->con->select('SELECT pages FROM documents WHERE document_id=\'' . $core->con->escape($document_id) . '\'');\r
- // Décale les pages vers le bas\r
- $this->decalePages($book_id, $after_page, $r->pages);\r
- // Insère les pages\r
- $c = $core->con->openCursor('book_pages');\r
- $c->book_id = $book_id;\r
- $c->document_id = $r->document_id;\r
- for($i = 1;$i <= $r->pages;$i++) {\r
- $c->document_page = $i;\r
- $c->book_page = $after_page + $i;\r
- $c->insert();\r
- }\r
- }\r
-\r
- protected function decalePages($book_id, $after_page, $decalage)\r
- {\r
- $decalage = ($decalage >= 0)?'+' . $decalage:$decalage;\r
- $core->con->execute('UPDATE book_pages SET book_page=book_page' . $decalage . ' WHERE book_page>' . $core->con->escape($book_page) . ' AND book_id=\'' . $core->con->escape($book_id) . '\'');\r
- }\r
-\r
- public function getListe($orderby = null, $sens = null, $limit = null)\r
- {\r
- if (!is_null($this->q)) {\r
- $where = '';\r
- if ($this->search_id) {\r
- $where .= ' book_id=\'' . $this->con->escape($this->q) . '\' OR ';\r
- }\r
- $where .= 'nom LIKE \'%' . $this->con->escape($this->q) . '%\'';\r
- $daoClient = new extranetDAOClient($this->con);\r
- $where .= ' OR proprietaire_id IN(' . $daoClient->querySearchByName($this->q) . ')';\r
- $where .= ' OR facturable_id IN(' . $daoClient->querySearchByName($this->q) . ')';\r
- $limit = null;\r
- } else {\r
- $where = $this->makeWhereFromFiltres();\r
- }\r
- $orderby = is_null($orderby)?'book_id':$orderby;\r
- $sens = is_null($sens)?'DESC':$sens;\r
- $limit = is_null($limit)?'':$this->con->limit($limit);\r
-\r
- $sql = 'SELECT * FROM books_vue WHERE ' . $where . ' ORDER BY ' . $orderby . ' ' . $sens . ' ' . $limit;\r
- $r = $this->con->select($sql);\r
- return $this->factory($r);\r
- }\r
-\r
- protected function makeWhereFromFiltres()\r
- {\r
- if (!is_null($this->filtres)) {\r
- $w = array('1=1');\r
- if (extranetFiltre::test('annee_book', $this->filtres)) {\r
- $w[] = 'YEAR(FROM_UNIXTIME(date)) IN (' . implode(',', array_keys($this->filtres['annee_book'])) . ')';\r
- }\r
- if (extranetFiltre::test('status_book', $this->filtres)) {\r
- $w[] = 'status IN(' . implode(',', array_keys($this->filtres['status_book'])) . ')';\r
- }\r
- return implode(' AND ', $w);\r
- } else {\r
- return '1=1';\r
- }\r
- }\r
-}\r
-\r
-?>
\ No newline at end of file
+++ /dev/null
-<?php\r
-class wsDAODocument extends extranetDAO {\r
- public function singleton($r)\r
- {\r
- $document = new wsDocument();\r
- $document->document_id = $r->document_id;\r
- $document->init();\r
- $document->file = $r->file;\r
- $document->proprietaire = $r->proprietaire;\r
- $document->pages = $r->pages;\r
- if ($r->trim) {\r
- $document->trim = unserialize($r->trim);\r
- }\r
- $document->date = $r->date;\r
- $document->localInfos = unserialize($r->localInfos);\r
- return $document;\r
- }\r
-\r
- public function getNextId()\r
- {\r
- $r = $this->con->select('SELECT MAX(document_id) AS document_id FROM documents');\r
- return $r->document_id + 1;\r
- }\r
-\r
- public function selectById($document_id)\r
- {\r
- $r = $this->con->select('SELECT * FROM documents WHERE document_id=\'' . $this->con->escape($document_id) . '\'');\r
- return $this->singleton($r);\r
- }\r
-\r
- public function selectInList($documentsId)\r
- {\r
- $r = $this->con->select('SELECT * FROM documents WHERE document_id IN(' . implode(',', $documentsId) . ')');\r
- return $this->factory($r);\r
- }\r
-\r
- public function cree()\r
- {\r
- $document = new wsDocument();\r
- $document->document_id = 'new';\r
- $document->file = '';\r
- $document->proprietaire = 0;\r
- $document->pages = 0;\r
- $document->trim = array();\r
- $document->date = TIME;\r
- $document->localInfos = new wsDocumentLocalInfos();\r
- return $document;\r
- }\r
-\r
- public function sauve($data)\r
- {\r
- if (!isset($data['document_id'])) {\r
- $data['document_id'] = 'new';\r
- }\r
- $c = $this->con->openCursor('documents');\r
- $c->file = $data['file'];\r
- $c->proprietaire = $data['proprietaire'];\r
- $c->pages = $data['pages'];\r
- if (isset($data['localInfos'])) {\r
- $c->localInfos = serialize($data['localInfos']);\r
- }\r
- if (isset($data['trim'])) {\r
- $c->trim = serialize($data['trim']);\r
- }\r
-\r
- if ($data['document_id'] == 'new') {\r
- $document_id = $c->document_id = $this->getNextId();\r
- $c->date = TIME;\r
- $c->insert();\r
- } else {\r
- $document_id = $data['document_id'];\r
- $c->update('WHERE document_id=\'' . $this->con->escape($data['document_id']) . '\'');\r
- }\r
- $doc = $this->selectById($document_id);\r
- return $doc;\r
- }\r
-}\r
-\r
-?>
\ No newline at end of file
+++ /dev/null
-<?php\r
-class wsBookParametres extends wsParametres {\r
- public function __construct()\r
- {\r
- parent::__construct();\r
- }\r
-\r
- protected function initFields()\r
- {\r
- parent::initFields();\r
- // .\r
- $this->fields['general'] = __('Informations générales');\r
- $this->fields['pages'] = array('type' => 'integer', 'default' => '', 'editable' => false, 'label' => __('Nombre de pages'), 'extra' => false, 'grade' => 0);\r
- $this->fields['width'] = array('type' => 'float', 'default' => '', 'editable' => false, 'label' => __('Largeur'), 'extra' => false, 'grade' => 0);\r
- $this->fields['height'] = array('type' => 'float', 'default' => '', 'editable' => false, 'label' => __('Hauteur'), 'extra' => false, 'grade' => 0);\r
- $this->fields['first_page_nr'] = array('type' => 'integer', 'default' => 1, 'editable' => true, 'label' => __('La numérotation débute à la page'), 'extra' => false, 'grade' => 1);\r
- $this->fields['preload'] = array('type' => 'integer', 'default' => 16, 'editable' => true, 'label' => __('Nombre de pages à précharger'), 'extra' => false, 'grade' => 1);\r
- $this->fields['reading_dir'] = array('type' => 'combo',\r
- 'datas' => array(__('De la gauche vers la droite') => 'ltr', __('De la droite vers la gauche') => 'rtl'),\r
- 'default' => 'ltr', 'editable' => true, 'label' => __('Sens de lecture'), 'extra' => false, 'grade' => 1);\r
- // .\r
- $this->fields['fonctions_generales'] = __('Fonctionnalités générales');\r
- $this->fields['print'] = array('type' => 'boolean', 'default' => true, 'editable' => true, 'label' => __('Impression'), 'extra' => false, 'grade' => 1);\r
- $this->fields['search'] = array('type' => 'boolean', 'default' => true, 'editable' => true, 'label' => __('Moteur de recherche'), 'extra' => false, 'grade' => 1);\r
- $this->fields['bookmark'] = array('type' => 'boolean', 'default' => true, 'editable' => true, 'label' => __('Marques-pages'), 'extra' => false, 'grade' => 1);\r
- $this->fields['url_link'] = array('type' => 'text', 'default' => 'http://', 'editable' => true, 'label' => __("URL du lien de retour au site"), 'extra' => false, 'grade' => 1);\r
- // .\r
- $this->fields['fonctions_pdf'] = __('Fonction Export PDF');\r
- $this->fields['pdf'] = array('type' => 'boolean', 'default' => true, 'editable' => true, 'label' => __('Export PDF'), 'extra' => false, 'grade' => 1);\r
- $this->fields['optimizepdf'] = array('type' => 'boolean', 'default' => true, 'editable' => true, 'label' => __('Optimiser le PDF'), 'extra' => false, 'grade' => 4);\r
- $this->fields['pdfComplex'] = array('type' => 'boolean', 'default' => false, 'editable' => true, 'label' => __('Export PDF avancé'), 'extra' => false, 'grade' => 3);\r
- // .\r
- $this->fields['fonctions_zoom'] = __('Zoom');\r
- $this->fields['zoom'] = array('type' => 'integer', 'default' => 200, 'editable' => true, 'label' => __('Zoom par défaut (atteint au clic)'), 'extra' => false, 'grade' => 1);\r
- $this->fields['zoomw'] = array('type' => 'integer', 'default' => 300, 'editable' => true, 'label' => __("Zoom maximal (atteint à l'aide de la molette)"), 'extra' => false, 'grade' => 1);\r
- $this->fields['fixedZoom'] = array('type' => 'boolean', 'default' => false, 'editable' => true, 'label' => __('Zoom magnétique'), 'extra' => true, 'grade' => 4);\r
- // .\r
- $this->fields['fonctions_friend'] = __('Fonction Envoyer à un ami et partage');\r
- $this->fields['friend'] = array('type' => 'boolean', 'default' => true, 'editable' => true, 'label' => __('Envoyer à un ami'), 'extra' => false, 'grade' => 1);\r
- $this->fields['email_title'] = array('type' => 'text', 'default' => __('%name% vous invite à découvrir %title%'), 'editable' => true, 'label' => __("Titre de l'email"), 'extra' => false, 'grade' => 1);\r
- $this->fields['email_body'] = array('type' => 'textarea', 'default' => __('Veuillez cliquer sur le lien suivant : %link%'), 'editable' => true, 'label' => __("Titre de l'email"), 'extra' => false, 'grade' => 1);\r
- $this->fields['email_editable'] = array('type' => 'boolean', 'default' => false, 'editable' => true, 'label' => __("Permettre au lecteur de modifier le corps de l'email"), 'extra' => false, 'grade' => 1);\r
- $this->fields['askAcknowledge'] = array('type' => 'boolean', 'default' => false, 'editable' => true, 'label' => __("Demander au destinataire un accusé de réception"), 'extra' => true, 'grade' => 4);\r
- $this->fields['attachPDFInEmail'] = array('type' => 'boolean', 'default' => false, 'editable' => true, 'label' => __("Joindre le fichier PDF de la page en cours à l'email"), 'extra' => true, 'grade' => 4);\r
- $this->fields['attachmentName'] = array('type' => 'text', 'default' => '', 'editable' => false, 'label' => __('Nom de la pièce jointe'), 'extra' => true, 'grade' => 4);\r
- $this->fields['addThis'] = array('type' => 'text', 'default' => '', 'editable' => true, 'label' => __("Identifiant addThis"), 'extra' => false, 'grade' => 4);\r
- $this->fields['addThisOptions'] = array('type' => 'textarea', 'default' => '', 'editable' => true, 'label' => __("Paramètres addThis"), 'extra' => false, 'grade' => 4);\r
- // .\r
- $this->fields['fonctions_stats'] = __('Fonction Statistiques');\r
- $this->fields['stats'] = array('type' => 'boolean', 'default' => true, 'editable' => true, 'label' => __('Activer les statistiques'), 'extra' => false, 'grade' => 1);\r
- $this->fields['statsWeborama'] = array('type' => 'text', 'default' => '', 'editable' => true, 'label' => __('Statistiques Weborama'), 'extra' => true, 'grade' => 4);\r
- // .\r
- $this->fields['fonctions_sommaire'] = __('Fonction Sommaire');\r
- $this->fields['displayChaptersAtStart'] = array('type' => 'boolean', 'default' => false, 'editable' => true, 'label' => __("Afficher le sommaire au chargement de la publication"), 'extra' => true, 'grade' => 4);\r
- $this->fields['chaptersPosition'] = array('type' => 'combo',\r
- 'datas' => array(__('Centré') => 'center' , __("Calé sur l'icône") => 'icon', __('Calé sur la gauche') => 'left'),\r
- 'default' => 'center', 'editable' => true, 'label' => __('Positionnement du sommaire'), 'grade' => 4);\r
- $this->fields['chaptersCloseOnTop'] = array('type' => 'boolean', 'default' => false, 'editable' => true, 'label' => __("Afficher le bouton fermer en haut du sommaire"), 'extra' => true, 'grade' => 4);\r
- $this->fields['chaptersMargin'] = array('type' => 'integer', 'default' => 20, 'editable' => false, 'label' => __('Marge latérale du sommaire'), 'extra' => true, 'grade' => 4);\r
- // .\r
- $this->fields['fonctions_liens'] = __('Liens et multimedia');\r
- $this->fields['playVideoAtStart'] = array('type' => 'boolean', 'default' => true, 'editable' => true, 'label' => __("Jouer les vidéos à l'affichage de la page"), 'extra' => true, 'grade' => 4);\r
- $this->fields['permanentLinks'] = array('type' => 'boolean', 'default' => false, 'editable' => true, 'label' => __('Liens visibles en permanence'), 'extra' => true, 'grade' => 4);\r
- $this->fields['linksColor'] = array('type' => 'color', 'default' => '', 'editable' => true, 'label' => __('Couleurs des liens (si différente de la couleur indiquée dans le thème)'), 'extra' => true, 'grade' => 4);\r
- $this->fields['zoomAreas'] = array('type' => 'boolean', 'default' => false, 'editable' => true, 'label' => __("Activer le zoom sur les liens ''Plus d'infos''"), 'extra' => true, 'grade' => 4);\r
- // .\r
- $this->fields['fonctions_sousmenu'] = __('Sous-menu supplémentaire');\r
- $this->fields['extraSubMenu'] = array('type' => 'boolean', 'default' => false, 'editable' => true, 'label' => __('Sous-menu supplémentaire'), 'extra' => true, 'grade' => 4);\r
- $this->fields['extraSMsizeX'] = array('type' => 'integer', 'default' => '', 'editable' => false, 'label' => __('Largeur du sous-menu supplémentaire'), 'extra' => true, 'grade' => 4);\r
- $this->fields['extraSMsizeY'] = array('type' => 'integer', 'default' => '', 'editable' => false, 'label' => __('Hauteur du sous-menu supplémentaire'), 'extra' => true, 'grade' => 4);\r
- $this->fields['extraName'] = array('type' => 'text', 'default' => '', 'editable' => false, 'label' => __('Nom du sous-menu supplémentaire'), 'extra' => true, 'grade' => 4);\r
- $this->fields['extraFileName'] = array('type' => 'text', 'default' => '', 'editable' => false, 'label' => __('Fichier du sous-menu supplémentaire'), 'extra' => true, 'grade' => 4);\r
- // .\r
- $this->fields['fonctions_onglets'] = __('Fonds multimédia et onglets');\r
- $this->fields['backClipName'] = array('type' => 'text', 'default' => '', 'editable' => false, 'label' => __('Fichier du fond animé'), 'extra' => true, 'grade' => 4);\r
- $this->fields['extraXSpace'] = array('type' => 'integer', 'default' => '0', 'editable' => false, 'label' => __('Largeur du décalage des flèches'), 'extra' => true, 'grade' => 4);\r
- // .\r
- $this->fields['fonctions_diverses'] = __('Fonctions diverses');\r
- $this->fields['immediateResize'] = array('type' => 'boolean', 'default' => false, 'editable' => true, 'label' => __("Redimensionner immédiatement la fenêtre"), 'extra' => true, 'grade' => 4);\r
- // .\r
- $this->fields['fonctions_perso'] = __('Fonctions de personnalisation');\r
- $this->fields['shadeOnMenu'] = array('type' => 'boolean', 'default' => true, 'editable' => true, 'label' => __('Ombre portée sous la barre du menu'), 'extra' => true, 'grade' => 4);\r
- $this->fields['pagesBar'] = array('type' => 'boolean', 'default' => true, 'editable' => true, 'label' => __("Afficher la barre d'accès rapide aux pages"), 'extra' => true, 'grade' => 4);\r
- $this->fields['shadeAlpha'] = array('type' => 'integer', 'default' => 100, 'editable' => true, 'label' => __('Transparence des ombres sur les pages (100 : maximale - 0 : invisible)'), 'extra' => true, 'grade' => 4);\r
- $this->fields['usePageEdges'] = array('type' => 'boolean', 'default' => true, 'editable' => true, 'label' => __("Afficher la bordure des pages"), 'extra' => true, 'grade' => 4);\r
- $this->fields['arrowsColor'] = array('type' => 'color', 'default' => 'ffffff', 'editable' => true, 'label' => __('Couleur des flèches des boutons de navigation (page suivante, page précédente)'), 'extra' => true, 'grade' => 4);\r
- $this->fields['pagesBarTxtColor'] = array('type' => 'color', 'default' => 'ffffff', 'editable' => true, 'label' => __("Couleur des numéros de page de la barre d'accès rapide aux pages"), 'extra' => true, 'grade' => 4);\r
- $this->fields['sections'] = array('type' => 'textarea', 'default' => '', 'editable' => true, 'label' => __("Sections"), 'extra' => false, 'grade' => 4);\r
- $this->fields['indexColors'] = array('type' => 'textarea', 'default' => '', 'editable' => true, 'label' => __("Couleurs des pages de l'index"), 'extra' => true, 'grade' => 4);\r
- $this->fields['displayPageNumber'] = array('type' => 'boolean', 'default' => true, 'editable' => true, 'label' => __('Afficher les numéros de page'), 'extra' => false, 'grade' => 1);\r
- }\r
-}\r
-\r
-?>
\ No newline at end of file
+++ /dev/null
-<?php\r
-class wsBook extends cubeMetier {\r
- protected $book_id;\r
- protected $nom;\r
-\r
- protected $lang;\r
-\r
- protected $theme;\r
-\r
- protected $proprietaire;\r
- protected $proprietaire_id;\r
-\r
- protected $facturable;\r
- protected $facturable_id;\r
-\r
- protected $hash;\r
- protected $compteur_visites;\r
-\r
- protected $status;\r
- protected $date_status;\r
-\r
- protected $date;\r
-\r
- protected $parametres;\r
-\r
- protected $pages;\r
-}\r
-\r
-?>
\ No newline at end of file
+++ /dev/null
-<?php\r
-class wsDocumentLocalInfos extends wsParametres {\r
- public function initFields()\r
- {\r
- parent::initFields();\r
- $this->fields['fileName'] = array('type' => 'text', 'default' => '', 'editable' => true, 'label' => __("Nom du fichier"), 'extra' => false, 'grade' => 0);\r
- $this->fields['fileSize'] = array('type' => 'integer', 'default' => '', 'editable' => true, 'label' => __("Couleur des sous-menus"), 'extra' => false, 'grade' => 0);\r
- $this->fields['modificationDate'] = array('type' => 'date', 'default' => TIME, 'editable' => true, 'label' => __("Date de dernière modification"), 'extra' => false, 'grade' => 0);\r
- $this->fields['creationDate'] = array('type' => 'date', 'default' => TIME, 'editable' => true, 'label' => __("Date de dernière modification"), 'extra' => false, 'grade' => 0);\r
- }\r
-}\r
-\r
-?>
\ No newline at end of file
+++ /dev/null
-<?php\r
-/**\r
- * wsDocument\r
- *\r
- * @package\r
- * @author Vincent\r
- * @copyright Copyright (c) 2010\r
- * @version $Id$\r
- * @access public\r
- */\r
-class wsDocument extends cubeMetier {\r
- protected $document_id;\r
- protected $file;\r
- protected $proprietaire;\r
- protected $pages;\r
- protected $trim;\r
- protected $date;\r
- protected $localInfos;\r
- protected $generalInfos;\r
- protected $bookmarks;\r
- protected $numberSections;\r
- protected $links;\r
-\r
- protected $out;\r
- protected $in;\r
- protected $log;\r
- protected $log_pointer;\r
- protected $infos;\r
- protected $textes;\r
-\r
- private $_basicInfos = null;\r
- private $_advancedInfos = null;\r
- private $_links = array();\r
-\r
- const NORMAL = 0;\r
- const FLATTEN = 1;\r
- const POLY2BITMAP = 2;\r
- const BITMAP = 3;\r
- const BARBARE = 4;\r
-\r
- public function init()\r
- {\r
- $this->out = ROOT . '/docs/' . $this->document_id . '/';\r
- $this->log = $this->out . 'log.txt';\r
- $this->in = $this->out . 'original.pdf';\r
- $this->infos = $this->out . 'infos.txt';\r
- $this->textes = $this->out . 'textes.txt';\r
- if (!file_exists($this->out)) {\r
- mkdir($this->out, 0755, true);\r
- }\r
- $this->log_pointer = fopen($this->log, 'a');\r
- }\r
-\r
- public function copyOriginal($tmp_file)\r
- {\r
- move_uploaded_file($tmp_file, $this->in);\r
- }\r
-\r
- public function getInfos()\r
- {\r
- $pdfinfo = $this->getBasicInfos();\r
- $pdftk = $this->getAdvancedInfos();\r
-\r
- $this->parseInfos($pdfinfo . $pdftk);\r
-\r
- file_put_contents($this->infos, $pdfinfo . $pdftk);\r
- }\r
-\r
- public function getBasicInfos()\r
- {\r
- if (is_null($this->_basicInfos)) {\r
- $pdfinfo = new cubeCommandLine('pdfinfo', null, false);\r
- $pdfinfo->setPath(CONVERTER_PATH);\r
- $pdfinfo->setArg('-box');\r
- $pdfinfo->setArg('f', 1);\r
- $pdfinfo->setArg('l', 10000);\r
- $pdfinfo->setArg(null, $this->in);\r
- $pdfinfo->execute();\r
- $this->addToLog($pdfinfo);\r
-\r
- $this->_basicInfos = $pdfinfo->output;\r
- }\r
- return $this->_basicInfos;\r
- }\r
-\r
- public function getAdvancedInfos()\r
- {\r
- if (is_null($this->_advancedInfos)) {\r
- $pdftk = new cubeCommandLine('pdftk', null, true);\r
- $pdftk->setPath(CONVERTER_PATH);\r
- $pdftk->setArg(null, $this->in);\r
- $pdftk->setArg(null, 'dump_data');\r
- $pdftk->execute();\r
- $this->addToLog($pdftk);\r
- $this->_advancedInfos = $pdftk->output;\r
- }\r
- return $this->_advancedInfos;\r
- }\r
-\r
- public function parseInfos($data)\r
- {\r
- // This function get general infos (pages sizes, boxes, number sections and\r
- // bookmarks\r
- // Init arrays\r
- $this->generalInfos = array();\r
- $this->bookmarks = array();\r
- $this->numberSections = array();\r
- // Number section styles\r
- $numberStyles = array('NoNumber' => 'no', 'DecimalArabicNumerals' => 'decimal',\r
- 'UppercaseRomanNumerals' => 'roman_up', 'LowercaseRomanNumerals' => 'roman_low',\r
- 'UppercaseLetters' => 'letters_up', 'LowercaseLetters' => 'letters_low');\r
-\r
- $res['size'] = array(0, 0);\r
- $lines = explode("\n", $data);\r
- foreach($lines as $line) {\r
- $line = trim(cubeText::condenseWhite($line));\r
- $e = explode(':', $line, 2);\r
- $k = trim($e[0]);\r
- $v = trim($e[1]);\r
- if ($k == 'Pages' || $k == 'NumberOfPages') {\r
- $this->generalInfos['pages'] = $v;\r
- } elseif (preg_match('|Page ([0-9]+) (.*)Box: ([0-9.]*) ([0-9.]*) ([0-9.]*) ([0-9.]*)|iu', $line, $m)) {\r
- $this->generalInfos['page'][$m[1]][strtolower($m[2])] = array($m[3], $m[4], $m[5], $m[6]);\r
- } elseif (preg_match('|Page ([0-9]+) size: ([0-9.]*)([\sx]+)([0-9.]*)(.*)|iu', $line, $m)) {\r
- $this->generalInfos['page'][$m[1]]['size'] = array($m[2], $m[4]);\r
- $this->generalInfos['size'][0] = max($this->generalInfos['size'][0], $m[2]);\r
- $this->generalInfos['size'][1] = max($this->generalInfos['size'][1], $m[4]);\r
- } elseif ($k == 'BookmarkTitle') {\r
- $this->bookmarks[$bookmark_id] = array('titre' => str_replace(' ', '', trim($v)));\r
- } elseif ($k == 'BookmarkLevel') {\r
- $this->bookmarks[$bookmark_id]['level'] = $v;\r
- } elseif ($k == 'BookmarkPageNumber') {\r
- $this->bookmarks[$bookmark_id]['page'] = $v;\r
- $bookmark_id++;\r
- } elseif ($k == 'PageLabelNewIndex') {\r
- $section = array('startAt' => $v, 'style' => 'decimal', 'firstNumber' => 1, 'prefix' => '');\r
- } else if ($k == 'PageLabelStart') {\r
- $section['firstNumber'] = $v;\r
- } elseif ($k == 'PageLabelPrefix') {\r
- $section['prefix'] = $v;\r
- } else if ($k == 'PageLabelNumStyle') {\r
- $section['style'] = $numberStyles[$v];\r
- $this->numberSections[] = $section;\r
- }\r
- }\r
- return $res;\r
- }\r
-\r
- public function getPagesNumber()\r
- {\r
- $this->parseInfos($this->getBasicInfos());\r
- return $this->generalInfos['pages'];\r
- }\r
-\r
- public function processOnePage($page)\r
- {\r
- $this->getTexts($page);\r
- $this->makeMiniShot($page);\r
- $this->makeRealShot($page);\r
- $this->makeSWFFiles($page);\r
- }\r
-\r
- public function processAllPages()\r
- {\r
- for($i = 1;$i <= $this->generalInfos['pages'];$i++) {\r
- $this->processOnePage($i);\r
- }\r
- }\r
-\r
- public function processRange($range)\r
- {\r
- foreach($pages as $i) {\r
- $this->processOnePage($i);\r
- }\r
- }\r
-\r
- public function getTexts($page = null)\r
- {\r
- $pdftotext = new cubeCommandLine('pdftotext', null, true);\r
- $pdftotext->setPath(CONVERTER_PATH);\r
- $pdftotext->setArg('q');\r
- if (is_null($page)) {\r
- $pdftotext->setArg('f', 1);\r
- $pdftotext->setArg('l', 10000);\r
- } else {\r
- $pdftotext->setArg('f', $page);\r
- $pdftotext->setArg('l', $page);\r
- }\r
- $pdftotext->setArg('-eol', 'unix');\r
- $pdftotext->setArg('-enc', 'UTF-8');\r
- $pdftotext->setArg(null, $this->in);\r
- $pdftotext->setArg(null, $this->textes);\r
- $pdftotext->execute();\r
- $this->addToLog($pdftotext);\r
- }\r
-\r
- public function makeMiniShot($page = null)\r
- {\r
- $this->makeShotFixedWidth($page, 'p', 100, 70, 4, 'GS');\r
- }\r
-\r
- public function makeRealShot($page = null)\r
- {\r
- $this->makeShot($page, 'te', 72);\r
- }\r
-\r
- public function makeShotFixedWidth($page = null, $prefix = '', $w = 100, $quality = 90, $antialiasing = 4, $method = 'GS')\r
- {\r
- // Make thumbs of $w width\r
- // resolution 72 make 1pt=1px\r
- $width = $this->generalInfos['size'][0];\r
- $ratio = $width / $w;\r
- $this->makeShot($page, $prefix, round(72 / $ratio, 2), $quality, $antialiasing, $method);\r
- }\r
-\r
- public function makeShotFixedHeight($page = null, $prefix = '', $h = '', $quality = 90, $antialiasing = 4, $method = 'GS')\r
- {\r
- // Make thumbs of $w height\r
- // resolution 72 make 1pt=1px\r
- $height = $this->generalInfos['size'][1];\r
- $ratio = $height / $h;\r
- $this->makeShot($page, $prefix, round(72 / $ratio, 2), $quality, $antialiasing, $method);\r
- }\r
-\r
- public function makeShot($page = null, $prefix = '', $resolution = 72, $quality = 90, $antialiasing = 4, $method = 'GS')\r
- {\r
- // Delete all old files\r
- for($i = 1;$i <= $this->generalInfos['pages'];$i++) {\r
- if (file_exists($this->out . $prefix . $i . '.jpg')) {\r
- @unlink($this->out . $prefix . $i . '.jpg');\r
- }\r
- }\r
- if ($method == 'GS') {\r
- $this->makeShotGS($page, $prefix, $resolution, $quality, $antialiasing);\r
- } elseif ($method == 'PNM') {\r
- $this->makeShotPNM($page, $prefix, $resolution, $quality, $antialiasing);\r
- }\r
- // Test the result by checking all files\r
- $error = false;\r
- $startpage = is_null($page)?1:$page;\r
- $endpage = is_null($page)?$this->generalInfos['pages']:$page;\r
-\r
- for($i = $startpage;$i <= $endpage;$i++) {\r
- if (!file_exists($this->out . $prefix . $i . '.jpg')) {\r
- $error = true;\r
- break;\r
- }\r
- }\r
- // If error, we try to make thumbs with other method\r
- if ($error) {\r
- if ($method == 'GS') {\r
- $this->makeShotPNM($page, $prefix, $resolution, $quality, $antialiasing);\r
- } elseif ($method == 'PNM') {\r
- $this->makeShotGS($page, $prefix, $resolution, $quality, $antialiasing);\r
- }\r
- }\r
- }\r
-\r
- protected function makeShotGS($page = null, $prefix = '', $resolution = 72, $quality = 90, $antialiasing = 4)\r
- {\r
- // Fabrication des thumbanails avec ghostscript\r
- $gs = new cubeCommandLine('gs', null, true);\r
- $gs->setPath(CONVERTER_PATH);\r
- $gs->setEnv('GS_FONTPATH', FONT_PATH);\r
- $gs->setArg('-dBATCH');\r
- $gs->setArg('-dNOPAUSE');\r
- $gs->setArg('-dNOPROMPT');\r
- $gs->setArg('-sDEVICE=jpeg');\r
- $gs->setArg('-dUseCIEColor');\r
- $gs->setArg('-r' . $resolution);\r
- $gs->setArg('-dJPEGQ=' . $quality);\r
- $gs->setArg('-dTextAlphaBits=' . $antialiasing);\r
- $gs->setArg('-dGraphicsAlphaBits=' . $antialiasing);\r
- // $gs->setArg('-dUseCropBox');\r
- if (!is_null($page)) {\r
- $gs->setArg('-dStartPage=' . $page);\r
- $gs->setArg('-dEndPage=' . $page);\r
- }\r
- $gs->setArg('-sOutputFile=' . $this->out . '/' . $prefix . '%d.jpg');\r
- $gs->setArg('-dAutoRotatePages=/None');\r
- $gs->setArg(null, $this->in);\r
- $gs->execute();\r
- $this->addToLog($gs);\r
- }\r
-\r
- protected function makeShotPNM($page = null, $prefix = '', $resolution = 72, $quality = 90, $antialiasing = 4)\r
- {\r
- $antialiasing = $antialiasing?'yes':'no';\r
- $resolution = round($resolution);\r
- // Exporte les fichiers\r
- $pdftoppm = new cubeCommandLine('pdftoppm', null, true);\r
- $pdftoppm->setPath(CONVERTER_PATH);\r
- if (is_null($page)) {\r
- $pdftoppm->setArg('f', 1);\r
- $pdftoppm->setArg('l', 10000);\r
- } else {\r
- $pdftoppm->setArg('f', $page);\r
- $pdftoppm->setArg('l', $page);\r
- }\r
-\r
- $pdftoppm->setArg('-freetype yes');\r
- $pdftoppm->setArg('-aa ' . $antialiasing);\r
- $pdftoppm->setArg('-aaVector ' . $antialiasing);\r
- if (!WINDOWS) {\r
- $pdftoppm->setArg('-t1lib yes');\r
- }\r
- $pdftoppm->setArg('r', $resolution);\r
- $pdftoppm->setArg(null, $this->in);\r
- $pdftoppm->setArg(null, $this->out . 'ppm');\r
- $pdftoppm->execute();\r
- $this->addToLog($pdftoppm);\r
-\r
- $startpage = is_null($page)?1:$page;\r
-\r
- for($i = $startpage;true;$i++) {\r
- $ppmfile = $this->out . 'ppm-' . cubeMath::fill($i, 6) . '.ppm';\r
- $jpegfile = $this->out . $prefix . $i . '.jpg';\r
- if (!file_exists($ppmfile)) {\r
- break;\r
- }\r
- $pnmtojpeg = new cubeCommandLine('pnmtojpeg', $jpegfile, false);\r
- $pnmtojpeg->setPath(CONVERTER_PATH);\r
- $pnmtojpeg->setArg('-quality=' . $quality);\r
- $pnmtojpeg->setArg('-density=' . $resolution . 'x' . $resolution . 'dpi');\r
- $pnmtojpeg->setManualArg($ppmfile);\r
- $pnmtojpeg->execute();\r
-\r
- $this->addToLog($pnmtojpeg, false);\r
- unlink($ppmfile);\r
- }\r
- }\r
-\r
- public function makeSWFFiles($page = null, $resolution = 150, $quality = 90, $storeAllChars = true, $maxObjects = 1800, $method = 0, &$muliply = 1)\r
- {\r
- if ($maxObjects <= 1) {\r
- $method = self::POLY2BITMAP;\r
- }\r
-\r
- $out = $this->pdf2swf($page, $resolution, $quality, $storeAllChars, $method, $multiply);\r
- if ($method < self::BARBARE) {\r
- // Analyse de la sortie pour détecter des typos manquantes\r
- $overflow = false;\r
- $overflowObjects = false;\r
- $written = false;\r
- $missing_fonts = array();\r
- if (file_exists($out['outputfile'])) {\r
- $fp = fopen($out['outputfile'], 'rb');\r
- while ($line = fgets($fp)) {\r
- if (preg_match('|Try putting a TTF version of that font \(named \"([A-Z-_0-9.]*)\"\)|Uui', trim($line), $matches)) {\r
- $missing_fonts[] = $matches[1];\r
- } elseif (stristr($line, 'ID Table overflow')) {\r
- $overflow = true;\r
- } elseif (stristr($line, 'NOTICE SWF written')) {\r
- $written = true;\r
- } elseif (stristr($line, 'NOTICE Writing SWF file')) {\r
- $written = true;\r
- }\r
- }\r
- }\r
- if (!is_null($page) && file_exists($this->out . 'p' . $page . '.swf')) {\r
- $written = true;\r
- }\r
- if ($written && $method < self::BITMAP && !isset($this->_links[$page])) {\r
- file_put_contents(ROOT . '/test.txt', print_r($out, true));\r
- $this->_links[$page] = $this->extractLinks($page, $out['outputfile'], $out['multiply']);\r
- }\r
- // On teste si le fichier est écrit et qu'il a été généré par le premier niveau\r
- if ($method < self::POLY2BITMAP && $written) {\r
- $overflowObjects = $this->checkObjectsNumber($this->out . 'p' . $page . '.swf', $maxObjects);\r
- }\r
-\r
- if (!$written || $overflow || $overflowObjects) {\r
- return $this->makeSWFFiles($page, $resolution, $quality, $storeAllChars, $maxObjects, $method + 1, $multiply);\r
- }\r
- }\r
-\r
- return $out;\r
- }\r
-\r
- protected function checkObjectsNumber($file, $maxObjects)\r
- {\r
- $swfdump = new cubeCommandLine('swfdump', null, true);\r
- $swfdump->setPath(CONVERTER_PATH);\r
- $swfdump->setArg('t');\r
- $swfdump->setArg(null, $file);\r
- $swfdump->execute();\r
- $this->addToLog($swfdump);\r
-\r
- str_replace('[01a]', '', $swfdump->output, $nbObjects);\r
- if ($nbObjects > $maxObjects) {\r
- return true;\r
- }\r
- return false;\r
- }\r
-\r
- protected function pdf2swf($page = null, $resolution = 150, $quality = 90, $storeAllChars = true, $method = 0)\r
- {\r
- /*\r
--h , --help Print short help message and exit\r
--V , --version Print version info and exit\r
--o , --output file.swf Direct output to file.swf. If file.swf contains '%' (file%.swf), then each page goes to a seperate file.\r
--p , --pages range Convert only pages in range with range e.g. 1-20 or 1,4,6,9-11 or\r
--P , --password password Use password for deciphering the pdf.\r
--v , --verbose Be verbose. Use more than one -v for greater effect.\r
--z , --zlib Use Flash 6 (MX) zlib compression.\r
--i , --ignore Allows pdf2swf to change the draw order of the pdf. This may make the generated\r
--j , --jpegquality quality Set quality of embedded jpeg pictures to quality. 0 is worst (small), 100 is best (big). (default:85)\r
--s , --set param=value Set a SWF encoder specific parameter. See pdf2swf -s help for more information.\r
--w , --samewindow When converting pdf hyperlinks, don't make the links open a new window.\r
--t , --stop Insert a stop() command in each page.\r
--T , --flashversion num Set Flash Version in the SWF header to num.\r
--F , --fontdir directory Add directory to the font search path.\r
--b , --defaultviewer Link a standard viewer to the swf file.\r
--l , --defaultloader Link a standard preloader to the swf file which will be displayed while the main swf is loading.\r
--B , --viewer filename Link viewer filename to the swf file.\r
--L , --preloader filename Link preloader filename to the swf file.\r
--q , --quiet Suppress normal messages. Use -qq to suppress warnings, also.\r
--S , --shapes Don't use SWF Fonts, but store everything as shape.\r
--f , --fonts Store full fonts in SWF. (Don't reduce to used characters).\r
--G , --flatten Remove as many clip layers from file as possible.\r
--I , --info Don't do actual conversion, just display a list of all pages in the PDF.\r
--Q , --maxtime n Abort conversion after n seconds. Only availableon Unix.\r
-\r
-PDF device global parameters:\r
------------------------------\r
-fontdir=<dir> a directory with additional fonts\r
-font=<filename> an additional font filename\r
-pages=<range> the range of pages to convert (example: pages=1-100,210-)\r
-zoom=<dpi> the resultion (default: 72)\r
-languagedir=<dir> Add an xpdf language directory\r
-multiply=<times> Render everything at <times> the resolution\r
-poly2bitmap Convert graphics to bitmaps\r
-bitmap Convert everything to bitmaps\r
-\r
-SWF Parameters :\r
-----------------\r
-SWF layer options :\r
--------------------\r
-\r
-jpegsubpixels=<pixels> resolution adjustment for jpeg images (same as jpegdpi, but in pixels)\r
-ppmsubpixels=<pixels resolution adjustment for lossless images (same asppmdpi, but in pixels)\r
-subpixels=<pixels> shortcut for setting both jpegsubpixels and ppmsubpixels\r
-drawonlyshapes convert everything to shapes (currently broken)\r
-ignoredraworder allow to perform a few optimizations for creating smaller SWFs\r
-linksopennewwindow make links open a new browser window\r
-linktarget target window name of new links\r
-linkcolor=<color) color of links (format: RRGGBBAA)\r
-linknameurl Link buttons will be named like the URL they refer to (handy for iterating through links with actionscript)\r
-storeallcharacters don't reduce the fonts to used characters in the output file\r
-enablezlib switch on zlib compression (also done if flashversion>=7)\r
-bboxvars store the bounding box of the SWF file in actionscript variables\r
-dots Take care to handle dots correctly\r
-reordertags=0/1 (default: 1) perform some tag optimizations\r
-internallinkfunction=<name> when the user clicks a internal link (to a different page) in the converted file, this actionscript function is called\r
-externallinkfunction=<name> when the user clicks an external link (e.g. http://www.foo.bar/) on the converted file, this actionscript function is called\r
-disable_polygon_conversion never convert strokes to polygons (will remove capstyles and joint styles)\r
-caplinewidth=<width> the minimum thichness a line needs to have so that capstyles become visible (and are converted)\r
-insertstop put an ActionScript "STOP" tag in every frame\r
-protect add a "protect" tag to the file, to prevent loading in the Flash editor\r
-flashversion=<version> the SWF fileversion (6)\r
-framerate=<fps> SWF framerate\r
-minlinewidth=<width> convert horizontal/vertical boxes smaller than this width to lines (0.05)\r
-simpleviewer Add next/previous buttons to the SWF\r
-animate insert a showframe tag after each placeobject (animate draw order of PDF files)\r
-jpegquality=<quality> set compression quality of jpeg images\r
-splinequality=<value> Set the quality of spline convertion to value (0-100, default: 100).\r
-disablelinks Disable links.\r
- */\r
-\r
- if (!is_null($page) && file_exists($this->out . 'p' . $page . '.swf')) {\r
- unlink($this->out . 'p' . $page . '.swf');\r
- }\r
-\r
- if ($method < self::BARBARE) {\r
- $resolution2multiply = array(72 => 2, 100 => 2, 150 => 3, 200 => 3, 300 => 3, 450 => 4, 600 => 5);\r
-\r
- $pdf2swf = new cubeCommandLine('pdf2swf', null, true);\r
- $pdf2swf->setPath(CONVERTER_PATH);\r
- if (!is_null($page)) {\r
- $pdf2swf->setArg('p', $page);\r
- }\r
- if ($method == self::NORMAL) {\r
- // Default\r
- $multiply = 1;\r
- } elseif ($method == self::FLATTEN) {\r
- $pdf2swf->setArg('flatten');\r
- $multiply = 1;\r
- } elseif ($method == self::POLY2BITMAP) {\r
- // Raster graphics, keep texts\r
- $pdf2swf->setArg('poly2bitmap');\r
- $multiply = $resolution2multiply[$resolution];\r
- $pdf2swf->setArg('multiply', $multiply);\r
- } elseif ($method == self::BITMAP) {\r
- // Raster all\r
- $pdf2swf->setArg('bitmap');\r
- $multiply = $resolution2multiply[$resolution];\r
- $pdf2swf->setArg('multiply', $multiply);\r
- }\r
-\r
- $pdf2swf->setArg('stop');\r
- $pdf2swf->setManualArg('-vvvv');\r
- $pdf2swf->setArg('T', 8);\r
- if ($storeAllChars) {\r
- $pdf2swf->setArg('fonts');\r
- }\r
- if (DEV) {\r
- $pdf2swf->setArg('F', 'C:/Windows/Fonts');\r
- } else {\r
- $pdf2swf->setArg('F', '/home/typo/fonts');\r
- }\r
- $pdf2swf->setArg('set subpixels', $resolution / 72);\r
- $pdf2swf->setArg('set jpegquality', $quality);\r
- $pdf2swf->setArg('set disablelinks');\r
- $pdf2swf->setArg('set dots');\r
-\r
- $pdf2swf->setArg(null, $this->in);\r
- $pdf2swf->setArg('output', $this->out . 'p%.swf');\r
- $pdf2swf->execute();\r
-\r
- $this->addToLog($pdf2swf, true);\r
- return array('outputfile' => $pdf2swf->outputfile, 'multiply' => $multiply, 'object' => $pdf2swf);\r
- } else {\r
- return array('outputfile' => $this->pdf2swfBarbare($page, $resolution, $quality), 'multiply' => 1);\r
- }\r
- }\r
-\r
- protected function makeAS3($swffile)\r
- {\r
- $swfcombine = new cubeCommandLine('swfcombine');\r
- $swfcombine->setPath(CONVERTER_PATH);\r
- $swfcombine->setArg('merge');\r
- $swfcombine->setArg('stack1');\r
- $swfcombine->setArg('z');\r
- $swfcombine->setManualArg('-vvvv');\r
- $swfcombine->setArg('o', $swffile);\r
- $swfcombine->setArg(null, ROOT . '/swf/as3Container.swf');\r
- $swfcombine->setManualArg('content=' . $swffile);\r
- $swfcombine->execute();\r
- $this->addToLog($swfcombine);\r
- }\r
-\r
- protected function pdf2swfBarbare($page = null, $resolution = 150, $quality = 85)\r
- {\r
- // Fabrique les images\r
- $this->makeShot($page, 'barbare', $resolution, $quality, 4, 'PNM');\r
- // A partir des images, on crée les swf\r
- if (is_null($page)) {\r
- $startpage = 1;\r
- $endpage = $this->generalInfos['pages'];\r
- } else {\r
- $startpage = $endpage = $page;\r
- }\r
-\r
- for($i = $startpage;$i <= $endpage;$i++) {\r
- $jpeg2swf = new cubeCommandLine('jpeg2swf');\r
- $jpeg2swf->setPath(CONVERTER_PATH);\r
- $jpeg2swf->setArg('q', $quality);\r
- $jpeg2swf->setArg('o', $this->out . 'p' . $i . '.swf');\r
- $jpeg2swf->setArg('f');\r
- $jpeg2swf->setArg(null, $this->out . 'barbare' . $i . '.jpg');\r
- $jpeg2swf->execute();\r
- $this->addToLog($jpeg2swf);\r
- // Suppression du jpeg\r
- @unlink($this->out . '/barbare' . $i . '.jpg') ;\r
- }\r
- return '';\r
- }\r
-\r
- public function addToLog($cl, $output = true)\r
- {\r
- if ($cl instanceof cubeCommandLine) {\r
- $c = '--- Exécuté en ' . $cl->execTime . " s\n" . $cl->commande . "\n\n";\r
- if ($output) {\r
- $c .= $cl->output . "\n\n";\r
- }\r
- } elseif (is_string($cl)) {\r
- $c = $cl;\r
- }\r
- fwrite($this->log_pointer, $c);\r
- }\r
-\r
- public function extractLinks($page, $outputfile, $multiply = 1)\r
- {\r
- /*\r
-DEBUG drawlink\r
-TRACE drawlink 122.00/579.00 236.00/579.00 236.00/527.00 122.00/527.00\r
-DEBUG | moveTo 122.00 579.00\r
-DEBUG | lineTo 236.00 579.00\r
-DEBUG | lineTo 236.00 527.00\r
-DEBUG | lineTo 122.00 527.00\r
-DEBUG | lineTo 122.00 579.00\r
-TRACE drawlink action=3\r
-TRACE drawlink s=http://www.ladocumentationfrancaise.fr/\r
-*/\r
-\r
- $fp = fopen($outputfile, 'rb');\r
- $log = 'BEGIN extracting link' . "\n";\r
- $link = null;\r
- while ($line = fgets($fp)) {\r
- $line = trim($line);\r
- if (preg_match('|TRACE drawlink(( [-0-9\./]+)+)|', $line, $matches)) {\r
- $log .= 'FOUND a link' . "\n";\r
- $link = new wsLink($multiply);\r
- $log .= 'SETTING POINTS ' . $matches[1] . "\n";\r
- $points = explode(' ', trim($matches[1]));\r
- foreach($points as $point) {\r
- $p = explode('/', $point);\r
- $log .= 'SET POINT ' . $p[0] . ' ' . $p[1] . "\n";\r
- $link->addPoint($p);\r
- }\r
- } elseif (preg_match('|TRACE drawlink action=(.*)|', $line, $matches)) {\r
- $log .= 'SETTING ACTION ' . $matches[1] . "\n";\r
- if (is_null($link)) {\r
- continue;\r
- }\r
- $link->setAction($matches[1]);\r
- } elseif (preg_match('|TRACE drawlink s=(.*)|', $line, $matches)) {\r
- $log .= 'SETTING LINK ' . $matches[1] . "\n";\r
- if (is_null($link)) {\r
- continue;\r
- }\r
- $link->setLink($matches[1]);\r
- $this->links[$page][] = $link->toArray();\r
- $log .= 'SAVE LINK' . print_r($link->toArray(), true) . "\n";\r
- $link = null;\r
- }\r
- }\r
- $log .= 'END OF EXTRACTING' . "\n";\r
- $this->addToLog($log);\r
- fclose($fp);\r
-\r
- return $log;\r
- }\r
-\r
- public function __destruct()\r
- {\r
- if (isset($this->log_pointer) && is_resource($this->log_pointer)) {\r
- fclose($this->log_pointer);\r
- }\r
- }\r
-}\r
-\r
-?>
\ No newline at end of file
+++ /dev/null
-<?php\r
-class wsLangueTextes extends cubeMetier {\r
- protected $textes;\r
-\r
- public function __toXML($xml = null)\r
- {\r
- if (is_null($xml)) {\r
- $xml = simplexml_load_string('<?xml version="1.0" encoding="UTF-8" ?><movie />');\r
- } elseif (is_string($xml)) {\r
- $xml = simplexml_load_string($xml);\r
- }\r
- foreach($this->textes as $t) {\r
- $xml->addChild('tradText', $t);\r
- }\r
- return $xml;\r
- }\r
-}\r
-\r
-?>
\ No newline at end of file
+++ /dev/null
-<?php\r
-class wsLink {\r
- private $origine;\r
- private $points;\r
- private $action;\r
- private $link;\r
- private $multiply;\r
-\r
- public function __construct($multiply = 1)\r
- {\r
- $this->origine = array();\r
- $this->points = array();\r
- $this->action = null;\r
- $this->link = null;\r
- $this->multiply = $multiply;\r
- }\r
-\r
- public function addPoint($point = array())\r
- {\r
- $point[0] = (float)$point[0] / $this->multiply;\r
- $point[1] = (float)$point[1] / $this->multiply;\r
- if ($this->origine == null) {\r
- $this->origine = $point;\r
- } else {\r
- $this->points[] = $point;\r
- }\r
- }\r
-\r
- public function setAction($action)\r
- {\r
- $this->action = $action;\r
- }\r
-\r
- public function setLink($link)\r
- {\r
- $this->link = $link;\r
- }\r
-\r
- public function toArray()\r
- {\r
- if (is_null($this->link)) {\r
- return false;\r
- }\r
-\r
- $res = array();\r
- $res['left'] = $this->origine[0];\r
- $res['top'] = $this->origine[1];\r
-\r
- $res['width'] = $this->points[1][0] - $this->origine[0];\r
- $res['height'] = $this->points[1][1] - $this->origine[1];\r
-\r
- if ($this->action == 0) {\r
- $res['href'] = 'temp.html#' . $this->link;\r
- } elseif ($this->action == 3) {\r
- $res['href'] = $this->link;\r
- }\r
-\r
- return $res;\r
- }\r
-}\r
-\r
-?>
\ No newline at end of file
+++ /dev/null
-<?php\r
-class wsParametres extends cubeMetier {\r
- protected $datas;\r
- protected $fields;\r
-\r
- public function __construct()\r
- {\r
- $this->initFields();\r
- $this->datas = array();\r
- }\r
-\r
- public function __set($varname, $value)\r
- {\r
- $this->set($varname, $value);\r
- }\r
-\r
- public function __unset($varname)\r
- {\r
- $this->set($varname, null);\r
- }\r
-\r
- public function __get($varname)\r
- {\r
- return $this->get($varname);\r
- }\r
-\r
- public function __isset($varname)\r
- {\r
- return $this->_isset($varname);\r
- }\r
-\r
- public function __sleep()\r
- {\r
- return array('datas');\r
- }\r
-\r
- public function __wakeup()\r
- {\r
- $this->initFields();\r
- }\r
-\r
- protected function initFields()\r
- {\r
- $this->fields = array();\r
- }\r
-\r
- protected function set($varname, $value)\r
- {\r
- if (!$this->_isset($varname)) {\r
- throw new Exception('You are setting an attribute (' . get_class($this) . '::' . $varname . ') which not exists');\r
- }\r
-\r
- if (is_null($value)) {\r
- $this->datas[$varname] = null;\r
- return;\r
- }\r
-\r
- switch ($this->fields[$varname]['type']) {\r
- case 'integer':\r
- $value = intval($value);\r
- break;\r
- case 'float':\r
- $value = floatval($value);\r
- break;\r
- case 'boolean':\r
- $value = ($value == '' || $value == '0' || $value == 'false')?false:true;\r
- break;\r
- case 'color':\r
- $value = substr(trim($value, '#'), 0, 6);\r
- break;\r
- case 'date':\r
- $value = intval($value);\r
- break;\r
- default:\r
- $value = (string)$value;\r
- break;\r
- } // switch\r
- $this->datas[$varname] = $value;\r
- }\r
-\r
- protected function _isset($varname)\r
- {\r
- return isset($this->fields[$varname]) && isset($this->fields[$varname]['default']);\r
- }\r
-\r
- protected function get($varname)\r
- {\r
- if (!$this->_isset($varname)) {\r
- throw new Exception('You are getting an attribute (' . get_class($this) . '::' . $varname . ') which not exists');\r
- }\r
- if (is_null($this->datas[$varname]) || !isset($this->datas[$varname])) {\r
- return $this->fields[$varname]['default'];\r
- }\r
- return $this->datas[$varname];\r
- }\r
-\r
- public function fromRecord($r)\r
- {\r
- $c = array_flip($r->columns());\r
- foreach($this->fields as $n => $f) {\r
- if (isset($c[$n]) && !is_null($r->$n)) {\r
- $this->set($n, $r->$n);\r
- }\r
- }\r
- }\r
-\r
- public function fromXML($xml)\r
- {\r
- foreach($this->fields as $n => $f) {\r
- $xp = $xml->$n;\r
- if (!$xp || !count($xp)) {\r
- continue;\r
- }\r
- foreach($xp as $x) {\r
- $this->set($n, $x);\r
- }\r
- }\r
- }\r
-}\r
-\r
-?>
\ No newline at end of file
+++ /dev/null
-<?php\r
-class wsThemeParametres extends wsParametres {\r
- public function __construct()\r
- {\r
- parent::__construct();\r
- }\r
-\r
- public function initFields()\r
- {\r
- parent::initFields();\r
- $this->fields['couleurA'] = array('type' => 'couleur', 'default' => '', 'editable' => true, 'label' => __("Couleur principale (boutons, liens)"), 'extra' => false, 'grade' => 3);\r
- $this->fields['couleurB'] = array('type' => 'couleur', 'default' => '', 'editable' => true, 'label' => __("Couleur des sous-menus"), 'extra' => false, 'grade' => 3);\r
- $this->fields['couleurS'] = array('type' => 'couleur', 'default' => '', 'editable' => true, 'label' => __("Couleur du texte du moteur de recherche"), 'extra' => false, 'grade' => 3);\r
- $this->fields['couleurL'] = array('type' => 'couleur', 'default' => '', 'editable' => true, 'label' => __("Couleur du fond du loader"), 'extra' => false, 'grade' => 3);\r
- $this->fields['repeat'] = array('type' => 'combo',\r
- 'datas' => array(__('Etirer') => '0', __('Etirer le fond') => '2', __("Répéter") => '1'),\r
- 'default' => '0', 'editable' => true, 'label' => __('Affichage du fond'), 'grade' => 3);\r
- }\r
-}\r
-\r
-?>
\ No newline at end of file
require_once(dirname(__FILE__) . '/extranet/Metier/_common.php');\r
require_once(dirname(__FILE__) . '/extranet/Controlleur/_common.php');\r
require_once(dirname(__FILE__) . '/extranet/DAO/_common.php');\r
+// Inclusion des classes propres au Fluidbook Workshop\r
+require_once(dirname(__FILE__) . '/ws/Metier/_common.php');\r
+require_once(dirname(__FILE__) . '/ws/Controlleur/_common.php');\r
+require_once(dirname(__FILE__) . '/ws/DAO/_common.php');\r
$GLOBALS['ajaxClasses'][] = 'extranetAjax';\r
// Instantiation de la classe de contrôle\r
$core = new extranetCore();\r
--- /dev/null
+<?php\r
+// Workshop\r
+$__autoload['wsFlash'] = dirname(__FILE__) . '/class.ws.flash.php';\r
+$__autoload['wsUrl'] = dirname(__FILE__) . '/class.ws.url.php';\r
+$__autoload['wsDroits'] = dirname(__FILE__) . '/class.ws.droits.php';\r
+$__autoload['wsConversionSession'] = dirname(__FILE__) . '/class.ws.conversion.session.php';\r
+\r
+?>
\ No newline at end of file
--- /dev/null
+<?php\r
+\r
+class wsConversionSession {\r
+ protected $documentsId = array();\r
+ protected $documents = array();\r
+ protected $guid;\r
+ protected $progress = 0;\r
+ protected $processing = false;\r
+ protected $inited=false;\r
+ protected $complete = false;\r
+ protected $totalPages = null;\r
+ protected $processedPages = 0;\r
+\r
+ public function __construct($guid)\r
+ {\r
+ $this->guid = $guid;\r
+ }\r
+\r
+ public function setDocuments($documents)\r
+ {\r
+ $this->documentsId = $documents;\r
+ }\r
+\r
+ public function initDocuments()\r
+ {\r
+ global $core;\r
+\r
+ $dao = new wsDAODocument($core->con);\r
+ $this->documents = $dao->selectInList($this->documentsId);\r
+ $this->totalPages = 0;\r
+\r
+ foreach($this->documents as $doc) {\r
+ $this->totalPages += $doc->getPagesNumber();\r
+ }\r
+ $inited=true;\r
+ }\r
+\r
+ public function process()\r
+ {\r
+ $this->processing = true;\r
+ $this->initDocuments();\r
+ $this->serialize();\r
+\r
+ foreach($this->documents as $doc) {\r
+ for($i = 1;$i <= $doc->generalInfos['pages'];$i++) {\r
+ $doc->processOnePage($i);\r
+ $this->processedPages++;\r
+ $this->setProgress(($this->processedPages / $this->totalPages) * 100);\r
+ }\r
+ }\r
+\r
+ $this->complete = true;\r
+ $this->processing = false;\r
+ $this->setProgress(100);\r
+ }\r
+\r
+ public function getProgress()\r
+ {\r
+ return $this->progress;\r
+ }\r
+\r
+ public function setProgress($i)\r
+ {\r
+ $this->progress = $i;\r
+ $this->serialize();\r
+ }\r
+\r
+ public function getTotalPages()\r
+ {\r
+ return $this->totalPages;\r
+ }\r
+\r
+ public function getProcessedPages()\r
+ {\r
+ return $this->processedPages;\r
+ }\r
+\r
+ public function serialize()\r
+ {\r
+ file_put_contents(self::getCachePath($this->guid), serialize($this));\r
+ }\r
+\r
+ public function __destruct()\r
+ {\r
+ //$this->serialize();\r
+ }\r
+\r
+ public static function openFromGUID($guid)\r
+ {\r
+ $serializedObject = self::getCachePath($guid);\r
+ if (file_exists($serializedObject)) {\r
+ return unserialize(file_get_contents($serializedObject));\r
+ } else {\r
+ return new wsConversionSession($guid);\r
+ }\r
+ }\r
+\r
+ public static function getCachePath($guid)\r
+ {\r
+ return CACHE . '/conversionSessions/' . $guid . '.obj';\r
+ }\r
+}\r
+\r
+?>
\ No newline at end of file
--- /dev/null
+<?php\r
+class wsDroits {\r
+ public static function navigation()\r
+ {\r
+ global $core;\r
+\r
+ $nav = array();\r
+ $nav[__('Dashboard')] = 'dashboard';\r
+ $nav[__('Publications')] = 'books';\r
+ return $nav;\r
+ }\r
+}\r
+\r
+?>
\ No newline at end of file
--- /dev/null
+<?php\r
+class wsFlash extends cubeFlashGateway {\r
+ const CNAME = __CLASS__;\r
+ public static function in($args)\r
+ {\r
+ global $core;\r
+ $args = cubePage::getArgs($args);\r
+ $n = self::CNAME;\r
+ $gateway = new $n($core->con, $args);\r
+ }\r
+\r
+ public function uploadDocument()\r
+ {\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['file'] = $infos['name'];\r
+ $li = new wsDocumentLocalInfos();\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
+ $document = $dao->sauve($data);\r
+ $document->copyOriginal($infos['tmp_name']);\r
+ }\r
+ $this->xml->addChild('document_id', $document->document_id);\r
+ $_SESSION['conversionSession'][] = $document->document_id;\r
+ }\r
+\r
+ public function testDocuments()\r
+ {\r
+ $toload = $this->xml->addChild('toLoad');\r
+ $alreadyLoaded = $this->xml->addChild('alreadyLoaded');\r
+\r
+ foreach($this->args['fileName'] as $k => $name) {\r
+ $toload->addChild('file', $name);\r
+ }\r
+ }\r
+\r
+ public function getPagesOfBook()\r
+ {\r
+ global $core;\r
+ $dao = new wsDAOBook($core->con);\r
+ $pages = $dao->getPagesOfBook($this->args['book_id']);\r
+ $p = $this->xml->addChild('pages');\r
+ $docs = array();\r
+ foreach($pages as $page => $info) {\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
+ $docs[] = $info['document_id'];\r
+ }\r
+ $docs = array_unique($docs);\r
+ $p->addAttribute('documents', implode(',', $docs));\r
+ }\r
+\r
+ public function processConversionSession()\r
+ {\r
+ $_SESSION['sessionConversionGUID'] = $sessionConversionGUID = uniqid('conversion_', true);\r
+ $session = new wsConversionSession($sessionConversionGUID);\r
+ $session->setDocuments($_SESSION['conversionSession']);\r
+ unset($_SESSION['conversionSession']);\r
+ $session->serialize();\r
+\r
+ $http = new cubeHTTP($_SERVER['HTTP_HOST']);\r
+ $http->setDataTimeout(1);\r
+ try {\r
+ $http->post('/flash/processConversionSessionAsync', array('user_email' => $_SESSION['user_email'], 'user_password' => $_SESSION['user_password'], 'sessionConversionGUID' => $sessionConversionGUID));\r
+ }\r
+ catch(Exception $e) {\r
+ }\r
+ }\r
+\r
+ public function processConversionSessionAsync()\r
+ {\r
+ cubePHP::neverStop();\r
+ $conversion = wsConversionSession::openFromGUID($_POST['sessionConversionGUID']);\r
+ $conversion->process();\r
+ }\r
+\r
+ public function getConversionSessionProgress()\r
+ {\r
+ set_time_limit(1);\r
+ $session = wsConversionSession::openFromGUID($_SESSION['sessionConversionGUID']);\r
+ $this->xml->addChild('progress', $session->getProgress());\r
+ $this->xml->addChild('totalPages',$session->getTotalPages());\r
+ $this->xml->addChild('processedPages',$session->getProcessedPages());\r
+ }\r
+}\r
+\r
+?>
\ No newline at end of file
--- /dev/null
+<?php\r
+class wsUrl {\r
+ public static function books($args)\r
+ {\r
+ global $core;\r
+\r
+ $settings = $core->user->getSettings('books');\r
+\r
+ $shortcuts = array();\r
+ $shortcuts[] = '<a href="' . SITE_PATH . 'editbook/new">' . $core->typo->Ajouter(__('Créer une nouvelle publication')) . '</a>';\r
+\r
+ $filtres = array();\r
+ $filtres[] = new extranetFiltre(__('Status'), 'status_book', $settings['filtres']);\r
+ $filtres[] = new extranetFiltre(__('Année'), 'annee_book', $settings['filtres']);\r
+ $res = extranetPage::barre($filtres , 'filtreBooks', 'books', $shortcuts);\r
+ $res .= extranetPage::tMain(null, true);\r
+ $res .= extranetPage::bh();\r
+ $res .= '<div id="listeBooks">';\r
+ $res .= self::listeBooks();\r
+ $res .= '</div>';\r
+ $res .= extranetPage::bf();\r
+ $res .= extranetPage::bMain();\r
+ return $res;\r
+ }\r
+\r
+ public static function listeBooks($dashboard = null, $settings = null)\r
+ {\r
+ global $core;\r
+ cubePage::truePopup();\r
+ extranetDroits::min(1);\r
+ $settings = is_null($settings)?$core->user->getSettings('books'):$settings;\r
+ $change = is_null($dashboard)?'Books':'Dashboard/' . $dashboard;\r
+ $dao = new wsDAOBook($core->con);\r
+ if (isset($settings['search']) && !is_null($settings['search'])) {\r
+ $dao->setSearch($settings['search']);\r
+ }\r
+ $dao->setFiltres($settings['filtres']);\r
+ $liste = $dao->getListe($settings['orderby'], $settings['sens'], $settings['limit']);\r
+\r
+ $res = '<table class="liste">';\r
+ $res .= '<tr><th>' . extranetUrl::orderby('#', 'book_id', $settings, 'sort' . $change) . '</th>';\r
+ $res .= '<th>' . extranetUrl::orderby(__('Titre de la publication'), 'nom', $settings, 'sort' . $change) . '</th>';\r
+ $res .= '<th>' . extranetUrl::orderby(__(''), 'lang', $settings, 'sort' . $change) . '</th>';\r
+ $res .= '<th>' . extranetUrl::orderby(__('Proprietaire'), 'proprietaire_nom', $settings, 'sort' . $change) . '</th>';\r
+ $res .= '<th>' . extranetUrl::orderby(__('Facturation'), 'facturable', $settings, 'sort' . $change) . '</th>';\r
+ $res .= '<th>' . extranetUrl::orderby(__('Status'), 'status', $settings, 'sort' . $change) . '</th>';\r
+ $res .= '<th class="min"></th><th class="min"></th><th class="min"></th><th class="min"></th><th class="min"></th></tr>';\r
+ $i = 0;\r
+\r
+ foreach($liste as $id => $book) {\r
+ $odd = cubeMath::isOdd($i)?' class="odd"':'';\r
+ $res .= '<tr' . $odd . '>';\r
+ $res .= '<td>' . $book->book_id . '</td>';\r
+ $res .= '<td>' . $book->nom . '</td>';\r
+ $res .= '<td>' . mb_strtoupper($book->lang) . '</td>';\r
+ $res .= '<td>' . $book->proprietaire . '</td>';\r
+ $f = $book->facturable;\r
+ $res .= '<td>' . $f . '</td>';\r
+ $res .= '<td>' . $core->books_status[$book->status] . '</td>';\r
+ $res .= '<td class="bouton"><a href="' . SITE_PATH . 'voirbook/' . $book->book_id . '_' . $book->hash . '_' . TIME . '/" class="popupFS">' . cubeMedia::cssRollover($core->typo->Voir('voir', '', false)) . '</a></td>';\r
+ $res .= '<td class="bouton"><a href="' . SITE_PATH . 'editbook/' . $book->book_id . '">' . cubeMedia::cssRollover($core->typo->Editer('éditer', '', false)) . '</a></td>';\r
+ $res .= '<td class="bouton"><a href="' . SITE_PATH . 'supprimebook/' . $book->book_id . '">' . cubeMedia::cssRollover($core->typo->Stats('stats', '', false)) . '</a></td>';\r
+ $res .= '<td class="bouton"><a href="' . SITE_PATH . 'supprimebook/' . $book->book_id . '">' . cubeMedia::cssRollover($core->typo->Telecharger('télécharger', '', false)) . '</a></td>';\r
+ $res .= '<td class="bouton"><a href="#" rel="supprimeBook/' . $book->book_id . '" class="ajax" title="' . __('Êtes-vous certain de vouloir supprimer cette publication ?') . '">' . cubeMedia::cssRollover($core->typo->Supprimer('suppr.', '', false)) . '</a></td>';\r
+ $res .= '</tr>';\r
+ $i++;\r
+ }\r
+ if (!isset($settings['search']) || is_null($settings['search'])) {\r
+ $odd = cubeMath::isOdd($i)?' class="odd"':'';\r
+ $res .= '<tr' . $odd . '><td colspan="11">';\r
+ $res .= extranetPage::pager($settings['page'], $dao->count() , $settings['par_page'], 'page' . $change . '/%d');\r
+ $res .= extranetUrl::formParPage('parPage' . $change, $settings['par_page'], __('publications'), false);\r
+ $res .= '</td></tr>';\r
+ }\r
+ $res .= '</table>';\r
+ return $res;\r
+ }\r
+\r
+ public static function editbook($args)\r
+ {\r
+ global $core;\r
+ $book_id = $args[1];\r
+\r
+ if ($book_id == 'new') {\r
+ $dao = new wsDAOBook($core->con);\r
+ $book = $dao->creeEmpty($core->user->utilisateur_id);\r
+ http::redirect(SITE_PATH . 'editbook/' . $book->book_id);\r
+ }\r
+\r
+ $step = isset($args[2])?$args[2]:1;\r
+\r
+ $shortcuts = array();\r
+\r
+ $steps = array();\r
+ $steps[1] = __('Composition');\r
+ $steps[2] = __('Personnalisation');\r
+ $steps[3] = __('Paramètres');\r
+ $steps[4] = __('Edition des liens');\r
+ $steps[5] = __('Aperçu');\r
+\r
+ foreach($steps as $s => $n) {\r
+ $template = 'Step';\r
+ if ($s == $step) {\r
+ $class = 'step active';\r
+ $ae = $as = '';\r
+ } else {\r
+ $class = 'step';\r
+ $as = '<a href="' . SITE_PATH . 'editbook/' . $book_id . '/' . $s . '">';\r
+ $ae = '</a>';\r
+ }\r
+\r
+ if ($s == count($steps)) {\r
+ $template = 'Last' . $template;\r
+ }\r
+ $shortcuts[] = $as . $core->typo->$template($s . '. ' . $n, $class, -1) . $ae;\r
+ }\r
+\r
+ $res = extranetPage::barre(null , null, null, $shortcuts);\r
+ $res .= extranetPage::tMain(null, true);\r
+ $res .= extranetPage::bh();\r
+ $res .= '<div id="listeBooks">';\r
+ if ($step == 1) {\r
+ $res .= self::editComposition($args);\r
+ } elseif ($step == 2) {\r
+ $res .= self::editTheme($args);\r
+ } elseif ($step == 3) {\r
+ $res .= self::editParametres($args);\r
+ } elseif ($step == 4) {\r
+ $res .= self::editLinks($args);\r
+ } else {\r
+ $res .= self::editApercu($args);\r
+ }\r
+ $res .= '</div>';\r
+ $res .= extranetPage::bf();\r
+ $res .= extranetPage::bMain();\r
+ return $res;\r
+ }\r
+\r
+ public static function editComposition($args)\r
+ {\r
+ $fv = array(session_name() => session_id(),\r
+ 'book_id' => $args[1],\r
+ 'finishedText' => __('Transfert terminé'),\r
+ 'loadingFileText' => __('Chargement du fichier'),\r
+ 'totalText' => __('Total'),\r
+ 'browseText' => __('Parcourir') . ' ...',\r
+ 'titreUpload' => __('Sélectionnez un ou plusieurs document PDF sur votre ordinateur'),\r
+ 'titreComposition' => __('Organisez le(s) document(s) pour composer votre fluidbook'));\r
+ $res = cubeMedia::flash(WEBROOT . '/swf/composer.swf', '960', '100%', $fv, 'composerSwf', 'swfPanel', 9, '#ffffff', '', 'false', 'noscale', 'transparent');\r
+ return $res;\r
+ }\r
+\r
+ public static function editTheme($args)\r
+ {\r
+ $fv = array(session_name() => session_id(),\r
+ 'book_id' => $args[1]);\r
+ $res = cubeMedia::flash(WEBROOT . '/swf/theme.swf', '960', '100%', $fv, 'composerSwf', 'swfPanel', 9, '#ffffff', '', 'false', 'noscale', 'transparent');\r
+ return $res;\r
+ }\r
+\r
+ public static function editParametres($args)\r
+ {\r
+ }\r
+\r
+ public static function editLinks($args)\r
+ {\r
+ $fv = array(session_name() => session_id(),\r
+ 'book_id' => $args[1]);\r
+ $res = cubeMedia::flash(WEBROOT . '/swf/links.swf', '960', '100%', $fv, 'composerSwf', 'swfPanel', 9, '#ffffff', '', 'false', 'noscale', 'transparent');\r
+ return $res;\r
+ }\r
+\r
+ public static function editApercu($args)\r
+ {\r
+ }\r
+}\r
+\r
+?>
\ No newline at end of file
--- /dev/null
+<?php\r
+$__autoload['wsDAOBook'] = dirname(__FILE__) . '/class.ws.dao.book.php';\r
+$__autoload['wsDAODocument'] = dirname(__FILE__) . '/class.ws.dao.document.php';\r
+\r
+?>
\ No newline at end of file
--- /dev/null
+<?php\r
+class wsDAOBook extends extranetDAO {\r
+ protected function singleton($r)\r
+ {\r
+ $book = new wsBook();\r
+ $book->book_id = $r->book_id;\r
+ $book->nom = $r->nom;\r
+ $book->lang = $r->lang;\r
+ $book->theme = $r->theme;\r
+ $book->proprietaire = $r->proprietaire_nom;\r
+ $book->proprietaire_id = $r->proprietaire_id;\r
+ $book->facturable = $r->facturable;\r
+ $book->facturable_id = $r->facturable_id;\r
+ $book->hash = $r->hash;\r
+ $book->compteur_visites = $r->compteur_visites;\r
+ $book->status = $r->status;\r
+ $book->date_status = $r->date_status;\r
+ $book->date = $r->date;\r
+ $book->pages = array();\r
+\r
+ $p = unserialize($r->parametres);\r
+ if (!$p) {\r
+ $p = new wsBookParametres();\r
+ }\r
+ $book->parametres = $p;\r
+\r
+ return $book;\r
+ }\r
+\r
+ protected function cree($r)\r
+ {\r
+ $book = new wsBook();\r
+ $book->book_id = 'new';\r
+ $book->nom = '';\r
+ $book->lang = 0;\r
+ $book->theme = 0;\r
+ $book->proprietaire = '';\r
+ $book->proprietaire_id = 0;\r
+ $book->facturable = '';\r
+ $book->facturable_id = 0;\r
+ $book->hash = '';\r
+ $book->compteur_visites = 20;\r
+ $book->status = 0;\r
+ $book->date_status = TIME;\r
+ $book->date = TIME;\r
+ $book->parametres = new wsBookParametres();\r
+ $book->pages = array();\r
+ return $book;\r
+ }\r
+\r
+ protected function getNextId()\r
+ {\r
+ $r = $this->con->select('SELECT MAX(book_id) AS book_id FROM books');\r
+ return $r->book_id + 1;\r
+ }\r
+\r
+ public function selectById($book_id = null)\r
+ {\r
+ if (is_null($book_id)) {\r
+ return $this->cree();\r
+ }\r
+ $sql = 'SELECT * FROM books_vue WHERE book_id=\'' . $this->con->escape($book_id) . '\' LIMIT 1';\r
+ $r = $this->con->select('SELECT * FROM books_vue WHERE book_id=\'' . $this->con->escape($book_id) . '\' LIMIT 1');\r
+ return $this->singleton($r);\r
+ }\r
+\r
+ public function sauve($createur, $data)\r
+ {\r
+ global $core;\r
+\r
+ $c = $this->con->openCursor('books');\r
+ $c->nom = $data['nom'];\r
+ $c->lang = $data['lang'];\r
+ $c->theme = $data['theme'];\r
+ $c->proprietaire = $data['proprietaire'];\r
+\r
+ if ($data['book_id'] == 'new' || $data['book_id'] == '') {\r
+ $c->date = TIME;\r
+ $c->hash = md5(rand(0, 1234567893));\r
+ $c->compteur_visites = 20;\r
+ $c->parametres = serialize(new wsParametres());\r
+ $book_id = $c->book_id = $this->getNextId();\r
+\r
+ $c->insert();\r
+ } else {\r
+ $book_id = $data['book_id'];\r
+ $c->update('WHERE book_id=\'' . $this->con->escape($data['book_id']) . '\'');\r
+ }\r
+\r
+ return $this->selectById($book_id);\r
+ }\r
+\r
+ public function creeEmpty($createur)\r
+ {\r
+ $c = $this->con->openCursor('books');\r
+ $c->proprietaire = $createur;\r
+ $c->date = TIME;\r
+ $c->hash = md5(rand(0, 1234567893));\r
+ $c->compteur_visites = 20;\r
+ $c->status = -1;\r
+ $c->date_status = TIME;\r
+ $c->parametres = serialize(new wsParametres());\r
+ $book_id = $c->book_id = $this->getNextId();\r
+ $c->insert();\r
+ fb($book_id);\r
+ return $this->selectById($book_id);\r
+ }\r
+\r
+ public function supprime($book_id)\r
+ {\r
+ return $this->con->execute('DELETE FROM books WHERE book_id=\'' . $this->con->escape($book_id) . '\'');\r
+ }\r
+\r
+ public function count()\r
+ {\r
+ $r = $this->con->select('SELECT COUNT(*) AS nb FROM books_vue WHERE ' . $this->makeWhereFromFiltres());\r
+ return $r->nb;\r
+ }\r
+\r
+ public function getPagesOfBook($book_id)\r
+ {\r
+ $pages = array();\r
+ $r = $this->con->select('SELECT * FROM book_pages WHERE book_id=\'' . $this->con->escape($book_id) . '\' ORDER BY book_page');\r
+ while ($r->fetch()) {\r
+ $pages[$r->book_page] = array('document_id' => $r->document_id, 'document_page' => $r->document_page);\r
+ }\r
+ return $pages;\r
+ }\r
+\r
+ public function appendDocument($book_id, $document_id)\r
+ {\r
+ $r = $core->con->select('SELECT MAX(book_page) AS book_page FROM books WHERE book_id=\'' . $core->con->escape($book_id) . '\'');\r
+ $lastPage = $r->book_page;\r
+ $this->insertDocument($book_id, $lastPage, $document_id);\r
+ }\r
+\r
+ public function removePage($book_id, $book_page)\r
+ {\r
+ // Supprime la page\r
+ $core->con->execute('DELETE FROM book_pages WHERE book_page=\'' . $core->con->escape($book_page) . '\' AND book_id=\'' . $core->con->escape($book_id) . '\'');\r
+ // Décale les pages suivantes vers le haut\r
+ $this->decalePages($book_id, $book_page, -1);\r
+ }\r
+\r
+ public function insertPage($book_id, $after_page, $document_id, $document_page)\r
+ {\r
+ // Décale les pages vers le bas\r
+ $this->decalePages($book_id, $after_page, 1);\r
+ // Insère la page\r
+ $c = $core->con->openCursor('book_pages');\r
+ $c->book_id = $book_id;\r
+ $c->book_page = $after_page + 1;\r
+ $c->document_id = $document_id;\r
+ $c->document_page = $document_page;\r
+ $c->insert();\r
+ }\r
+\r
+ public function insertDocument($book_id, $after_page, $document_id)\r
+ {\r
+ // Obtiens le nombre de pages\r
+ $r = $core->con->select('SELECT pages FROM documents WHERE document_id=\'' . $core->con->escape($document_id) . '\'');\r
+ // Décale les pages vers le bas\r
+ $this->decalePages($book_id, $after_page, $r->pages);\r
+ // Insère les pages\r
+ $c = $core->con->openCursor('book_pages');\r
+ $c->book_id = $book_id;\r
+ $c->document_id = $r->document_id;\r
+ for($i = 1;$i <= $r->pages;$i++) {\r
+ $c->document_page = $i;\r
+ $c->book_page = $after_page + $i;\r
+ $c->insert();\r
+ }\r
+ }\r
+\r
+ protected function decalePages($book_id, $after_page, $decalage)\r
+ {\r
+ $decalage = ($decalage >= 0)?'+' . $decalage:$decalage;\r
+ $core->con->execute('UPDATE book_pages SET book_page=book_page' . $decalage . ' WHERE book_page>' . $core->con->escape($book_page) . ' AND book_id=\'' . $core->con->escape($book_id) . '\'');\r
+ }\r
+\r
+ public function getListe($orderby = null, $sens = null, $limit = null)\r
+ {\r
+ if (!is_null($this->q)) {\r
+ $where = '';\r
+ if ($this->search_id) {\r
+ $where .= ' book_id=\'' . $this->con->escape($this->q) . '\' OR ';\r
+ }\r
+ $where .= 'nom LIKE \'%' . $this->con->escape($this->q) . '%\'';\r
+ $daoClient = new extranetDAOClient($this->con);\r
+ $where .= ' OR proprietaire_id IN(' . $daoClient->querySearchByName($this->q) . ')';\r
+ $where .= ' OR facturable_id IN(' . $daoClient->querySearchByName($this->q) . ')';\r
+ $limit = null;\r
+ } else {\r
+ $where = $this->makeWhereFromFiltres();\r
+ }\r
+ $orderby = is_null($orderby)?'book_id':$orderby;\r
+ $sens = is_null($sens)?'DESC':$sens;\r
+ $limit = is_null($limit)?'':$this->con->limit($limit);\r
+\r
+ $sql = 'SELECT * FROM books_vue WHERE ' . $where . ' ORDER BY ' . $orderby . ' ' . $sens . ' ' . $limit;\r
+ $r = $this->con->select($sql);\r
+ return $this->factory($r);\r
+ }\r
+\r
+ protected function makeWhereFromFiltres()\r
+ {\r
+ if (!is_null($this->filtres)) {\r
+ $w = array('1=1');\r
+ if (extranetFiltre::test('annee_book', $this->filtres)) {\r
+ $w[] = 'YEAR(FROM_UNIXTIME(date)) IN (' . implode(',', array_keys($this->filtres['annee_book'])) . ')';\r
+ }\r
+ if (extranetFiltre::test('status_book', $this->filtres)) {\r
+ $w[] = 'status IN(' . implode(',', array_keys($this->filtres['status_book'])) . ')';\r
+ }\r
+ return implode(' AND ', $w);\r
+ } else {\r
+ return '1=1';\r
+ }\r
+ }\r
+}\r
+\r
+?>
\ No newline at end of file
--- /dev/null
+<?php\r
+class wsDAODocument extends extranetDAO {\r
+ public function singleton($r)\r
+ {\r
+ $document = new wsDocument();\r
+ $document->document_id = $r->document_id;\r
+ $document->init();\r
+ $document->file = $r->file;\r
+ $document->proprietaire = $r->proprietaire;\r
+ $document->pages = $r->pages;\r
+ if ($r->trim) {\r
+ $document->trim = unserialize($r->trim);\r
+ }\r
+ $document->date = $r->date;\r
+ $document->localInfos = unserialize($r->localInfos);\r
+ return $document;\r
+ }\r
+\r
+ public function getNextId()\r
+ {\r
+ $r = $this->con->select('SELECT MAX(document_id) AS document_id FROM documents');\r
+ return $r->document_id + 1;\r
+ }\r
+\r
+ public function selectById($document_id)\r
+ {\r
+ $r = $this->con->select('SELECT * FROM documents WHERE document_id=\'' . $this->con->escape($document_id) . '\'');\r
+ return $this->singleton($r);\r
+ }\r
+\r
+ public function selectInList($documentsId)\r
+ {\r
+ $r = $this->con->select('SELECT * FROM documents WHERE document_id IN(' . implode(',', $documentsId) . ')');\r
+ return $this->factory($r);\r
+ }\r
+\r
+ public function cree()\r
+ {\r
+ $document = new wsDocument();\r
+ $document->document_id = 'new';\r
+ $document->file = '';\r
+ $document->proprietaire = 0;\r
+ $document->pages = 0;\r
+ $document->trim = array();\r
+ $document->date = TIME;\r
+ $document->localInfos = new wsDocumentLocalInfos();\r
+ return $document;\r
+ }\r
+\r
+ public function sauve($data)\r
+ {\r
+ if (!isset($data['document_id'])) {\r
+ $data['document_id'] = 'new';\r
+ }\r
+ $c = $this->con->openCursor('documents');\r
+ $c->file = $data['file'];\r
+ $c->proprietaire = $data['proprietaire'];\r
+ $c->pages = $data['pages'];\r
+ if (isset($data['localInfos'])) {\r
+ $c->localInfos = serialize($data['localInfos']);\r
+ }\r
+ if (isset($data['trim'])) {\r
+ $c->trim = serialize($data['trim']);\r
+ }\r
+\r
+ if ($data['document_id'] == 'new') {\r
+ $document_id = $c->document_id = $this->getNextId();\r
+ $c->date = TIME;\r
+ $c->insert();\r
+ } else {\r
+ $document_id = $data['document_id'];\r
+ $c->update('WHERE document_id=\'' . $this->con->escape($data['document_id']) . '\'');\r
+ }\r
+ $doc = $this->selectById($document_id);\r
+ return $doc;\r
+ }\r
+}\r
+\r
+?>
\ No newline at end of file
--- /dev/null
+<?php\r
+$__autoload['wsBook'] = dirname(__FILE__) . '/class.ws.book.php';\r
+$__autoload['wsParametres'] = dirname(__FILE__) . '/class.ws.parametres.php';\r
+$__autoload['wsThemeParametres'] = dirname(__FILE__) . '/class.ws.theme.parametres.php';\r
+$__autoload['wsBookParametres'] = dirname(__FILE__) . '/class.ws.book.parametres.php';\r
+$__autoload['wsLangueTextes'] = dirname(__FILE__) . '/class.ws.langue.textes.php';\r
+$__autoload['wsDocument'] = dirname(__FILE__) . '/class.ws.document.php';\r
+$__autoload['wsLink'] = dirname(__FILE__) . '/class.ws.link.php';\r
+$__autoload['wsDocumentLocalInfos'] = dirname(__FILE__) . '/class.ws.document.localinfos.php';\r
+\r
+?>
\ No newline at end of file
--- /dev/null
+<?php\r
+class wsBookParametres extends wsParametres {\r
+ public function __construct()\r
+ {\r
+ parent::__construct();\r
+ }\r
+\r
+ protected function initFields()\r
+ {\r
+ parent::initFields();\r
+ // .\r
+ $this->fields['general'] = __('Informations générales');\r
+ $this->fields['pages'] = array('type' => 'integer', 'default' => '', 'editable' => false, 'label' => __('Nombre de pages'), 'extra' => false, 'grade' => 0);\r
+ $this->fields['width'] = array('type' => 'float', 'default' => '', 'editable' => false, 'label' => __('Largeur'), 'extra' => false, 'grade' => 0);\r
+ $this->fields['height'] = array('type' => 'float', 'default' => '', 'editable' => false, 'label' => __('Hauteur'), 'extra' => false, 'grade' => 0);\r
+ $this->fields['first_page_nr'] = array('type' => 'integer', 'default' => 1, 'editable' => true, 'label' => __('La numérotation débute à la page'), 'extra' => false, 'grade' => 1);\r
+ $this->fields['preload'] = array('type' => 'integer', 'default' => 16, 'editable' => true, 'label' => __('Nombre de pages à précharger'), 'extra' => false, 'grade' => 1);\r
+ $this->fields['reading_dir'] = array('type' => 'combo',\r
+ 'datas' => array(__('De la gauche vers la droite') => 'ltr', __('De la droite vers la gauche') => 'rtl'),\r
+ 'default' => 'ltr', 'editable' => true, 'label' => __('Sens de lecture'), 'extra' => false, 'grade' => 1);\r
+ // .\r
+ $this->fields['fonctions_generales'] = __('Fonctionnalités générales');\r
+ $this->fields['print'] = array('type' => 'boolean', 'default' => true, 'editable' => true, 'label' => __('Impression'), 'extra' => false, 'grade' => 1);\r
+ $this->fields['search'] = array('type' => 'boolean', 'default' => true, 'editable' => true, 'label' => __('Moteur de recherche'), 'extra' => false, 'grade' => 1);\r
+ $this->fields['bookmark'] = array('type' => 'boolean', 'default' => true, 'editable' => true, 'label' => __('Marques-pages'), 'extra' => false, 'grade' => 1);\r
+ $this->fields['url_link'] = array('type' => 'text', 'default' => 'http://', 'editable' => true, 'label' => __("URL du lien de retour au site"), 'extra' => false, 'grade' => 1);\r
+ // .\r
+ $this->fields['fonctions_pdf'] = __('Fonction Export PDF');\r
+ $this->fields['pdf'] = array('type' => 'boolean', 'default' => true, 'editable' => true, 'label' => __('Export PDF'), 'extra' => false, 'grade' => 1);\r
+ $this->fields['optimizepdf'] = array('type' => 'boolean', 'default' => true, 'editable' => true, 'label' => __('Optimiser le PDF'), 'extra' => false, 'grade' => 4);\r
+ $this->fields['pdfComplex'] = array('type' => 'boolean', 'default' => false, 'editable' => true, 'label' => __('Export PDF avancé'), 'extra' => false, 'grade' => 3);\r
+ // .\r
+ $this->fields['fonctions_zoom'] = __('Zoom');\r
+ $this->fields['zoom'] = array('type' => 'integer', 'default' => 200, 'editable' => true, 'label' => __('Zoom par défaut (atteint au clic)'), 'extra' => false, 'grade' => 1);\r
+ $this->fields['zoomw'] = array('type' => 'integer', 'default' => 300, 'editable' => true, 'label' => __("Zoom maximal (atteint à l'aide de la molette)"), 'extra' => false, 'grade' => 1);\r
+ $this->fields['fixedZoom'] = array('type' => 'boolean', 'default' => false, 'editable' => true, 'label' => __('Zoom magnétique'), 'extra' => true, 'grade' => 4);\r
+ // .\r
+ $this->fields['fonctions_friend'] = __('Fonction Envoyer à un ami et partage');\r
+ $this->fields['friend'] = array('type' => 'boolean', 'default' => true, 'editable' => true, 'label' => __('Envoyer à un ami'), 'extra' => false, 'grade' => 1);\r
+ $this->fields['email_title'] = array('type' => 'text', 'default' => __('%name% vous invite à découvrir %title%'), 'editable' => true, 'label' => __("Titre de l'email"), 'extra' => false, 'grade' => 1);\r
+ $this->fields['email_body'] = array('type' => 'textarea', 'default' => __('Veuillez cliquer sur le lien suivant : %link%'), 'editable' => true, 'label' => __("Titre de l'email"), 'extra' => false, 'grade' => 1);\r
+ $this->fields['email_editable'] = array('type' => 'boolean', 'default' => false, 'editable' => true, 'label' => __("Permettre au lecteur de modifier le corps de l'email"), 'extra' => false, 'grade' => 1);\r
+ $this->fields['askAcknowledge'] = array('type' => 'boolean', 'default' => false, 'editable' => true, 'label' => __("Demander au destinataire un accusé de réception"), 'extra' => true, 'grade' => 4);\r
+ $this->fields['attachPDFInEmail'] = array('type' => 'boolean', 'default' => false, 'editable' => true, 'label' => __("Joindre le fichier PDF de la page en cours à l'email"), 'extra' => true, 'grade' => 4);\r
+ $this->fields['attachmentName'] = array('type' => 'text', 'default' => '', 'editable' => false, 'label' => __('Nom de la pièce jointe'), 'extra' => true, 'grade' => 4);\r
+ $this->fields['addThis'] = array('type' => 'text', 'default' => '', 'editable' => true, 'label' => __("Identifiant addThis"), 'extra' => false, 'grade' => 4);\r
+ $this->fields['addThisOptions'] = array('type' => 'textarea', 'default' => '', 'editable' => true, 'label' => __("Paramètres addThis"), 'extra' => false, 'grade' => 4);\r
+ // .\r
+ $this->fields['fonctions_stats'] = __('Fonction Statistiques');\r
+ $this->fields['stats'] = array('type' => 'boolean', 'default' => true, 'editable' => true, 'label' => __('Activer les statistiques'), 'extra' => false, 'grade' => 1);\r
+ $this->fields['statsWeborama'] = array('type' => 'text', 'default' => '', 'editable' => true, 'label' => __('Statistiques Weborama'), 'extra' => true, 'grade' => 4);\r
+ // .\r
+ $this->fields['fonctions_sommaire'] = __('Fonction Sommaire');\r
+ $this->fields['displayChaptersAtStart'] = array('type' => 'boolean', 'default' => false, 'editable' => true, 'label' => __("Afficher le sommaire au chargement de la publication"), 'extra' => true, 'grade' => 4);\r
+ $this->fields['chaptersPosition'] = array('type' => 'combo',\r
+ 'datas' => array(__('Centré') => 'center' , __("Calé sur l'icône") => 'icon', __('Calé sur la gauche') => 'left'),\r
+ 'default' => 'center', 'editable' => true, 'label' => __('Positionnement du sommaire'), 'grade' => 4);\r
+ $this->fields['chaptersCloseOnTop'] = array('type' => 'boolean', 'default' => false, 'editable' => true, 'label' => __("Afficher le bouton fermer en haut du sommaire"), 'extra' => true, 'grade' => 4);\r
+ $this->fields['chaptersMargin'] = array('type' => 'integer', 'default' => 20, 'editable' => false, 'label' => __('Marge latérale du sommaire'), 'extra' => true, 'grade' => 4);\r
+ // .\r
+ $this->fields['fonctions_liens'] = __('Liens et multimedia');\r
+ $this->fields['playVideoAtStart'] = array('type' => 'boolean', 'default' => true, 'editable' => true, 'label' => __("Jouer les vidéos à l'affichage de la page"), 'extra' => true, 'grade' => 4);\r
+ $this->fields['permanentLinks'] = array('type' => 'boolean', 'default' => false, 'editable' => true, 'label' => __('Liens visibles en permanence'), 'extra' => true, 'grade' => 4);\r
+ $this->fields['linksColor'] = array('type' => 'color', 'default' => '', 'editable' => true, 'label' => __('Couleurs des liens (si différente de la couleur indiquée dans le thème)'), 'extra' => true, 'grade' => 4);\r
+ $this->fields['zoomAreas'] = array('type' => 'boolean', 'default' => false, 'editable' => true, 'label' => __("Activer le zoom sur les liens ''Plus d'infos''"), 'extra' => true, 'grade' => 4);\r
+ // .\r
+ $this->fields['fonctions_sousmenu'] = __('Sous-menu supplémentaire');\r
+ $this->fields['extraSubMenu'] = array('type' => 'boolean', 'default' => false, 'editable' => true, 'label' => __('Sous-menu supplémentaire'), 'extra' => true, 'grade' => 4);\r
+ $this->fields['extraSMsizeX'] = array('type' => 'integer', 'default' => '', 'editable' => false, 'label' => __('Largeur du sous-menu supplémentaire'), 'extra' => true, 'grade' => 4);\r
+ $this->fields['extraSMsizeY'] = array('type' => 'integer', 'default' => '', 'editable' => false, 'label' => __('Hauteur du sous-menu supplémentaire'), 'extra' => true, 'grade' => 4);\r
+ $this->fields['extraName'] = array('type' => 'text', 'default' => '', 'editable' => false, 'label' => __('Nom du sous-menu supplémentaire'), 'extra' => true, 'grade' => 4);\r
+ $this->fields['extraFileName'] = array('type' => 'text', 'default' => '', 'editable' => false, 'label' => __('Fichier du sous-menu supplémentaire'), 'extra' => true, 'grade' => 4);\r
+ // .\r
+ $this->fields['fonctions_onglets'] = __('Fonds multimédia et onglets');\r
+ $this->fields['backClipName'] = array('type' => 'text', 'default' => '', 'editable' => false, 'label' => __('Fichier du fond animé'), 'extra' => true, 'grade' => 4);\r
+ $this->fields['extraXSpace'] = array('type' => 'integer', 'default' => '0', 'editable' => false, 'label' => __('Largeur du décalage des flèches'), 'extra' => true, 'grade' => 4);\r
+ // .\r
+ $this->fields['fonctions_diverses'] = __('Fonctions diverses');\r
+ $this->fields['immediateResize'] = array('type' => 'boolean', 'default' => false, 'editable' => true, 'label' => __("Redimensionner immédiatement la fenêtre"), 'extra' => true, 'grade' => 4);\r
+ // .\r
+ $this->fields['fonctions_perso'] = __('Fonctions de personnalisation');\r
+ $this->fields['shadeOnMenu'] = array('type' => 'boolean', 'default' => true, 'editable' => true, 'label' => __('Ombre portée sous la barre du menu'), 'extra' => true, 'grade' => 4);\r
+ $this->fields['pagesBar'] = array('type' => 'boolean', 'default' => true, 'editable' => true, 'label' => __("Afficher la barre d'accès rapide aux pages"), 'extra' => true, 'grade' => 4);\r
+ $this->fields['shadeAlpha'] = array('type' => 'integer', 'default' => 100, 'editable' => true, 'label' => __('Transparence des ombres sur les pages (100 : maximale - 0 : invisible)'), 'extra' => true, 'grade' => 4);\r
+ $this->fields['usePageEdges'] = array('type' => 'boolean', 'default' => true, 'editable' => true, 'label' => __("Afficher la bordure des pages"), 'extra' => true, 'grade' => 4);\r
+ $this->fields['arrowsColor'] = array('type' => 'color', 'default' => 'ffffff', 'editable' => true, 'label' => __('Couleur des flèches des boutons de navigation (page suivante, page précédente)'), 'extra' => true, 'grade' => 4);\r
+ $this->fields['pagesBarTxtColor'] = array('type' => 'color', 'default' => 'ffffff', 'editable' => true, 'label' => __("Couleur des numéros de page de la barre d'accès rapide aux pages"), 'extra' => true, 'grade' => 4);\r
+ $this->fields['sections'] = array('type' => 'textarea', 'default' => '', 'editable' => true, 'label' => __("Sections"), 'extra' => false, 'grade' => 4);\r
+ $this->fields['indexColors'] = array('type' => 'textarea', 'default' => '', 'editable' => true, 'label' => __("Couleurs des pages de l'index"), 'extra' => true, 'grade' => 4);\r
+ $this->fields['displayPageNumber'] = array('type' => 'boolean', 'default' => true, 'editable' => true, 'label' => __('Afficher les numéros de page'), 'extra' => false, 'grade' => 1);\r
+ }\r
+}\r
+\r
+?>
\ No newline at end of file
--- /dev/null
+<?php\r
+class wsBook extends cubeMetier {\r
+ protected $book_id;\r
+ protected $nom;\r
+\r
+ protected $lang;\r
+\r
+ protected $theme;\r
+\r
+ protected $proprietaire;\r
+ protected $proprietaire_id;\r
+\r
+ protected $facturable;\r
+ protected $facturable_id;\r
+\r
+ protected $hash;\r
+ protected $compteur_visites;\r
+\r
+ protected $status;\r
+ protected $date_status;\r
+\r
+ protected $date;\r
+\r
+ protected $parametres;\r
+\r
+ protected $pages;\r
+}\r
+\r
+?>
\ No newline at end of file
--- /dev/null
+<?php\r
+class wsDocumentLocalInfos extends wsParametres {\r
+ public function initFields()\r
+ {\r
+ parent::initFields();\r
+ $this->fields['fileName'] = array('type' => 'text', 'default' => '', 'editable' => true, 'label' => __("Nom du fichier"), 'extra' => false, 'grade' => 0);\r
+ $this->fields['fileSize'] = array('type' => 'integer', 'default' => '', 'editable' => true, 'label' => __("Couleur des sous-menus"), 'extra' => false, 'grade' => 0);\r
+ $this->fields['modificationDate'] = array('type' => 'date', 'default' => TIME, 'editable' => true, 'label' => __("Date de dernière modification"), 'extra' => false, 'grade' => 0);\r
+ $this->fields['creationDate'] = array('type' => 'date', 'default' => TIME, 'editable' => true, 'label' => __("Date de dernière modification"), 'extra' => false, 'grade' => 0);\r
+ }\r
+}\r
+\r
+?>
\ No newline at end of file
--- /dev/null
+<?php\r
+/**\r
+ * wsDocument\r
+ *\r
+ * @package\r
+ * @author Vincent\r
+ * @copyright Copyright (c) 2010\r
+ * @version $Id$\r
+ * @access public\r
+ */\r
+class wsDocument extends cubeMetier {\r
+ protected $document_id;\r
+ protected $file;\r
+ protected $proprietaire;\r
+ protected $pages;\r
+ protected $trim;\r
+ protected $date;\r
+ protected $localInfos;\r
+ protected $generalInfos;\r
+ protected $bookmarks;\r
+ protected $numberSections;\r
+ protected $links;\r
+\r
+ protected $out;\r
+ protected $in;\r
+ protected $log;\r
+ protected $log_pointer;\r
+ protected $infos;\r
+ protected $textes;\r
+\r
+ private $_basicInfos = null;\r
+ private $_advancedInfos = null;\r
+ private $_links = array();\r
+\r
+ const NORMAL = 0;\r
+ const FLATTEN = 1;\r
+ const POLY2BITMAP = 2;\r
+ const BITMAP = 3;\r
+ const BARBARE = 4;\r
+\r
+ public function init()\r
+ {\r
+ $this->out = ROOT . '/docs/' . $this->document_id . '/';\r
+ $this->log = $this->out . 'log.txt';\r
+ $this->in = $this->out . 'original.pdf';\r
+ $this->infos = $this->out . 'infos.txt';\r
+ $this->textes = $this->out . 'textes.txt';\r
+ if (!file_exists($this->out)) {\r
+ mkdir($this->out, 0755, true);\r
+ }\r
+ $this->log_pointer = fopen($this->log, 'a');\r
+ }\r
+\r
+ public function copyOriginal($tmp_file)\r
+ {\r
+ move_uploaded_file($tmp_file, $this->in);\r
+ }\r
+\r
+ public function getInfos()\r
+ {\r
+ $pdfinfo = $this->getBasicInfos();\r
+ $pdftk = $this->getAdvancedInfos();\r
+\r
+ $this->parseInfos($pdfinfo . $pdftk);\r
+\r
+ file_put_contents($this->infos, $pdfinfo . $pdftk);\r
+ }\r
+\r
+ public function getBasicInfos()\r
+ {\r
+ if (is_null($this->_basicInfos)) {\r
+ $pdfinfo = new cubeCommandLine('pdfinfo', null, false);\r
+ $pdfinfo->setPath(CONVERTER_PATH);\r
+ $pdfinfo->setArg('-box');\r
+ $pdfinfo->setArg('f', 1);\r
+ $pdfinfo->setArg('l', 10000);\r
+ $pdfinfo->setArg(null, $this->in);\r
+ $pdfinfo->execute();\r
+ $this->addToLog($pdfinfo);\r
+\r
+ $this->_basicInfos = $pdfinfo->output;\r
+ }\r
+ return $this->_basicInfos;\r
+ }\r
+\r
+ public function getAdvancedInfos()\r
+ {\r
+ if (is_null($this->_advancedInfos)) {\r
+ $pdftk = new cubeCommandLine('pdftk', null, true);\r
+ $pdftk->setPath(CONVERTER_PATH);\r
+ $pdftk->setArg(null, $this->in);\r
+ $pdftk->setArg(null, 'dump_data');\r
+ $pdftk->execute();\r
+ $this->addToLog($pdftk);\r
+ $this->_advancedInfos = $pdftk->output;\r
+ }\r
+ return $this->_advancedInfos;\r
+ }\r
+\r
+ public function parseInfos($data)\r
+ {\r
+ // This function get general infos (pages sizes, boxes, number sections and\r
+ // bookmarks\r
+ // Init arrays\r
+ $this->generalInfos = array();\r
+ $this->bookmarks = array();\r
+ $this->numberSections = array();\r
+ // Number section styles\r
+ $numberStyles = array('NoNumber' => 'no', 'DecimalArabicNumerals' => 'decimal',\r
+ 'UppercaseRomanNumerals' => 'roman_up', 'LowercaseRomanNumerals' => 'roman_low',\r
+ 'UppercaseLetters' => 'letters_up', 'LowercaseLetters' => 'letters_low');\r
+\r
+ $res['size'] = array(0, 0);\r
+ $lines = explode("\n", $data);\r
+ foreach($lines as $line) {\r
+ $line = trim(cubeText::condenseWhite($line));\r
+ $e = explode(':', $line, 2);\r
+ $k = trim($e[0]);\r
+ $v = trim($e[1]);\r
+ if ($k == 'Pages' || $k == 'NumberOfPages') {\r
+ $this->generalInfos['pages'] = $v;\r
+ } elseif (preg_match('|Page ([0-9]+) (.*)Box: ([0-9.]*) ([0-9.]*) ([0-9.]*) ([0-9.]*)|iu', $line, $m)) {\r
+ $this->generalInfos['page'][$m[1]][strtolower($m[2])] = array($m[3], $m[4], $m[5], $m[6]);\r
+ } elseif (preg_match('|Page ([0-9]+) size: ([0-9.]*)([\sx]+)([0-9.]*)(.*)|iu', $line, $m)) {\r
+ $this->generalInfos['page'][$m[1]]['size'] = array($m[2], $m[4]);\r
+ $this->generalInfos['size'][0] = max($this->generalInfos['size'][0], $m[2]);\r
+ $this->generalInfos['size'][1] = max($this->generalInfos['size'][1], $m[4]);\r
+ } elseif ($k == 'BookmarkTitle') {\r
+ $this->bookmarks[$bookmark_id] = array('titre' => str_replace(' ', '', trim($v)));\r
+ } elseif ($k == 'BookmarkLevel') {\r
+ $this->bookmarks[$bookmark_id]['level'] = $v;\r
+ } elseif ($k == 'BookmarkPageNumber') {\r
+ $this->bookmarks[$bookmark_id]['page'] = $v;\r
+ $bookmark_id++;\r
+ } elseif ($k == 'PageLabelNewIndex') {\r
+ $section = array('startAt' => $v, 'style' => 'decimal', 'firstNumber' => 1, 'prefix' => '');\r
+ } else if ($k == 'PageLabelStart') {\r
+ $section['firstNumber'] = $v;\r
+ } elseif ($k == 'PageLabelPrefix') {\r
+ $section['prefix'] = $v;\r
+ } else if ($k == 'PageLabelNumStyle') {\r
+ $section['style'] = $numberStyles[$v];\r
+ $this->numberSections[] = $section;\r
+ }\r
+ }\r
+ return $res;\r
+ }\r
+\r
+ public function getPagesNumber()\r
+ {\r
+ $this->parseInfos($this->getBasicInfos());\r
+ return $this->generalInfos['pages'];\r
+ }\r
+\r
+ public function processOnePage($page)\r
+ {\r
+ $this->getTexts($page);\r
+ $this->makeMiniShot($page);\r
+ $this->makeRealShot($page);\r
+ $this->makeSWFFiles($page);\r
+ }\r
+\r
+ public function processAllPages()\r
+ {\r
+ for($i = 1;$i <= $this->generalInfos['pages'];$i++) {\r
+ $this->processOnePage($i);\r
+ }\r
+ }\r
+\r
+ public function processRange($range)\r
+ {\r
+ foreach($pages as $i) {\r
+ $this->processOnePage($i);\r
+ }\r
+ }\r
+\r
+ public function getTexts($page = null)\r
+ {\r
+ $pdftotext = new cubeCommandLine('pdftotext', null, true);\r
+ $pdftotext->setPath(CONVERTER_PATH);\r
+ $pdftotext->setArg('q');\r
+ if (is_null($page)) {\r
+ $pdftotext->setArg('f', 1);\r
+ $pdftotext->setArg('l', 10000);\r
+ } else {\r
+ $pdftotext->setArg('f', $page);\r
+ $pdftotext->setArg('l', $page);\r
+ }\r
+ $pdftotext->setArg('-eol', 'unix');\r
+ $pdftotext->setArg('-enc', 'UTF-8');\r
+ $pdftotext->setArg(null, $this->in);\r
+ $pdftotext->setArg(null, $this->textes);\r
+ $pdftotext->execute();\r
+ $this->addToLog($pdftotext);\r
+ }\r
+\r
+ public function makeMiniShot($page = null)\r
+ {\r
+ $this->makeShotFixedWidth($page, 'p', 100, 70, 4, 'GS');\r
+ }\r
+\r
+ public function makeRealShot($page = null)\r
+ {\r
+ $this->makeShot($page, 'te', 72);\r
+ }\r
+\r
+ public function makeShotFixedWidth($page = null, $prefix = '', $w = 100, $quality = 90, $antialiasing = 4, $method = 'GS')\r
+ {\r
+ // Make thumbs of $w width\r
+ // resolution 72 make 1pt=1px\r
+ $width = $this->generalInfos['size'][0];\r
+ $ratio = $width / $w;\r
+ $this->makeShot($page, $prefix, round(72 / $ratio, 2), $quality, $antialiasing, $method);\r
+ }\r
+\r
+ public function makeShotFixedHeight($page = null, $prefix = '', $h = '', $quality = 90, $antialiasing = 4, $method = 'GS')\r
+ {\r
+ // Make thumbs of $w height\r
+ // resolution 72 make 1pt=1px\r
+ $height = $this->generalInfos['size'][1];\r
+ $ratio = $height / $h;\r
+ $this->makeShot($page, $prefix, round(72 / $ratio, 2), $quality, $antialiasing, $method);\r
+ }\r
+\r
+ public function makeShot($page = null, $prefix = '', $resolution = 72, $quality = 90, $antialiasing = 4, $method = 'GS')\r
+ {\r
+ // Delete all old files\r
+ for($i = 1;$i <= $this->generalInfos['pages'];$i++) {\r
+ if (file_exists($this->out . $prefix . $i . '.jpg')) {\r
+ @unlink($this->out . $prefix . $i . '.jpg');\r
+ }\r
+ }\r
+ if ($method == 'GS') {\r
+ $this->makeShotGS($page, $prefix, $resolution, $quality, $antialiasing);\r
+ } elseif ($method == 'PNM') {\r
+ $this->makeShotPNM($page, $prefix, $resolution, $quality, $antialiasing);\r
+ }\r
+ // Test the result by checking all files\r
+ $error = false;\r
+ $startpage = is_null($page)?1:$page;\r
+ $endpage = is_null($page)?$this->generalInfos['pages']:$page;\r
+\r
+ for($i = $startpage;$i <= $endpage;$i++) {\r
+ if (!file_exists($this->out . $prefix . $i . '.jpg')) {\r
+ $error = true;\r
+ break;\r
+ }\r
+ }\r
+ // If error, we try to make thumbs with other method\r
+ if ($error) {\r
+ if ($method == 'GS') {\r
+ $this->makeShotPNM($page, $prefix, $resolution, $quality, $antialiasing);\r
+ } elseif ($method == 'PNM') {\r
+ $this->makeShotGS($page, $prefix, $resolution, $quality, $antialiasing);\r
+ }\r
+ }\r
+ }\r
+\r
+ protected function makeShotGS($page = null, $prefix = '', $resolution = 72, $quality = 90, $antialiasing = 4)\r
+ {\r
+ // Fabrication des thumbanails avec ghostscript\r
+ $gs = new cubeCommandLine('gs', null, true);\r
+ $gs->setPath(CONVERTER_PATH);\r
+ $gs->setEnv('GS_FONTPATH', FONT_PATH);\r
+ $gs->setArg('-dBATCH');\r
+ $gs->setArg('-dNOPAUSE');\r
+ $gs->setArg('-dNOPROMPT');\r
+ $gs->setArg('-sDEVICE=jpeg');\r
+ $gs->setArg('-dUseCIEColor');\r
+ $gs->setArg('-r' . $resolution);\r
+ $gs->setArg('-dJPEGQ=' . $quality);\r
+ $gs->setArg('-dTextAlphaBits=' . $antialiasing);\r
+ $gs->setArg('-dGraphicsAlphaBits=' . $antialiasing);\r
+ // $gs->setArg('-dUseCropBox');\r
+ if (!is_null($page)) {\r
+ $gs->setArg('-dStartPage=' . $page);\r
+ $gs->setArg('-dEndPage=' . $page);\r
+ }\r
+ $gs->setArg('-sOutputFile=' . $this->out . '/' . $prefix . '%d.jpg');\r
+ $gs->setArg('-dAutoRotatePages=/None');\r
+ $gs->setArg(null, $this->in);\r
+ $gs->execute();\r
+ $this->addToLog($gs);\r
+ }\r
+\r
+ protected function makeShotPNM($page = null, $prefix = '', $resolution = 72, $quality = 90, $antialiasing = 4)\r
+ {\r
+ $antialiasing = $antialiasing?'yes':'no';\r
+ $resolution = round($resolution);\r
+ // Exporte les fichiers\r
+ $pdftoppm = new cubeCommandLine('pdftoppm', null, true);\r
+ $pdftoppm->setPath(CONVERTER_PATH);\r
+ if (is_null($page)) {\r
+ $pdftoppm->setArg('f', 1);\r
+ $pdftoppm->setArg('l', 10000);\r
+ } else {\r
+ $pdftoppm->setArg('f', $page);\r
+ $pdftoppm->setArg('l', $page);\r
+ }\r
+\r
+ $pdftoppm->setArg('-freetype yes');\r
+ $pdftoppm->setArg('-aa ' . $antialiasing);\r
+ $pdftoppm->setArg('-aaVector ' . $antialiasing);\r
+ if (!WINDOWS) {\r
+ $pdftoppm->setArg('-t1lib yes');\r
+ }\r
+ $pdftoppm->setArg('r', $resolution);\r
+ $pdftoppm->setArg(null, $this->in);\r
+ $pdftoppm->setArg(null, $this->out . 'ppm');\r
+ $pdftoppm->execute();\r
+ $this->addToLog($pdftoppm);\r
+\r
+ $startpage = is_null($page)?1:$page;\r
+\r
+ for($i = $startpage;true;$i++) {\r
+ $ppmfile = $this->out . 'ppm-' . cubeMath::fill($i, 6) . '.ppm';\r
+ $jpegfile = $this->out . $prefix . $i . '.jpg';\r
+ if (!file_exists($ppmfile)) {\r
+ break;\r
+ }\r
+ $pnmtojpeg = new cubeCommandLine('pnmtojpeg', $jpegfile, false);\r
+ $pnmtojpeg->setPath(CONVERTER_PATH);\r
+ $pnmtojpeg->setArg('-quality=' . $quality);\r
+ $pnmtojpeg->setArg('-density=' . $resolution . 'x' . $resolution . 'dpi');\r
+ $pnmtojpeg->setManualArg($ppmfile);\r
+ $pnmtojpeg->execute();\r
+\r
+ $this->addToLog($pnmtojpeg, false);\r
+ unlink($ppmfile);\r
+ }\r
+ }\r
+\r
+ public function makeSWFFiles($page = null, $resolution = 150, $quality = 90, $storeAllChars = true, $maxObjects = 1800, $method = 0, &$muliply = 1)\r
+ {\r
+ if ($maxObjects <= 1) {\r
+ $method = self::POLY2BITMAP;\r
+ }\r
+\r
+ $out = $this->pdf2swf($page, $resolution, $quality, $storeAllChars, $method, $multiply);\r
+ if ($method < self::BARBARE) {\r
+ // Analyse de la sortie pour détecter des typos manquantes\r
+ $overflow = false;\r
+ $overflowObjects = false;\r
+ $written = false;\r
+ $missing_fonts = array();\r
+ if (file_exists($out['outputfile'])) {\r
+ $fp = fopen($out['outputfile'], 'rb');\r
+ while ($line = fgets($fp)) {\r
+ if (preg_match('|Try putting a TTF version of that font \(named \"([A-Z-_0-9.]*)\"\)|Uui', trim($line), $matches)) {\r
+ $missing_fonts[] = $matches[1];\r
+ } elseif (stristr($line, 'ID Table overflow')) {\r
+ $overflow = true;\r
+ } elseif (stristr($line, 'NOTICE SWF written')) {\r
+ $written = true;\r
+ } elseif (stristr($line, 'NOTICE Writing SWF file')) {\r
+ $written = true;\r
+ }\r
+ }\r
+ }\r
+ if (!is_null($page) && file_exists($this->out . 'p' . $page . '.swf')) {\r
+ $written = true;\r
+ }\r
+ if ($written && $method < self::BITMAP && !isset($this->_links[$page])) {\r
+ file_put_contents(ROOT . '/test.txt', print_r($out, true));\r
+ $this->_links[$page] = $this->extractLinks($page, $out['outputfile'], $out['multiply']);\r
+ }\r
+ // On teste si le fichier est écrit et qu'il a été généré par le premier niveau\r
+ if ($method < self::POLY2BITMAP && $written) {\r
+ $overflowObjects = $this->checkObjectsNumber($this->out . 'p' . $page . '.swf', $maxObjects);\r
+ }\r
+\r
+ if (!$written || $overflow || $overflowObjects) {\r
+ return $this->makeSWFFiles($page, $resolution, $quality, $storeAllChars, $maxObjects, $method + 1, $multiply);\r
+ }\r
+ }\r
+\r
+ return $out;\r
+ }\r
+\r
+ protected function checkObjectsNumber($file, $maxObjects)\r
+ {\r
+ $swfdump = new cubeCommandLine('swfdump', null, true);\r
+ $swfdump->setPath(CONVERTER_PATH);\r
+ $swfdump->setArg('t');\r
+ $swfdump->setArg(null, $file);\r
+ $swfdump->execute();\r
+ $this->addToLog($swfdump);\r
+\r
+ str_replace('[01a]', '', $swfdump->output, $nbObjects);\r
+ if ($nbObjects > $maxObjects) {\r
+ return true;\r
+ }\r
+ return false;\r
+ }\r
+\r
+ protected function pdf2swf($page = null, $resolution = 150, $quality = 90, $storeAllChars = true, $method = 0)\r
+ {\r
+ /*\r
+-h , --help Print short help message and exit\r
+-V , --version Print version info and exit\r
+-o , --output file.swf Direct output to file.swf. If file.swf contains '%' (file%.swf), then each page goes to a seperate file.\r
+-p , --pages range Convert only pages in range with range e.g. 1-20 or 1,4,6,9-11 or\r
+-P , --password password Use password for deciphering the pdf.\r
+-v , --verbose Be verbose. Use more than one -v for greater effect.\r
+-z , --zlib Use Flash 6 (MX) zlib compression.\r
+-i , --ignore Allows pdf2swf to change the draw order of the pdf. This may make the generated\r
+-j , --jpegquality quality Set quality of embedded jpeg pictures to quality. 0 is worst (small), 100 is best (big). (default:85)\r
+-s , --set param=value Set a SWF encoder specific parameter. See pdf2swf -s help for more information.\r
+-w , --samewindow When converting pdf hyperlinks, don't make the links open a new window.\r
+-t , --stop Insert a stop() command in each page.\r
+-T , --flashversion num Set Flash Version in the SWF header to num.\r
+-F , --fontdir directory Add directory to the font search path.\r
+-b , --defaultviewer Link a standard viewer to the swf file.\r
+-l , --defaultloader Link a standard preloader to the swf file which will be displayed while the main swf is loading.\r
+-B , --viewer filename Link viewer filename to the swf file.\r
+-L , --preloader filename Link preloader filename to the swf file.\r
+-q , --quiet Suppress normal messages. Use -qq to suppress warnings, also.\r
+-S , --shapes Don't use SWF Fonts, but store everything as shape.\r
+-f , --fonts Store full fonts in SWF. (Don't reduce to used characters).\r
+-G , --flatten Remove as many clip layers from file as possible.\r
+-I , --info Don't do actual conversion, just display a list of all pages in the PDF.\r
+-Q , --maxtime n Abort conversion after n seconds. Only availableon Unix.\r
+\r
+PDF device global parameters:\r
+-----------------------------\r
+fontdir=<dir> a directory with additional fonts\r
+font=<filename> an additional font filename\r
+pages=<range> the range of pages to convert (example: pages=1-100,210-)\r
+zoom=<dpi> the resultion (default: 72)\r
+languagedir=<dir> Add an xpdf language directory\r
+multiply=<times> Render everything at <times> the resolution\r
+poly2bitmap Convert graphics to bitmaps\r
+bitmap Convert everything to bitmaps\r
+\r
+SWF Parameters :\r
+----------------\r
+SWF layer options :\r
+-------------------\r
+\r
+jpegsubpixels=<pixels> resolution adjustment for jpeg images (same as jpegdpi, but in pixels)\r
+ppmsubpixels=<pixels resolution adjustment for lossless images (same asppmdpi, but in pixels)\r
+subpixels=<pixels> shortcut for setting both jpegsubpixels and ppmsubpixels\r
+drawonlyshapes convert everything to shapes (currently broken)\r
+ignoredraworder allow to perform a few optimizations for creating smaller SWFs\r
+linksopennewwindow make links open a new browser window\r
+linktarget target window name of new links\r
+linkcolor=<color) color of links (format: RRGGBBAA)\r
+linknameurl Link buttons will be named like the URL they refer to (handy for iterating through links with actionscript)\r
+storeallcharacters don't reduce the fonts to used characters in the output file\r
+enablezlib switch on zlib compression (also done if flashversion>=7)\r
+bboxvars store the bounding box of the SWF file in actionscript variables\r
+dots Take care to handle dots correctly\r
+reordertags=0/1 (default: 1) perform some tag optimizations\r
+internallinkfunction=<name> when the user clicks a internal link (to a different page) in the converted file, this actionscript function is called\r
+externallinkfunction=<name> when the user clicks an external link (e.g. http://www.foo.bar/) on the converted file, this actionscript function is called\r
+disable_polygon_conversion never convert strokes to polygons (will remove capstyles and joint styles)\r
+caplinewidth=<width> the minimum thichness a line needs to have so that capstyles become visible (and are converted)\r
+insertstop put an ActionScript "STOP" tag in every frame\r
+protect add a "protect" tag to the file, to prevent loading in the Flash editor\r
+flashversion=<version> the SWF fileversion (6)\r
+framerate=<fps> SWF framerate\r
+minlinewidth=<width> convert horizontal/vertical boxes smaller than this width to lines (0.05)\r
+simpleviewer Add next/previous buttons to the SWF\r
+animate insert a showframe tag after each placeobject (animate draw order of PDF files)\r
+jpegquality=<quality> set compression quality of jpeg images\r
+splinequality=<value> Set the quality of spline convertion to value (0-100, default: 100).\r
+disablelinks Disable links.\r
+ */\r
+\r
+ if (!is_null($page) && file_exists($this->out . 'p' . $page . '.swf')) {\r
+ unlink($this->out . 'p' . $page . '.swf');\r
+ }\r
+\r
+ if ($method < self::BARBARE) {\r
+ $resolution2multiply = array(72 => 2, 100 => 2, 150 => 3, 200 => 3, 300 => 3, 450 => 4, 600 => 5);\r
+\r
+ $pdf2swf = new cubeCommandLine('pdf2swf', null, true);\r
+ $pdf2swf->setPath(CONVERTER_PATH);\r
+ if (!is_null($page)) {\r
+ $pdf2swf->setArg('p', $page);\r
+ }\r
+ if ($method == self::NORMAL) {\r
+ // Default\r
+ $multiply = 1;\r
+ } elseif ($method == self::FLATTEN) {\r
+ $pdf2swf->setArg('flatten');\r
+ $multiply = 1;\r
+ } elseif ($method == self::POLY2BITMAP) {\r
+ // Raster graphics, keep texts\r
+ $pdf2swf->setArg('poly2bitmap');\r
+ $multiply = $resolution2multiply[$resolution];\r
+ $pdf2swf->setArg('multiply', $multiply);\r
+ } elseif ($method == self::BITMAP) {\r
+ // Raster all\r
+ $pdf2swf->setArg('bitmap');\r
+ $multiply = $resolution2multiply[$resolution];\r
+ $pdf2swf->setArg('multiply', $multiply);\r
+ }\r
+\r
+ $pdf2swf->setArg('stop');\r
+ $pdf2swf->setManualArg('-vvvv');\r
+ $pdf2swf->setArg('T', 8);\r
+ if ($storeAllChars) {\r
+ $pdf2swf->setArg('fonts');\r
+ }\r
+ if (DEV) {\r
+ $pdf2swf->setArg('F', 'C:/Windows/Fonts');\r
+ } else {\r
+ $pdf2swf->setArg('F', '/home/typo/fonts');\r
+ }\r
+ $pdf2swf->setArg('set subpixels', $resolution / 72);\r
+ $pdf2swf->setArg('set jpegquality', $quality);\r
+ $pdf2swf->setArg('set disablelinks');\r
+ $pdf2swf->setArg('set dots');\r
+\r
+ $pdf2swf->setArg(null, $this->in);\r
+ $pdf2swf->setArg('output', $this->out . 'p%.swf');\r
+ $pdf2swf->execute();\r
+\r
+ $this->addToLog($pdf2swf, true);\r
+ return array('outputfile' => $pdf2swf->outputfile, 'multiply' => $multiply, 'object' => $pdf2swf);\r
+ } else {\r
+ return array('outputfile' => $this->pdf2swfBarbare($page, $resolution, $quality), 'multiply' => 1);\r
+ }\r
+ }\r
+\r
+ protected function makeAS3($swffile)\r
+ {\r
+ $swfcombine = new cubeCommandLine('swfcombine');\r
+ $swfcombine->setPath(CONVERTER_PATH);\r
+ $swfcombine->setArg('merge');\r
+ $swfcombine->setArg('stack1');\r
+ $swfcombine->setArg('z');\r
+ $swfcombine->setManualArg('-vvvv');\r
+ $swfcombine->setArg('o', $swffile);\r
+ $swfcombine->setArg(null, ROOT . '/swf/as3Container.swf');\r
+ $swfcombine->setManualArg('content=' . $swffile);\r
+ $swfcombine->execute();\r
+ $this->addToLog($swfcombine);\r
+ }\r
+\r
+ protected function pdf2swfBarbare($page = null, $resolution = 150, $quality = 85)\r
+ {\r
+ // Fabrique les images\r
+ $this->makeShot($page, 'barbare', $resolution, $quality, 4, 'PNM');\r
+ // A partir des images, on crée les swf\r
+ if (is_null($page)) {\r
+ $startpage = 1;\r
+ $endpage = $this->generalInfos['pages'];\r
+ } else {\r
+ $startpage = $endpage = $page;\r
+ }\r
+\r
+ for($i = $startpage;$i <= $endpage;$i++) {\r
+ $jpeg2swf = new cubeCommandLine('jpeg2swf');\r
+ $jpeg2swf->setPath(CONVERTER_PATH);\r
+ $jpeg2swf->setArg('q', $quality);\r
+ $jpeg2swf->setArg('o', $this->out . 'p' . $i . '.swf');\r
+ $jpeg2swf->setArg('f');\r
+ $jpeg2swf->setArg(null, $this->out . 'barbare' . $i . '.jpg');\r
+ $jpeg2swf->execute();\r
+ $this->addToLog($jpeg2swf);\r
+ // Suppression du jpeg\r
+ @unlink($this->out . '/barbare' . $i . '.jpg') ;\r
+ }\r
+ return '';\r
+ }\r
+\r
+ public function addToLog($cl, $output = true)\r
+ {\r
+ if ($cl instanceof cubeCommandLine) {\r
+ $c = '--- Exécuté en ' . $cl->execTime . " s\n" . $cl->commande . "\n\n";\r
+ if ($output) {\r
+ $c .= $cl->output . "\n\n";\r
+ }\r
+ } elseif (is_string($cl)) {\r
+ $c = $cl;\r
+ }\r
+ fwrite($this->log_pointer, $c);\r
+ }\r
+\r
+ public function extractLinks($page, $outputfile, $multiply = 1)\r
+ {\r
+ /*\r
+DEBUG drawlink\r
+TRACE drawlink 122.00/579.00 236.00/579.00 236.00/527.00 122.00/527.00\r
+DEBUG | moveTo 122.00 579.00\r
+DEBUG | lineTo 236.00 579.00\r
+DEBUG | lineTo 236.00 527.00\r
+DEBUG | lineTo 122.00 527.00\r
+DEBUG | lineTo 122.00 579.00\r
+TRACE drawlink action=3\r
+TRACE drawlink s=http://www.ladocumentationfrancaise.fr/\r
+*/\r
+\r
+ $fp = fopen($outputfile, 'rb');\r
+ $log = 'BEGIN extracting link' . "\n";\r
+ $link = null;\r
+ while ($line = fgets($fp)) {\r
+ $line = trim($line);\r
+ if (preg_match('|TRACE drawlink(( [-0-9\./]+)+)|', $line, $matches)) {\r
+ $log .= 'FOUND a link' . "\n";\r
+ $link = new wsLink($multiply);\r
+ $log .= 'SETTING POINTS ' . $matches[1] . "\n";\r
+ $points = explode(' ', trim($matches[1]));\r
+ foreach($points as $point) {\r
+ $p = explode('/', $point);\r
+ $log .= 'SET POINT ' . $p[0] . ' ' . $p[1] . "\n";\r
+ $link->addPoint($p);\r
+ }\r
+ } elseif (preg_match('|TRACE drawlink action=(.*)|', $line, $matches)) {\r
+ $log .= 'SETTING ACTION ' . $matches[1] . "\n";\r
+ if (is_null($link)) {\r
+ continue;\r
+ }\r
+ $link->setAction($matches[1]);\r
+ } elseif (preg_match('|TRACE drawlink s=(.*)|', $line, $matches)) {\r
+ $log .= 'SETTING LINK ' . $matches[1] . "\n";\r
+ if (is_null($link)) {\r
+ continue;\r
+ }\r
+ $link->setLink($matches[1]);\r
+ $this->links[$page][] = $link->toArray();\r
+ $log .= 'SAVE LINK' . print_r($link->toArray(), true) . "\n";\r
+ $link = null;\r
+ }\r
+ }\r
+ $log .= 'END OF EXTRACTING' . "\n";\r
+ $this->addToLog($log);\r
+ fclose($fp);\r
+\r
+ return $log;\r
+ }\r
+\r
+ public function __destruct()\r
+ {\r
+ if (isset($this->log_pointer) && is_resource($this->log_pointer)) {\r
+ fclose($this->log_pointer);\r
+ }\r
+ }\r
+}\r
+\r
+?>
\ No newline at end of file
--- /dev/null
+<?php\r
+class wsLangueTextes extends cubeMetier {\r
+ protected $textes;\r
+\r
+ public function __toXML($xml = null)\r
+ {\r
+ if (is_null($xml)) {\r
+ $xml = simplexml_load_string('<?xml version="1.0" encoding="UTF-8" ?><movie />');\r
+ } elseif (is_string($xml)) {\r
+ $xml = simplexml_load_string($xml);\r
+ }\r
+ foreach($this->textes as $t) {\r
+ $xml->addChild('tradText', $t);\r
+ }\r
+ return $xml;\r
+ }\r
+}\r
+\r
+?>
\ No newline at end of file
--- /dev/null
+<?php\r
+class wsLink {\r
+ private $origine;\r
+ private $points;\r
+ private $action;\r
+ private $link;\r
+ private $multiply;\r
+\r
+ public function __construct($multiply = 1)\r
+ {\r
+ $this->origine = array();\r
+ $this->points = array();\r
+ $this->action = null;\r
+ $this->link = null;\r
+ $this->multiply = $multiply;\r
+ }\r
+\r
+ public function addPoint($point = array())\r
+ {\r
+ $point[0] = (float)$point[0] / $this->multiply;\r
+ $point[1] = (float)$point[1] / $this->multiply;\r
+ if ($this->origine == null) {\r
+ $this->origine = $point;\r
+ } else {\r
+ $this->points[] = $point;\r
+ }\r
+ }\r
+\r
+ public function setAction($action)\r
+ {\r
+ $this->action = $action;\r
+ }\r
+\r
+ public function setLink($link)\r
+ {\r
+ $this->link = $link;\r
+ }\r
+\r
+ public function toArray()\r
+ {\r
+ if (is_null($this->link)) {\r
+ return false;\r
+ }\r
+\r
+ $res = array();\r
+ $res['left'] = $this->origine[0];\r
+ $res['top'] = $this->origine[1];\r
+\r
+ $res['width'] = $this->points[1][0] - $this->origine[0];\r
+ $res['height'] = $this->points[1][1] - $this->origine[1];\r
+\r
+ if ($this->action == 0) {\r
+ $res['href'] = 'temp.html#' . $this->link;\r
+ } elseif ($this->action == 3) {\r
+ $res['href'] = $this->link;\r
+ }\r
+\r
+ return $res;\r
+ }\r
+}\r
+\r
+?>
\ No newline at end of file
--- /dev/null
+<?php\r
+class wsParametres extends cubeMetier {\r
+ protected $datas;\r
+ protected $fields;\r
+\r
+ public function __construct()\r
+ {\r
+ $this->initFields();\r
+ $this->datas = array();\r
+ }\r
+\r
+ public function __set($varname, $value)\r
+ {\r
+ $this->set($varname, $value);\r
+ }\r
+\r
+ public function __unset($varname)\r
+ {\r
+ $this->set($varname, null);\r
+ }\r
+\r
+ public function __get($varname)\r
+ {\r
+ return $this->get($varname);\r
+ }\r
+\r
+ public function __isset($varname)\r
+ {\r
+ return $this->_isset($varname);\r
+ }\r
+\r
+ public function __sleep()\r
+ {\r
+ return array('datas');\r
+ }\r
+\r
+ public function __wakeup()\r
+ {\r
+ $this->initFields();\r
+ }\r
+\r
+ protected function initFields()\r
+ {\r
+ $this->fields = array();\r
+ }\r
+\r
+ protected function set($varname, $value)\r
+ {\r
+ if (!$this->_isset($varname)) {\r
+ throw new Exception('You are setting an attribute (' . get_class($this) . '::' . $varname . ') which not exists');\r
+ }\r
+\r
+ if (is_null($value)) {\r
+ $this->datas[$varname] = null;\r
+ return;\r
+ }\r
+\r
+ switch ($this->fields[$varname]['type']) {\r
+ case 'integer':\r
+ $value = intval($value);\r
+ break;\r
+ case 'float':\r
+ $value = floatval($value);\r
+ break;\r
+ case 'boolean':\r
+ $value = ($value == '' || $value == '0' || $value == 'false')?false:true;\r
+ break;\r
+ case 'color':\r
+ $value = substr(trim($value, '#'), 0, 6);\r
+ break;\r
+ case 'date':\r
+ $value = intval($value);\r
+ break;\r
+ default:\r
+ $value = (string)$value;\r
+ break;\r
+ } // switch\r
+ $this->datas[$varname] = $value;\r
+ }\r
+\r
+ protected function _isset($varname)\r
+ {\r
+ return isset($this->fields[$varname]) && isset($this->fields[$varname]['default']);\r
+ }\r
+\r
+ protected function get($varname)\r
+ {\r
+ if (!$this->_isset($varname)) {\r
+ throw new Exception('You are getting an attribute (' . get_class($this) . '::' . $varname . ') which not exists');\r
+ }\r
+ if (is_null($this->datas[$varname]) || !isset($this->datas[$varname])) {\r
+ return $this->fields[$varname]['default'];\r
+ }\r
+ return $this->datas[$varname];\r
+ }\r
+\r
+ public function fromRecord($r)\r
+ {\r
+ $c = array_flip($r->columns());\r
+ foreach($this->fields as $n => $f) {\r
+ if (isset($c[$n]) && !is_null($r->$n)) {\r
+ $this->set($n, $r->$n);\r
+ }\r
+ }\r
+ }\r
+\r
+ public function fromXML($xml)\r
+ {\r
+ foreach($this->fields as $n => $f) {\r
+ $xp = $xml->$n;\r
+ if (!$xp || !count($xp)) {\r
+ continue;\r
+ }\r
+ foreach($xp as $x) {\r
+ $this->set($n, $x);\r
+ }\r
+ }\r
+ }\r
+}\r
+\r
+?>
\ No newline at end of file
--- /dev/null
+<?php\r
+class wsThemeParametres extends wsParametres {\r
+ public function __construct()\r
+ {\r
+ parent::__construct();\r
+ }\r
+\r
+ public function initFields()\r
+ {\r
+ parent::initFields();\r
+ $this->fields['couleurA'] = array('type' => 'couleur', 'default' => '', 'editable' => true, 'label' => __("Couleur principale (boutons, liens)"), 'extra' => false, 'grade' => 3);\r
+ $this->fields['couleurB'] = array('type' => 'couleur', 'default' => '', 'editable' => true, 'label' => __("Couleur des sous-menus"), 'extra' => false, 'grade' => 3);\r
+ $this->fields['couleurS'] = array('type' => 'couleur', 'default' => '', 'editable' => true, 'label' => __("Couleur du texte du moteur de recherche"), 'extra' => false, 'grade' => 3);\r
+ $this->fields['couleurL'] = array('type' => 'couleur', 'default' => '', 'editable' => true, 'label' => __("Couleur du fond du loader"), 'extra' => false, 'grade' => 3);\r
+ $this->fields['repeat'] = array('type' => 'combo',\r
+ 'datas' => array(__('Etirer') => '0', __('Etirer le fond') => '2', __("Répéter") => '1'),\r
+ 'default' => '0', 'editable' => true, 'label' => __('Affichage du fond'), 'grade' => 3);\r
+ }\r
+}\r
+\r
+?>
\ No newline at end of file