ILIAS  release_8 Revision v8.24
ilCharSelectorGUI Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. More...

+ Inheritance diagram for ilCharSelectorGUI:
+ Collaboration diagram for ilCharSelectorGUI:

Public Member Functions

 setConfig (ilCharSelectorConfig $a_config)
 
 getConfig ()
 
 addFormProperties (ilPropertyFormGUI $a_form)
 add the configuration elements to a property form More...
 
 setFormValues (ilPropertyFormGUI $a_form)
 Set the values in a property form based on the configuration. More...
 
 getFormValues (ilPropertyFormGUI $a_form)
 Set the configuration based on the values of a property form. More...
 
 addToPage ()
 Adds the the character selector to the ilias page Initializes the selector according to the state saved in the user session. More...
 
 getSelectorHTML ()
 Get the HTML code of the selector panel. More...
 
 saveState ()
 Save the selector panel state in the user session (This keeps the panel state between page moves) More...
 
 executeCommand ()
 

Static Public Member Functions

static _isAllowed ()
 Check if the CharSelector is allowed for the current GUI. More...
 
static _getCurrentGUI (ilObjTest $a_test_obj=null)
 Get the GUI that is used for the currently available selector (other GUI instances may exist for configuration in property forms) More...
 

Protected Attributes

ilLanguage $lng
 
ilCtrl $ctrl
 
ilGlobalTemplateInterface $tpl
 
stdClass $jsconfig
 
stdClass $jstexts
 
ILIAS Refinery Factory $refinery
 
ILIAS HTTP Wrapper WrapperFactory $wrapper
 

Private Attributes

ilCharSelectorConfig $config = null
 
bool $added_to_page = false
 

Static Private Attributes

static array $allowed_guis
 list of command classes for which the char selector is allowed (can also be a parent class of the actual command class) More...
 
static ilCharSelectorGUI $current_gui
 

Detailed Description

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning This shows a character selector

Deprecated:
needs to be moved to KS

Definition at line 23 of file class.ilCharSelectorGUI.php.

Member Function Documentation

◆ _getCurrentGUI()

static ilCharSelectorGUI::_getCurrentGUI ( ilObjTest  $a_test_obj = null)
static

Get the GUI that is used for the currently available selector (other GUI instances may exist for configuration in property forms)

Definition at line 103 of file class.ilCharSelectorGUI.php.

103 : self
104 {
105 if (!isset(self::$current_gui)) {
106 self::$current_gui = new ilCharSelectorGUI();
107 self::$current_gui->setConfig(ilCharSelectorConfig::_getCurrentConfig($a_test_obj));
108 }
109 return self::$current_gui;
110 }
static _getCurrentConfig(ilObjTest $a_test_obj=null)
Get the configuration that should be used for the current selector.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static ilCharSelectorGUI $current_gui

References $current_gui, and ilCharSelectorConfig\_getCurrentConfig().

Referenced by ilPropertyFormGUI\getContent(), and ilTestPlayerAbstractGUI\populateCharSelectorIfRequired().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _isAllowed()

static ilCharSelectorGUI::_isAllowed ( )
static

Check if the CharSelector is allowed for the current GUI.

Definition at line 73 of file class.ilCharSelectorGUI.php.

73 : bool
74 {
75 global $DIC;
76
77 $ilCtrl = $DIC->ctrl();
78
79 // get the command class
80 // with correct case for checking parent classes
81 $class = false;
82 foreach ($ilCtrl->getCallHistory() as $call) {
83 if (($call['mode'] ?? "") === 'execComm') {
84 $class = $call['class'];
85 }
86 }
87
88 // check the class and her parent classes
89 while ($class != false) {
90 if (in_array($class, self::$allowed_guis)) {
91 return true;
92 }
93 $class = get_parent_class($class);
94 }
95
96 return false;
97 }
global $DIC
Definition: feed.php:28

References $DIC.

Referenced by ilPropertyFormGUI\getContent().

+ Here is the caller graph for this function:

◆ addFormProperties()

ilCharSelectorGUI::addFormProperties ( ilPropertyFormGUI  $a_form)

