Commit ef892294 authored by ephoto_dam's avatar ephoto_dam

dev Ephoto Dam Field in progress

parent 97b863d5
......@@ -9,7 +9,7 @@ dependencies:
- drupal:system
'interface translation project': ephoto_dam
'interface translation server pattern': modules/%project/translations/%language.po
'interface translation server pattern': modules/contrib/%project/translations/%language.po
version: '8.x-2.7'
project: 'ephoto_dam'
......
......@@ -8,8 +8,8 @@ dependencies:
- drupal:field
- drupal:system
'interface translation project': ephoto_dam
'interface translation server pattern': modules/%project/translations/%language.po
'interface translation project': ephoto_dam_field
'interface translation server pattern': modules/contrib/ephoto_dam/translations/%language.po
version: '8.x-2.7'
project: 'ephoto_dam'
......
......@@ -93,21 +93,21 @@ class EphotoDamField extends FieldItemBase {
$form = [];
$form['server_url'] = [
'#title' => $this->t('Server URL'),
'#title' => t('Server URL'),
'#type' => 'url',
'#default_value' => $this->getSetting('server_url'),
'#description' => $this->t('Please enter the URL of your Ephoto Dam software'),
'#description' => t('Please enter the URL of your Ephoto Dam software'),
'#required' => true,
'#attributes' => [
'class' => ['form-text', 'ephoto-dam-field-settings-url'],
'placeholder' => $this->t('https://ephoto.mycompany.com/')
'placeholder' => t('https://ephoto.mycompany.com/')
],
'#size' => 50,
];
$form['version_support'] = [
'#title' => $this->t('Version support'),
'#description' => $this->t('An url will be automatically associated with each version with the same name in Ephoto Dam') . '.',
'#title' => t('Version support'),
'#description' => t('An url will be automatically associated with each version with the same name in Ephoto Dam') . '.',
'#type' => 'checkbox',
'#default_value' => $this->getSetting('version_support'),
'#attributes' => [
......
......@@ -19,7 +19,7 @@ use Drupal\Core\Form\FormStateInterface;
*/
class EphotoDamFieldWidget extends WidgetBase {
private $_first = true;
private static $_first = true;
/**
* {@inheritdoc}
......@@ -28,13 +28,13 @@ class EphotoDamFieldWidget extends WidgetBase {
$is_default_values_form = $this->isDefaultValueWidget($form_state);
$version_support = $this->getFieldSetting('version_support');
if ($this->$_first) {
if (self::$_first) {
$classes = ['button', 'ephoto-dam-field-button', 'ephoto-dam-field-versions-button'];
if (!$version_support) $classes[] = 'ephoto-dam-field-hidden';
$element['versions-select'] = [
'#type' => 'button',
'#value' => $this->t('Select'),
'#value' => t('Select'),
'#disabled' => $is_default_values_form,
'#attributes' => [
'class' => $classes,
......@@ -42,7 +42,7 @@ class EphotoDamFieldWidget extends WidgetBase {
],
];
$this->$_first = false;
self::$_first = false;
}
$classes = ['ephoto-dam-field-field', 'ephoto-dam-field-url-field'];
......@@ -52,7 +52,7 @@ class EphotoDamFieldWidget extends WidgetBase {
$element['url'] = [
'#type' => 'textfield',
'#title' => $this->t('URL') . ' ' . ($delta + 1),
'#title' => t('URL') . ' ' . ($delta + 1),
'#default_value' => isset($items[$delta]->url) ? $items[$delta]->url : null,
'#size' => 70,
'#maxlength' => 256,
......@@ -81,7 +81,7 @@ class EphotoDamFieldWidget extends WidgetBase {
'#field_suffix' => '<span class="' . implode(' ', $suffix_classes). '">px</span>',
'#attributes' => [
'class' => $classes,
'placeholder' => $this->t('Size'),
'placeholder' => t('Size'),
'max' => 1600,
'onclick' => 'this.focus();this.select()'
]
......@@ -101,10 +101,10 @@ class EphotoDamFieldWidget extends WidgetBase {
'#default_value' => !empty($items[$delta]->version) ? $items[$delta]->version : null,
'#size' => 10,
'#maxlength' => 60,
'#field_prefix' => '<span class="' . implode(' ', $prefix_classes). '">, &nbsp;' . $this->t('version') . '</span>',
'#field_prefix' => '<span class="' . implode(' ', $prefix_classes). '">, &nbsp;' . t('version') . '</span>',
'#attributes' => [
'class' => $classes,
'placeholder' => $this->t('Name'),
'placeholder' => t('Name'),
'onclick' => 'this.focus();this.select()'
]
];
......@@ -114,7 +114,7 @@ class EphotoDamFieldWidget extends WidgetBase {
$element['file-select'] = [
'#type' => 'button',
'#value' => $this->t('Select'),
'#value' => t('Select'),
'#disabled' => $is_default_values_form,
'#attributes' => [
'class' => $classes,
......
......@@ -33,8 +33,12 @@ class EphotoDamFieldConstraintValidator extends ConstraintValidator implements C
return NULL;
}
error_log(var_export($field->image_size, true));
$message = t('The "Size" field must respect one of the following patterns: "x{height}", "{width}x", "{width}x{height}" or "{width/height (detect auto)}". Examples: "x500", "500x", "500x500" or "500".');
//$this->context->addViolation('');
$test1 = preg_match('/^[0-9x]+$/', $field->image_size);
if (!$test1) {
$this->context->addViolation($message);
}
}
}
No preview for this file type
......@@ -106,8 +106,23 @@ msgstr "Nom de la version"
msgid "URL"
msgstr "URL"
msgid "Size"
msgstr "Taille"
msgid "Name"
msgstr "Nom"
msgid "version"
msgstr "version"
msgid "Select"
msgstr "Sélectionner"
msgid "An url will be automatically associated with each version with the same name in Ephoto Dam"
msgstr "Une url sera automatiquement associée à chaque version du même nom dans Ephoto Dam"
msgid "Versions support"
msgstr "Prise en charge des versions"
msgid "The \"Size\" field must respect one of the following patterns: \"x{height}\", \"{width}x\", \"{width}x{height}\" or \"{width/height (detect auto)}\". Examples: \"x500\", \"500x\", \"500x500\" or \"500\"."
msgstr "Le champ \"Taille\" doit respecter un des paternes suivant : \"x{hauteur}\", \"{longueur}x\", \"{longueur}x{hauteur}\" ou \"{longueur/hauteur(auto)}\". Exemples: \"x500\", \"500x\", \"500x500\" ou \"500\"."
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment