mirror of
https://gitlab.unicamp.br/infimecc_drupal11_modules/site_users.git
synced 2026-05-06 07:25:28 -03:00
- Formatadores FieldFormatter para Lattes, ORCID e MathSciNet: geram link para o perfil na plataforma a partir do ID armazenado no campo - MicrositeHeaderBlock: inclui lattes_id, orcid_id e mathscinet_id - Template: exibe ícones SVG via site_tools_academic_icon() (extensão Twig do módulo site_tools) com links acessíveis para cada plataforma - CSS: estilos para .msite-header-block__academic-links com animação de hover nos ícones Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
49 lines
1.3 KiB
PHP
49 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace Drupal\site_users\Plugin\Field\FieldFormatter;
|
|
|
|
use Drupal\Core\Field\Attribute\FieldFormatter;
|
|
use Drupal\Core\Field\FieldDefinitionInterface;
|
|
use Drupal\Core\Field\FieldItemListInterface;
|
|
use Drupal\Core\Field\FormatterBase;
|
|
use Drupal\Core\StringTranslation\TranslatableMarkup;
|
|
use Drupal\Core\Url;
|
|
|
|
/**
|
|
* Formata o ORCID como link para o perfil em orcid.org.
|
|
*
|
|
* URL gerada: https://orcid.org/{orcid}
|
|
*
|
|
* @FieldFormatter(
|
|
* id = "site_users_orcid_link",
|
|
* label = @Translation("Link para o perfil ORCID"),
|
|
* field_types = {"string"}
|
|
* )
|
|
*/
|
|
#[FieldFormatter(
|
|
id: 'site_users_orcid_link',
|
|
label: new TranslatableMarkup('Link para o perfil ORCID'),
|
|
field_types: ['string'],
|
|
)]
|
|
class OrcidLinkFormatter extends FormatterBase {
|
|
|
|
public static function isApplicable(FieldDefinitionInterface $field_definition): bool {
|
|
return $field_definition->getName() === 'field_user_orcid';
|
|
}
|
|
|
|
public function viewElements(FieldItemListInterface $items, $langcode): array {
|
|
$elements = [];
|
|
foreach ($items as $delta => $item) {
|
|
$id = $item->value;
|
|
$elements[$delta] = [
|
|
'#type' => 'link',
|
|
'#title' => $id,
|
|
'#url' => Url::fromUri('https://orcid.org/' . $id),
|
|
'#attributes' => ['target' => '_blank', 'rel' => 'noopener noreferrer'],
|
|
];
|
|
}
|
|
return $elements;
|
|
}
|
|
|
|
}
|