add the configuration elements to a property form

Definition at line 125 of file class.ilCharSelectorGUI.php.

125 : void
126 {
128 $lng->loadLanguageModule('adve');
129
130 $availability = new ilCharSelectorRadioGroupInputGUI($lng->txt('char_selector_' . $this->config->getContext()), 'char_selector_availability');
131 $inactive = new ilRadioOption($lng->txt('char_selector_inactive_' . $this->config->getContext()), ilCharSelectorConfig::INACTIVE);
132 $inactive->setInfo($lng->txt('char_selector_inactive_info_' . $this->config->getContext()));
133 $inherit = new ilRadioOption($lng->txt('char_selector_inherit_' . $this->config->getContext()), ilCharSelectorConfig::INHERIT);
134 $inherit->setInfo($lng->txt('char_selector_inherit_info_' . $this->config->getContext()));
135 $enabled = new ilRadioOption($lng->txt('char_selector_enabled_' . $this->config->getContext()), ilCharSelectorConfig::ENABLED);
136 $enabled->setInfo($lng->txt('char_selector_enabled_info_' . $this->config->getContext()));
137 $disabled = new ilRadioOption($lng->txt('char_selector_disabled_' . $this->config->getContext()), ilCharSelectorConfig::DISABLED);
138 $disabled->setInfo($lng->txt('char_selector_disabled_info_' . $this->config->getContext()));
139
140 $blocks = new ilSelectInputGUI($lng->txt('char_selector_blocks'), 'char_selector_blocks');
141 $blocks->setInfo($lng->txt('char_selector_blocks_info'));
142 $blocks->setOptions($this->config->getBlockOptions());
143 $blocks->setMulti(true);
144 $enabled->addSubItem($blocks);
145
146 $custom_items = new ilTextAreaInputGUI($lng->txt('char_selector_custom_items'), 'char_selector_custom_items');
147 $tpl = new ilTemplate("tpl.char_selector_custom_info.html", true, true, "Services/UIComponent/CharSelector");
148 $tpl->setVariable('1', $lng->txt('char_selector_custom_items_info1'));
149 $tpl->setVariable('2a', $lng->txt('char_selector_custom_items_info2a'));
150 $tpl->setVariable('2b', $lng->txt('char_selector_custom_items_info2b'));
151 $tpl->setVariable('3a', $lng->txt('char_selector_custom_items_info3a'));
152 $tpl->setVariable('3b', $lng->txt('char_selector_custom_items_info3b'));
153 $tpl->setVariable('4a', $lng->txt('char_selector_custom_items_info4a'));
154 $tpl->setVariable('4b', $lng->txt('char_selector_custom_items_info4b'));
155 $tpl->setVariable('5a', $lng->txt('char_selector_custom_items_info5a'));
156 $tpl->setVariable('5b', $lng->txt('char_selector_custom_items_info5b'));
157 $tpl->setVariable('6a', $lng->txt('char_selector_custom_items_info6a'));
158 $tpl->setVariable('6b', $lng->txt('char_selector_custom_items_info6b'));
159 $custom_items->setInfo($tpl->get());
160 $enabled->addSubItem($custom_items);
161
162 switch ($this->config->getContext()) {
164 $availability->addOption($inactive);
165 $availability->addOption($enabled);
166 $availability->addOption($disabled);
167 $a_form->addItem($availability);
168 break;
169
172 $availability->addOption($inherit);
173 $availability->addOption($enabled);
174 $availability->addOption($disabled);
175 $a_form->addItem($availability);
176 break;
177 }
178 }
const INACTIVE
Availabilities INACTIVE/INHERIT corresponds to an unconfigured selector (no database entries)
ilGlobalTemplateInterface $tpl
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
loadLanguageModule(string $a_module)
Load language module.
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This class represents a selection list property in a property form.
special template class to simplify handling of ITX/PEAR
This class represents a text area property in a property form.
setVariable(string $variable, $value='')
Sets the given variable to the given value.
get(string $part=self::DEFAULT_BLOCK)
Renders the given block and returns the html string.
bool $enabled
Whether the system instance is enabled to accept connection requests.
Definition: System.php:123

References ILIAS\LTI\ToolProvider\$enabled, $lng, $tpl, ilPropertyFormGUI\addItem(), ilCharSelectorConfig\CONTEXT_ADMIN, ilCharSelectorConfig\CONTEXT_TEST, ilCharSelectorConfig\CONTEXT_USER, ilCharSelectorConfig\DISABLED, ilCharSelectorConfig\ENABLED, ilGlobalTemplateInterface\get(), ilCharSelectorConfig\INACTIVE, ilCharSelectorConfig\INHERIT, ilLanguage\loadLanguageModule(), ilGlobalTemplateInterface\setVariable(), and ilLanguage\txt().

Referenced by ilObjAdvancedEditingGUI\initCharSelectorSettingsForm().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ addToPage()

ilCharSelectorGUI::addToPage ( )

Adds the the character selector to the ilias page Initializes the selector according to the state saved in the user session.

See also
self::saveState()

Definition at line 207 of file class.ilCharSelectorGUI.php.

207 : void
208 {
209 $ilCtrl = $this->ctrl;
212
213 // don't add the panel twice
214 if ($this->added_to_page) {
215 return;
216 }
217
218 $lng->loadLanguageModule('adve');
219
220 // prepare the configuration for the js script
221 $this->jsconfig = new stdClass();
222 $this->jsconfig->pages = $this->config->getCharPages();
223 $this->jsconfig->ajax_url = $ilCtrl->getLinkTargetByClass("ilcharselectorgui", "saveState", "", true);
224 $this->jsconfig->open = (int) ilSession::get('char_selector_open');
225 $this->jsconfig->current_page = (int) ilSession::get('char_selector_current_page');
226 $this->jsconfig->current_subpage = (int) ilSession::get('char_selector_current_subpage');
227
228 // provide texts to be dynamically rendered in the js script
229 $this->jstexts = new stdClass();
230 $this->jstexts->page = $lng->txt('page');
231 // fau: testNav - add texts for open/close char selector actions in the question menu
232 $this->jstexts->open = $lng->txt('char_selector_menu_open');
233 $this->jstexts->close = $lng->txt('char_selector_menu_close');
234 // fau.
235
236 // add everything neded to the page
237 // addLightbox() is just used to add the panel template outside the body
238 // The panel template is added as <script> to be not included in the DOM by default
239 // It will be included by js below the main header when the selector is switched on
240 $tpl->addCss(ilUtil::getStyleSheetLocation('', 'char_selector_style.css', 'Services/UIComponent/CharSelector'));
241 $tpl->addJavaScript('./Services/UIComponent/CharSelector/js/ilCharSelector.js');
242 $tpl->addLightbox($this->getSelectorHTML(), 2);
244 'il.CharSelector.init(' .
245 json_encode($this->jsconfig, JSON_THROW_ON_ERROR) . ',' .
246 json_encode($this->jstexts, JSON_THROW_ON_ERROR) . ')'
247 );
248 $this->added_to_page = true;
249 }
getSelectorHTML()
Get the HTML code of the selector panel.
static get(string $a_var)
static getStyleSheetLocation(string $mode="output", string $a_css_name="", string $a_css_location="")
get full style sheet file name (path inclusive) of current user
addJavaScript(string $a_js_file, bool $a_add_version_parameter=true, int $a_batch=2)
Add a javascript file that should be included in the header.
addLightbox(string $a_html, string $a_id)
Add a lightbox html to the template.
addOnLoadCode(string $a_code, int $a_batch=2)
Add on load code.
addCss(string $a_css_file, string $media="screen")
Add a css file that should be included in the header.

References $ctrl, $lng, $tpl, ilGlobalTemplateInterface\addCss(), ilGlobalTemplateInterface\addJavaScript(), ilGlobalTemplateInterface\addLightbox(), ilGlobalTemplateInterface\addOnLoadCode(), ilSession\get(), getSelectorHTML(), ilUtil\getStyleSheetLocation(), ILIAS\Repository\int(), ilLanguage\loadLanguageModule(), and ilLanguage\txt().

+ Here is the call graph for this function:

◆ executeCommand()

ilCharSelectorGUI::executeCommand ( )

Definition at line 309 of file class.ilCharSelectorGUI.php.

309 : void
310 {
311 $ilCtrl = $this->ctrl;
312 $cmd = $ilCtrl->getCmd("saveState");
313 switch ($cmd) {
314 case 'saveState':
315 $this->$cmd();
316 break;
317 default:
318 break;
319 }
320 }
getCmd(string $fallback_command=null)
@inheritDoc

References $ctrl, and ilCtrl\getCmd().

+ Here is the call graph for this function:

◆ getConfig()

ilCharSelectorGUI::getConfig ( )

Definition at line 117 of file class.ilCharSelectorGUI.php.

118 {
119 return $this->config;
120 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
ilCharSelectorConfig $config

References $config.

◆ getFormValues()

ilCharSelectorGUI::getFormValues ( ilPropertyFormGUI  $a_form)

Set the configuration based on the values of a property form.

Definition at line 195 of file class.ilCharSelectorGUI.php.

195 : void
196 {
197 $this->config->setAvailability((int) $a_form->getInput('char_selector_availability'));
198 $this->config->setAddedBlocks((array) $a_form->getInput('char_selector_blocks'));
199 $this->config->setCustomItems((string) $a_form->getInput('char_selector_custom_items'));
200 }
getInput(string $a_post_var, bool $ensureValidation=true)
Returns the input of an item, if item provides getInput method and as fallback the value of the HTTP-...

References ilPropertyFormGUI\getInput().

+ Here is the call graph for this function:

◆ getSelectorHTML()

ilCharSelectorGUI::getSelectorHTML ( )

Get the HTML code of the selector panel.

Definition at line 254 of file class.ilCharSelectorGUI.php.

254 : string
255 {
257 $tpl = new ilTemplate("tpl.char_selector_panel.html", true, true, "Services/UIComponent/CharSelector");
258
259 if (count($this->jsconfig->pages) > 1) {
260 $index = 0;
261 foreach ($this->jsconfig->pages as $page) {
262 $tpl->setCurrentBlock('page_option');
263 $tpl->setVariable("PAGE_INDEX", $index);
264 $tpl->setVariable("PAGE_NAME", $page[0]);
266 $index++;
267 }
268 }
269
270 $tpl->setVariable('TXT_PREVIOUS_PAGE', $lng->txt('previous'));
271 $tpl->setVariable('TXT_NEXT_PAGE', $lng->txt('next'));
272 $tpl->setVariable('TXT_PAGE', $lng->txt('page'));
273
274 $tpl->touchBlock('chars');
275 return '<script type="text/html" id="ilCharSelectorTemplate">' . $tpl->get() . '</script>';
276 }
touchBlock(string $block)
overwrites ITX::touchBlock.
setCurrentBlock(string $part=self::DEFAULT_BLOCK)
Sets the template to the given block.
parseCurrentBlock(string $block_name=self::DEFAULT_BLOCK)
Parses the given block.
$index
Definition: metadata.php:145

References $index, $lng, $tpl, ilGlobalTemplateInterface\get(), ilGlobalTemplateInterface\parseCurrentBlock(), ilGlobalTemplateInterface\setCurrentBlock(), ilGlobalTemplateInterface\setVariable(), ilGlobalTemplateInterface\touchBlock(), and ilLanguage\txt().

Referenced by addToPage().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ saveState()

ilCharSelectorGUI::saveState ( )

Save the selector panel state in the user session (This keeps the panel state between page moves)

See also
self::addToPage()

Definition at line 284 of file class.ilCharSelectorGUI.php.

284 : void
285 {
286 $int = $this->refinery->kindlyTo()->int();
288 'char_selector_open',
289 $this->wrapper->query()->retrieve("open", $int)
290 );
292 'char_selector_current_page',
293 $this->wrapper->query()->retrieve("current_page", $int)
294 );
296 'char_selector_current_subpage',
297 $this->wrapper->query()->retrieve("current_subpage", $int)
298 );
299
300 // debugging output (normally ignored by the js part)
301 echo json_encode(array(
302 'open' => ilSession::get('char_selector_open'),
303 'current_page' => ilSession::get('char_selector_current_page'),
304 'current_subpage' => ilSession::get('char_selector_current_subpage'),
305 ), JSON_THROW_ON_ERROR);
306 exit;
307 }
static set(string $a_var, $a_val)
Set a value.
exit
Definition: login.php:28

References exit, ilSession\get(), ILIAS\Repository\refinery(), and ilSession\set().

+ Here is the call graph for this function:

◆ setConfig()

ilCharSelectorGUI::setConfig ( ilCharSelectorConfig  $a_config)

Definition at line 112 of file class.ilCharSelectorGUI.php.

112 : void
113 {
114 $this->config = $a_config;
115 }

◆ setFormValues()

ilCharSelectorGUI::setFormValues ( ilPropertyFormGUI  $a_form)

Set the values in a property form based on the configuration.

Definition at line 184 of file class.ilCharSelectorGUI.php.

184 : void
185 {
186 $a_form->getItemByPostVar('char_selector_availability')->setValue($this->config->getAvailability());
187 $a_form->getItemByPostVar('char_selector_blocks')->setValue($this->config->getAddedBlocks());
188 $a_form->getItemByPostVar('char_selector_custom_items')->setValue($this->config->getCustomItems());
189 }
getItemByPostVar(string $a_post_var)

References ilPropertyFormGUI\getItemByPostVar().

+ Here is the call graph for this function:

Field Documentation

◆ $added_to_page

bool ilCharSelectorGUI::$added_to_page = false
private

Definition at line 48 of file class.ilCharSelectorGUI.php.

◆ $allowed_guis

array ilCharSelectorGUI::$allowed_guis
staticprivate
Initial value:
= array(
'assQuestionGUI',
'ilAssQuestionFeedbackEditingGUI',
'ilAssQuestionHintGUI',
'ilObjTestSettingsGeneralGUI',
'ilTestScoringGUI'
)

list of command classes for which the char selector is allowed (can also be a parent class of the actual command class)

Definition at line 35 of file class.ilCharSelectorGUI.php.

◆ $config

ilCharSelectorConfig ilCharSelectorGUI::$config = null
private

Definition at line 45 of file class.ilCharSelectorGUI.php.

Referenced by getConfig().

◆ $ctrl

ilCtrl ilCharSelectorGUI::$ctrl
protected

Definition at line 26 of file class.ilCharSelectorGUI.php.

Referenced by addToPage(), and executeCommand().

◆ $current_gui

ilCharSelectorGUI ilCharSelectorGUI::$current_gui
staticprivate

Definition at line 44 of file class.ilCharSelectorGUI.php.

Referenced by _getCurrentGUI().

◆ $jsconfig

stdClass ilCharSelectorGUI::$jsconfig
protected

Definition at line 28 of file class.ilCharSelectorGUI.php.

◆ $jstexts

stdClass ilCharSelectorGUI::$jstexts
protected

Definition at line 29 of file class.ilCharSelectorGUI.php.

◆ $lng

ilLanguage ilCharSelectorGUI::$lng
protected

Definition at line 25 of file class.ilCharSelectorGUI.php.

Referenced by addFormProperties(), addToPage(), and getSelectorHTML().

◆ $refinery

ILIAS Refinery Factory ilCharSelectorGUI::$refinery
protected

Definition at line 50 of file class.ilCharSelectorGUI.php.

◆ $tpl

ilGlobalTemplateInterface ilCharSelectorGUI::$tpl
protected

Definition at line 27 of file class.ilCharSelectorGUI.php.

Referenced by addFormProperties(), addToPage(), and getSelectorHTML().

◆ $wrapper

ILIAS HTTP Wrapper WrapperFactory ilCharSelectorGUI::$wrapper
protected

Definition at line 51 of file class.ilCharSelectorGUI.php.


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