Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .project/tests/phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -2515,6 +2515,16 @@ parameters:
count: 1
path: ../../Classes/Hook/PluginPreviewRenderer.php

-
message: "#^If condition is always true\\.$#"
count: 1
path: ../../Classes/Tca/AddAutocompleteTokens.php

-
message: "#^Offset 'useDefaultItems' on string on left side of \\?\\? does not exist\\.$#"
count: 1
path: ../../Classes/Tca/AddAutocompleteTokens.php

-
message: "#^Method In2code\\\\Powermail\\\\Tca\\\\AddOptionsToSelection\\:\\:addOptionsForFeUserProperty\\(\\) has parameter \\$params with no value type specified in iterable type array\\.$#"
count: 1
Expand Down
92 changes: 92 additions & 0 deletions Classes/Domain/Model/Field.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,26 @@ class Field extends AbstractEntity

protected string $mandatoryText = '';

/**
* @var string
*/
protected string $autocompleteToken = '';

/**
* @var string
*/
protected string $autocompleteSection = '';

/**
* @var string
*/
protected string $autocompleteType = '';

/**
* @var string
*/
protected string $autocompletePurpose = '';

/**
* @var Page
* This property can hold Page|int|null (depending on the context). "@var" must set to Page for property mapping.
Expand Down Expand Up @@ -643,4 +663,76 @@ protected function getExportableTypesFromTypoScript(): array

return $types;
}

/**
* @return string
*/
public function getAutocompleteToken(): string
{
return $this->autocompleteToken;
}

/**
* @param string $autocompleteToken
*
* @return void
*/
public function setAutocompleteToken(string $autocompleteToken): void
{
$this->autocompleteToken = $autocompleteToken;
}

/**
* @return string
*/
public function getAutocompleteSection(): string
{
return $this->autocompleteSection;
}

/**
* @param string $autocompleteSection
*
* @return void
*/
public function setAutocompleteSection(string $autocompleteSection): void
{
$this->autocompleteSection = $autocompleteSection;
}

/**
* @return string
*/
public function getAutocompleteType(): string
{
return $this->autocompleteType;
}

/**
* @param string $autocompleteType
*
* @return void
*/
public function setAutocompleteType(string $autocompleteType): void
{
$this->autocompleteType = $autocompleteType;
}

/**
* @return string
*/
public function getAutocompletePurpose(): string
{
return $this->autocompletePurpose;
}

/**
* @param string $autocompletePurpose
*
* @return void
*/
public function setAutocompletePurpose(string $autocompletePurpose): void
{
$this->autocompletePurpose = $autocompletePurpose;
}
}
23 changes: 23 additions & 0 deletions Classes/Domain/Model/Form.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ class Form extends AbstractEntity
*/
protected array $pagesByUid = [];

protected string $autocompleteToken = '';

/**
* @return string
*/
public function getTitle(): string
{
return $this->title;
Expand Down Expand Up @@ -195,4 +200,22 @@ protected function isCorrectFieldType(Field $field, string $fieldType): bool

return false;
}

/**
* @return string
*/
public function getAutocompleteToken(): string
{
return $this->autocompleteToken;
}

/**
* @param string $autocompleteToken
*
* @return void
*/
public function setAutocompleteToken(string $autocompleteToken): void
{
$this->autocompleteToken = $autocompleteToken;
}
}
96 changes: 96 additions & 0 deletions Classes/Tca/AddAutocompleteTokens.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
<?php

declare(strict_types=1);

namespace In2code\Powermail\Tca;

