]> _ Git - cubeextranet.git/commitdiff
(no commit message)
authorvincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Mon, 22 Feb 2010 12:23:16 +0000 (12:23 +0000)
committervincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Mon, 22 Feb 2010 12:23:16 +0000 (12:23 +0000)
inc/extranet/Controlleur/class.ws.conversion.session.php
inc/extranet/Controlleur/class.ws.flash.php
inc/extranet/DAO/class.ws.dao.document.php
inc/extranet/Metier/class.ws.document.php
swf/_src/as3Container.fla [new file with mode: 0644]

index e906025743790e0b63b3bbf144c399ab3b81d974..89a990b18a0dd6dc22ed6b00238b8285c252d6c0 100644 (file)
@@ -1,9 +1,13 @@
 <?php\r
 \r
 class wsConversionSession {\r
+       protected $documentsId = array();\r
        protected $documents = array();\r
        protected $guid;\r
        protected $progress = 0;\r
+       protected $processing = false;\r
+       protected $complete = false;\r
+       protected $totalPages = null;\r
 \r
        public function __construct($guid)\r
        {\r
@@ -12,17 +16,31 @@ class wsConversionSession {
 \r
        public function setDocuments($documents)\r
        {\r
-               $this->documents = $documents;\r
+               $this->documentsId = $documents;\r
        }\r
 \r
-       public function process()\r
+       public function initDocuments()\r
        {\r
-               for($i = 1;$i <= 100;$i++) {\r
-                       cubePHP::sleep(0.1);\r
-                       $i++;\r
+               global $core;\r
+\r
+               $dao = new wsDAODocument($core->con);\r
+               $this->documents = $dao->selectInList($this->documentsId);\r
+               $this->totalPages = 0;\r
+\r
+               foreach($this->documents as $doc) {\r
+                       $this->totalPages += $doc->getPagesNumber;\r
                }\r
        }\r
 \r
+       public function process()\r
+       {\r
+               $this->processing = true;\r
+               $this->initDocuments();\r
+\r
+               $this->complete = true;\r
+               $this->processing = false;\r
+       }\r
+\r
        public function getProgress()\r
        {\r
                return $this->progress;\r
@@ -56,7 +74,7 @@ class wsConversionSession {
 \r
        public static function getCachePath($guid)\r
        {\r
-               return CACHE . '/conversionSessions/' . $guid;\r
+               return CACHE . '/conversionSessions/' . $guid . '.obj';\r
        }\r
 }\r
 \r
index 7d1268077be62339f9eeedcce61a9cb850996530..05f60190d0bacba571f32a7aa30b0a50fec7f266 100644 (file)
@@ -71,11 +71,15 @@ class wsFlash extends cubeFlashGateway {
                $_SESSION['sessionConversionGUID'] = $sessionConversionGUID = uniqid('conversion_', true);\r
                $session = new wsConversionSession($sessionConversionGUID);\r
                $session->setDocuments($_SESSION['conversionSession']);\r
-               $conversion->serialize();\r
+               $session->serialize();\r
 \r
                $http = new cubeHTTP($_SERVER['HTTP_HOST']);\r
-               $http->setDataTimeout(3);\r
-               $http->post('/flash/processConversionSessionAsync', array('user_email' => $_SESSION['user_email'], 'user_password' => $_SESSION['user_password'], 'sessionConversionGUID' => $sessionConversionGUID));\r
+               $http->setDataTimeout(1);\r
+               try {\r
+                       $http->post('/flash/processConversionSessionAsync', array('user_email' => $_SESSION['user_email'], 'user_password' => $_SESSION['user_password'], 'sessionConversionGUID' => $sessionConversionGUID));\r
+               }\r
+               catch(Exception $e) {\r
+               }\r
        }\r
 \r
        public function processConversionSessionAsync()\r
@@ -87,6 +91,7 @@ class wsFlash extends cubeFlashGateway {
 \r
        public function getConversionSessionProgress()\r
        {\r
+               set_time_limit(1);\r
                $session = wsConversionSession::openFromGUID($_SESSION['sessionConversionGUID']);\r
                $this->xml->addChild('progress', $session->getProgress());\r
        }\r
index 22f47793a7f00f9ad1677e2bad44e4b487a56abb..b3276a494d300a79e1689df11ea8ec1f028de07a 100644 (file)
@@ -27,6 +27,12 @@ class wsDAODocument extends extranetDAO {
                return $this->singleton($r);\r
        }\r
 \r
+       public function selectInList($documentsId)\r
+       {\r
+               $r = $this->con->select('SELECT * FROM documents WHERE document_id IN(' . implode(',', $documentsId) . ')');\r
+               return $this->factory($r);\r
+       }\r
+\r
        public function cree()\r
        {\r
                $document = new wsDocument();\r
index 5f7e19999636d100c37ca1e47daa1a3bbba7f6b5..3b319609271f8c8e28b5d57b18f7e702b2c6af9e 100644 (file)
@@ -1,4 +1,13 @@
 <?php\r
+/**\r
+ * wsDocument\r
+ *\r
+ * @package\r
+ * @author Vincent\r
+ * @copyright Copyright (c) 2010\r
+ * @version $Id$\r
+ * @access public\r
+ */\r
 class wsDocument extends cubeMetier {\r
        protected $document_id;\r
        protected $file;\r
@@ -19,6 +28,9 @@ class wsDocument extends cubeMetier {
        protected $infos;\r
        protected $textes;\r
 \r
+       private $_basicInfos = null;\r
+       private $_advancedInfos = null;\r
+\r
        public function copyOriginal($tmp_file)\r
        {\r
                $this->out = ROOT . '/docs/' . $this->document_id . '/';\r
@@ -35,23 +47,41 @@ class wsDocument extends cubeMetier {
 \r
        public function getInfos()\r
        {\r
-               $pdfinfo = new cubeCommandLine('pdfinfo', null, false);\r
-               $pdfinfo->setArg('-box');\r
-               $pdfinfo->setArg('f', 1);\r
-               $pdfinfo->setArg('l', 10000);\r
-               $pdfinfo->setArg(null, $this->in);\r
-               $pdfinfo->execute();\r
-               $this->addToLog($pdfinfo);\r
-\r
-               $pdftk = new cubeCommandLine('pdftk', null, true);\r
-               $pdftk->setArg(null, $this->in);\r
-               $pdftk->setArg(null, 'dump_data');\r
-               $pdftk->execute();\r
-               $this->addToLog($pdftk);\r
-\r
-               $this->parseInfos($pdfinfo->output . $pdftk->output);\r
-\r
-               file_put_contents($this->infos, $pdfinfo->output . $pdftk->output);\r
+               $pdfinfo = $this->getBasicInfos();\r
+               $pdftk = $this->getAdvancedInfos();\r
+\r
+               $this->parseInfos($pdfinfo . $pdftk);\r
+\r
+               file_put_contents($this->infos, $pdfinfo . $pdftk);\r
+       }\r
+\r
+       public function getBasicInfos()\r
+       {\r
+               if (is_null($this->_basicInfos)) {\r
+                       $pdfinfo = new cubeCommandLine('pdfinfo', null, false);\r
+                       $pdfinfo->setArg('-box');\r
+                       $pdfinfo->setArg('f', 1);\r
+                       $pdfinfo->setArg('l', 10000);\r
+                       $pdfinfo->setArg(null, $this->in);\r
+                       $pdfinfo->execute();\r
+                       $this->addToLog($pdfinfo);\r
+\r
+                       $this->_basicInfos = $pdfinfo->output;\r
+               }\r
+               return $this->_basicInfos;\r
+       }\r
+\r
+       public function getAdvancedInfos()\r
+       {\r
+               if (is_null($this->_advancedInfos)) {\r
+                       $pdftk = new cubeCommandLine('pdftk', null, true);\r
+                       $pdftk->setArg(null, $this->in);\r
+                       $pdftk->setArg(null, 'dump_data');\r
+                       $pdftk->execute();\r
+                       $this->addToLog($pdftk);\r
+                       $this->_advancedInfos = $pdftk->output;\r
+               }\r
+               return $this->_advancedInfos;\r
        }\r
 \r
        public function parseInfos($data)\r
@@ -103,6 +133,12 @@ class wsDocument extends cubeMetier {
                return $res;\r
        }\r
 \r
+       public function getPagesNumber()\r
+       {\r
+               $this->parseInfos($this->getBasicInfos());\r
+               return $this->generalInfos['pages'];\r
+       }\r
+\r
        public function getTexts()\r
        {\r
                $pdftotext = new cubeCommandLine('pdftotext', null, true);\r
diff --git a/swf/_src/as3Container.fla b/swf/_src/as3Container.fla
new file mode 100644 (file)
index 0000000..5ce85eb
Binary files /dev/null and b/swf/_src/as3Container.fla differ