]> _ Git - fluidbook_tools.git/commitdiff
wip #4666 @0.5
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 8 Sep 2021 15:51:36 +0000 (17:51 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 8 Sep 2021 15:51:36 +0000 (17:51 +0200)
.idea/php.xml
composer.json
src/Jobs/ProcessFile.php
src/Jobs/ProcessPage.php
src/PDF/Document.php
src/PDF/PDFTools.php

index 56f594b88b2447e79c6fa9eeb7b3a3499f46ad14..592710e73abe486bb7a9e099809cc9e59e4d3522 100644 (file)
@@ -67,5 +67,5 @@
       <path value="$PROJECT_DIR$/vendor/barryvdh/laravel-debugbar" />
     </include_path>
   </component>
-  <component name="PhpProjectSharedConfiguration" php_language_level="7" />
+  <component name="PhpProjectSharedConfiguration" php_language_level="8.0" />
 </project>
\ No newline at end of file
index 34fc7cc4d49062c6fb1fbc6b30678e2bbf9afb05..26548a74dac18a4747bb7d93bdc87de02ae3e926 100644 (file)
@@ -22,7 +22,7 @@
         }
     ],
     "require": {
-        "php": ">=7.0.0",
+        "php": ">=8.0",
         "ext-libxml": "*",
         "ext-mbstring": "*",
         "ext-dom": "*",
index 7a498eb48a7e1731eb473bd8c1111ce772ec3fa8..f72f35cef7c28fd6f073dc176e4db0e0f7772d54 100644 (file)
@@ -2,6 +2,7 @@
 
 namespace Fluidbook\Tools\Jobs;
 
+use Cubist\Util\Files\Files;
 use Fluidbook\Tools\PDF\PDFTools;
 use Fluidbook\Tools\SVG\SVGTools;
 
@@ -9,7 +10,7 @@ class ProcessFile
 {
     protected $format = 'jpg';
     /**
-     * @var int
+     * @var int|string
      */
     protected $resolution = 150;
     /**
@@ -24,14 +25,7 @@ class ProcessFile
      * @var string
      */
     protected $version = 'html';
-    /**
-     * @var int
-     */
-    protected $page = 0;
-    /**
-     * @var string
-     */
-    protected $out;
+
     /**
      * @var ProcessPage
      */
@@ -66,17 +60,17 @@ class ProcessFile
     }
 
     /**
-     * @param int $resolution
+     * @param int|string $resolution
      */
-    public function setResolution(int $resolution)
+    public function setResolution(int|string $resolution)
     {
         $this->resolution = $resolution;
     }
 
     /**
-     * @return int
+     * @return int|string
      */
-    public function getResolution(): int
+    public function getResolution(): int|string
     {
         return $this->resolution;
     }
@@ -129,13 +123,6 @@ class ProcessFile
         return $this->job->getOut();
     }
 
-    /**
-     * @param mixed $out
-     */
-    public function setOut($out)
-    {
-        $this->out = $out;
-    }
 
     /**
      * @return string
@@ -231,6 +218,7 @@ class ProcessFile
             sleep(10);
             return $this->getPath();
         }
+        Files::mkdir(dirname($lock));
         touch($lock);
         if ($this->getFormat() === 'svg') {
             if ($this->isWithGraphics()) {
@@ -253,7 +241,7 @@ class ProcessFile
 
     public function makeSVGFile($force = false)
     {
-        $svgFile = $this->out . '/html/fp' . $this->getPage() . '.svg';
+        $svgFile = $this->getOut() . '/html/fp' . $this->getPage() . '.svg';
         if (!$force && file_exists($svgFile) && filesize($svgFile) > 0) {
             return $svgFile;
         }
@@ -278,7 +266,7 @@ class ProcessFile
 
     protected function getSplittedPDFPage()
     {
-        $res = $this->out . 'pdf/p' . $this->getPage() . '.pdf';
+        $res = $this->getOut() . 'pdf/p' . $this->getPage() . '.pdf';
         if (!file_exists($res)) {
             $this->getJob()->splitDoc();
         }
index 601840f9952ce2c0f6798acde85b56e69c047cb6..d333f62ef59eb4631b4ee657faf27cefb75c338d 100644 (file)
@@ -2,6 +2,7 @@
 
 namespace Fluidbook\Tools\Jobs;
 
+use Cubist\Util\Files\Files;
 use Fluidbook\Tools\PDF\Document;
 use Fluidbook\Tools\PDF\PDFTools;
 use Fluidbook\Tools\SVG\SVGTools;
@@ -41,6 +42,7 @@ class ProcessPage implements ShouldQueue
      * @param $document Document
      * @param $page integer
      * @param $out string
+     * @param ProcessFile[] $files
      */
     public function __construct($document, $page, $out, $files = [])
     {
@@ -102,9 +104,7 @@ class ProcessPage implements ShouldQueue
     {
         start_measure('Split PDF');
 
-        if (!file_exists($this->out . '/pdf') && !mkdir($concurrentDirectory = $this->out . '/pdf') && !is_dir($concurrentDirectory)) {
-            throw new \RuntimeException(sprintf('Directory "%s" was not created', $concurrentDirectory));
-        }
+        Files::mkdir($this->out . '/pdf');
         $pdftk = new CommandLine('pdftk');
         $pdftk->setArg(null, $this->getPDFInput());
         $pdftk->setArg(null, 'burst');
index d9f99bf75d5f646962e0a9cde6844863ca0507b0..31c5deb6e4ed441a5004e290a91bc1dc05d7beac 100644 (file)
@@ -4,6 +4,7 @@ namespace Fluidbook\Tools\PDF;
 
 use Cubist\Util\CommandLine;
 use Fluidbook\Tools\FluidbookTools;
+use Fluidbook\Tools\Jobs\ProcessFile;
 use Fluidbook\Tools\Jobs\ProcessPage;
 
 class Document
@@ -108,8 +109,10 @@ class Document
     }
 
     /**
-     * @param $i
-     * @param $dest
+     * @param $page int
+     * @param $dest string
+     * @param $files ProcessFile[]
+     * @param false $sync
      */
     public function processPage($page, $dest, $files, $sync = false)
     {
index d7fba2c4fa99f298f2c5ae61984da9eb94dd41fc..03187046d7d9923f476720695194d6060905ebcf 100644 (file)
@@ -3,6 +3,7 @@
 namespace Fluidbook\Tools\PDF;
 
 use Cubist\Util\CommandLine;
+use Cubist\Util\Files\Files;
 use DOMDocument;
 use DOMNode;
 use DOMXPath;
@@ -169,7 +170,7 @@ class PDFTools
 
     protected static function makeShotGS($in, $out, $page, $prefix = '', $resolution = 72, $quality = 90, $antialiasing = 4, $width = null, $height = null, $format = 'jpg')
     {
-        // Fabrication des thumbanails avec ghostscript
+        // Fabrication des thumbnails avec ghostscript
         $gs = new CommandLine('gs', null, true);
         $gs->setArg('-dBATCH');
         $gs->setArg('-dNOPAUSE');
@@ -204,7 +205,7 @@ class PDFTools
 
     public static function makeShotPNM($in, $out, $page, $prefix = '', $resolution = 72, $quality = 90, $antialiasing = 4, $texts = true, $width = null, $height = null, $format = 'jpg')
     {
-        $tmp = cubeFiles::tempnam();
+        $tmp =Files::tempnam();
 
         $antialiasing = $antialiasing ? 'yes' : 'no';
         $freetype = $texts ? 'yes' : 'no';