Skip to content

Commit

Permalink
[TASK] Add url to tca to get api keys
Browse files Browse the repository at this point in the history
  • Loading branch information
fseipel committed Nov 11, 2024
1 parent fca4bba commit 81c132c
Show file tree
Hide file tree
Showing 4 changed files with 342 additions and 271 deletions.
35 changes: 35 additions & 0 deletions Classes/FormEngine/FieldInformation/ApiKeyInfoElement.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php

declare(strict_types=1);

namespace Pagemachine\AItools\FormEngine\FieldInformation;

use TYPO3\CMS\Backend\Form\Element\AbstractFormElement;

class ApiKeyInfoElement extends AbstractFormElement
{

private $urls = [
'aigude' => 'https://aigude.io/',
'openai' => 'https://platform.openai.com/account/api-keys',
'deepl' => 'https://www.deepl.com/pro-api',
];

public function render()
{
$type = $this->data['recordTypeValue'];
$href = $this->urls[$type] ?? null;

if (!$href) {
return [
'html' => '',
];
}

$linkText = $this->getLanguageService()->sL('LLL:EXT:ai_tools/Resources/Private/Language/locallang_db.xlf:tx_aitools_domain_model_server.apikey.linktext');

return [
'html' => '<div class="form-control-wrap" style="font-weight: bold;">[<a href="' . htmlspecialchars((string) $href) . '" target="_blank">'. htmlspecialchars($linkText) . '</a>]</div>',
];
}
}
Loading

0 comments on commit 81c132c

Please sign in to comment.