]> _ Git - fluidbook-toolbox.git/commitdiff
wip #7868 @3
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Fri, 6 Feb 2026 18:59:45 +0000 (19:59 +0100)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Fri, 6 Feb 2026 18:59:45 +0000 (19:59 +0100)
app/Models/FluidbookAuditLink.php
app/Models/ShortLink.php
app/Models/ToolWebflow.php

index 1dd0f4df125908c55a47c75b92044638ec469c64..c4dc98a1555419c28a22c7cd180cba5b2e148113 100644 (file)
@@ -34,7 +34,22 @@ class FluidbookAuditLink extends CubistMagicAbstractModel
         $this->addUniqueKey(['fluidbook_id', 'link_id']);
     }
 
-    public static function getURLToTest($limit){
+    public static function getAllURLAudits()
+    {
+        $all = self::all();
+        $res = [];
+        foreach ($all as $l) {
+            /** @var $l FluidbookAuditLink */
+            if (!isset($res[$l->url])) {
+                $res[$l->url] = ['http_code' => $l->http_code, 'code_date' => $l->code_date, 'target_code' => $l->target_code, 'target_url' => $l->target_url, 'fluidbook_links' => []];
+            }
+            $res[$l->url]['fluidbook_links'][] = ['fluidbook_id' => $l->fluidbook_id, 'page' => $l->page, 'link_id' => $l->link_id];
+        }
+        return $res;
+    }
+
+    public static function getURLToTest($limit)
+    {
 
     }
 }
index df234594d2cd76ec67518d1b9bee7fcf13e5a055..5861dcab4c47e6b5ed3661ae2f6bda09b8c72c65 100644 (file)
@@ -4,7 +4,9 @@ namespace App\Models;
 
 use App\Models\Base\ToolboxModel;
 use Cubist\Backpack\Magic\Fields\Hidden;
+use Cubist\Backpack\Magic\Fields\Integer;
 use Cubist\Backpack\Magic\Fields\SelectFromArray;
+use Cubist\Backpack\Magic\Fields\Textarea;
 use Cubist\Backpack\Magic\Fields\URL;
 use Cubist\Backpack\Magic\Traits\CustomDataSource;
 use Cubist\Util\Files\Files;
@@ -38,9 +40,13 @@ class ShortLink extends ToolboxModel
 
         $this->addField('server', SelectFromArray::class, __('Serveur'), ['type' => 'hidden', 'options' => LinkShortener::getAvaiableShorteners()]);
         $this->addField('url', URL::class, __('URL'), ['column' => true]);
-        $this->addField('shortlink', URL::class, __('Short URL'), ['type' => 'hidden_visible', 'column' => 'url', 'database_unique' => true]);
+        $this->addField('shortlink', URL::class, __('URL courte'), ['type' => 'hidden_visible', 'column' => 'url', 'database_unique' => true]);
+        $this->addField('http_code', Integer::class, __('Code HTTP'), ['type' => 'hidden_visible', 'column' => true]);
+        $this->addField('code_date', \Cubist\Backpack\Magic\Fields\Datetime::class, __('Code observĂ© le'), ['type' => 'hidden_visible', 'column' => true]);
+        $this->addField('target_code', Integer::class, __('Code final'), ['type' => 'hidden_visible', 'column' => true]);
+        $this->addField('target_url', URL::class, __('URL finale'), ['type' => 'hidden_visible', 'column' => true]);
+        $this->addField('fluidbook_links', Textarea::class, __('PrĂ©sence dans les fluidbooks'), ['type' => 'hidden_visible', 'column' => true]);
         $this->addOwnerField(['column' => false, 'type' => Hidden::class]);
-
     }
 
     public function showPrimaryColumn()
@@ -53,6 +59,8 @@ class ShortLink extends ToolboxModel
      */
     protected static function _getData()
     {
+        $auditLinks = FluidbookAuditLink::getAllURLAudits();
+
         $data = [];
         foreach (LinkShortener::getAvaiableShorteners(true) as $id => $s) {
             try {
@@ -70,6 +78,9 @@ class ShortLink extends ToolboxModel
                         'created_ok' => '1',
                         'owner' => $s['owner'],
                     ];
+                    if (isset($auditLinks[$i->url])) {
+                        $d = array_merge($d, $auditLinks[$i->url]);
+                    }
                     $data[$d['id']] = $d;
                 }
             } catch (\Exception $e) {
@@ -79,6 +90,11 @@ class ShortLink extends ToolboxModel
         return $data;
     }
 
+    public static function shouldRefreshDatabase()
+    {
+        return true;
+    }
+
     public static function getDataLastChangeFile()
     {
         return Files::mkdir(resource_path('shortlink')) . 'lastchange';
index cb46e76e3bcb0efc522e3da1e63a1f86c7201331..320a7e6f19382fffc6b94eff873ac0eb8c25f78b 100644 (file)
@@ -121,7 +121,6 @@ class ToolWebflow extends ToolboxTranslatableModel
 
     public function onSaving(): bool
     {
-
         $this->saveDataInWebflow();
 
         $change = false;
@@ -530,8 +529,6 @@ class ToolWebflow extends ToolboxTranslatableModel
      */
     protected function compileHTMLFile($f, $relative, $dest, $isMainLocale, $locale, $texts, $images, $seo, $env = 'dev')
     {
-
-
         $urlmaps = $this->getURLMaps();
         $urlmap = $urlmaps[$locale];
         $origRelative = $relative;
@@ -556,7 +553,6 @@ class ToolWebflow extends ToolboxTranslatableModel
             }
         }
 
-
         // Replace URL
         foreach ($urlmap as $k => $v) {
             $html = str_replace(ltrim($k, '/'), ltrim($v, '/'), $html);
@@ -617,7 +613,6 @@ class ToolWebflow extends ToolboxTranslatableModel
     <meta content="' . $og_title . '" property="twitter:title" />
     <meta content="' . $og_desc . '" property="twitter:description" />';
                 $html = preg_replace('/<title>[^<]*<\/title>/', '<title>' . e($currentPage['seo_title']) . '</title>' . $meta, $html);
-
             }
         }
 
@@ -716,8 +711,6 @@ class ToolWebflow extends ToolboxTranslatableModel
             }
 
             Cache::put('webflow_' . $this->id . '_locales', $locales);
-
-
         } catch (LockTimeoutException $e) {
 
         } finally {