diff --git a/locales/default.pot b/locales/default.pot index 30510c4c3..d6183354f 100644 --- a/locales/default.pot +++ b/locales/default.pot @@ -1,7 +1,7 @@ msgid "" msgstr "" "Project-Id-Version: BEdita 4 \n" -"POT-Creation-Date: 2024-12-02 16:33:07 \n" +"POT-Creation-Date: 2024-12-19 11:17:51 \n" "MIME-Version: 1.0 \n" "Content-Transfer-Encoding: 8bit \n" "Language-Team: BEdita I18N & I10N Team \n" @@ -112,9 +112,6 @@ msgstr "" msgid "Cannot create abstract objects or objects without schema" msgstr "" -msgid "Cannot produce a thumbnail for this file" -msgstr "" - msgid "Captions" msgstr "" @@ -610,9 +607,6 @@ msgstr "" msgid "Open File" msgstr "" -msgid "Open image" -msgstr "" - msgid "Open module" msgstr "" @@ -808,9 +802,6 @@ msgstr "" msgid "Size" msgstr "" -msgid "Sorry, your browser does not support embedded {0} element" -msgstr "" - msgid "State Name" msgstr "" @@ -844,9 +835,6 @@ msgstr "" msgid "Temporary folder missing" msgstr "" -msgid "The thumbnail is not available" -msgstr "" - msgid "There were errors creating the thumbnail(s)" msgstr "" @@ -856,9 +844,6 @@ msgstr "" msgid "Thumb not ready: coming soon" msgstr "" -msgid "Thumbnail is not ready" -msgstr "" - msgid "Title" msgstr "" @@ -970,9 +955,6 @@ msgstr "" msgid "View file" msgstr "" -msgid "View original" -msgstr "" - msgid "Website" msgstr "" @@ -1659,6 +1641,29 @@ msgstr "" msgid "Valid" msgstr "" +msgid "" +"Sorry, your browser does not support embedded audio element" +msgstr "" + +msgid "Cannot produce a thumbnail for this file" +msgstr "" + +msgid "The thumbnail is not available" +msgstr "" + +msgid "The thumbnail is not ready" +msgstr "" + +msgid "Open image" +msgstr "" + +msgid "" +"Sorry, your browser does not support embedded video element" +msgstr "" + +msgid "View original" +msgstr "" + msgid "Password" msgstr "" diff --git a/locales/en_US/default.po b/locales/en_US/default.po index 49ff32e5a..4ea0e62d7 100644 --- a/locales/en_US/default.po +++ b/locales/en_US/default.po @@ -1,7 +1,7 @@ msgid "" msgstr "" "Project-Id-Version: BEdita Manager \n" -"POT-Creation-Date: 2024-12-02 16:33:07 \n" +"POT-Creation-Date: 2024-12-19 11:17:51 \n" "PO-Revision-Date: \n" "Last-Translator: \n" "Language-Team: BEdita I18N & I10N Team \n" @@ -115,9 +115,6 @@ msgstr "" msgid "Cannot create abstract objects or objects without schema" msgstr "" -msgid "Cannot produce a thumbnail for this file" -msgstr "" - msgid "Captions" msgstr "" @@ -613,9 +610,6 @@ msgstr "" msgid "Open File" msgstr "" -msgid "Open image" -msgstr "" - msgid "Open module" msgstr "" @@ -811,9 +805,6 @@ msgstr "" msgid "Size" msgstr "" -msgid "Sorry, your browser does not support embedded {0} element" -msgstr "" - msgid "State Name" msgstr "" @@ -847,9 +838,6 @@ msgstr "" msgid "Temporary folder missing" msgstr "" -msgid "The thumbnail is not available" -msgstr "" - msgid "There were errors creating the thumbnail(s)" msgstr "" @@ -859,9 +847,6 @@ msgstr "" msgid "Thumb not ready: coming soon" msgstr "" -msgid "Thumbnail is not ready" -msgstr "" - msgid "Title" msgstr "" @@ -973,9 +958,6 @@ msgstr "" msgid "View file" msgstr "" -msgid "View original" -msgstr "" - msgid "Website" msgstr "" @@ -1662,6 +1644,29 @@ msgstr "" msgid "Valid" msgstr "" +msgid "" +"Sorry, your browser does not support embedded audio element" +msgstr "" + +msgid "Cannot produce a thumbnail for this file" +msgstr "" + +msgid "The thumbnail is not available" +msgstr "" + +msgid "The thumbnail is not ready" +msgstr "" + +msgid "Open image" +msgstr "" + +msgid "" +"Sorry, your browser does not support embedded video element" +msgstr "" + +msgid "View original" +msgstr "" + msgid "Password" msgstr "" diff --git a/locales/it_IT/default.po b/locales/it_IT/default.po index 1d717bab9..ee36ce5d2 100644 --- a/locales/it_IT/default.po +++ b/locales/it_IT/default.po @@ -1,7 +1,7 @@ msgid "" msgstr "" "Project-Id-Version: BEdita Manager \n" -"POT-Creation-Date: 2024-12-02 16:33:07 \n" +"POT-Creation-Date: 2024-12-19 11:17:51 \n" "PO-Revision-Date: \n" "Last-Translator: \n" "Language-Team: BEdita I18N & I10N Team \n" @@ -117,9 +117,6 @@ msgstr "Calendario" msgid "Cannot create abstract objects or objects without schema" msgstr "Impossibile creare oggetti astratti o oggetti senza schema" -msgid "Cannot produce a thumbnail for this file" -msgstr "Impossibile produrre una miniatura per questo file" - msgid "Captions" msgstr "Sottotitoli" @@ -616,9 +613,6 @@ msgstr "Apri" msgid "Open File" msgstr "Apri File" -msgid "Open image" -msgstr "Apri immagine" - msgid "Open module" msgstr "Apri modulo" @@ -816,9 +810,6 @@ msgstr "Accedi con {0}" msgid "Size" msgstr "Dimensione" -msgid "Sorry, your browser does not support embedded {0} element" -msgstr "Spiacenti, il tuo browser non supporta l'elemento {0} incorporato" - msgid "State Name" msgstr "Provincia" @@ -853,9 +844,6 @@ msgstr "Tag" msgid "Temporary folder missing" msgstr "Cartella temporanea mancante" -msgid "The thumbnail is not available" -msgstr "La miniatura non è disponibile" - msgid "There were errors creating the thumbnail(s)" msgstr "È avvenuto un errore nella creazione delle miniature" @@ -865,9 +853,6 @@ msgstr "Miniatura non disponibile" msgid "Thumb not ready: coming soon" msgstr "Miniatura non pronta: in lavorazione" -msgid "Thumbnail is not ready" -msgstr "La miniatura non è pronta" - msgid "Title" msgstr "Titolo" @@ -979,9 +964,6 @@ msgstr "Video" msgid "View file" msgstr "Vedi file" -msgid "View original" -msgstr "Vedi originale" - msgid "Website" msgstr "Sito Web" @@ -1679,6 +1661,31 @@ msgstr "Parametri" msgid "Valid" msgstr "Valido" +msgid "" +"Sorry, your browser does not support embedded audio element" +msgstr "" +"Spiacenti, il tuo browser non supporta l'elemento audio incorporato" + +msgid "Cannot produce a thumbnail for this file" +msgstr "Impossibile produrre una miniatura per questo file" + +msgid "The thumbnail is not available" +msgstr "La miniatura non è disponibile" + +msgid "The thumbnail is not ready" +msgstr "La miniatura non è pronta" + +msgid "Open image" +msgstr "Apri immagine" + +msgid "" +"Sorry, your browser does not support embedded video element" +msgstr "" +"Spiacenti, il tuo browser non supporta l'elemento video incorporato" + +msgid "View original" +msgstr "Vedi originale" + msgid "Password" msgstr "Password" diff --git a/resources/js/app/app.js b/resources/js/app/app.js index 6baa06153..e3c227423 100644 --- a/resources/js/app/app.js +++ b/resources/js/app/app.js @@ -92,6 +92,7 @@ const _vueInstance = new Vue({ PlaceholderList: () => import(/* webpackChunkName: "placeholder-list" */'app/components/placeholder-list/placeholder-list'), BarChart:() => import(/* webpackChunkName: "bar-chart" */'app/components/charts/bar-chart'), SortRelated: () => import(/* webpackChunkName: "sort-related" */'app/components/sort-related/sort-related'), + MediaItem: () => import(/* webpackChunkName: "media-item" */'app/components/media-item/media-item'), AppIcon, }, diff --git a/resources/js/app/components/media-item/media-item.vue b/resources/js/app/components/media-item/media-item.vue new file mode 100644 index 000000000..7cf868560 --- /dev/null +++ b/resources/js/app/components/media-item/media-item.vue @@ -0,0 +1,153 @@ + + diff --git a/resources/js/app/components/property-view/property-view.js b/resources/js/app/components/property-view/property-view.js index 515a7f5f3..af688f937 100644 --- a/resources/js/app/components/property-view/property-view.js +++ b/resources/js/app/components/property-view/property-view.js @@ -47,6 +47,7 @@ export default { ObjectCaptions: () => import(/* webpackChunkName: "object-captions" */'app/components/object-captions/object-captions'), ObjectCategories: () => import(/* webpackChunkName: "object-categories" */'app/components/object-categories/object-categories'), PlaceholderList: () => import(/* webpackChunkName: "placeholder-list" */'app/components/placeholder-list/placeholder-list'), + MediaItem: () => import(/* webpackChunkName: "media-item" */'app/components/media-item/media-item'), }, props: { diff --git a/src/Controller/Component/PropertiesComponent.php b/src/Controller/Component/PropertiesComponent.php index 72ed34ecd..5edab109b 100644 --- a/src/Controller/Component/PropertiesComponent.php +++ b/src/Controller/Component/PropertiesComponent.php @@ -45,6 +45,13 @@ class PropertiesComponent extends Component 'title', 'description', ], + 'media' => [ + 'provider', + 'provider_uid', + 'provider_url', + 'provider_thumbnail', + 'provider_extra', + ], // publishing related 'publish' => [ 'uname', diff --git a/src/View/Helper/LayoutHelper.php b/src/View/Helper/LayoutHelper.php index 9ba4cf096..03d640b4e 100644 --- a/src/View/Helper/LayoutHelper.php +++ b/src/View/Helper/LayoutHelper.php @@ -426,4 +426,23 @@ public function trashLink(?string $type): string ['class' => $classes, 'title' => $title, 'escape' => false] ); } + + /** + * Return properties group for given property + * + * @param string $needle The property to search + * @return ?string + */ + public function propertyGroup(string $needle): ?string + { + $properties = (array)$this->getView()->get('properties'); + foreach ($properties as $group => $props) { + $keys = array_keys($props); + if (in_array($needle, $keys)) { + return $group; + } + } + + return null; + } } diff --git a/templates/Element/Form/captions.twig b/templates/Element/Form/captions.twig index 9c9bf0d9c..787f62984 100644 --- a/templates/Element/Form/captions.twig +++ b/templates/Element/Form/captions.twig @@ -1,3 +1,4 @@ +{% if object.id %} {% if schema.properties.captions %} {% set captions = object.attributes.captions %} @@ -24,3 +25,4 @@ {% endif %} +{% endif %} diff --git a/templates/Element/Form/media.twig b/templates/Element/Form/media.twig index 826780ce5..558500154 100644 --- a/templates/Element/Form/media.twig +++ b/templates/Element/Form/media.twig @@ -11,61 +11,74 @@ {% if object.attributes.provider_extra.html %} {% set height = object.attributes.provider_extra.height|default(1) %} {% set width = object.attributes.provider_extra.width|default(1) %} -
{{ object.attributes.provider_extra.html|raw }}
+ {% if object.attributes.provider and object.attributes.provider_url %} +
+ {% if Layout.propertyGroup('provider_url') == 'media' %} +
+ {{ Form.hidden('upload_behavior', {value: 'embed'})|raw }} + {{ Property.control('remote_url', {value: object.attributes.provider_url})|raw }} +
+ {% endif %} + {% if Layout.propertyGroup('provider') == 'media' %} +
+ {{ Property.control('provider', object.attributes.provider, {'disabled': true})|raw }} +
+ {% endif %} + {% if Layout.propertyGroup('provider_url') == 'media' %} +
+ {{ Property.control('provider_url', object.attributes.provider_url, {'disabled': true})|raw }} +
+ {% endif %} + {% if Layout.propertyGroup('provider_uid') == 'media' %} +
+ {{ Property.control('provider_uid', object.attributes.provider_uid, {'disabled': true})|raw }} +
+ {% endif %} + {% if Layout.propertyGroup('provider_thumbnail') == 'media' %} +
+ {{ Property.control('provider_thumbnail', object.attributes.provider_thumbnail, {'disabled': true})|raw }} +
+ {% endif %} + {% if Layout.propertyGroup('provider_extra') == 'media' %} +
+ {{ Property.control('provider_extra', object.attributes.provider_extra, {'disabled': true, 'readonly': true})|raw }} +
+ {% endif %} +
+ {% endif %} {% else %} {# Show first stream #} {% set stream = streams|first %} - {% set thumb = null %} + {% set thumb = '' %} + {% if object.type == 'images' %} + {% set thumb = stream.attributes.mime_type == 'image/svg+xml' ? stream.meta.url : Thumb.getUrl(object) %} + {% endif %} + {% set thumbCodes = { + notAcceptable: constant('BEdita\\WebTools\\View\\Helper\\ThumbHelper::NOT_ACCEPTABLE'), + notAvailable: constant('BEdita\\WebTools\\View\\Helper\\ThumbHelper::NOT_AVAILABLE'), + notReady: constant('BEdita\\WebTools\\View\\Helper\\ThumbHelper::NOT_READY'), + noUrl: constant('BEdita\\WebTools\\View\\Helper\\ThumbHelper::NO_URL'), + } %} {# the stream #}
- {# thumb #} - {% if object.type == 'images' %} - {% if stream.attributes.mime_type == 'image/svg+xml' %} - {% set thumb = stream.meta.url %} - {% else %} - {% set thumb = Thumb.getUrl(object) %} - {% endif %} - {% if thumb == constant('BEdita\\WebTools\\View\\Helper\\ThumbHelper::NOT_ACCEPTABLE') %} -

{{ __('Cannot produce a thumbnail for this file') }}

- {% elseif thumb == constant('BEdita\\WebTools\\View\\Helper\\ThumbHelper::NOT_AVAILABLE') %} -

{{ __('The thumbnail is not available') }}

-

- - {{ __('View original') }} - -

- {% elseif thumb == constant('BEdita\\WebTools\\View\\Helper\\ThumbHelper::NOT_READY') %} -

{{ __('Thumbnail is not ready') }}

- {% elseif thumb == constant('BEdita\\WebTools\\View\\Helper\\ThumbHelper::NO_URL') %} -

- - {{ __('View original') }} - -

- {% else %} -
- - - -
- {% endif %} - {% elseif object.type == 'videos' %} - - {% elseif object.type == 'audio' %} - - {% endif %} + +
{# Stream properties #} diff --git a/templates/Element/Form/other_properties.twig b/templates/Element/Form/other_properties.twig index ca052f6e8..4c19eea1e 100644 --- a/templates/Element/Form/other_properties.twig +++ b/templates/Element/Form/other_properties.twig @@ -1,5 +1,5 @@ -{# Remaining properties groups: 'other' and custom groups not in 'core', '_keep', 'publish', 'advanced' #} -{% set otherProperties = Array.removeKeys(properties, ['core', '_keep', 'publish', 'advanced']) %} +{# Remaining properties groups: 'other' and custom groups not in 'core', '_keep', 'publish', 'advanced', 'media' #} +{% set otherProperties = Array.removeKeys(properties, ['core', '_keep', 'publish', 'advanced', 'media']) %} {% for group, props in otherProperties %} {% set customElement = Element.custom(group, 'group') %} diff --git a/tests/TestCase/Controller/Component/PropertiesComponentTest.php b/tests/TestCase/Controller/Component/PropertiesComponentTest.php index 1b30bf1f9..4eb0cba66 100644 --- a/tests/TestCase/Controller/Component/PropertiesComponentTest.php +++ b/tests/TestCase/Controller/Component/PropertiesComponentTest.php @@ -259,6 +259,7 @@ public function viewGroupsProvider(): array 'core' => [ 'title' => 'A', ], + 'media' => [], 'publish' => [ 'uname' => 'an-object', 'status' => 'on', @@ -284,6 +285,7 @@ public function viewGroupsProvider(): array 'core' => [ 'something' => '', ], + 'media' => [], 'publish' => [ 'uname' => 'test', 'status' => 'on', @@ -314,6 +316,7 @@ public function viewGroupsProvider(): array 'core' => [ 'title' => 'A', ], + 'media' => [], 'advanced' => [ 'json_field' => 'json', ], @@ -353,6 +356,7 @@ public function viewGroupsProvider(): array 'title' => 'A', 'extra' => [], ], + 'media' => [], 'publish' => [ 'uname' => 'test', 'status' => 'on', @@ -389,6 +393,7 @@ public function viewGroupsProvider(): array 'core' => [ 'title' => 'A', ], + 'media' => [], 'publish' => [ 'status' => 'on', ], @@ -428,6 +433,7 @@ public function viewGroupsProvider(): array 'title' => 'Example', 'body' => 'some text', ], + 'media' => [], 'publish' => [ ], 'advanced' => [ @@ -454,6 +460,7 @@ public function viewGroupsProvider(): array 'core' => [ 'title' => 'Example', ], + 'media' => [], 'publish' => [ ], 'advanced' => [ diff --git a/tests/TestCase/View/Helper/LayoutHelperTest.php b/tests/TestCase/View/Helper/LayoutHelperTest.php index 1eea1fddc..cce86cb01 100644 --- a/tests/TestCase/View/Helper/LayoutHelperTest.php +++ b/tests/TestCase/View/Helper/LayoutHelperTest.php @@ -887,4 +887,27 @@ public function testShowCounter(): void static::assertTrue($actual); Configure::delete('UI.modules.counters'); } + + /** + * Test `propertyGroup` method. + * + * @return void + * @covers ::propertyGroup() + */ + public function testPropertyGroup(): void + { + $view = new View(); + $layout = new LayoutHelper($view); + $view->set('properties', [ + 'media' => [ + 'provider' => '', + 'provider_uid' => '', + ], + ]); + $actual = $layout->propertyGroup('whatever'); + static::assertNull($actual); + $expected = 'media'; + $actual = $layout->propertyGroup('provider_uid'); + static::assertEquals($expected, $actual); + } }