]> _ Git - fluidbook-toolbox.git/commitdiff
wip #5228 @1.5
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Thu, 5 May 2022 14:15:35 +0000 (16:15 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Thu, 5 May 2022 14:15:35 +0000 (16:15 +0200)
.idea/workspace.xml
app/Http/Controllers/Admin/Operations/Tools/PDF2SVGOperation.php
app/Models/CubedesignersEmails.php
app/Models/FluidbookQuote.php
composer.json
composer.lock

index 902b67339d1fa89a804e55175529c45678b79c18..4539a062f81b559e3c93dc58e54c1603a58585e3 100644 (file)
   <component name="ChangeListManager">
     <list default="true" id="5d2ecd5e-a05a-4f96-a195-fa6372618165" name="Default Changelist" comment="wip #5265 @0.5">
       <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
-      <change beforePath="$PROJECT_DIR$/config/backup.php" beforeDir="false" afterPath="$PROJECT_DIR$/config/backup.php" afterDir="false" />
-      <change beforePath="$PROJECT_DIR$/resources/emailconfig/postfix-main.cf" beforeDir="false" afterPath="$PROJECT_DIR$/resources/emailconfig/postfix-main.cf" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/app/Http/Controllers/Admin/Operations/Tools/PDF2SVGOperation.php" beforeDir="false" afterPath="$PROJECT_DIR$/app/Http/Controllers/Admin/Operations/Tools/PDF2SVGOperation.php" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/app/Models/CubedesignersEmails.php" beforeDir="false" afterPath="$PROJECT_DIR$/app/Models/CubedesignersEmails.php" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/app/Models/FluidbookQuote.php" beforeDir="false" afterPath="$PROJECT_DIR$/app/Models/FluidbookQuote.php" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/composer.json" beforeDir="false" afterPath="$PROJECT_DIR$/composer.json" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/composer.lock" beforeDir="false" afterPath="$PROJECT_DIR$/composer.lock" afterDir="false" />
     </list>
     <option name="SHOW_DIALOG" value="false" />
     <option name="HIGHLIGHT_CONFLICTS" value="true" />
       <workItem from="1651398713511" duration="1801000" />
       <workItem from="1651561264763" duration="4820000" />
       <workItem from="1651587683461" duration="1063000" />
-      <workItem from="1651655455708" duration="30000" />
-    </task>
-    <task id="LOCAL-00224" summary="wip #5045 @1">
-      <created>1643386780400</created>
-      <option name="number" value="00224" />
-      <option name="presentableId" value="LOCAL-00224" />
-      <option name="project" value="LOCAL" />
-      <updated>1643386780400</updated>
+      <workItem from="1651655455708" duration="641000" />
+      <workItem from="1651746630722" duration="1339000" />
+      <workItem from="1651753148416" duration="6255000" />
     </task>
     <task id="LOCAL-00225" summary="wip #5045 @0.5">
       <created>1643389174195</created>
       <option name="project" value="LOCAL" />
       <updated>1651565022545</updated>
     </task>
-    <option name="localTasksCounter" value="273" />
+    <task id="LOCAL-00273" summary="wip #5265 @0.5">
+      <created>1651655495699</created>
+      <option name="number" value="00273" />
+      <option name="presentableId" value="LOCAL-00273" />
+      <option name="project" value="LOCAL" />
+      <updated>1651655495699</updated>
+    </task>
+    <option name="localTasksCounter" value="274" />
     <servers />
   </component>
   <component name="TypeScriptGeneratedFilesManager">
index af7955f06d1ada5ed202cb03980516fd36cca091..b8ec38b7e2bb7e2357f19905c753369d3bdff16f 100644 (file)
@@ -15,6 +15,7 @@ use Cubist\Util\ArrayUtil;
 use Cubist\Util\Files\Files;
 use Cubist\Util\Str;
 use Cubist\Util\Zip;
+use DOMDocument;
 use Fluidbook\Tools\Document;
 use Fluidbook\Tools\Jobs\ProcessFile;
 use Fluidbook\Tools\Jobs\ProcessPage;
@@ -22,6 +23,11 @@ use Symfony\Component\HttpFoundation\File\UploadedFile;
 
 trait PDF2SVGOperation
 {
+    /**
+     * @var int
+     */
+    protected static $_svgAttr = 0;
+
     public function pdf2svg()
     {
         $form = new Form(backpack_url('tools/convertpdf'));
@@ -61,12 +67,54 @@ trait PDF2SVGOperation
             $f = new ProcessFile($format, $resolution, $withGraphics, $withTexts);
             $pageJob = new ProcessPage($doc, $page, [$f]);
             $f->setJob($pageJob);
-            rename($f->getPath(), $dir . '/' . $n . '-' . $page . '.' . $format);
+            $fname = $n . '-' . $page ;
+            $dest = $dir . '/' . $fname. '.' . $format;
+            rename($f->getPath(), $dest);
+            if ($format === 'svg') {
+                self::identifySVG($dest);
+            }
+        }
+
+        if (count($pages) === 1) {
+            $ext = $format;
+            $tmpfile = $dest;
+        } else {
+            $ext = 'zip';
+            $fname = $file->getClientOriginalName();
+            $tmpfile = Files::tempnam() . '.zip';
+            Zip::archive($dir, $tmpfile);
         }
 
-        $tmpfile = Files::tempnam() . '.zip';
-        $zip = Zip::archive($dir, $tmpfile);
+        return response()->download($tmpfile, $fname . '.' . $ext)->deleteFileAfterSend(true);
+    }
+
+    public static function identifySVG($path)
+    {
+        self::$_svgAttr = 0;
+        $svg = new DOMDocument();
+        $svg->preserveWhiteSpace = true;
+        $svg->load($path, LIBXML_PARSEHUGE);
+        self::_identifySVGNode($svg);
+
+        file_put_contents($path, $svg->saveXML());
+    }
 
-        return response()->download($tmpfile, $file->getClientOriginalName() . '.zip')->deleteFileAfterSend(true);
+
+    public static function _identifySVGNode(\DOMNode $node)
+    {
+
+        if ($node instanceof \DOMElement) {
+            if (!$node->hasAttribute('id')) {
+                self::$_svgAttr++;
+                $node->setAttribute('id', 'e-' . self::$_svgAttr);
+
+            }
+        }
+
+        if ($node->hasChildNodes()) {
+            foreach ($node->childNodes as $childNode) {
+                self::_identifySVGNode($childNode);
+            }
+        }
     }
 }
