mediatheque

This commit is contained in:
armansansd
2023-07-18 10:47:46 +01:00
commit 4b7c97a02e
3044 changed files with 544089 additions and 0 deletions
@@ -0,0 +1,30 @@
{%- set user = admin.user -%}
{%- set route = controller.route -%}
{%- set type = directory.config('admin.template') ?? target -%}
{# Set action from ?preview=1 #}
{%- if key and uri.currentUri().queryParam('preview') %}
{% set action = 'preview' %}
{% endif -%}
{%- set template -%}
{%- if action == 'add' -%}
edit
{%- elseif action == 'delete' -%}
list
{%- else -%}
{{- action ?: task ?: 'types' -}}
{%- endif -%}
{%- endset -%}
{%- set separator = config.system.param_sep -%}
{%- set view_config = directory.config('admin.views.' ~ template) ?? directory.config('admin.' ~ template) ?? [] -%}
{%- include target ? [
'flex-objects/types/' ~ type ~ '/' ~ template ~ '.html.twig',
'flex-objects/types/default/' ~ template ~ '.html.twig',
'flex-objects/layouts/404.html.twig'
] : [
'flex-objects/types/default/' ~ template ~ '.html.twig',
'flex-objects/layouts/404.html.twig'
] -%}
@@ -0,0 +1 @@
{{- admin.json_response|json_encode|raw -}}
@@ -0,0 +1 @@
{{ 'PLUGIN_FLEX_OBJECTS.ERROR.LAYOUT_NOT_FOUND'|tu(template, null) }}
@@ -0,0 +1,3 @@
<a id="titlebar-button-add" class="button" href="{{ route.withGravParam('', 'add').toString(true) }}">
<i class="fa fa-plus"></i> {{ 'PLUGIN_ADMIN.ADD'|tu }}
</a>
@@ -0,0 +1,3 @@
<a id="titlebar-button-back" class="button" href="{{ back_url }}">
<i class="fa fa-reply"></i> {{ "PLUGIN_ADMIN.BACK"|tu }}
</a>
@@ -0,0 +1,7 @@
{%- set authorize = directory.config('admin.views.configure.authorize') ?? directory.config('admin.configure.authorize') ?? 'admin.super' %}
{%- if configure_url and user.authorize(authorize) %}
<a id="titlebar-button-configure" class="button" href="{{ configure_url }}">
<i class="fa fa-cog"></i> {{ 'PLUGIN_ADMIN.CONFIGURATION'|tu }}
</a>
{% endif %}
@@ -0,0 +1,3 @@
<a id="titlebar-button-delete" href="#delete" data-remodal-target="delete" data-delete-url="{{ uri.addNonce(route.withoutParams().withGravParam('task', 'delete').getUri(), 'admin-form', 'admin-nonce') }}" class="button danger">
<i class="fa fa-fw fa-trash-o"></i> {{ 'PLUGIN_ADMIN.DELETE'|tu }}
</a>
@@ -0,0 +1,3 @@
<a id="titlebar-button-export-csv" class="button" href="{{ route.withGravParam('', 'csv').toString(true) }}">
<i class="fa fa-download"></i> {{ 'PLUGIN_FLEX_OBJECTS.CSV'|tu }}
</a>
@@ -0,0 +1,21 @@
{% if export.options %}
<div id="titlebar-button-export" class="button-group">
<button id="titlebar-button-export" type="button" class="button dropdown-toggle" data-toggle="dropdown">
<i class="fa fa-download"></i> {{ 'PLUGIN_ADMIN.EXPORT'|tu }} <i class="fa fa-caret-down"></i>
</button>
<ul class="dropdown-menu lang-switcher">
{% for type,option in export.options %}
<li>
<a id="titlebar-button-export" class="button" href="{{ route.withGravParam('', 'export').withQueryParam('type', type).toString(true) }}">
{{ option.title|tu }}
</a>
</li>
{% endfor %}
</ul>
</div>
{% else %}
<a id="titlebar-button-export" class="button" href="{{ route.withGravParam('', 'export').toString(true) }}">
<i class="fa fa-download"></i> {{ export.title ?? (export.formatter.class ? 'PLUGIN_ADMIN.EXPORT'|tu : 'PLUGIN_FLEX_OBJECTS.CSV'|tu) }}
</a>
{% endif %}
@@ -0,0 +1,18 @@
<div id="titlebar-languages" class="button-group">
<button type="button" class="button disabled">
<i class="fa fa-flag-o"></i>
{{ all_languages[language] ?? language }}
</button>
{% if admin_languages|length > (language in admin_languages)|int %}
<button type="button" class="button dropdown-toggle" data-toggle="dropdown">
<i class="fa fa-caret-down"></i>
</button>
<ul class="dropdown-menu language-switcher">
{% for lang_code in admin_languages %}
{% if lang_code != language %}
<li><a href="{{ admin_route(route.getRoute(1), lang_code) }}">{{ all_languages[lang_code] ?? lang_code }}</a></li>
{% endif %}
{% endfor %}
</ul>
{% endif %}
</div>
@@ -0,0 +1,5 @@
{% if preview_url %}
<a id="titlebar-button-preview-open" href="{{ preview_url }}" class="button" target="_blank">
<i class="fa fa-external-link"></i> {{ "PLUGIN_ADMIN.OPEN_NEW_TAB"|tu }}
</a>
{% endif %}
@@ -0,0 +1,3 @@
<a id="titlebar-button-preview" href="{{ route.withGravParam('', 'preview').toString(true) }}" class="button">
<i class="fa fa-eye"></i> {{ "PLUGIN_ADMIN.PREVIEW"|tu }}
</a>
@@ -0,0 +1,4 @@
{% set task = task ?? 'save' %}
<button id="titlebar-button-save" class="button" type="submit" name="task" value="{{ task }}" form="blueprints" data-flex-safe-action>
<i class="fa fa-check"></i> {{ "PLUGIN_ADMIN.SAVE"|tu }}
</button>
@@ -0,0 +1,103 @@
{% extends 'partials/base.html.twig' %}
{% use 'flex-objects/types/default/titlebar/configure.html.twig' %}
{% set name = view_config['form'] %}
{% set form = form ?? directory.directoryForm(name) %}
{# Allowed actions #}
{% set can_save = can_save ?? user.authorize(view_config['authorize'] ?? 'admin.super') %}
{# These variables can be overridden from the main template file #}
{% set allowed = allowed ?? (directory and form and can_save) %}
{% set back_route = back_route ?? ('/' ~ route.getRoute(1)) %}
{% set title_icon = title_icon ?? view_config['icon'] ?? 'fa-cog' %}
{% set title -%}
{%- set title_config = view_config['title'] ?? null -%}
{%- if title_config.template -%}
{{- include(template_from_string(title_config.template, 'configure title template')) -}}
{%- else -%}
{{- directory.title|tu }} - {{ 'PLUGIN_ADMIN.CONFIGURATION'|tu -}}
{% endif %}
{%- endset %}
{% macro spanToggle(input, length) %}
{{ (repeat('&nbsp;&nbsp;', (length - input|length) / 2) ~ input ~ repeat('&nbsp;&nbsp;', (length - input|length) / 2))|raw }}
{% endmacro %}
{% import _self as macro %}
{% block body %}
{% set back_url = back_url ?? admin_route(back_route) %}
{{ parent() }}
{% endblock body %}
{% block content_top %}
{% if allowed and user.authorize('admin.super') %}
{% set save_location = directory.getDirectoryConfigUri(name) %}
<div class="alert notice">{{ "PLUGIN_ADMIN.SAVE_LOCATION"|tu }}: <b>{{ url(save_location, false, true)|trim('/') }}</b></div>
{% endif %}
{% endblock %}
{% block topbar %}
{% if user.authorize('admin.super') %}
<form id="admin-mode-toggle">
{% set normalText = 'PLUGIN_ADMIN.NORMAL'|tu %}
{% set expertText = 'PLUGIN_ADMIN.EXPERT'|tu %}
{% set maxLen = max([normalText|length, expertText|length]) %}
{% set normalText = macro.spanToggle(normalText, maxLen) %}
{% set expertText = macro.spanToggle(expertText, maxLen) %}
<div class="switch-toggle switch-grav">
<input type="radio" value="normal" data-leave-url="{{ route.withGravParam('mode', 'normal').toString(true) }}" id="normal" name="mode-switch" class="highlight" {% if admin.session.expert == '0' %} checked="checked"{% endif %}>
<label for="normal">{{ normalText|raw }}</label>
<input type="radio" value="expert" data-leave-url="{{ route.withGravParam('mode', 'expert').toString(true) }}" id="expert" name="mode-switch" class="highlight" {% if admin.session.expert == '1' %} checked="checked"{% endif %}>
<label for="expert">{{ expertText|raw }}</label>
<a></a>
</div>
</form>
{% endif %}
{% endblock topbar %}
{% block content %}
{{ parent() }}
{% if allowed %}
<div class="clear directory admin-flex-config">
<div class="admin-form-wrapper">
{# TODO: RAW MODE
<div id="admin-topbar">
{{ block('topbar') }}
</div>
#}
{% block edit %}
{% include 'partials/blueprints.html.twig' with { form: form, data: form.data } %}
{% endblock %}
</div>
</div>
{% include 'partials/modal-changes-detected.html.twig' %}
{% else %}
{% do page.modifyHeader('http_response_code', 404) %}
<div class="error-block">
<h1>{{ 'PLUGIN_ADMIN.ERROR'|tu }} 404</h1>
<div class="padding">
<p>
{{ 'PLUGIN_FLEX_OBJECTS.ERROR.PAGE_NOT_EXIST'|tu }}
</p>
</div>
</div>
{% endif %}
{% endblock %}
{% block bottom %}
{{ parent() }}
{# TODO: RAW MODE
<script>
$('.admin-flex-config .form-tabs .tabs-nav').css('margin-right', ($('#admin-topbar').width() + 20) + 'px');
</script>
#}
{% endblock bottom %}
@@ -0,0 +1,121 @@
{% extends 'partials/base.html.twig' %}
{% use 'flex-objects/types/default/titlebar/edit.html.twig' %}
{# Avoid defining form and object twice: object should always come from the form! #}
{% if form is not defined %}
{% set form = object.form %}
{% set object = form.object %}
{% endif %}
{# Allowed actions #}
{% set can_list = can_list ?? directory.isAuthorized('list', 'admin', user) %}
{% set can_read = can_read ?? (object.exists ? object.isAuthorized('read', 'admin', user) : directory.isAuthorized('create', 'admin', user)) %}
{% set can_create = can_create ?? object.isAuthorized('create', 'admin', user) %}
{% set can_save = can_save ?? (object.exists ? object.isAuthorized('update', 'admin', user) : directory.isAuthorized('create', 'admin', user)) %}
{% set can_delete = can_delete ?? (object.exists and object.isAuthorized('delete', 'admin', user)) %}
{% set can_translate = can_translate ?? (admin.multilang and object.hasFlexFeature('flex-translate')) %}
{% set can_preview = can_preview ?? (can_read and object.exists and (directory.config('admin.views.preview.enabled') ?? directory.config('admin.preview.enabled', false))) %}
{# Translations #}
{% if can_translate %}
{% set translate_include_default = translate_include_default ?? grav.config.get('system.languages.include_default_lang_file_extension', true) %}
{% set all_languages = grav.admin.siteLanguages %}
{% set admin_languages = admin.languages_enabled %}
{% set default_language = grav.language.default %}
{% set object_language = object.language %}
{% set language = controller.language %}
{% set has_translation = object.hasTranslation(language, false) %}
{#
{% if translate_include_default %}
{% set all_languages = all_languages|merge({'': 'Default'}) %}
{% set admin_languages = admin_languages|merge({'': ''}) %}
{% set object_languages = object.languages(true) %}
{% else %}
#}
{% set language = language ?: default_language %}
{% set object_language = object_language ?: default_language %}
{% set object_languages = object.languages(false) %}
{# endif #}
{% endif %}
{# These variables can be overridden from the main template file #}
{% set allowed = allowed ?? (directory and (object.exists and (can_read or can_save)) or (action == 'add' and can_read)) %}
{% set back_route = back_route ?? ('/' ~ (action != 'edit' and not key ? route.getRoute(1, not can_list ? -1 : null) : route.getRoute(1, not can_list ? -2 : -1))) %}
{% set title_icon = title_icon ?? view_config['icon'] ?? directory.config.admin.menu.list.icon ?? 'fa-file-text-o' %}
{% set title -%}
{%- set title_config = view_config['title'] -%}
{%- if title_config.template -%}
{{- include(template_from_string(title_config.template, 'edit title template')) -}}
{%- else -%}
{{- title ?? object.form.getValue('title') ?? object.title ?? key -}}
{% endif %}
{%- endset %}
{% block body %}
{% set back_url = back_url ?? admin_route(back_route) %}
{% set id = key %}
{% set blueprint = blueprint ?? form.blueprint %}
{{ parent() }}
{% endblock body %}
{% block content_top %}
{% if allowed and user.authorize('admin.super') %}
{% if directory and object or action == 'add' %}
{% set save_location = object.getStorageFolder() ?? directory.getStorageFolder() %}
<div class="alert notice">{{ "PLUGIN_ADMIN.SAVE_LOCATION"|tu }}: <b>{{ url(save_location, false, true)|trim('/') }} {{ not object.exists ? '[' ~ 'PLUGIN_FLEX_OBJECTS.NEW'|tu|upper ~ ']' }}</b></div>
{% endif %}
{% endif %}
{% if object.exists and form.flash.exists %}
<div class="alert secondary-accent">
<i class="fa fa-lightbulb-o"></i> {{ 'PLUGIN_FLEX_OBJECTS.STATE.EDITING_DRAFT'|tu }} <button class="button button-link" type="submit" name="task" value="reset" form="blueprints">{{ "PLUGIN_ADMIN.RESET"|tu }}</button>
</div>
{% endif %}
{% endblock %}
{% block content %}
{% if allowed %}
<div class="clear directory admin-{{ target }}">
<div class="admin-form-wrapper">
<div id="admin-topbar">
{% block topbar %}{% endblock %}
</div>
{% block edit %}
{% include 'partials/blueprints.html.twig' with { form: form, context: object, data: object } %}
{% endblock %}
</div>
</div>
{% include 'partials/modal-changes-detected.html.twig' %}
{% if can_delete %}
{% include ['flex-objects/types/' ~ target ~ '/modals/remove.html.twig', 'flex-objects/types/default/modals/remove.html.twig'] with { name: target } %}
{% endif %}
{% elseif (object.exists) %}
{% do page.modifyHeader('http_response_code', 403) %}
<div class="error-block">
<h1>{{ 'PLUGIN_ADMIN.ERROR'|tu }} 403</h1>
<div class="padding">
<p>
{{ 'PLUGIN_FLEX_OBJECTS.ERROR.PAGE_FORBIDDEN'|tu }}
</p>
</div>
</div>
{% else %}
{% do page.modifyHeader('http_response_code', 404) %}
<div class="error-block">
<h1>{{ 'PLUGIN_ADMIN.ERROR'|tu }} 404</h1>
<div class="padding">
<p>
{{ 'PLUGIN_FLEX_OBJECTS.ERROR.PAGE_NOT_EXIST'|tu }}
</p>
</div>
</div>
{% endif %}
{% endblock %}
@@ -0,0 +1,98 @@
{% extends 'partials/base.html.twig' %}
{% use 'flex-objects/types/default/titlebar/list.html.twig' %}
{# Allowed actions #}
{% set export = directory.config('admin.views.export') ?? directory.config('admin.export') ?? [] %}
{% set can_export = can_export ?? (export['enabled'] ?? export|array|count)|bool %}
{% set can_create = can_create ?? directory.isAuthorized('create', 'admin', user) %}
{% set can_translate = can_translate ?? (admin.multilang and directory.object.hasFlexFeature('flex-translate')) %}
{% set per_page = per_page ?? grav.uri.currentUri.queryParam('per_page') %}
{# Translations #}
{% if can_translate %}
{% set translate_include_default = translate_include_default ?? grav.config.get('system.languages.include_default_lang_file_extension', true) %}
{% set all_languages = grav.admin.siteLanguages %}
{% set admin_languages = admin.languages_enabled %}
{% set default_language = grav.language.default %}
{% set language = controller.language %}
{#
{% if translate_include_default %}
{% set all_languages = all_languages|merge({'': 'Default'}) %}
{% set admin_languages = admin_languages|merge({'': ''}) %}
{% else %}
#}
{% set language = language ?: default_language %}
{# endif #}
{% endif %}
{# These variables can be overridden from the main template file #}
{% set allowed = allowed ?? (directory and directory.isAuthorized('list', 'admin', user)) %}
{% set back_route = back_route ?? route.getRoute(1, -1) %}
{% set configure_path = directory.config('admin.router.actions.configure.path') %}
{% set configure_route = configure_route ?? (configure_path ? route.withRoute(admin_route(configure_path).toString(true)|trim('/')) : null) %}
{% set configure_route = configure_route ?? route.withGravParam('', 'configure').toString(true) %}
{% set title_icon = title_icon ?? view_config['icon'] ?? directory.config.admin.menu.list.icon ?? 'fa-file-text-o' %}
{% set title -%}
{%- set title_config = view_config['title'] ?? null -%}
{%- if title_config.template -%}
{{- include(template_from_string(title_config.template, 'configure title template')) -}}
{%- else -%}
{{- directory.title|tu -}}
{% endif %}
{%- endset %}
{% set schema = directory.blueprint.schema %}
{% do assets.addJs('plugin://flex-objects/js/flex-objects.js', { 'group': 'bottom', 'loading': 'defer' }) %}
{% block body %}
{% set collection = directory ? collection.isAuthorized('list', 'admin', user) %}
{% set directory_config = view_config['options'] ?? config.get('plugins.flex-objects.admin_list', { per_page: 15, order: { by: 'updated_timestamp', dir: 'desc' }}) %}
{% set per_page = max(1, per_page ?? directory_config.per_page) %}
{% set table = directory ? flex.dataTable(collection.flexDirectory(), { collection: collection, limit: per_page, sort: directory_config.order.by ~ '|' ~ directory_config.order.dir }) %}
{% set back_url = admin_route(back_route) %}
{% set configure_url = (directory.config('admin.views.configure.hidden') ?? directory.config('admin.configure.hidden', false)) is not same as(true) ? configure_route.toString(true) %}
{% set fields = table.getColumns() %}
{% set fields_count = fields ? count(fields) : 0 %}
{% set fields_width = 8 %}
{% set fields_set = 0 %}
{% set title_field = view_config['title'] %}
{% for key,options in fields %}
{% set fields_width = fields_width + options.width ?: 0 %}
{% set fields_set = fields_set + (options.width ? 1 : 0) %}
{% if not title_field and options.link == 'edit' %}
{% set title_field = key %}
{% endif %}
{% endfor %}
{{ parent() }}
{% endblock body %}
{% block content_top %}
{% if allowed and user.authorize('admin.super') %}
{% set save_location = directory.getStorageFolder() %}
<div class="alert notice">{{ "PLUGIN_ADMIN.SAVE_LOCATION"|tu }}: <b>{{ url(save_location, false, true)|trim('/') }}</b></div>
{% endif %}
{% endblock %}
{% block content %}
{% if allowed %}
{% block content_list %}
{% include ['flex-objects/types/' ~ target ~ '/list/list.html.twig', 'flex-objects/types/default/list/list.html.twig'] %}
{% endblock %}
{% else %}
{% do page.modifyHeader('http_response_code', 404) %}
<div class="error-block">
<h1>{{ 'PLUGIN_ADMIN.ERROR'|tu }} 404</h1>
<div class="padding">
<p>
{{ 'PLUGIN_FLEX_OBJECTS.ERROR.PAGE_NOT_EXIST'|tu }}
</p>
</div>
</div>
{% endif %}
{% endblock %}
@@ -0,0 +1,112 @@
{% block directory %}
<div id="directory">
{% if not fields %}
{% block no_list %}
<div class="no-entries">
<p>{{ 'PLUGIN_FLEX_OBJECTS.ERROR.BLUEPRINT_NO_LIST'|tu( target, null )|raw }}</p>
<ul>
<li>
{{ 'PLUGIN_FLEX_OBJECTS.ERROR.BLUEPRINT_NO_LIST_ADVISE'|tu }}
</li>
<li>
{{ 'PLUGIN_FLEX_OBJECTS.ERROR.BLUEPRINT_NO_LIST_TEMPLATE'|tu( target, null )|raw }}
</li>
</ul>
</div>
{% endblock %}
{% elseif not collection.count %}
{% block no_entries %}
<div class="no-entries">
{% if directory.isAuthorized('create', 'admin', user) %}
{% set createLink = admin_route(flex.adminRoute(collection, {action: 'add'})) %}
{{ 'PLUGIN_FLEX_OBJECTS.ERROR.LIST_EMPTY_ADD'|tu(createLink, null)|raw }}
{% else %}
{{ 'PLUGIN_FLEX_OBJECTS.ERROR.LIST_EMPTY'|tu }}
{% endif %}
</div>
{% endblock %}
{% else %}
{% block entries %}
{% set per_page = per_page ?? directory_config.per_page %}
{% set tableFields = [] %}
{% set searchFields = [] %}
{% for key, options in fields %}
{% set name = key %}
{% set sortField = options.sort.field ?? key %}
{% set title = (options.field.label ?? schema.get(options.alias ?? key).label)|tu %}
{% set width = options.width ?: ((100-fields_width) / ((fields_count-fields_set) ?: 1))|round(3) %}
{% set title_class = options.title_class ?: '' %}
{% set data_class = options.data_class ?: '' %}
{# Vuetable doesn't like field names with `.` in them, so we convert name and sortField to `_` #}
{% set tableFields = tableFields|merge([
{
name: name|replace({'.': '_'}),
sortField: sortField,
title: title ?? 'N/A',
width: width ~ '%',
titleClass: title_class,
dataClass: data_class
}
]) %}
{# FIXME: Search fields should be passed and individually customizable, right now defaulting to all fields selected #}
{% set searchFields = searchFields|merge([key|replace({'.': '_'})]) %}
{% endfor %}
{% set tableFields = tableFields|merge([{ name: '_actions_', title: "PLUGIN_FLEX_OBJECTS.ACTION.ACTIONS"|tu, titleClass: 'right' }]) %}
{% set list = table.jsonSerialize %}
<div
id="flex-objects-list"
data-initial-store="{{
{
data: list,
api: grav.uri.currentRoute().withExtension('json').uri()|string,
perPage: per_page,
fields: tableFields,
searchFields: searchFields,
sortOrder: [{ field: directory_config.order.by, direction: directory_config.order.dir }],
searchPlaceholder: "PLUGIN_ADMIN.RESOURCE_FILTER"|tu,
paginationInfo: "PLUGIN_FLEX_OBJECTS.LIST_INFO"|tu,
emptyResult: "PLUGIN_FLEX_OBJECTS.EMPTY_RESULT"|tu
}|json_encode|e('html_attr')
}}">
<svg viewBox="0 0 1060 {{ 31 * (min(per_page, list.data|count) + 2) }}">
{% for i in 0..((min(per_page, list.data|count) + 3) - 1) %}
<rect clip-path="url(#clip-path-{{ i }})" x="0" y="0" width="1060" height="{{ 31 * per_page }}" style="fill: url(#linear-gradient-{{ i }})"></rect>
<defs>
<clipPath id="clip-path-{{ i }}">
<rect x="13" y="{{ 31 * i + 10 }}" rx="6" ry="6" width="{{ 200 * random([0.7, 0.8, 0.9, 1]) }}" height="12"></rect>
<rect x="533" y="{{ 31 * i + 10 }}" rx="6" ry="6" width="{{ 63 * random([0.7, 0.8, 0.9, 1]) }}" height="12"></rect>
<rect x="653" y="{{ 31 * i + 10 }}" rx="6" ry="6" width="{{ 78 * random([0.7, 0.8, 0.9, 1]) }}" height="12"></rect>
<rect x="755" y="{{ 31 * i + 10 }}" rx="6" ry="6" width="{{ 117 * random([0.7, 0.8, 0.9, 1]) }}" height="12"></rect>
<rect x="938" y="{{ 31 * i + 10 }}" rx="6" ry="6" width="{{ 83 * random([0.7, 0.8, 0.9, 1]) }}" height="12"></rect>
<rect x="0" y="{{ 31 * i }}" rx="6" ry="6" width="1060" height=".3"></rect>
</clipPath>
<linearGradient id="linear-gradient-{{ i }}">
<stop offset="-0.60016" stop-color="#d9d9d9" stop-opacity="1">
<animate attributeName="offset" values="-3; 1" dur="2s" repeatCount="indefinite"></animate>
</stop>
<stop offset="0.39984" stop-color="#ecebeb" stop-opacity="1">
<animate attributeName="offset" values="-2; 2" dur="2s" repeatCount="indefinite"></animate>
</stop>
<stop offset="1.39984" stop-color="#d9d9d9" stop-opacity="1">
<animate attributeName="offset" values="-1; 3" dur="2s" repeatCount="indefinite"></animate>
</stop>
</linearGradient>
</defs>
{% endfor %}
</svg>
</div>
{% endblock %}
{% endif %}
{% block modals %}
{% include 'flex-objects/types/default/modals/remove.html.twig' with { name: target } %}
{% endblock %}
</div>
{% endblock %}
@@ -0,0 +1,39 @@
{% set object_title = title_field ? "'" ~ object[title_field]|join(' ') ~ "'" : 'Item' %}
{% set can_read = object.isAuthorized('read', 'admin', user) %}
{% set can_update = object.isAuthorized('update', 'admin', user) %}
{% set can_delete = object.isAuthorized('delete', 'admin', user) %}
{% if can_read and object.getRoute() %}
{% block action_preview %}
<a href="{{ route.withAddedPath(object.getKey()).withoutParams().withQueryParam('preview', 1).getUri() }}" title="{{ "PLUGIN_ADMIN.PREVIEW"|tu }}" class="preview-action">
<i class="fa fa-eye"></i>
</a>
{% endblock %}
{% endif %}
{% if can_update %}
{% block action_edit %}
<a href="{{ route.withAddedPath(object.getKey()).withoutParams().getUri() }}" title="Edit {{ object_title }}" class="edit-action">
<i class="fa fa-pencil"></i>
</a>
{% endblock %}
{% elseif can_read %}
{% block action_read %}
<a href="{{ route.withAddedPath(object.getKey()).withoutParams().getUri() }}" title="View {{ object_title }}" class="edit-action">
<i class="fa fa-search"></i>
</a>
{% endblock %}
{% endif %}
{% if can_delete %}
{% block action_delete %}
<a href="#delete"
class="page-delete delete-action"
title="Delete {{ object_title }}"
data-remodal-target="delete"
data-delete-url="{{ grav.uri.addNonce(route.withAddedPath(object.getKey()).withoutParams().withGravParam('task', 'delete').getUri(), 'admin-form', 'admin-nonce') }}"
>
<i class="fa fa-close"></i>
</a>
{% endblock %}
{% endif %}
@@ -0,0 +1,13 @@
<div class="remodal" data-remodal-id="delete" data-remodal-options="hashTracking: false">
<form>
{# FIXME -name|singularize- is not translatable #}
<h1>{{ 'PLUGIN_FLEX_OBJECTS.ACTION.DELETE_N'|tu }} {{ name|singularize|capitalize }}</h1>
<p class="bigger">
{{ 'PLUGIN_FLEX_OBJECTS.ACTION.REALLY_DELETE'|tu( name|singularize, null ) }}
</p>
<div class="button-bar">
<button data-remodal-action="cancel" class="button secondary remodal-cancel"><i class="fa fa-fw fa-close"></i> {{ "PLUGIN_ADMIN.CANCEL"|tu }}</button>
<a class="button disable-after-click" data-delete-action href="#"><i class="fa fa-fw fa-check"></i> {{ "PLUGIN_ADMIN.CONTINUE"|tu }}</a>
</div>
</form>
</div>
@@ -0,0 +1,62 @@
{% extends 'partials/base.html.twig' %}
{% use 'flex-objects/types/default/titlebar/preview.html.twig' %}
{# Allowed actions #}
{% set can_preview = can_preview ?? (object.exists and (view_config['enabled'] ?? false)) %}
{% set can_translate = can_translate ?? (admin.multilang and object.hasFlexFeature('flex-translate')) %}
{# These variables can be overridden from the main template file #}
{% set allowed = allowed ?? (directory and (object.exists or action == 'add')) %}
{% set back_route = back_route ?? ('/' ~ route.getRoute(1)) %}
{% set title_icon = title_icon ?? view_config['icon'] ?? directory.config.admin.menu.list.icon ?? 'fa-file-text-o' %}
{% set title -%}
{%- set title_config = view_config['title'] -%}
{%- if title_config.template -%}
{{- include(template_from_string(title_config.template, 'edit title template')) -}}
{%- else -%}
{{- title ?? object.form.getValue('title') ?? object.title ?? key -}}
{% endif %}
{%- endset %}
{% set preview_url -%}
{%- set route_config = view_config['route'] -%}
{%- if route_config.template -%}
{{- include(template_from_string(route_config.template, 'preview route template')) -}}
{%- else -%}
{{- preview_url ?? object.getRoute().uri ?: '' -}}
{%- endif -%}
{% endset -%}
{% block body %}
{% if not can_preview or not preview_url %}
{% set allowed = false %}
{% endif %}
{% set id = key %}
{% set blueprint = object.blueprint ?? directory.blueprint %}
{% set back_url = back_url ?? admin_route(back_route) %}
{{ parent() }}
{% endblock body %}
{% block content_wrapper %}
{% if can_preview and allowed and preview_url %}
<div class="content-wrapper preview-wrapper">
<div class="content-padding" width="100%" height="100%">
<iframe width="100%" height="100%" frameborder="0" src="{{ preview_url }}"></iframe>
</div>
</div>
{% else %}
{{ parent() }}
{% endif %}
{% endblock content_wrapper %}
{% block content %}
{% do page.modifyHeader('http_response_code', 404) %}
<div class="error-block">
<h1>{{ 'PLUGIN_ADMIN.ERROR'|tu }} 404</h1>
<div class="padding">
<p>
{{ 'PLUGIN_FLEX_OBJECTS.ERROR.PAGE_NOT_EXIST'|tu }}
</p>
</div>
</div>
{% endblock content %}
@@ -0,0 +1,32 @@
{% block titlebar %}
{% block titlebar_button_bar %}
<div class="button-bar">
{# BACK #}
{% block back_button %}
{% include ['flex-objects/types/' ~ target ~ '/buttons/back.html.twig', 'flex-objects/types/default/buttons/back.html.twig'] %}
{% endblock back_button %}
{% block extra_buttons %}{% endblock extra_buttons %}
{# SAVE #}
{% if can_save %}
{% block save_button %}
{% include ['flex-objects/types/' ~ target ~ '/buttons/save.html.twig', 'flex-objects/types/default/buttons/save.html.twig'] with {task: 'configure'} %}
{% endblock save_button %}
{% endif %}
</div>
{% endblock titlebar_button_bar %}
{% block titlebar_title %}
<h1>
{% if allowed %}
<i class="fa fa-fw fa-cog"></i>
{{ title }}
{% else %}
<i class="fa fa-fw fa-exclamation-triangle"></i>
{{ 'PLUGIN_ADMIN.ERROR'|tu }}
  {% endif %}
</h1>
{% endblock titlebar_title %}
{% endblock %}
@@ -0,0 +1,46 @@
{% block titlebar %}
{% block titlebar_button_bar %}
<div class="button-bar">
{# BACK #}
{% block back_button %}
{% include ['flex-objects/types/' ~ target ~ '/buttons/back.html.twig', 'flex-objects/types/default/buttons/back.html.twig'] %}
{% endblock back_button %}
{# PREVIEW #}
{% if can_preview %}
{% block preview_button %}
{% include ['flex-objects/types/' ~ target ~ '/buttons/preview.html.twig', 'flex-objects/types/default/buttons/preview.html.twig'] %}
{% endblock preview_button %}
{% endif %}
{# DELETE #}
{% if can_delete %}
{% block delete_button %}
{% include ['flex-objects/types/' ~ target ~ '/buttons/delete.html.twig', 'flex-objects/types/default/buttons/delete.html.twig'] %}
{% endblock delete_button %}
{% endif %}
{% block extra_buttons %}{% endblock extra_buttons %}
{# SAVE #}
{% if allowed and can_save %}
{% block save_button %}
{% include ['flex-objects/types/' ~ target ~ '/buttons/save.html.twig', 'flex-objects/types/default/buttons/save.html.twig'] with {task: 'save'} %}
{% endblock save_button %}
{% endif %}
</div>
{% endblock titlebar_button_bar %}
{% block titlebar_title %}
<h1>
{% if allowed %}
<i class="fa fa-fw {{ title_icon }}"></i>
{{ not object.exists ? '[' ~ 'PLUGIN_FLEX_OBJECTS.NEW'|tu|upper ~ ']' }} {{ title|tu }}
{% else %}
<i class="fa fa-fw fa-exclamation-triangle"></i>
{{ 'PLUGIN_ADMIN.ERROR'|tu }}
{% endif %}
</h1>
{% endblock titlebar_title %}
{% endblock %}
@@ -0,0 +1,48 @@
{% block titlebar %}
{% block titlebar_button_bar %}
<div class="button-bar">
{# BACK #}
{% block back_button %}
{% include ['flex-objects/types/' ~ target ~ '/buttons/back.html.twig', 'flex-objects/types/default/buttons/back.html.twig'] %}
{% endblock back_button %}
{# EXPORT #}
{% if can_export %}
{% block export_button %}
{% include ['flex-objects/types/' ~ target ~ '/buttons/export.html.twig', 'flex-objects/types/default/buttons/export.html.twig'] with {export: directory.config('admin.views.export') ?? directory.config('admin.export') ?? []} %}
{% endblock export_button %}
{% endif %}
{# CREATE #}
{% if can_create %}
{% block create_button %}
{% include ['flex-objects/types/' ~ target ~ '/buttons/add.html.twig', 'flex-objects/types/default/buttons/add.html.twig'] %}
{% endblock create_button %}
{% endif %}
{# LANGUAGES #}
{% if can_translate %}
{% block languages_button %}
{% include ['flex-objects/types/' ~ target ~ '/buttons/languages.html.twig', 'flex-objects/types/default/buttons/languages.html.twig'] %}
{% endblock languages_button %}
{% endif %}
{# CONFIGURE #}
{% block configure %}
{% include 'flex-objects/types/default/buttons/configuration.html.twig' %}
{% endblock configure %}
</div>
{% endblock titlebar_button_bar %}
{% block titlebar_title %}
<h1>
{% if allowed %}
<i class="fa fa-fw {{ directory ? title_icon : 'fa-exclamation-triangle' }}"></i>
{{ directory ? title|tu : 'Error' }}
{% else %}
<i class="fa fa-fw fa-exclamation-triangle"></i>
{{ 'PLUGIN_ADMIN.ERROR'|tu }}
{% endif %}
</h1>
{% endblock titlebar_title %}
{% endblock %}
@@ -0,0 +1,30 @@
{% block titlebar %}
{% block titlebar_button_bar %}
<div class="button-bar">
{# BACK #}
{% block back_button %}
{% include ['flex-objects/types/' ~ target ~ '/buttons/back.html.twig', 'flex-objects/types/default/buttons/back.html.twig'] %}
{% endblock back_button %}
{# PREVIEW #}
{% if can_preview %}
{% block preview_button %}
{% include ['flex-objects/types/' ~ target ~ '/buttons/preview-open.html.twig', 'flex-objects/types/default/buttons/preview-open.html.twig'] %}
{% endblock preview_button %}
{% endif %}
</div>
{% endblock titlebar_button_bar %}
{% block titlebar_title %}
<h1>
{% if allowed %}
<i class="fa fa-fw {{ title_icon }}"></i>
{{ "PLUGIN_ADMIN.PREVIEW"|tu }}: {{ not object.exists ? '[' ~ 'PLUGIN_FLEX_OBJECTS.NEW'|tu|upper ~ ']' }} <strong>{{ title }}</strong>
{% else %}
<i class="fa fa-fw fa-exclamation-triangle"></i>
{{ 'PLUGIN_ADMIN.ERROR'|tu }}
{% endif %}
</h1>
{% endblock titlebar_title %}
{% endblock %}
@@ -0,0 +1,22 @@
{% block titlebar %}
{% block titlebar_button_bar %}
<div class="button-bar">
{# BACK #}
{% block back_button %}
{% include 'flex-objects/types/default/buttons/back.html.twig' %}
{% endblock back_button %}
{# CONFIGURE #}
{% block configure %}
{% include 'flex-objects/types/default/buttons/configuration.html.twig' %}
{% endblock configure %}
</div>
{% endblock titlebar_button_bar %}
{% block titlebar_title %}
<h1>
<i class="fa fa-fw fa-list"></i>
{{ "PLUGIN_FLEX_OBJECTS.TITLE"|tu }}
</h1>
{% endblock titlebar_title %}
{% endblock %}
@@ -0,0 +1,46 @@
{% extends 'partials/base.html.twig' %}
{% use 'flex-objects/types/default/titlebar/types.html.twig' %}
{% set flex = grav['flex_objects'] %}
{# These variables can be overridden from the main template file #}
{% set back_route = back_route ?? ('/' ~ route.getRoute(1, -1)) %}
{% set configure_route = '/plugins/flex-objects' %}
{% block body %}
{% set back_url = admin_route(back_route) %}
{% set configure_url = configure_route ? admin_route(configure_route) : null %}
{{ parent() }}
{% endblock body %}
{% block content %}
<h1>{{ 'PLUGIN_FLEX_OBJECTS.TYPES_TITLE'|tu }}</h1>
<div id="types" class="card-row grid fixed-blocks pure-g">
{% for name,directory in flex.directories if directory.enabled and directory.config('admin.hidden', false) is not same as(true) and not directory.config('admin.menu') %}
{% try %}
{% set collection = directory.collection %}
{% if flex.adminRoute(collection) %}
<div class="card-item pure-u-1-3">
<h2><a href="{{ admin_route(flex.adminRoute(collection)) }}">{{ directory.title|tu }}</a> <span class="badge">{{ collection.isAuthorized('list', 'admin', user).count }}</span></h2>
<p>
{{ directory.description }}
</p>
</div>
{% endif %}
{% catch %}
<div class="card-item pure-u-1-3">
<h2>{{ 'PLUGIN_FLEX_OBJECTS.ERROR.BAD_DIRECTORY'|tu }} '{{ name }}'</h2>
<p>
{{ e.message }}
</p>
</div>
{% endcatch %}
{% endfor %}
</div>
{% endblock %}
@@ -0,0 +1,9 @@
{% extends 'flex-objects/types/default/configure.html.twig' %}
{% set back_route = back_route ?? ('/' ~ route.getRoute(1, -1)) %}
{% block content_top %}
{% include 'flex-objects/layouts/accounts/partials/top.html.twig' %}
{{ parent() }}
{% endblock %}
@@ -0,0 +1,9 @@
{% extends 'flex-objects/types/default/edit.html.twig' %}
{% if not directory.isAuthorized('list', 'admin', user) %}
{% set back_route = '/' %}
{% endif %}
{% if not object.exists %}
{% do object.onPrepareRegistration() %}
{% endif %}
@@ -0,0 +1,7 @@
{% extends 'flex-objects/types/default/list.html.twig' %}
{% block content_top %}
{% include 'flex-objects/layouts/accounts/partials/top.html.twig' %}
{{ parent() }}
{% endblock %}
@@ -0,0 +1,9 @@
{% extends 'flex-objects/types/default/configure.html.twig' %}
{% set back_route = back_route ?? ('/' ~ route.getRoute(1, -1)) %}
{% block content_top %}
{% include 'flex-objects/layouts/accounts/partials/top.html.twig' %}
{{ parent() }}
{% endblock %}
@@ -0,0 +1,7 @@
{% extends 'flex-objects/types/default/list.html.twig' %}
{% block content_top %}
{% include 'flex-objects/layouts/accounts/partials/top.html.twig' %}
{{ parent() }}
{% endblock %}
@@ -0,0 +1,69 @@
{% extends "forms/field.html.twig" %}
{% macro spanToggle(input, length) %}
{% set space = repeat('&nbsp;&nbsp;', (length - input|length) / 2) %}
{{ (space ~ input ~ space)|raw }}
{% endmacro %}
{% import _self as macro %}
{% set value = (value is null ? field.default : value) %}
{% block global_attributes %}
{{ parent() }}
data-grav-field-name="{{ (scope ~ field.name)|fieldName }}"
{% endblock %}
{% block input %}
{% set flex = grav['flex_objects'] %}
{% set all = flex.blueprints %}
{% if all|count %}
{% set legacy = flex.getLegacyBlueprintMap() %}
{% for label, directory in all %}
{% set url = directory.blueprintFile %}
{% set found = url in value %}
{% if not found and legacy[url] is defined %}
{% set found = legacy[url] in value %}
{% endif %}
<div class="form-data block size-2-3" data-grav-field="toggle" data-grav-disabled="" data-grav-default="null" data-grav-field-name="{{ (scope ~ field.name)|fieldName }}[{{ loop.index0 }}]">
<div class="switch-toggle switch-grav switch-2">
{% set maxLen = 0 %}
{% for text in ['PLUGIN_ADMIN.ENABLED', 'PLUGIN_ADMIN.DISABLED'] %}
{% set translation = grav.twig.twig.filters['tu'] is defined ? text|tu : text|t %}
{% set maxLen = max(translation|length, maxLen) %}
{% endfor %}
{% set id = "toggle_" ~ field.name ~ '_' ~ label %}
<input type="radio"
value="{{ url }}"
id="{{ id ~ '_yes' }}"
name="{{ (scope ~ field.name)|fieldName }}[{{ loop.index0 }}]"
class="highlight"
{% if found %}
checked="checked"
{% endif %}
/>
{% set text = 'PLUGIN_ADMIN.ENABLED' %}
{% set translation = (grav.twig.twig.filters['tu'] is defined ? text|tu : text|t)|trim %}
<label for="{{ id ~ '_yes' }}">{{ (macro.spanToggle(translation, maxLen)|trim)|raw }}</label>
<input type="radio"
value=""
name="{{ (scope ~ field.name)|fieldName }}[{{ loop.index0 }}]"
id="{{ id ~ '_no' }}"
{% if not found %}
checked="checked"
{% endif %}
/>
{% set text = 'PLUGIN_ADMIN.DISABLED' %}
{% set translation = (grav.twig.twig.filters['tu'] is defined ? text|tu : text|t)|trim %}
<label for="{{ id ~ '_no' }}">{{ (macro.spanToggle(translation, maxLen)|trim)|raw }}</label>
</div>
<span title="{{ directory.description|tu }}">{{ directory.title|tu }}</span>
</div>
{% endfor %}
{% else %}
<div>{{ 'PLUGIN_FLEX_OBJECTS.ERROR.NO_FLEX_DIRECTORIES'|tu }}</div>
{% endif %}
{% endblock %}
@@ -0,0 +1,36 @@
{% extends "forms/field.html.twig" %}
{% set originalValue = value %}
{% set value = (value is null ? field.default : value) %}
{% set isNew = key ? false : true %}
{% set savedOption = grav.session.post_entries_save|default('edit') %}
{% if isNew %}
{% set options = {'create-new':'PLUGIN_FLEX_OBJECTS.ACTION.CREATE_NEW', 'edit':'PLUGIN_FLEX_OBJECTS.ACTION.EDIT_ITEM', 'list':'PLUGIN_FLEX_OBJECTS.ACTION.LIST_ITEMS'} %}
{% else %}
{% set options = {'edit':'PLUGIN_FLEX_OBJECTS.ACTION.EDIT_ITEM', 'list':'PLUGIN_FLEX_OBJECTS.ACTION.LIST_ITEMS'} %}
{% endif %}
{% block input %}
{% for key, text in options %}
{% set id = field.id|default(field.name) ~ '-' ~ key %}
{% if savedOption == key %}
{% set value = savedOption %}
{% endif %}
<span class="radio">
<input type="radio"
value="{{ key|e }}"
id="{{ id|e }}"
name="{{ (field.name)|fieldName }}"
{% if key == value %}checked="checked" {% endif %}
{% if field.disabled or isDisabledToggleable %}disabled="disabled"{% endif %}
{% if field.validate.required in ['on', 'true', 1] %}required="required"{% endif %}
/>
<label style="display: inline" class="inline" for="{{ id|e }}">{{ text|tu|e }}</label>
</span>
{% endfor %}
{% endblock %}