]> _ Git - fluidbook_processfarm.git/commitdiff
wip #5524 @0.5
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 22 Feb 2023 07:27:27 +0000 (08:27 +0100)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 22 Feb 2023 07:27:27 +0000 (08:27 +0100)
app/process.php
app/src/ProcessFile.php
app/src/ProcessFileNoMapping.php [deleted file]
app/src/ProcessToolboxDocumentFile.php [new file with mode: 0644]
app/src/ProcessToolboxPDFFile.php [new file with mode: 0644]

index 87ab21cdc5455318ef8f3a1e43b3a8f2836b6cdc..0dcc04e622bbe38510c9994992c9427e4b7ff6b3 100644 (file)
@@ -1,15 +1,20 @@
 <?php
 
 use Fluidbook\Farmer\ProcessFile;
-use Fluidbook\Farmer\ProcessFileNoMapping;
+use Fluidbook\Farmer\ProcessToolboxDocumentFile;
+use Fluidbook\Farmer\ProcessToolboxPDFFile;
 
 require_once __DIR__ . "/vendor/autoload.php";
 
 
-if (isset($_POST['toolbox'])) {
-       $class = ProcessFileNoMapping::class;
+if (!isset($_POST['pdf'])) {
+       if (isset($_POST['toolbox'])) {
+               $class = ProcessToolboxDocumentFile::class;
+       } else {
+               $class = ProcessFile::class;
+       }
+       $p = new $class($_POST['out'], $_POST['page'], $_POST['resolutionRatio'], $_POST['mobileRatio'], $_POST['format'], $_POST['resolution'], $_POST['withGraphics'], $_POST['withText'], $_POST['version'], $_POST['force']);
 } else {
-       $class = ProcessFile::class;
+       $p = new ProcessToolboxPDFFile($_POST['pdf'], $_POST['out'], $_POST['page'], $_POST['resolutionRatio'], $_POST['mobileRatio'], $_POST['format'], $_POST['resolution'], $_POST['withGraphics'], $_POST['withText'], $_POST['version'], $_POST['force']);
 }
-$p = new $class($_POST['out'], $_POST['page'], $_POST['resolutionRatio'], $_POST['mobileRatio'], $_POST['format'], $_POST['resolution'], $_POST['withGraphics'], $_POST['withText'], $_POST['version'], $_POST['force']);
 die($p->process());
\ No newline at end of file
index c9eeb660f21aae61fba6f186bdc616e36cead2e7..424737a790f701a63ec3007f3f89533c560b394d 100644 (file)
@@ -131,10 +131,14 @@ class ProcessFile extends \Fluidbook\Tools\Jobs\ProcessFile {
                }
        }
 
+       public function getPdf(): string {
+               return Files::firstThatExists($this->getOut() . '/crop.pdf', $this->getOut() . '/fixed.pdf', $this->getOut() . '/original.pdf');
+       }
+
        public function getSplittedPDFPage() {
                $res = $this->getOut() . 'pdf/p' . $this->getPage() . '.pdf';
                if (!file_exists($res)) {
-                       PDFTools::split(Files::firstThatExists($this->getOut() . '/crop.pdf', $this->getOut() . '/fixed.pdf', $this->getOut() . '/original.pdf'), $this->getOut() . '/pdf');
+                       PDFTools::split($this->getPdf(), $this->getOut() . '/pdf');
                }
                return $res;
        }
diff --git a/app/src/ProcessFileNoMapping.php b/app/src/ProcessFileNoMapping.php
deleted file mode 100644 (file)
index d48c05e..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-<?php
-
-namespace Fluidbook\Farmer;
-
-
-class ProcessFileNoMapping extends ProcessFile{
-       public function getOut() {
-               $this->getDistantOut();
-       }
-
-       public function process() {
-               $this->getPath($this->isForce());
-       }
-}
\ No newline at end of file
diff --git a/app/src/ProcessToolboxDocumentFile.php b/app/src/ProcessToolboxDocumentFile.php
new file mode 100644 (file)
index 0000000..4476313
--- /dev/null
@@ -0,0 +1,14 @@
+<?php
+
+namespace Fluidbook\Farmer;
+
+
+class ProcessToolboxDocumentFile extends ProcessFile{
+       public function getOut() {
+               $this->getDistantOut();
+       }
+
+       public function process() {
+               $this->getPath($this->isForce());
+       }
+}
\ No newline at end of file
diff --git a/app/src/ProcessToolboxPDFFile.php b/app/src/ProcessToolboxPDFFile.php
new file mode 100644 (file)
index 0000000..baa8fd1
--- /dev/null
@@ -0,0 +1,31 @@
+<?php
+
+namespace Fluidbook\Farmer;
+
+
+class ProcessToolboxPDFFile extends ProcessToolboxDocumentFile {
+
+       /**
+        * @var string
+        */
+       protected $_pdf;
+
+       public function __construct($pdf, $out, $page, $resolutionRatio, $mobileRatio, $format = 'jpg', $resolution = 150, $withGraphics = true, $withTexts = true, $version = 'html', $force = false) {
+               $this->setPdf($pdf);
+               parent::__construct($out, $page, $resolutionRatio, $mobileRatio, $format, $resolution, $withGraphics, $withTexts, $version, $force);
+       }
+
+       /**
+        * @return string
+        */
+       public function getPdf(): string {
+               return $this->_pdf;
+       }
+
+       /**
+        * @param string $pdf
+        */
+       public function setPdf(string $pdf): void {
+               $this->_pdf = $pdf;
+       }
+}
\ No newline at end of file