ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
ilAdvancedMDTranslationGUI Class Reference
+ Inheritance diagram for ilAdvancedMDTranslationGUI:
+ Collaboration diagram for ilAdvancedMDTranslationGUI:

Public Member Functions

 __construct (ilAdvancedMDRecord $record)
 
 executeCommand ()
 Execute command and save parameter record id. More...
 

Protected Member Functions

 setTabs (string $active_tab)
 
 translations ()
 
 addTranslations (ilPropertyFormGUI $form=null)
 show translation creation form More...
 
 initCreateTranslationForm ()
 
 addToolbarLanguageCreation ()
 
 getAvailableLanguagesOptions ()
 
 saveAdditionalTranslations ()
 

Protected Attributes

const CMD_DEFAULT = 'translations'
 
const CMD_ADD_TRANSLATION = 'addTranslations'
 
const CMD_SAVE_ADDITIONAL_TRANSLATIONS = 'saveAdditionalTranslations'
 
ilCtrl $ctrl
 
ilGlobalTemplateInterface $tpl
 
ilToolbarGUI $toolbar
 
ilTabsGUI $tabs
 
ilLanguage $language
 
RequestInterface $request
 
ilLogger $logger
 
ilAdvancedMDRecord $record
 

Detailed Description

Definition at line 7 of file class.ilAdvancedMDTranslationGUI.php.

Constructor & Destructor Documentation

◆ __construct()

ilAdvancedMDTranslationGUI::__construct ( ilAdvancedMDRecord  $record)

PhpUndefinedMethodInspection

Definition at line 22 of file class.ilAdvancedMDTranslationGUI.php.

References $DIC, $record, ILIAS\Repository\ctrl(), ILIAS\UI\examples\Symbol\Glyph\Language\language(), ILIAS\Repository\logger(), ILIAS\Repository\tabs(), and ILIAS\Repository\toolbar().

23  {
24  global $DIC;
25 
26  $this->ctrl = $DIC->ctrl();
27  $this->tpl = $DIC->ui()->mainTemplate();
28  $this->toolbar = $DIC->toolbar();
29  $this->tabs = $DIC->tabs();
30  $this->language = $DIC->language();
31  $this->language->loadLanguageModule('obj');
32  $this->request = $DIC->http()->request();
34  $this->logger = $DIC->logger()->amet();
35  $this->record = $record;
36  }
global $DIC
Definition: feed.php:28
+ Here is the call graph for this function:

Member Function Documentation

◆ addToolbarLanguageCreation()

ilAdvancedMDTranslationGUI::addToolbarLanguageCreation ( )
protected

Definition at line 106 of file class.ilAdvancedMDTranslationGUI.php.

References ILIAS\Repository\ctrl(), ilLinkButton\getInstance(), and ILIAS\Repository\toolbar().

106  : void
107  {
108  $button = ilLinkButton::getInstance();
109  $button->setCaption('obj_add_languages');
110  $button->setUrl(
111  $this->ctrl->getLinkTargetByClass(
112  strtolower(get_class($this)),
113  self::CMD_ADD_TRANSLATION
114  )
115  );
116  $this->toolbar->addButtonInstance($button);
117  }
+ Here is the call graph for this function:

◆ addTranslations()

ilAdvancedMDTranslationGUI::addTranslations ( ilPropertyFormGUI  $form = null)
protected

show translation creation form

Definition at line 70 of file class.ilAdvancedMDTranslationGUI.php.

References initCreateTranslationForm(), and ILIAS\Repository\tabs().

Referenced by saveAdditionalTranslations().

