From: Vincent Vanwaelscappel Date: Fri, 6 Feb 2026 18:59:45 +0000 (+0100) Subject: wip #7868 @3 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=66e6b6b0dd1a91edf97c5d8774f86454f3a60a2d;p=fluidbook-toolbox.git wip #7868 @3 --- diff --git a/app/Models/FluidbookAuditLink.php b/app/Models/FluidbookAuditLink.php index 1dd0f4df1..c4dc98a15 100644 --- a/app/Models/FluidbookAuditLink.php +++ b/app/Models/FluidbookAuditLink.php @@ -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) + { } } diff --git a/app/Models/ShortLink.php b/app/Models/ShortLink.php index df234594d..5861dcab4 100644 --- a/app/Models/ShortLink.php +++ b/app/Models/ShortLink.php @@ -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'; diff --git a/app/Models/ToolWebflow.php b/app/Models/ToolWebflow.php index cb46e76e3..320a7e6f1 100644 --- a/app/Models/ToolWebflow.php +++ b/app/Models/ToolWebflow.php @@ -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 '; $html = preg_replace('/[^<]*<\/title>/', '<title>' . e($currentPage['seo_title']) . '' . $meta, $html); - } } @@ -716,8 +711,6 @@ class ToolWebflow extends ToolboxTranslatableModel } Cache::put('webflow_' . $this->id . '_locales', $locales); - - } catch (LockTimeoutException $e) { } finally {