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