index 1acaaf53aa28a8567d09455efcd8a14dbd701ec6..c511673236a06e5bb5f44cfbecf3451d735c4ad3 100644 (file)
@@ -115,6 +115,7 @@ class CubedesignersEmails extends CubistMagicAbstractModel
                 }
                 $allAliases[$from . '@' . $domain] = array_merge($allAliases[$from . '@' . $domain], $dest);
             }
+//            $allAliases['@' . $domain] = ['postmaster+catchall@' . $maindomain];
         }
         $aliasesFile = [];
         foreach ($allAliases as $from => $dest) {
@@ -144,8 +145,8 @@ class CubedesignersEmails extends CubistMagicAbstractModel
         }
         $my_networks = array_unique($my_networks);
 
-        $this->_replaceInFile('postfix-main.cf',['my_networks'=> implode(', ', $my_networks)]);
-        $this->_replaceInFile('fail2ban-jail.cf',['ignoreip'=> implode(',', $my_networks)]);
+        $this->_replaceInFile('postfix-main.cf', ['my_networks' => implode(', ', $my_networks)]);
+        $this->_replaceInFile('fail2ban-jail.cf', ['ignoreip' => implode(',', $my_networks)]);
 
         touch(storage_path('emailconfig/__UPDATED__'));
     }
index ee960f94e1805abee1bc54b14d00777357276f87..dff1d6115a8594654b653c7fa9bacefcf6a25634 100644 (file)
@@ -10,8 +10,11 @@ use App\Http\Controllers\Admin\Operations\FluidbookQuote\ConfirmAssignmentOperat
 use App\Http\Controllers\Admin\Operations\FluidbookQuote\CreateFromWebsite;
 use App\Models\Base\ToolboxModel;
 use App\Widgets;
