mirror of
https://gitlab.unicamp.br/infimecc_drupal11_modules/site_users.git
synced 2026-05-06 23:55:28 -03:00
Adiciona links acadêmicos ao MicrositeHeaderBlock e formatadores de campo
- 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>
This commit is contained in:
48
src/Plugin/Field/FieldFormatter/MathSciNetLinkFormatter.php
Normal file
48
src/Plugin/Field/FieldFormatter/MathSciNetLinkFormatter.php
Normal file
@@ -0,0 +1,48 @@
|
||||
<?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 MathSciNet ID como link para o perfil de autor no MathSciNet.
|
||||
*
|
||||
* URL gerada: https://mathscinet.ams.org/mathscinet/author?AuthorID={id}
|
||||
*
|
||||
* @FieldFormatter(
|
||||
* id = "site_users_mathscinet_link",
|
||||
* label = @Translation("Link para o perfil MathSciNet"),
|
||||
* field_types = {"integer"}
|
||||
* )
|
||||
*/
|
||||
#[FieldFormatter(
|
||||
id: 'site_users_mathscinet_link',
|
||||
label: new TranslatableMarkup('Link para o perfil MathSciNet'),
|
||||
field_types: ['integer'],
|
||||
)]
|
||||
class MathSciNetLinkFormatter extends FormatterBase {
|
||||
|
||||
public static function isApplicable(FieldDefinitionInterface $field_definition): bool {
|
||||
return $field_definition->getName() === 'field_user_mathscinetid';
|
||||
}
|
||||
|
||||
public function viewElements(FieldItemListInterface $items, $langcode): array {
|
||||
$elements = [];
|
||||
foreach ($items as $delta => $item) {
|
||||
$id = (string) $item->value;
|
||||
$elements[$delta] = [
|
||||
'#type' => 'link',
|
||||
'#title' => $id,
|
||||
'#url' => Url::fromUri('https://mathscinet.ams.org/mathscinet/author?AuthorID=' . $id),
|
||||
'#attributes' => ['target' => '_blank', 'rel' => 'noopener noreferrer'],
|
||||
];
|
||||
}
|
||||
return $elements;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user