From 84dbe1d2e7ec145bb0581964f445953b3294d6cf Mon Sep 17 00:00:00 2001 From: "vincent@cubedesigners.com" Date: Tue, 29 Sep 2009 17:34:40 +0000 Subject: [PATCH] --- inc/config.inc.php | 3 + inc/extranet/Controlleur/class.ws.flash.php | 23 ++++++- inc/extranet/Controlleur/class.ws.url.php | 8 +-- inc/extranet/DAO/_common.php | 1 + inc/extranet/DAO/class.ws.dao.document.php | 72 +++++++++++++++++++++ inc/extranet/Metier/_common.php | 2 + inc/extranet/Metier/class.ws.document.php | 40 ++++++++++++ inc/prepend.php | 6 ++ 8 files changed, 150 insertions(+), 5 deletions(-) create mode 100644 inc/extranet/DAO/class.ws.dao.document.php create mode 100644 inc/extranet/Metier/class.ws.document.php diff --git a/inc/config.inc.php b/inc/config.inc.php index db9b73bb2..45ec90aa2 100644 --- a/inc/config.inc.php +++ b/inc/config.inc.php @@ -11,6 +11,7 @@ if (in_array($_SERVER['HTTP_HOST'], array_merge($localrel, $localabs))) { define('DB_NAME', 'extranet'); define('DB_USER', 'root'); define('DB_PASSWORD', 'valparaiso'); + define('DEV',true); if (in_array($_SERVER['HTTP_HOST'], $localrel)) { define('WEBROOT', '/cubeExtranet'); @@ -20,6 +21,7 @@ if (in_array($_SERVER['HTTP_HOST'], array_merge($localrel, $localabs))) { define('SITE_PATH', WEBROOT . '/'); } + $tools = ROOT . '/../inc/tools/'; } else { // Définition des variables dans l'environnement de production define('DB_HOST', 'localhost'); @@ -31,6 +33,7 @@ if (in_array($_SERVER['HTTP_HOST'], array_merge($localrel, $localabs))) { define('SITE_PATH', WEBROOT . '/'); define('FTPROOT', '/usb/ftpextranet/'); + define('DEV',false); } if (in_array($_SERVER['HTTP_HOST'], $ws)) { diff --git a/inc/extranet/Controlleur/class.ws.flash.php b/inc/extranet/Controlleur/class.ws.flash.php index 6553873b1..0759422ae 100644 --- a/inc/extranet/Controlleur/class.ws.flash.php +++ b/inc/extranet/Controlleur/class.ws.flash.php @@ -11,7 +11,28 @@ class wsFlash extends cubeFlashGateway { public function uploadDocument() { - + global $core; + $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']); + $document->getInfos(); + } + $this->xml->addChild('document_id', $document->document_id); } public function testDocuments() diff --git a/inc/extranet/Controlleur/class.ws.url.php b/inc/extranet/Controlleur/class.ws.url.php index 2b135635e..74bbc2e92 100644 --- a/inc/extranet/Controlleur/class.ws.url.php +++ b/inc/extranet/Controlleur/class.ws.url.php @@ -61,7 +61,7 @@ class wsUrl { $res .= '' . cubeMedia::cssRollover($core->typo->Editer('éditer', '', false)) . ''; $res .= '' . cubeMedia::cssRollover($core->typo->Stats('stats', '', false)) . ''; $res .= '' . cubeMedia::cssRollover($core->typo->Telecharger('télécharger', '', false)) . ''; - $res .= '' . cubeMedia::cssRollover($core->typo->Supprimer('suppr.', '', false)) . ''; + $res .= '' . cubeMedia::cssRollover($core->typo->Supprimer('suppr.', '', false)) . ''; $res .= ''; $i++; } @@ -146,7 +146,7 @@ class wsUrl { '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'); + $res = cubeMedia::flash(WEBROOT . '/swf/composer.swf', '960', '100%', $fv, 'composerSwf', 'swfPanel', 9, '#ffffff', '', 'false', 'noscale', 'transparent'); return $res; } @@ -154,7 +154,7 @@ class wsUrl { { $fv = array(session_name() => session_id(), 'book_id' => $args[1]); - $res = cubeMedia::flash(WEBROOT . '/swf/theme.swf', '960', '100%', $fv, 'composerSwf', 'swfPanel', 9, '#ffffff'); + $res = cubeMedia::flash(WEBROOT . '/swf/theme.swf', '960', '100%', $fv, 'composerSwf', 'swfPanel', 9, '#ffffff', '', 'false', 'noscale', 'transparent'); return $res; } @@ -166,7 +166,7 @@ class wsUrl { { $fv = array(session_name() => session_id(), 'book_id' => $args[1]); - $res = cubeMedia::flash(WEBROOT . '/swf/links.swf', '960', '100%', $fv, 'composerSwf', 'swfPanel', 9, '#ffffff'); + $res = cubeMedia::flash(WEBROOT . '/swf/links.swf', '960', '100%', $fv, 'composerSwf', 'swfPanel', 9, '#ffffff', '', 'false', 'noscale', 'transparent'); return $res; } diff --git a/inc/extranet/DAO/_common.php b/inc/extranet/DAO/_common.php index b2f933f4c..96f1a5e62 100644 --- a/inc/extranet/DAO/_common.php +++ b/inc/extranet/DAO/_common.php @@ -12,5 +12,6 @@ $__autoload['extranetDAOEntreprise'] = dirname(__FILE__) . '/class.extranet.dao. $__autoload['extranetDAOFichier'] = dirname(__FILE__) . '/class.extranet.dao.fichier.php'; $__autoload['wsDAOBook'] = dirname(__FILE__) . '/class.ws.dao.book.php'; +$__autoload['wsDAODocument'] = dirname(__FILE__) . '/class.ws.dao.document.php'; ?> \ 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 new file mode 100644 index 000000000..22f47793a --- /dev/null +++ b/inc/extranet/DAO/class.ws.dao.document.php @@ -0,0 +1,72 @@ +document_id = $r->document_id; + $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 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/_common.php b/inc/extranet/Metier/_common.php index 3f92f22f0..0501d9c39 100644 --- a/inc/extranet/Metier/_common.php +++ b/inc/extranet/Metier/_common.php @@ -18,5 +18,7 @@ $__autoload['wsParametres'] = dirname(__FILE__) . '/class.ws.parametres.php'; $__autoload['wsThemeParametres'] = dirname(__FILE__) . '/class.ws.theme.parametres.php'; $__autoload['wsBookParametres'] = dirname(__FILE__) . '/class.ws.book.parametres.php'; $__autoload['wsLangueTextes'] = dirname(__FILE__) . '/class.ws.langue.textes.php'; +$__autoload['wsDocument'] = dirname(__FILE__) . '/class.ws.document.php'; +$__autoload['wsDocumentLocalInfos'] = dirname(__FILE__) . '/class.ws.document.localinfos.php'; ?> \ No newline at end of file diff --git a/inc/extranet/Metier/class.ws.document.php b/inc/extranet/Metier/class.ws.document.php new file mode 100644 index 000000000..3681dc004 --- /dev/null +++ b/inc/extranet/Metier/class.ws.document.php @@ -0,0 +1,40 @@ +out = ROOT . '/docs/' . $this->document_id . '/'; + $this->log = $this->out . 'log.txt'; + $this->in = $this->out . 'original.pdf'; + if (!file_exists($this->out)) { + mkdir($this->out, 0755, true); + } + move_uploaded_file($tmp_file, $this->in); + } + + public function getInfos() + { + echo 'pdfinfo'; + $pdfinfo = new cubeCommandLine('pdfinfo', $this->log); + $pdfinfo->setArg('-box'); + $pdfinfo->setArg('f', 1); + $pdfinfo->setArg('l', 10000); + $pdfinfo->setArg(null, $this->in); + $pdfinfo->execute(); + } +} + +?> \ No newline at end of file diff --git a/inc/prepend.php b/inc/prepend.php index 4f7b29fcd..560eb7d67 100644 --- a/inc/prepend.php +++ b/inc/prepend.php @@ -22,4 +22,10 @@ if (isset($_POST['q'])) { $_SESSION['q'] = null; } +if (DEV) { + cubePHP::appendEnv('PATH', $tools); + cubePHP::appendEnv('PATH', $tools . 'gs8.70/bin/'); + cubePHP::appendEnv('PATH', $tools . 'gs8.70/lin/'); +} + ?> \ No newline at end of file -- 2.39.5