@@ -50,8 +50,8 @@ public function configure(DataTable $dataTable, array $options): void
5050 {
5151 $ dataTable ->add ('dont_matter ' , RowClassColumn::class, [
5252 'render ' => function ($ value , Attachment $ context ): string {
53- //Mark attachments with missing files yellow
54- if (!$ this ->attachmentHelper ->isFileExisting ($ context )){
53+ //Mark attachments yellow which have an internal file linked that doesn't exist
54+ if ($ context -> hasInternal () && !$ this ->attachmentHelper ->isInternalFileExisting ($ context )){
5555 return 'table-warning ' ;
5656 }
5757
@@ -64,8 +64,8 @@ public function configure(DataTable $dataTable, array $options): void
6464 'className ' => 'no-colvis ' ,
6565 'render ' => function ($ value , Attachment $ context ): string {
6666 if ($ context ->isPicture ()
67- && ! $ context -> isExternal ()
68- && $ this -> attachmentHelper -> isFileExisting ( $ context )) {
67+ && $ this -> attachmentHelper -> isInternalFileExisting ( $ context )) {
68+
6969 $ title = htmlspecialchars ($ context ->getName ());
7070 if ($ context ->getFilename ()) {
7171 $ title .= ' ( ' .htmlspecialchars ($ context ->getFilename ()).') ' ;
@@ -93,26 +93,6 @@ public function configure(DataTable $dataTable, array $options): void
9393 $ dataTable ->add ('name ' , TextColumn::class, [
9494 'label ' => 'attachment.edit.name ' ,
9595 'orderField ' => 'NATSORT(attachment.name) ' ,
96- 'render ' => function ($ value , Attachment $ context ) {
97- //Link to external source
98- if ($ context ->isExternal ()) {
99- return sprintf (
100- '<a href="%s" class="link-external">%s</a> ' ,
101- htmlspecialchars ((string ) $ context ->getURL ()),
102- htmlspecialchars ($ value )
103- );
104- }
105-
106- if ($ this ->attachmentHelper ->isFileExisting ($ context )) {
107- return sprintf (
108- '<a href="%s" target="_blank" data-no-ajax>%s</a> ' ,
109- $ this ->entityURLGenerator ->viewURL ($ context ),
110- htmlspecialchars ($ value )
111- );
112- }
113-
114- return $ value ;
115- },
11696 ]);
11797
11898 $ dataTable ->add ('attachment_type ' , TextColumn::class, [
@@ -136,15 +116,42 @@ public function configure(DataTable $dataTable, array $options): void
136116 ),
137117 ]);
138118
139- $ dataTable ->add ('filename ' , TextColumn::class, [
140- 'label ' => $ this -> translator -> trans ( ' attachment.table.filename ' ),
119+ $ dataTable ->add ('internal_link ' , TextColumn::class, [
120+ 'label ' => ' Internal copy ' , #TODO: translation
141121 'propertyPath ' => 'filename ' ,
122+ 'render ' => function ($ value , Attachment $ context ) {
123+ if ($ this ->attachmentHelper ->isInternalFileExisting ($ context )) {
124+ return sprintf (
125+ '<a href="%s" target="_blank" data-no-ajax>%s</a> ' ,
126+ $ this ->entityURLGenerator ->viewURL ($ context ),
127+ htmlspecialchars ($ value )
128+ );
129+ }
130+
131+ return $ value ;
132+ }
133+ ]);
134+
135+ $ dataTable ->add ('external_link ' , TextColumn::class, [
136+ 'label ' => 'External copy ' , #TODO: translation
137+ 'propertyPath ' => 'host ' ,
138+ 'render ' => function ($ value , Attachment $ context ) {
139+ if ($ context ->hasExternal ()) {
140+ return sprintf (
141+ '<a href="%s" class="link-external">%s</a> ' ,
142+ htmlspecialchars ((string ) $ context ->getExternalPath ()),
143+ htmlspecialchars ($ value )
144+ );
145+ }
146+
147+ return $ value ;
148+ }
142149 ]);
143150
144151 $ dataTable ->add ('filesize ' , TextColumn::class, [
145152 'label ' => $ this ->translator ->trans ('attachment.table.filesize ' ),
146153 'render ' => function ($ value , Attachment $ context ) {
147- if ($ context ->isExternal ()) {
154+ if (! $ context ->hasInternal ()) {
148155 return sprintf (
149156 '<span class="badge bg-primary">
150157 <i class="fas fa-globe fa-fw"></i>%s
@@ -153,8 +160,13 @@ public function configure(DataTable $dataTable, array $options): void
153160 );
154161 }
155162
156- if ($ this ->attachmentHelper ->isFileExisting ($ context )) {
157- return $ this ->attachmentHelper ->getHumanFileSize ($ context );
163+ if ($ this ->attachmentHelper ->isInternalFileExisting ($ context )) {
164+ return sprintf (
165+ '<span class="badge bg-secondary">
166+ <i class="fas fa-hdd fa-fw"></i> %s
167+ </span> ' ,
168+ $ this ->attachmentHelper ->getHumanFileSize ($ context )
169+ );
158170 }
159171
160172 return sprintf (
0 commit comments