+use Cubist\Backpack\Magic\Fields\Hidden;
 use Cubist\Backpack\Magic\Fields\Integer;
+use Cubist\Backpack\Magic\Fields\ModelAttribute;
 use Cubist\Backpack\Magic\Fields\Number;
+use Cubist\Backpack\Magic\Fields\StaticValue;
 
 class FluidbookQuote extends ToolboxModel
 {
@@ -33,10 +36,6 @@ class FluidbookQuote extends ToolboxModel
     {
         parent::setFields();
 
-        $this->addField('type', 'Hidden');
-        $this->addField('pages', 'Hidden');
-        $this->addField('links', 'Hidden');
-        $this->addField('langs', 'Hidden');
 
         $this->addField('user', FluidbookUser::class, __('Utilisateur'),
             [
@@ -46,6 +45,8 @@ class FluidbookQuote extends ToolboxModel
                 'can_write' => 'fluidbook-quote:admin',
             ]);
 
+        $this->addField('email', ModelAttribute::class, __('Email'), ['column' => true, 'attribute' => 'useremail', 'column_type' => 'email']);
+
         $this->addField(['name' => 'created_at',
             'label' => __('Date'),
             'type' => 'Datetime',
@@ -67,6 +68,11 @@ class FluidbookQuote extends ToolboxModel
             ]
         );
 
+        $this->addField('type', Hidden::class, __('Type'));
+        $this->addField('pages', Hidden::class, __('Pages'));
+        $this->addField('links', Hidden::class, __('Liens'));
+        $this->addField('langs', Hidden::class, __('Langues'));
+
         $this->addField('gclid', 'Text', 'Google Adwords ID (gclid)', ['can' => 'fluidbook-quote:admin',]);
 
         $this->addField('coupon', 'Hidden', __('Coupon'), ['can' => 'fluidbook-quote:admin',]);
@@ -104,6 +110,11 @@ class FluidbookQuote extends ToolboxModel
         return $this->getAttribute('gclid') ? 'Paid' : 'Organic';
     }
 
+    public function getUseremailAttribute()
+    {
+       return User::find($this->getAttribute('user'))->getAttribute('email');
+    }
+
     public function addWidgets()
     {
         Widgets::fluidbookQuoteWidgets();
index 507422c987e7110d1c2e42ffb8148b707176d042..04886302e5ef66dbf939ce25316fefd09ca750c1 100644 (file)
@@ -21,6 +21,8 @@
         "php": ">=8.0",
         "ext-json": "*",
         "ext-simplexml": "*",
+        "ext-dom": "*",
+        "ext-libxml": "*",
         "ext-tidy": "*",
         "ext-zip": "*",
         "ahmadshah/lucy": "dev-master",
@@ -34,7 +36,8 @@
         "mxl/laravel-job": "^1.3",
         "php-ffmpeg/php-ffmpeg": "^0.18.0",
         "phpoffice/phpspreadsheet": "^1.22",
-        "rustici-software/scormcloud-api-v2-client-php": "^2.0"
+        "rustici-software/scormcloud-api-v2-client-php": "^2.0",
+
     },
     "require-dev": {
         "facade/ignition": "^2.17",
index 6bce8e607e8be0f5556e570728d97e884d8dfef6..15c6c5c3254097febbd1c5739af32725315586a2 100644 (file)
         },
         {
             "name": "laravel/framework",
-            "version": "v8.83.10",
+            "version": "v8.83.11",
             "source": {
                 "type": "git",
                 "url": "https://github.com/laravel/framework.git",
-                "reference": "148ae59b7da6c3db6736374d357c5aaef9506fb7"
+                "reference": "d85c34179f209977043502441f9e44ca432a14b4"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/laravel/framework/zipball/148ae59b7da6c3db6736374d357c5aaef9506fb7",
-                "reference": "148ae59b7da6c3db6736374d357c5aaef9506fb7",
+                "url": "https://api.github.com/repos/laravel/framework/zipball/d85c34179f209977043502441f9e44ca432a14b4",
+                "reference": "d85c34179f209977043502441f9e44ca432a14b4",
                 "shasum": ""
             },
             "require": {
                 "issues": "https://github.com/laravel/framework/issues",
                 "source": "https://github.com/laravel/framework"
             },
-            "time": "2022-04-27T14:07:37+00:00"
+            "time": "2022-05-03T14:47:00+00:00"
         },
         {
             "name": "laravel/serializable-closure",
         },
         {
             "name": "nesbot/carbon",
-            "version": "2.57.0",
+            "version": "2.58.0",
             "source": {
                 "type": "git",
                 "url": "https://github.com/briannesbitt/Carbon.git",
-                "reference": "4a54375c21eea4811dbd1149fe6b246517554e78"
+                "reference": "97a34af22bde8d0ac20ab34b29d7bfe360902055"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/briannesbitt/Carbon/zipball/4a54375c21eea4811dbd1149fe6b246517554e78",
-                "reference": "4a54375c21eea4811dbd1149fe6b246517554e78",
+                "url": "https://api.github.com/repos/briannesbitt/Carbon/zipball/97a34af22bde8d0ac20ab34b29d7bfe360902055",
+                "reference": "97a34af22bde8d0ac20ab34b29d7bfe360902055",
                 "shasum": ""
             },
             "require": {
                 "phpmd/phpmd": "^2.9",
                 "phpstan/extension-installer": "^1.0",
                 "phpstan/phpstan": "^0.12.54 || ^1.0",
-                "phpunit/phpunit": "^7.5.20 || ^8.5.14",
+                "phpunit/php-file-iterator": "^2.0.5",
+                "phpunit/phpunit": "^7.5.20 || ^8.5.23",
                 "squizlabs/php_codesniffer": "^3.4"
             },
             "bin": [
                     "type": "tidelift"
                 }
             ],
-            "time": "2022-02-13T18:13:33+00:00"
+            "time": "2022-04-25T19:31:17+00:00"
         },
         {
             "name": "neutron/temporary-filesystem",
         },
         {
             "name": "psy/psysh",
-            "version": "v0.11.2",
+            "version": "v0.11.3",
             "source": {
                 "type": "git",
                 "url": "https://github.com/bobthecow/psysh.git",
-                "reference": "7f7da640d68b9c9fec819caae7c744a213df6514"
+                "reference": "6833626ee48ef9bcc8aca8f9f166760441c12573"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/bobthecow/psysh/zipball/7f7da640d68b9c9fec819caae7c744a213df6514",
-                "reference": "7f7da640d68b9c9fec819caae7c744a213df6514",
+                "url": "https://api.github.com/repos/bobthecow/psysh/zipball/6833626ee48ef9bcc8aca8f9f166760441c12573",
+                "reference": "6833626ee48ef9bcc8aca8f9f166760441c12573",
                 "shasum": ""
             },
             "require": {
                 "symfony/console": "4.4.37 || 5.3.14 || 5.3.15 || 5.4.3 || 5.4.4 || 6.0.3 || 6.0.4"
             },
             "require-dev": {
-                "bamarni/composer-bin-plugin": "^1.2",
-                "hoa/console": "3.17.05.02"
+                "bamarni/composer-bin-plugin": "^1.2"
             },
             "suggest": {
                 "ext-pcntl": "Enabling the PCNTL extension makes PsySH a lot happier :)",
                 "ext-pdo-sqlite": "The doc command requires SQLite to work.",
                 "ext-posix": "If you have PCNTL, you'll want the POSIX extension as well.",
-                "ext-readline": "Enables support for arrow-key history navigation, and showing and manipulating command history.",
-                "hoa/console": "A pure PHP readline implementation. You'll want this if your PHP install doesn't already support readline or libedit."
+                "ext-readline": "Enables support for arrow-key history navigation, and showing and manipulating command history."
             },
             "bin": [
                 "bin/psysh"
             ],
             "support": {
                 "issues": "https://github.com/bobthecow/psysh/issues",
-                "source": "https://github.com/bobthecow/psysh/tree/v0.11.2"
+                "source": "https://github.com/bobthecow/psysh/tree/v0.11.3"
             },
-            "time": "2022-02-28T15:28:54+00:00"
+            "time": "2022-05-05T02:19:43+00:00"
         },
         {
             "name": "sebastian/code-unit-reverse-lookup",