Skip to content

Commit

Permalink
Merge branch 'release/1.1.8'
Browse files Browse the repository at this point in the history
  • Loading branch information
rhukster committed Jan 28, 2022
2 parents 682cde3 + 55ebb68 commit 89673d3
Show file tree
Hide file tree
Showing 18 changed files with 168 additions and 36 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
# v1.1.8
## 01/28/2022

1. [](#new)
* Require **Grav 1.7.29**
3. [](#improved)
* Made path handling unicode-safe, use new `Utils::basename()` and `Utils::pathinfo()` everywhere

# v1.1.7
## 01/03/2022

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ The **Flex Objects** Plugin is for [Grav CMS](https://github.com/getgrav/grav).

## System Requirements

Plugin requires **Grav** v1.7.19 or later version in order to run. Additionally you need **Form Plugin** v5.1.0 and optionally **Admin Plugin** v1.10.19 or later version.
Plugin requires **Grav** v1.7.25 or later version in order to run. Additionally you need **Form Plugin** v5.1.0 and optionally **Admin Plugin** v1.10.25 or later version.

## Installation

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
{%- if title_config.template -%}
{{- include(template_from_string(title_config.template, 'configure title template')) -}}
{%- else -%}
{{- directory.title }} {{ 'PLUGIN_ADMIN.CONFIGURATION'|tu -}}
{{- directory.title|tu }} - {{ 'PLUGIN_ADMIN.CONFIGURATION'|tu -}}
{% endif %}
{%- endset %}

Expand Down
2 changes: 1 addition & 1 deletion admin/templates/flex-objects/types/default/edit.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
{% 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 ? '[NEW]' }}</b></div>
<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 %}
Expand Down
2 changes: 1 addition & 1 deletion admin/templates/flex-objects/types/default/list.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
{%- if title_config.template -%}
{{- include(template_from_string(title_config.template, 'configure title template')) -}}
{%- else -%}
{{- directory.title -}}
{{- directory.title|tu -}}
{% endif %}
{%- endset %}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
<h1>
{% if allowed %}
<i class="fa fa-fw {{ title_icon }}"></i>
{{ not object.exists ? '[NEW]' }} {{ title }}
{{ 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 }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<h1>
{% if allowed %}
<i class="fa fa-fw {{ title_icon }}"></i>
{{ "PLUGIN_ADMIN.PREVIEW"|tu }}: {{ not object.exists ? '[NEW]' }} <strong>{{ title }}</strong>
{{ "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 }}
Expand Down
2 changes: 1 addition & 1 deletion admin/templates/flex-objects/types/pages/edit.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
{% if allowed and user.authorize('admin.super') %}
<div class="alert notice">
{% set save_location = object.getStorageFolder() ?: directory.getStorageFolder() %}
{{ "PLUGIN_ADMIN.SAVE_LOCATION"|tu }}: <b>{{ url(save_location, false, true)|trim('/') }} {{ not object.exists ? '[NEW]' }}</b> (type: <b>{{ (form.getValue('name') ?: 'default') }}</b>)
{{ "PLUGIN_ADMIN.SAVE_LOCATION"|tu }}: <b>{{ url(save_location, false, true)|trim('/') }} {{ not object.exists ? '[' ~ 'PLUGIN_FLEX_OBJECTS.NEW'|tu|upper ~ ']' }}</b> (type: <b>{{ (form.getValue('name') ?: 'default') }}</b>)
</div>
{% endif %}
{% if object.exists and form.flash.exists %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
{% 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 }}">{{ directory.title }}</span>
<span title="{{ directory.description|tu }}">{{ directory.title|tu }}</span>
</div>
{% endfor %}
{% else %}
Expand Down
4 changes: 2 additions & 2 deletions blueprints.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Flex Objects
slug: flex-objects
type: plugin
version: 1.1.7
version: 1.1.8
description: Flex Objects plugin allows you to manage Flex Objects in Grav Admin.
icon: list-alt
author:
Expand All @@ -14,7 +14,7 @@ docs: https://github.com/trilbymedia/grav-plugin-flex-objects/blob/develop/READM
license: MIT

dependencies:
- { name: grav, version: '>=1.7.25' }
- { name: grav, version: '>=1.7.29' }
- { name: form, version: '>=5.1.0' }

form:
Expand Down
41 changes: 39 additions & 2 deletions classes/Controllers/MediaController.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public function taskMediaUpload(): ResponseInterface
$media = $object->getMedia();
$media->add($filename, $medium);

$basename = str_replace(['@3x', '@2x'], '', pathinfo($filename, PATHINFO_BASENAME));
$basename = str_replace(['@3x', '@2x'], '', Utils::pathinfo($filename, PATHINFO_BASENAME));
if (isset($media[$basename])) {
$metadata = $media[$basename]->metadata() ?: [];
}
Expand All @@ -132,6 +132,43 @@ public function taskMediaUpload(): ResponseInterface
return $this->createJsonResponse($response);
}

public function taskMediaUploadMeta(): ResponseInterface
{
$this->checkAuthorization('media.create');

$object = $this->getObject();
if (null === $object) {
throw new RuntimeException('Not Found', 404);
}

if (!method_exists($object, 'checkUploadedMediaFile')) {
throw new RuntimeException('Not Found', 404);
}

// Get updated object from Form Flash.
$flash = $this->getFormFlash($object);
if ($flash->exists()) {
$object = $flash->getObject() ?? $object;
$object->update([], $flash->getFilesByFields());
}

// Get field and data for the uploaded media.
$field = $this->getPost('field');
$data = $this->getPost('data');
$filename = Utils::basename($data['name']);

$response = [
'code' => 200,
'status' => 'success',
'message' => $this->translate('PLUGIN_ADMIN.FILE_UPLOADED_SUCCESSFULLY'),
'field' => $field,
'filename' => $filename,
'metadata' => $data
];

return $this->createJsonResponse($response);
}

/**
* @return ResponseInterface
*/
Expand Down Expand Up @@ -207,7 +244,7 @@ public function taskMediaCopy(): ResponseInterface
$metadata = [];
$include_metadata = $this->grav['config']->get('system.media.auto_metadata_exif', false);
if ($include_metadata) {
$basename = str_replace(['@3x', '@2x'], '', pathinfo($filename, PATHINFO_BASENAME));
$basename = str_replace(['@3x', '@2x'], '', Utils::pathinfo($filename, PATHINFO_BASENAME));
$media = $object->getMedia();
if (isset($media[$basename])) {
$metadata = $media[$basename]->metadata() ?: [];
Expand Down
4 changes: 2 additions & 2 deletions classes/Flex.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public function __construct(FlexInterface $flex, array $types)
// Backwards compatibility to v1.0.0-rc.3
$blueprint = $legacy[$blueprint] ?? $blueprint;

$type = basename((string)$blueprint, '.yaml');
$type = Utils::basename((string)$blueprint, '.yaml');
if ($type) {
$this->managed[] = $type;
}
Expand Down Expand Up @@ -238,7 +238,7 @@ public function getBlueprints(): array
$directories = [];
$all = Folder::all('blueprints://flex-objects', $params);
foreach ($all as $url) {
$type = basename($url, '.yaml');
$type = Utils::basename($url, '.yaml');
$directory = new FlexDirectory($type, $url);
if ($directory->getConfig('hidden') !== true) {
$directories[$type] = $directory;
Expand Down
3 changes: 2 additions & 1 deletion cli/FlexConvertDataCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Grav\Plugin\Console;

use Exception;
use Grav\Common\Utils;
use Grav\Common\Yaml;
use Grav\Console\ConsoleCommand;
use Symfony\Component\Console\Input\InputOption;
Expand Down Expand Up @@ -51,7 +52,7 @@ protected function serve(): int

$out_raw = null;
$in = $input->getOption('in');
$in_parts = pathinfo($in);
$in_parts = Utils::pathinfo($in);
$in_extension = $in_parts['extension'];
$out_extension = $input->getOption('out');

Expand Down
3 changes: 2 additions & 1 deletion flex-objects.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use Grav\Common\Page\Types;
use Grav\Common\Plugin;
use Grav\Common\User\Interfaces\UserInterface;
use Grav\Common\Utils;
use Grav\Events\FlexRegisterEvent;
use Grav\Events\PermissionsRegisterEvent;
use Grav\Events\PluginsLoadedEvent;
Expand Down Expand Up @@ -479,7 +480,7 @@ protected function registerDirectories(\Grav\Framework\Flex\Flex $flex, array $t
foreach ($types as $blueprint) {
// Backwards compatibility to v1.0.0-rc.3
$blueprint = $map[$blueprint] ?? $blueprint;
$type = basename((string)$blueprint, '.yaml');
$type = Utils::basename((string)$blueprint, '.yaml');
if (!$type) {
continue;
}
Expand Down
13 changes: 12 additions & 1 deletion languages/de.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,17 @@ PLUGIN_FLEX_OBJECTS:
CSV: "CSV"
PARENTS: "Eltern"

CONTROLLER:
TASK_DELETE_SUCCESS: 'Eintrag erfolgreich gelöscht'
TASK_DELETE_FAILURE: 'Löschen des Eintrags fehlgeschlagen: %s'
TASK_NEW_FOLDER_SUCCESS: 'Ordner erfolgreich angelegt'
TASK_COPY_SUCCESS: 'Kopie erfolgreich angelegt'
TASK_COPY_FAILURE: 'Kopieren des Eintrags fehlgeschlagen: %s'
TASK_SAVE_SUCCESS: 'Eintrag erfolgreich gespeichert'
TASK_SAVE_FAILURE: 'Speichern des Eintrags fehlgeschlagen: %s'
TASK_CONFIGURE_SUCCESS: 'Konfiguration erfolgreich gespeichert'
TASK_CONFIGURE_FAILURE: 'Speichern der Konfiguration fehlgeschlagen: %s'

ACTION:
CREATE_NEW: Neuen Eintrag anlegen
EDIT_ITEM: Eintrag bearbeiten
Expand Down Expand Up @@ -57,4 +68,4 @@ PLUGIN_FLEX_OBJECTS:
BLUEPRINT_NO_LIST_TEMPLATE: "Bitte leg für diesen Typ ein Template an <b>flex-objects/types/%s/list.html.twig</b>"
LIST_EMPTY: "Keine Einträge vorhanden."
LIST_EMPTY_ADD: "Keine Einträge vorhanden. Klicke den <a href=\"%s\">Hinzufügen</a> Button um einen Eintrag anzulegen."
NO_FLEX_DIRECTORIES: "Keine Flex Verzeichnisse erkannt"
NO_FLEX_DIRECTORIES: "Keine Flex Verzeichnisse erkannt"
27 changes: 14 additions & 13 deletions languages/en.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,37 +5,38 @@ PLUGIN_FLEX_OBJECTS:
TITLE: Flex Objects
TYPES_TITLE: Directories
AFTER_SAVE: After Save…
LIST_INFO: 'Displaying {from} to {to} out of {total} records'
LIST_INFO: "Displaying {from} to {to} out of {total} records"
EMPTY_RESULT: The requested query returns no result

USE_BUILT_IN_CSS: "Use built in CSS"
EXTRA_ADMIN_TWIG_PATH: "Extra Admin Twig Path"
DIRECTORIES: "Directories"
CSV: "CSV"
PARENTS: "Parents"
NEW: "New"

CONTROLLER:
TASK_DELETE_SUCCESS: 'Entry deleted successfully'
TASK_DELETE_FAILURE: 'Failed to delete entry: %s'
TASK_NEW_FOLDER_SUCCESS: 'Folder created successfully'
TASK_COPY_SUCCESS: 'Copy created successfully'
TASK_COPY_FAILURE: 'Failed to create copy: %s'
TASK_SAVE_SUCCESS: 'Entry saved successfully'
TASK_SAVE_FAILURE: 'Failed to save entry: %s'
TASK_CONFIGURE_SUCCESS: 'Configuration saved successfully'
TASK_CONFIGURE_FAILURE: 'Failed to save configuration: %s'
TASK_DELETE_SUCCESS: "Entry deleted successfully"
TASK_DELETE_FAILURE: "Failed to delete entry: %s"
TASK_NEW_FOLDER_SUCCESS: "Folder created successfully"
TASK_COPY_SUCCESS: "Copy created successfully"
TASK_COPY_FAILURE: "Failed to create copy: %s"
TASK_SAVE_SUCCESS: "Entry saved successfully"
TASK_SAVE_FAILURE: "Failed to save entry: %s"
TASK_CONFIGURE_SUCCESS: "Configuration saved successfully"
TASK_CONFIGURE_FAILURE: "Failed to save configuration: %s"

ACTION:
CREATE_NEW: Create New Item
EDIT_ITEM: Edit Item
LIST_ITEMS: "List Items"
LIST_ITEM: List Items
DELETE_N: "Delete" # In some languages 'delete OBJECT' may need a special declination
REALLY_DELETE: "Are you sure you want to permanently delete the %s?"
SEARCH_PLACEHOLDER: "Search…"
ADVANCED_OPTIONS: "Advanced Options"
APPLY_FILTERS: "Apply Filters"
RESET_FILTERS: "Reset to Defaults"
LIST_ITEMS: "List Items"

FILTER:
PAGE_ATTRIBUTES: "Page Attributes"
Expand Down Expand Up @@ -68,5 +69,5 @@ PLUGIN_FLEX_OBJECTS:
BLUEPRINT_NO_LIST_ADVISE: "Please add list of fields to blueprints file."
BLUEPRINT_NO_LIST_TEMPLATE: "Please create template file for the type in <b>flex-objects/types/%s/list.html.twig</b>"
LIST_EMPTY: "There are currently no entries."
LIST_EMPTY_ADD: "There are currently no entries, click the <a href=\"%s\">Add</a> button to create a new one…"
NO_FLEX_DIRECTORIES: "No Flex Directories detected"
LIST_EMPTY_ADD: "There are currently no entries. Click the <a href=\"%s\">Add</a> button to create a new one…"
NO_FLEX_DIRECTORIES: "No Flex Directories detected"
73 changes: 73 additions & 0 deletions languages/es.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
PLUGIN_FLEX_OBJECTS:
PLUGIN_NAME: "Flex Objects"
PLUGIN_DESCRIPTION: "El plugin Flex Objects permite manejar Objetos Flex en Grav Admin."

TITLE: Flex Objects
TYPES_TITLE: Directorios
AFTER_SAVE: "Después de guardar…"
LIST_INFO: "Mostrando de {from} a {to} de {total} registros"
EMPTY_RESULT: The requested query returns no result

USE_BUILT_IN_CSS: "Usar CSS incorporado"
EXTRA_ADMIN_TWIG_PATH: "Ruta extra de twig para Admin"
DIRECTORIES: "Directorios"
CSV: "CSV"
PARENTS: "Madres"
NEW: Nuevo

CONTROLLER:
TASK_DELETE_SUCCESS: "Entrada eliminada exitosamente"
TASK_DELETE_FAILURE: "Falla al eliminar la entrada: %s"
TASK_NEW_FOLDER_SUCCESS: "Carpeta creada exitosamente"
TASK_COPY_SUCCESS: "Copia creada exitosamente"
TASK_COPY_FAILURE: "Falla al crear la copia: %s"
TASK_SAVE_SUCCESS: "Entrada guardada exitosamente"
TASK_SAVE_FAILURE: "Falla al guardar la entrada: %s"
TASK_CONFIGURE_SUCCESS: "Configuración gardada exitosamente"
TASK_CONFIGURE_FAILURE: "Falla al guardar la configuración: %s"

ACTION:
CREATE_NEW: "Crear nuevo ítem"
EDIT_ITEM: "Editar ítem"
LIST_ITEMS: "Listar ítems"
LIST_ITEM: "Listar ítem"
DELETE_N: "Eliminar"
REALLY_DELETE: "¿Realmente quieres eliminar %s permanentemente?"
SEARCH_PLACEHOLDER: "Buscar…"
ADVANCED_OPTIONS: "Opciones avazadas"
APPLY_FILTERS: "Aplicar filtros"
RESET_FILTERS: "Restablecer filtros"

FILTER:
PAGE_ATTRIBUTES: "Atributos de página"
PAGE_TYPES: "Tipos de página"
MODULAR_TYPES: "Tipos de módulo"

LANGUAGE:
USING_DEFAULT: "Usando archivo de idioma <b>Predeterminado</b>."
UNUSED_DEFAULT: "También existe un archvivo de idioma <b>Predeterminado</b>."
USING_OVERRIDE: "Usando el idioma de remplazo <b>%s</b>."
NOT_TRANSLATED_YET: "¡Esta página aún no ha sido traducida a <i class=\"fa fa-flag-o\"></i> <b>%s</b>!"
NO_FALLBACK_FOUND: "No se han encontrado traducciones de apoyo."
FALLING_BACK: "Retrocediendo a <b>%s</b>."

STATE:
LOADING: "Cargando…"
CREATED_SUCCESSFULLY: "Creado exitosamente"
UPDATED_SUCCESSFULLY: "Actualizado exitosamente"
DELETED_SUCCESSFULLY: "Eliminado exitosamente"
EDITING_DRAFT: "Estás editando un borrador."
NOT_CREATED_YET: "Esta página no existe hasta que se guarde."

ERROR:
BAD_DIRECTORY: "Directorio errado"
PAGE_NOT_FOUND: "Página no encontrada"
PAGE_NOT_EXIST: "¡Uy! Parece que esta página no existe."
PAGE_FORBIDDEN: "¡Uy! Parece que no tienes permiso para ver esta página."
LAYOUT_NOT_FOUND: "Maquetación de objeto '%s' no encontrada."
BLUEPRINT_NO_LIST: "Plano para <i>%s</i> no define campos mostrados ni remplazo de página de lista."
BLUEPRINT_NO_LIST_ADVISE: "Por favor agrega una lista de campos para el archivo de planos."
BLUEPRINT_NO_LIST_TEMPLATE: "Por favor crea un archivo de plantilla para el tipo en <b>flex-objects/types/%s/list.html.twig</b>"
LIST_EMPTY: "No hay entradas por el momento."
LIST_EMPTY_ADD: "No hay entradas por el momento. Da clic en el botón <a href=\"%s\">Agregar</a> para crear una nueva…"
NO_FLEX_DIRECTORIES: "No se detectan Directorios Flex"
12 changes: 6 additions & 6 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1884,9 +1884,9 @@ flatted@^3.1.0:
integrity sha512-JaTY/wtrcSyvXJl4IMFHPKyFur1sE9AUqc0QnhOaJ0CxHtAoIV8pYDzeEfAaNEtGkOfq4gr3LBFmdXW5mOQFnA==

follow-redirects@^1.14.0:
version "1.14.4"
resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.14.4.tgz#838fdf48a8bbdd79e52ee51fb1c94e3ed98b9379"
integrity sha512-zwGkiSXC1MUJG/qmeIFH2HBJx9u0V46QGUe3YR1fXG8bXQxq7fLj0RjLZQ5nubr9qNJUZrH+xUcwXEoXNpfS+g==
version "1.14.7"
resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.14.7.tgz#2004c02eb9436eee9a21446a6477debf17e81685"
integrity sha512-+hbxoLbFMbRKDwohX8GkTataGqO6Jb7jGwpAlwgy2bIz25XtRm7KEzJM76R1WiNT5SwZkX4Y75SwBolkpmE7iQ==

fs.realpath@^1.0.0:
version "1.0.0"
Expand Down Expand Up @@ -2368,9 +2368,9 @@ nanocolors@^0.1.5:
integrity sha512-2pvTw6vYRaBLGir2xR7MxaJtyWkrn+C53EpW8yPotG+pdAwBvt0Xwk4VJ6VHLY0aLthVZPvDfm9TdZvrvAm5UQ==

nanoid@^3.1.25:
version "3.1.25"
resolved "https://registry.yarnpkg.com/nanoid/-/nanoid-3.1.25.tgz#09ca32747c0e543f0e1814b7d3793477f9c8e152"
integrity sha512-rdwtIXaXCLFAQbnfqDRnI6jaRHp9fTcYBjtFKE8eezcZ7LuLjhUaQGNeMXf1HmRoCH32CLz6XwX0TtxEOS/A3Q==
version "3.2.0"
resolved "https://registry.yarnpkg.com/nanoid/-/nanoid-3.2.0.tgz#62667522da6673971cca916a6d3eff3f415ff80c"
integrity sha512-fmsZYa9lpn69Ad5eDn7FMcnnSR+8R34W9qJEijxYhTbfOWzr22n1QxCMzXLK+ODyW2973V3Fux959iQoUxzUIA==

natural-compare@^1.4.0:
version "1.4.0"
Expand Down

0 comments on commit 89673d3

Please sign in to comment.