/**
* Class AddAutocompleteTokens
*/
class AddAutocompleteTokens
{
/**
* @var string
*/
public static string $LLL = 'LLL:EXT:powermail/Resources/Private/Language/locallang_db.xlf:autocomplete_token.';

/**
* @param array<array<string>> $config
*
* @return void
*/
public function getAutocompleteTokens(array &$config)
{
if ($config['config']['itemsProcConfig']['useDefaultItems'] ?? true) {
$defaultSelectItems = self::getDefaultAutocompleteTokens();
$config['items'] = array_merge(
$config['items'],
$defaultSelectItems
);
}
}

/**
* https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#autofill-field
* @return array<array<string>>
*/
public static function getDefaultAutocompleteTokens(): array
{
return [
['label' => self::$LLL . 'name', 'value' => 'name', 'icon' => '', 'group' => 'name'],
['label' => self::$LLL . 'honorific-prefix', 'value' => 'honorific-prefix', 'icon' => '', 'group' => 'name'],
['label' => self::$LLL . 'given-name', 'value' => 'given-name', 'icon' => '', 'group' => 'name'],
['label' => self::$LLL . 'additional-name', 'value' => 'additional-name', 'icon' => '', 'group' => 'name'],
['label' => self::$LLL . 'family-name', 'value' => 'family-name', 'icon' => '', 'group' => 'name'],
['label' => self::$LLL . 'honorific-suffix', 'value' => 'honorific-suffix', 'icon' => '', 'group' => 'name'],
['label' => self::$LLL . 'nickname', 'value' => 'nickname', 'icon' => '', 'group' => 'name'],
['label' => self::$LLL . 'sex', 'value' => 'sex', 'icon' => '', 'group' => 'name'],
['label' => self::$LLL . 'email', 'value' => 'email', 'icon' => '', 'group' => 'contact'],
['label' => self::$LLL . 'impp', 'value' => 'impp', 'icon' => '', 'group' => 'contact'],
['label' => self::$LLL . 'url', 'value' => 'url', 'icon' => '', 'group' => 'contact'],
['label' => self::$LLL . 'organization-title', 'value' => 'organization-title', 'icon' => '', 'group' => 'contact'],
['label' => self::$LLL . 'organization', 'value' => 'organization', 'icon' => '', 'group' => 'contact'],
['label' => self::$LLL . 'street-address', 'value' => 'street-address', 'icon' => '', 'group' => 'contact'],
['label' => self::$LLL . 'country', 'value' => 'country', 'icon' => '', 'group' => 'contact'],
['label' => self::$LLL . 'country-name', 'value' => 'country-name', 'icon' => '', 'group' => 'contact'],
['label' => self::$LLL . 'postal-code', 'value' => 'postal-code', 'icon' => '', 'group' => 'contact'],
['label' => self::$LLL . 'address-line1', 'value' => 'address-line1', 'icon' => '', 'group' => 'address'],
['label' => self::$LLL . 'address-line2', 'value' => 'address-line2', 'icon' => '', 'group' => 'address'],
['label' => self::$LLL . 'address-line3', 'value' => 'address-line3', 'icon' => '', 'group' => 'address'],
['label' => self::$LLL . 'address-level1', 'value' => 'address-level1', 'icon' => '', 'group' => 'address'],
['label' => self::$LLL . 'address-level2', 'value' => 'address-level2', 'icon' => '', 'group' => 'address'],
['label' => self::$LLL . 'address-level3', 'value' => 'address-level3', 'icon' => '', 'group' => 'address'],
['label' => self::$LLL . 'address-level4', 'value' => 'address-level4', 'icon' => '', 'group' => 'address'],
['label' => self::$LLL . 'tel', 'value' => 'tel', 'icon' => '', 'group' => 'tel'],
['label' => self::$LLL . 'tel-country-code', 'value' => 'tel-country-code', 'icon' => '', 'group' => 'tel'],
['label' => self::$LLL . 'tel-area-code', 'value' => 'tel-area-code', 'icon' => '', 'group' => 'tel'],
['label' => self::$LLL . 'tel-national', 'value' => 'tel-national', 'icon' => '', 'group' => 'tel'],
['label' => self::$LLL . 'tel-local', 'value' => 'tel-local', 'icon' => '', 'group' => 'tel'],
['label' => self::$LLL . 'tel-local-prefix', 'value' => 'tel-local-prefix', 'icon' => '', 'group' => 'tel'],
['label' => self::$LLL . 'tel-local-suffix', 'value' => 'tel-local-suffix', 'icon' => '', 'group' => 'tel'],
['label' => self::$LLL . 'tel-extension', 'value' => 'tel-extension', 'icon' => '', 'group' => 'tel'],
['label' => self::$LLL . 'username', 'value' => 'username', 'icon' => '', 'group' => 'user'],
['label' => self::$LLL . 'new-password', 'value' => 'new-password', 'icon' => '', 'group' => 'user'],
['label' => self::$LLL . 'current-password', 'value' => 'current-password', 'icon' => '', 'group' => 'user'],
['label' => self::$LLL . 'one-time-code', 'value' => 'one-time-code', 'icon' => '', 'group' => 'user'],
['label' => self::$LLL . 'bday', 'value' => 'bday', 'icon' => '', 'group' => 'bday'],
['label' => self::$LLL . 'bday-day', 'value' => 'bday-day', 'icon' => '', 'group' => 'bday'],
['label' => self::$LLL . 'bday-month', 'value' => 'bday-month', 'icon' => '', 'group' => 'bday'],
['label' => self::$LLL . 'bday-year', 'value' => 'bday-year', 'icon' => '', 'group' => 'bday'],
['label' => self::$LLL . 'cc-name', 'value' => 'cc-name', 'icon' => '', 'group' => 'cc'],
['label' => self::$LLL . 'cc-given-name', 'value' => 'cc-given-name', 'icon' => '', 'group' => 'cc'],
['label' => self::$LLL . 'cc-additional-name', 'value' => 'cc-additional-name', 'icon' => '', 'group' => 'cc'],
['label' => self::$LLL . 'cc-family-name', 'value' => 'cc-family-name', 'icon' => '', 'group' => 'cc'],
['label' => self::$LLL . 'cc-number', 'value' => 'cc-number', 'icon' => '', 'group' => 'cc'],
['label' => self::$LLL . 'cc-exp', 'value' => 'cc-exp', 'icon' => '', 'group' => 'cc'],
['label' => self::$LLL . 'cc-exp-month', 'value' => 'cc-exp-month', 'icon' => '', 'group' => 'cc'],
['label' => self::$LLL . 'cc-exp-year', 'value' => 'cc-exp-year', 'icon' => '', 'group' => 'cc'],
['label' => self::$LLL . 'cc-csc', 'value' => 'cc-csc', 'icon' => '', 'group' => 'cc'],
['label' => self::$LLL . 'cc-type', 'value' => 'cc-type', 'icon' => '', 'group' => 'cc'],
['label' => self::$LLL . 'transaction-currency', 'value' => 'transaction-currency', 'icon' => '', 'group' => 'cc'],
['label' => self::$LLL . 'transaction-amount', 'value' => 'transaction-amount', 'icon' => '', 'group' => 'cc'],
['label' => self::$LLL . 'language', 'value' => 'language', 'icon' => '', 'group' => 'other'],
['label' => self::$LLL . 'photo', 'value' => 'photo', 'icon' => '', 'group' => 'other'],
];
}
}
Loading