71  {
72  $this->tabs->activateTab(self::CMD_DEFAULT);
73  if (!$form instanceof ilPropertyFormGUI) {
74  $form = $this->initCreateTranslationForm();
75  }
76  $this->tpl->setContent($form->getHTML());
77  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ executeCommand()

ilAdvancedMDTranslationGUI::executeCommand ( )

Execute command and save parameter record id.

Definition at line 41 of file class.ilAdvancedMDTranslationGUI.php.

References ILIAS\Repository\ctrl().

42  {
43  $this->ctrl->setParameterByClass(
44  strtolower(get_class($this)),
45  'record_id',
46  $this->record->getRecordId()
47  );
48 
49  $next_class = $this->ctrl->getNextClass($this);
50  $cmd = $this->ctrl->getCmd(self::CMD_DEFAULT);
51  switch ($next_class) {
52  default:
53  $this->$cmd();
54  }
55  }
+ Here is the call graph for this function:

◆ getAvailableLanguagesOptions()

ilAdvancedMDTranslationGUI::getAvailableLanguagesOptions ( )
protected
Returns
array<string, string>
Todo:
handle generic isConfigured

Definition at line 123 of file class.ilAdvancedMDTranslationGUI.php.

References ILIAS\LTI\ToolProvider\$key, $language, ilLanguage\_getInstalledLanguages(), ilAdvancedMDRecordTranslations\getInstanceByRecordId(), and ILIAS\UI\examples\Symbol\Glyph\Language\language().

Referenced by initCreateTranslationForm().

123  : array
124  {
125  $languages = ilAdvancedMDRecordTranslations::getInstanceByRecordId($this->record->getRecordId());
126 
127  $this->language->loadLanguageModule('meta');
128  $installed_languages = ilLanguage::_getInstalledLanguages();
129  $options = [];
130  $options[''] = $this->language->txt('select_one');
131  foreach ($installed_languages as $key => $language) {
132  if ($languages->isConfigured($language)) {
133  continue;
134  }
135  $options[$language] = $this->language->txt('meta_l_' . $language);
136  }
137  return $options;
138  }
string $key
Consumer key/client ID value.
Definition: System.php:193
static _getInstalledLanguages()
Get installed languages.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ initCreateTranslationForm()

ilAdvancedMDTranslationGUI::initCreateTranslationForm ( )
protected

Definition at line 79 of file class.ilAdvancedMDTranslationGUI.php.

References ILIAS\Repository\ctrl(), getAvailableLanguagesOptions(), and ILIAS\UI\examples\Symbol\Glyph\Language\language().

Referenced by addTranslations(), and saveAdditionalTranslations().

80  {
81  $form = new \ilPropertyFormGUI();
82  $form->setFormAction($this->ctrl->getFormAction($this));
83  $form->setTitle($this->language->txt('obj_add_languages'));
84 
85  $language_options = $this->getAvailableLanguagesOptions();
86  $languages = new ilSelectInputGUI(
87  $this->language->txt('obj_additional_langs'),
88  'languages'
89  );
90  $languages->setOptions($language_options);
91  $languages->setMulti(true);
92  $languages->setRequired(true);
93  $form->addItem($languages);
94 
95  $form->addCommandButton(
96  self::CMD_SAVE_ADDITIONAL_TRANSLATIONS,
97  $this->language->txt('save')
98  );
99  $form->addCommandButton(
100  self::CMD_DEFAULT,
101  $this->language->txt('cancel')
102  );
103  return $form;
104  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ saveAdditionalTranslations()

ilAdvancedMDTranslationGUI::saveAdditionalTranslations ( )
protected

Definition at line 140 of file class.ilAdvancedMDTranslationGUI.php.

References addTranslations(), ILIAS\Repository\ctrl(), ilAdvancedMDRecordTranslations\getInstanceByRecordId(), initCreateTranslationForm(), and ILIAS\UI\examples\Symbol\Glyph\Language\language().

140  : void
141  {
142  $form = $this->initCreateTranslationForm();
143  if (!$form->checkInput()) {
144  $form->setValuesByPost();
145  $this->tpl->setOnScreenMessage('failure', $this->language->txt('err_check_input'));
146  $this->addTranslations($form);
147  return;
148  }
149  foreach (array_unique((array) $form->getInput('languages')) as $language_code) {
150  $languages = ilAdvancedMDRecordTranslations::getInstanceByRecordId($this->record->getRecordId());
151  $languages->addTranslationEntry($language_code);
152  }
153 
154  $this->tpl->setOnScreenMessage('success', $this->language->txt('settings_saved'), true);
155  $this->ctrl->redirect($this, self::CMD_DEFAULT);
156  }
addTranslations(ilPropertyFormGUI $form=null)
show translation creation form
+ Here is the call graph for this function:

◆ setTabs()

ilAdvancedMDTranslationGUI::setTabs ( string  $active_tab)
protected

Definition at line 57 of file class.ilAdvancedMDTranslationGUI.php.

References ILIAS\Repository\tabs(), and translations().

Referenced by ilAdvancedMDRecordTranslationGUI\translations().

58  {
59  $this->tabs->activateTab($active_tab);
60  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ translations()

ilAdvancedMDTranslationGUI::translations ( )
abstractprotected
Returns
void

Referenced by setTabs().

+ Here is the caller graph for this function:

Field Documentation

◆ $ctrl

ilCtrl ilAdvancedMDTranslationGUI::$ctrl
protected

Definition at line 13 of file class.ilAdvancedMDTranslationGUI.php.

◆ $language

ilLanguage ilAdvancedMDTranslationGUI::$language
protected

Definition at line 17 of file class.ilAdvancedMDTranslationGUI.php.

Referenced by getAvailableLanguagesOptions().

◆ $logger

ilLogger ilAdvancedMDTranslationGUI::$logger
protected

Definition at line 19 of file class.ilAdvancedMDTranslationGUI.php.

◆ $record

ilAdvancedMDRecord ilAdvancedMDTranslationGUI::$record
protected

Definition at line 20 of file class.ilAdvancedMDTranslationGUI.php.

Referenced by __construct().

◆ $request

RequestInterface ilAdvancedMDTranslationGUI::$request
protected

Definition at line 18 of file class.ilAdvancedMDTranslationGUI.php.

◆ $tabs

ilTabsGUI ilAdvancedMDTranslationGUI::$tabs
protected

Definition at line 16 of file class.ilAdvancedMDTranslationGUI.php.

◆ $toolbar

ilToolbarGUI ilAdvancedMDTranslationGUI::$toolbar
protected

Definition at line 15 of file class.ilAdvancedMDTranslationGUI.php.

◆ $tpl

ilGlobalTemplateInterface ilAdvancedMDTranslationGUI::$tpl
protected

Definition at line 14 of file class.ilAdvancedMDTranslationGUI.php.

◆ CMD_ADD_TRANSLATION

const ilAdvancedMDTranslationGUI::CMD_ADD_TRANSLATION = 'addTranslations'
protected

Definition at line 10 of file class.ilAdvancedMDTranslationGUI.php.

◆ CMD_DEFAULT

const ilAdvancedMDTranslationGUI::CMD_DEFAULT = 'translations'
protected

Definition at line 9 of file class.ilAdvancedMDTranslationGUI.php.

◆ CMD_SAVE_ADDITIONAL_TRANSLATIONS

const ilAdvancedMDTranslationGUI::CMD_SAVE_ADDITIONAL_TRANSLATIONS = 'saveAdditionalTranslations'
protected

Definition at line 11 of file class.ilAdvancedMDTranslationGUI.php.


The documentation for this class was generated from the following file: