]> _ Git - fluidbook-toolbox.git/commitdiff
wip #7868 @2
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Tue, 10 Feb 2026 18:50:46 +0000 (19:50 +0100)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Tue, 10 Feb 2026 18:50:46 +0000 (19:50 +0100)
app/Fields/ShortLinkFluidbooks.php [new file with mode: 0644]
app/Models/LinkShortener.php
app/Models/ShortLink.php
resources/views/fields/shortlinks_fluidbooks.blade.php [new file with mode: 0644]

diff --git a/app/Fields/ShortLinkFluidbooks.php b/app/Fields/ShortLinkFluidbooks.php
new file mode 100644 (file)
index 0000000..83f29a5
--- /dev/null
@@ -0,0 +1,13 @@
+<?php
+
+namespace App\Fields;
+
+use Cubist\Backpack\Magic\Fields\Textarea;
+
+class ShortLinkFluidbooks extends Textarea
+{
+    protected $_columnType = 'shortlinks_fluidbooks';
+    protected $_columnViewNamespace = 'columns';
+    protected $_adminType = 'shortlinks_fluidbooks';
+    protected $_viewNamespace = 'fields';
+}
index a4db242b4d8dcd47d624e79eb149288e83ce2338..9154bda1d097f15ecd987ec2a8fcefb80f2ab7d3 100644 (file)
@@ -73,7 +73,7 @@ class LinkShortener extends ToolboxModel
             if ($code === 200) {
 
             }
-            if ($res->shorturl) {
+            if (isset($res->shorturl) && $res->shorturl) {
                 return $res->shorturl;
             }
         });
index 7d1f10fe24194f4e0183e449b0839279fd563d07..79466622a04f8cc7fb19d1a70363eaf6930a8ef6 100644 (file)
@@ -2,6 +2,7 @@
 
 namespace App\Models;
 
+use App\Fields\ShortLinkFluidbooks;
 use App\Models\Base\ToolboxModel;
 use Cubist\Backpack\CubistBackpackServiceProvider;
 use Cubist\Backpack\Magic\Fields\Hidden;
@@ -43,11 +44,11 @@ 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, __('URL courte'), ['type' => 'hidden_visible', 'column' => true, 'column_view_namespace' => CubistBackpackServiceProvider::NAMESPACE . '::columns', 'column_type' => 'url', 'database_unique' => true]);
-        $this->addField('http_code', Integer::class, __('Code HTTP'), ['type' => 'hidden_visible', 'column' => true, 'column_label' => '<i class="las la-chevron-circle-down" title="'.__('Résultat du test').'"></i>', 'column_type' => 'http_code', 'column_view_namespace' => 'columns']);
+        $this->addField('http_code', Integer::class, __('Code HTTP'), ['type' => 'hidden_visible', 'column' => true, 'column_label' => '<i class="las la-chevron-circle-down" title="' . __('Résultat du test') . '"></i>', 'column_type' => 'http_code', 'column_view_namespace' => 'columns']);
         $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, 'column_type' => 'http_code', 'column_view_namespace' => 'columns','column_label' => '<i class="las la-chevron-circle-right" title="'.__('Résultat du test de la page redirigée').'"></i>']);
+        $this->addField('target_code', Integer::class, __('Code final'), ['type' => 'hidden_visible', 'column' => true, 'column_type' => 'http_code', 'column_view_namespace' => 'columns', 'column_label' => '<i class="las la-chevron-circle-right" title="' . __('Résultat du test de la page redirigée') . '"></i>']);
         $this->addField('target_url', URL::class, __('URL finale'), ['type' => 'hidden_visible', 'column' => true, 'column_view_namespace' => CubistBackpackServiceProvider::NAMESPACE . '::columns', 'column_type' => 'url', 'column_limit' => 40]);
-        $this->addField('fluidbook_links', Textarea::class, __('Présence dans les fluidbooks'), ['type' => 'hidden_visible', 'column_label' => '<i class="las la-link" title="' . __('Nombre d\'occurence dans les fluidbooks') . '"></i>','column' => true, 'column_type' => 'shortlinks_fluidbooks', 'column_view_namespace' => 'columns']);
+        $this->addField('fluidbook_links', ShortLinkFluidbooks::class, __('Présence dans les fluidbooks'), ['column_label' => '<i class="las la-link" title="' . __('Nombre d\'occurence dans les fluidbooks') . '"></i>', 'column' => true]);
         $this->addOwnerField(['column' => false, 'type' => Hidden::class]);
     }
 
diff --git a/resources/views/fields/shortlinks_fluidbooks.blade.php b/resources/views/fields/shortlinks_fluidbooks.blade.php
new file mode 100644 (file)
index 0000000..6c2db58
--- /dev/null
@@ -0,0 +1,29 @@
+@php
+
+    $value=old(square_brackets_to_dots($field['name'])) ?? $field['value'] ?? $field['default'] ?? '';
+@endphp
+
+@include('crud::fields.inc.wrapper_start')
+<label>{!! $field['label'] !!}</label>
+@include('crud::fields.inc.translatable_icon')
+
+<ul>
+    @foreach(json_decode($value,true) as $v)
+        @php
+            /** @var \App\Models\FluidbookPublication $fluidbook */
+            $fluidbook=\App\Models\FluidbookPublication::find($v['fluidbook_id']);
+        @endphp
+        <li>{{__('Fluidbook #:fluidbook_id, Page :page, Lien :link_id',$v)}}
+            <a target="_blank" href="{{$fluidbook->getPreviewURL().'#/page/'.$v['page']}}"
+               title="{{__('Ouvrir la publication')}}"><i class="las la-eye"></i></a>
+            @if(App\Models\FluidbookPublication::hasPermission($v['fluidbook_id']))
+                <a target="_blank" href="{{url('fluidbook-publication/'.$v['fluidbook_id'].'/edit/links#'.$v['page'])}}"
+                   title="{{__('Ouvrir l\'éditeur de liens')}}"><i class="las la-edit"></i></a>
+            @endif
+        </li>
+    @endforeach
+</ul>
+{{-- HINT --}}
+
+@include('crud::fields.inc.wrapper_end')
+