19declare(strict_types=1);
21use Psr\Http\Message\RequestInterface;
58 $this->
ctrl = $DIC->ctrl();
59 $this->tpl =
$DIC->ui()->mainTemplate();
60 $this->
toolbar = $DIC->toolbar();
61 $this->
tabs = $DIC->tabs();
63 $this->
language->loadLanguageModule(
'obj');
64 $this->request =
$DIC->http()->request();
66 $this->ui_factory =
$DIC->ui()->factory();
67 $this->ui_renderer =
$DIC->ui()->renderer();
68 $this->
http = $DIC->http();
70 $this->data_factory =
new DataFactory();
72 $this->record->getRecordId()
81 $this->
ctrl->setParameterByClass(
82 strtolower(get_class($this)),
84 $this->record->getRecordId()
87 $next_class = $this->
ctrl->getNextClass($this);
88 $cmd = $this->
ctrl->getCmd(self::CMD_DEFAULT);
90 switch ($next_class) {
104 protected function setTabs(
string $active_tab)
106 $this->
tabs->activateTab($active_tab);
111 $this->
setTabs(self::CMD_DEFAULT);
116 $this->record_translations
127 $table = $table_builder->get($url_builder, $id_token, $action_token);
129 $this->tpl->setContent($this->ui_renderer->render($table));
134 $link = ILIAS_HTTP_PATH .
'/' . $this->
ctrl->getLinkTargetByClass(
135 ilAdvancedMDRecordTranslationGUI::class,
136 $this::CMD_TABLE_ACTION
138 $url_builder =
new URLBuilder($this->data_factory->uri($link));
140 return $url_builder->acquireParameters([
'advmd_ml'],
'table_ids',
'table_action');
145 $parameter_name = $id_token->
getName();
146 $wrapper = $this->
http->wrapper()->query();
149 if ($wrapper->has($parameter_name)) {
150 $raw_ids = $wrapper->retrieve(
152 $this->
refinery->kindlyTo()->listOf($this->refinery->kindlyTo()->string())
156 if ($raw_ids === [
'ALL_OBJECTS']) {
160 return $raw_ids ?? [];
165 $name = $action_token->
getName();
166 $wrapper = $this->
http->wrapper()->query();
168 if ($wrapper->has($name)) {
169 return (
string) $wrapper->retrieve(
171 $this->
refinery->kindlyTo()->string()
183 $this->record_translations
190 case TableBuilder::ACTION_ACTIVATE:
193 case TableBuilder::ACTION_DEACTIVATE:
196 case TableBuilder::ACTION_SET_DEFAULT:
203 protected function activate(array $lang_keys): void
205 $record_id = $this->record->getRecordId();
208 foreach ($lang_keys as $lang_key) {
209 if (!$translations->isConfigured($lang_key)) {
210 $translations->addTranslationEntry($lang_key);
214 if (count($lang_keys) > 0) {
215 $this->tpl->setOnScreenMessage(
'success', $this->
language->txt(
'settings_saved'),
true);
218 $this->
ctrl->redirect($this, self::CMD_DEFAULT);
223 $record_id = $this->record->getRecordId();
227 foreach ($lang_keys as $lang_key) {
228 if ($lang_key === $this->record->getDefaultLanguage()) {
229 $this->tpl->setOnScreenMessage(
'failure', $this->
language->txt(
'md_adn_int_error_no_default'),
true);
231 $translation = $translations->getTranslation($lang_key);
233 $translation->delete();
240 $this->tpl->setOnScreenMessage(
'success', $this->
language->txt(
'settings_saved'),
true);
243 $this->
ctrl->redirect($this, self::CMD_DEFAULT);
248 $lang_key = reset($lang_keys);
251 $this->
ctrl->redirect($this, self::CMD_DEFAULT);
255 if (!$translations->isConfigured($lang_key)) {
256 $this->tpl->setOnScreenMessage(
'failure', $this->
language->txt(
'err_check_input'),
true);
257 $this->
ctrl->redirect($this, self::CMD_DEFAULT);
260 $this->record->setDefaultLanguage($lang_key);
261 $this->record->update();
263 $this->tpl->setOnScreenMessage(
'success', $this->
language->txt(
'settings_saved'),
true);
264 $this->
ctrl->redirect($this, self::CMD_DEFAULT);
Builds a Color from either hex- or rgb values.
getName()
Get the full name of the token including its namespace.
@ilCtrl_IsCalledBy ilAdvancedMDRecordTranslationGUI: ilAdvancedMDSettingsGUI
getTableActionURLBuilder()
getLanguageCodesFromQuery(URLBuilderToken $id_token, DataRetrieval $data_retrieval)
__construct(ilAdvancedMDRecord $record)
DataFactory $data_factory
RequestInterface $request
ilAdvancedMDRecordTranslations $record_translations
ilAdvancedMDRecord $record
ilGlobalTemplateInterface $tpl
executeCommand()
Execute command and save parameter record id.
setTabs(string $active_tab)
getTableActionFromQuery(URLBuilderToken $action_token)
RefineryFactory $refinery
const string CMD_TABLE_ACTION
setDefault(array $lang_keys)
activate(array $lang_keys)
deactivate(array $lang_keys)
Class ilAdvancedMDRecordTranslation.
static getInstanceByRecordId(int $record_id)
Class ilCtrl provides processing control methods.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
An entity that renders components to a string output.
static http()
Fetches the global http state from ILIAS.