Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
03728ce49f | ||
|
|
a7637aedcc | ||
|
|
7f4f86080a |
@@ -30,6 +30,6 @@ Szkielet komponentu Joomla 6 do gromadzenia pytań testowych.
|
|||||||
|
|
||||||
## Instalacja
|
## Instalacja
|
||||||
|
|
||||||
W Joomla wybierz **System → Install → Install from Folder** i wskaż ten katalog. Manifestem instalacyjnym jest `com_testquestions.xml` (wersja 1.42.2).
|
W Joomla wybierz **System → Install → Install from Folder** i wskaż ten katalog. Manifestem instalacyjnym jest `com_testquestions.xml` (wersja 1.42.5).
|
||||||
|
|
||||||
Po instalacji komponent jest dostępny w panelu administratora jako **Pytania testowe**.
|
Po instalacji komponent jest dostępny w panelu administratora jako **Pytania testowe**.
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
<option value="openai">OpenAI</option>
|
<option value="openai">OpenAI</option>
|
||||||
<option value="grok">Grok</option>
|
<option value="grok">Grok</option>
|
||||||
</field>
|
</field>
|
||||||
<field name="ai_api_key" type="password" label="COM_TESTQUESTIONS_AI_API_KEY" filter="raw" autocomplete="off" />
|
<field name="ai_api_key" type="aiapikey" addfieldprefix="Komponent\Component\Testquestions\Administrator\Field" label="COM_TESTQUESTIONS_AI_API_KEY" filter="raw" autocomplete="off" size="120" class="w-100" />
|
||||||
</fieldset>
|
</fieldset>
|
||||||
</fields>
|
</fields>
|
||||||
</config>
|
</config>
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
-- No database changes required for version 1.42.3.
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
-- No database changes required for version 1.42.4.
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
-- No database changes required for version 1.42.5.
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Komponent\Component\Testquestions\Administrator\Field;
|
||||||
|
|
||||||
|
defined('_JEXEC') or die;
|
||||||
|
|
||||||
|
use Joomla\CMS\Form\FormField;
|
||||||
|
|
||||||
|
class AiapikeyField extends FormField
|
||||||
|
{
|
||||||
|
protected $type = 'Aiapikey';
|
||||||
|
|
||||||
|
protected function getInput(): string
|
||||||
|
{
|
||||||
|
$id = htmlspecialchars($this->id, ENT_QUOTES, 'UTF-8');
|
||||||
|
$name = htmlspecialchars($this->name, ENT_QUOTES, 'UTF-8');
|
||||||
|
$value = htmlspecialchars((string) $this->value, ENT_QUOTES, 'UTF-8');
|
||||||
|
$length = mb_strlen((string) $this->value);
|
||||||
|
|
||||||
|
return '<div class="input-group">'
|
||||||
|
. '<input type="password" id="' . $id . '" name="' . $name . '" value="' . $value . '" size="120" autocomplete="off" class="form-control">'
|
||||||
|
. '<button type="button" class="btn btn-outline-secondary" data-ai-key-toggle="' . $id . '">Pokaż</button>'
|
||||||
|
. '</div>'
|
||||||
|
. '<small class="form-text text-muted">Zapisany klucz: ' . (int) $length . ' znaków.</small>'
|
||||||
|
. '<script>
|
||||||
|
document.addEventListener("click", function (event) {
|
||||||
|
var button = event.target.closest("[data-ai-key-toggle]");
|
||||||
|
if (!button) return;
|
||||||
|
var input = document.getElementById(button.getAttribute("data-ai-key-toggle"));
|
||||||
|
if (!input) return;
|
||||||
|
var visible = input.type === "text";
|
||||||
|
input.type = visible ? "password" : "text";
|
||||||
|
button.textContent = visible ? "Pokaż" : "Ukryj";
|
||||||
|
});
|
||||||
|
</script>';
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -94,22 +94,29 @@ class ResultModel extends BaseDatabaseModel
|
|||||||
$provider = trim((string) $params->get('ai_provider', 'openai'));
|
$provider = trim((string) $params->get('ai_provider', 'openai'));
|
||||||
$apiKey = trim((string) $params->get('ai_api_key', ''));
|
$apiKey = trim((string) $params->get('ai_api_key', ''));
|
||||||
|
|
||||||
// Pole typu password może zwrócić zamaskowaną wartość zamiast pustej.
|
// Odczytaj zapisane parametry bezpośrednio z bazy. Dzięki temu nie użyjemy
|
||||||
// W takim przypadku odczytaj rzeczywiste parametry bezpośrednio z rekordu rozszerzenia.
|
// nieaktualnej wartości z pamięci ComponentHelper, a maska pola hasła
|
||||||
if ($apiKey === '' || preg_match('/^\*+$/', $apiKey)) {
|
// (np. ********) nie zostanie potraktowana jako prawdziwy klucz.
|
||||||
$db = Factory::getContainer()->get('DatabaseDriver');
|
$db = Factory::getContainer()->get('DatabaseDriver');
|
||||||
$storedParams = (string) $db->setQuery(
|
$storedParams = (string) $db->setQuery(
|
||||||
$db->getQuery(true)
|
$db->getQuery(true)
|
||||||
->select($db->quoteName('params'))
|
->select($db->quoteName('params'))
|
||||||
->from($db->quoteName('#__extensions'))
|
->from($db->quoteName('#__extensions'))
|
||||||
->where($db->quoteName('type') . ' = ' . $db->quote('component'))
|
->where($db->quoteName('type') . ' = ' . $db->quote('component'))
|
||||||
->where($db->quoteName('element') . ' = ' . $db->quote('com_testquestions'))
|
->where($db->quoteName('element') . ' = ' . $db->quote('com_testquestions'))
|
||||||
)->loadResult();
|
)->loadResult();
|
||||||
$storedParams = json_decode($storedParams, true);
|
$storedParams = json_decode($storedParams, true);
|
||||||
|
|
||||||
if (is_array($storedParams)) {
|
if (is_array($storedParams)) {
|
||||||
$provider = trim((string) ($storedParams['ai_provider'] ?? $provider));
|
$storedProvider = trim((string) ($storedParams['ai_provider'] ?? ''));
|
||||||
$apiKey = trim((string) ($storedParams['ai_api_key'] ?? ''));
|
$storedApiKey = trim((string) ($storedParams['ai_api_key'] ?? ''));
|
||||||
|
|
||||||
|
if ($storedProvider !== '') {
|
||||||
|
$provider = $storedProvider;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($storedApiKey !== '' && !preg_match('/^\*+$/', $storedApiKey)) {
|
||||||
|
$apiKey = $storedApiKey;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
<creationDate>2026-10-14</creationDate>
|
<creationDate>2026-10-14</creationDate>
|
||||||
<author>Komponent</author>
|
<author>Komponent</author>
|
||||||
<license>GNU General Public License version 2 or later</license>
|
<license>GNU General Public License version 2 or later</license>
|
||||||
<version>1.42.2</version>
|
<version>1.42.5</version>
|
||||||
<description>COM_TESTQUESTIONS_DESCRIPTION</description>
|
<description>COM_TESTQUESTIONS_DESCRIPTION</description>
|
||||||
<element>com_testquestions</element>
|
<element>com_testquestions</element>
|
||||||
<namespace path="src">Komponent\Component\Testquestions</namespace>
|
<namespace path="src">Komponent\Component\Testquestions</namespace>
|
||||||
|
|||||||
Reference in New Issue
Block a user