ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
ilCharSelectorGUI Class Reference

This shows a character selector. More...

+ Collaboration diagram for ilCharSelectorGUI:

Public Member Functions

 __construct ($a_context=ilCharSelectorConfig::CONTEXT_NONE)
 Constructor. More...
 
 setConfig (ilCharSelectorConfig $a_config)
 Set the configuraton object. More...
 
 getConfig ()
 Get the configuraton object. More...
 
 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 ()
 execute command More...
 

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...
 

Private Attributes

 $config = null
 
 $added_to_page = false
 

Static Private Attributes

static $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 $current_gui
 ilCharSelectorGUI instance used for the current selector More...
 

Detailed Description

This shows a character selector.

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

Constructor & Destructor Documentation

◆ __construct()

ilCharSelectorGUI::__construct (   $a_context = ilCharSelectorConfig::CONTEXT_NONE)

Constructor.

Parameters
stringconfiguration context

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

45  {
46  $this->config = new ilCharSelectorConfig($a_context);
47  }

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)

Parameters
object(optional) current running test
Returns
object

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

References ilCharSelectorConfig\_getCurrentConfig().

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

88  {
89  if (!isset(self::$current_gui))
90  {
91  self::$current_gui = new ilCharSelectorGUI();
92  self::$current_gui->setConfig(ilCharSelectorConfig::_getCurrentConfig($a_test_obj));
93  }
94  return self::$current_gui;
95  }
static _getCurrentConfig(ilObjTest $a_test_obj=null)
Get the configuration that should be used for the current selector.
This shows a character selector.
+ 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.

Returns
boolean CharSelector is allowed

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

References $ilCtrl.

Referenced by ilPropertyFormGUI\getContent().

54  {
55  global $ilCtrl;
56 
57  // get the command class
58  // with correct case for checking parent classes
59  foreach ($ilCtrl->getCallHistory() as $call)
60  {
61  if ($call['mode'] == 'execComm')
62  {
63  $class = $call['class'];
64  }
65  }
66 
67  // check the class and her parent classes
68  while ($class != false)
69  {
70  if (in_array($class, self::$allowed_guis))
71  {
72  return true;
73  }
74  $class = get_parent_class($class);
75  }
76 
77  return false;
78  }
global $ilCtrl
Definition: ilias.php:18
+ Here is the caller graph for this function:

◆ addFormProperties()

ilCharSelectorGUI::addFormProperties ( ilPropertyFormGUI  $a_form)

add the configuration elements to a property form

Parameters
objectproperty form

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

References $lng, $tpl, ilPropertyFormGUI\addItem(), ilCharSelectorConfig\CONTEXT_ADMIN, ilCharSelectorConfig\CONTEXT_TEST, ilCharSelectorConfig\CONTEXT_USER, ilCharSelectorConfig\DISABLED, ilCharSelectorConfig\ENABLED, ilCharSelectorConfig\INACTIVE, ilCharSelectorConfig\INHERIT, and ilFormPropertyGUI\setInfo().

Referenced by ilObjAdvancedEditingGUI\initCharSelectorSettingsForm().

120  {
121  global $lng;
122  $lng->loadLanguageModule('adve');
123 
124  require_once ('Services/UIComponent/CharSelector/classes/class.ilCharSelectorRadioGroupInputGUI.php');
125  $availability = new ilCharSelectorRadioGroupInputGUI($lng->txt('char_selector_'.$this->config->getContext()), 'char_selector_availability');
126  $inactive = new ilRadioOption($lng->txt('char_selector_inactive_'.$this->config->getContext()),ilCharSelectorConfig::INACTIVE);
127  $inactive->setInfo($lng->txt('char_selector_inactive_info_'.$this->config->getContext()));
128  $inherit = new ilRadioOption($lng->txt('char_selector_inherit_'.$this->config->getContext()),ilCharSelectorConfig::INHERIT);
129  $inherit->setInfo($lng->txt('char_selector_inherit_info_'.$this->config->getContext()));
130  $enabled = new ilRadioOption($lng->txt('char_selector_enabled_'.$this->config->getContext()), ilCharSelectorConfig::ENABLED);
131  $enabled->setInfo($lng->txt('char_selector_enabled_info_'.$this->config->getContext()));
132  $disabled = new ilRadioOption($lng->txt('char_selector_disabled_'.$this->config->getContext()), ilCharSelectorConfig::DISABLED);
133  $disabled->setInfo($lng->txt('char_selector_disabled_info_'.$this->config->getContext()));
134 
135  $blocks = new ilSelectInputGUI($lng->txt('char_selector_blocks'), 'char_selector_blocks');
136  $blocks->setInfo($lng->txt('char_selector_blocks_info'));
137  $blocks->setOptions($this->config->getBlockOptions());
138  $blocks->setMulti(true);
139  $enabled->addSubItem($blocks);
140 
141  $custom_items = new ilTextAreaInputGUI($lng->txt('char_selector_custom_items'),'char_selector_custom_items');
142  $tpl = new ilTemplate("tpl.char_selector_custom_info.html", true, true, "Services/UIComponent/CharSelector");
143  $tpl->setVariable('1',$lng->txt('char_selector_custom_items_info1'));
144  $tpl->setVariable('2a',$lng->txt('char_selector_custom_items_info2a'));
145  $tpl->setVariable('2b',$lng->txt('char_selector_custom_items_info2b'));
146  $tpl->setVariable('3a',$lng->txt('char_selector_custom_items_info3a'));
147  $tpl->setVariable('3b',$lng->txt('char_selector_custom_items_info3b'));
148  $tpl->setVariable('4a',$lng->txt('char_selector_custom_items_info4a'));
149  $tpl->setVariable('4b',$lng->txt('char_selector_custom_items_info4b'));
150  $tpl->setVariable('5a',$lng->txt('char_selector_custom_items_info5a'));
151  $tpl->setVariable('5b',$lng->txt('char_selector_custom_items_info5b'));
152  $tpl->setVariable('6a',$lng->txt('char_selector_custom_items_info6a'));
153  $tpl->setVariable('6b',$lng->txt('char_selector_custom_items_info6b'));
154  $custom_items->setInfo($tpl->get());
155  $enabled->addSubItem($custom_items);
156 
157  switch($this->config->getContext())
158  {
160  $availability->addOption($inactive);
161  $availability->addOption($enabled);
162  $availability->addOption($disabled);
163  $a_form->addItem($availability);
164  break;
165 
168  $availability->addOption($inherit);
169  $availability->addOption($enabled);
170  $availability->addOption($disabled);
171  $a_form->addItem($availability);
172  break;
173  }
174  }
This class represents an option in a radio group.
This class represents a selection list property in a property form.
Radio input for character seelctor definition.
addItem($a_item)
Add Item (Property, SectionHeader).
global $tpl
Definition: ilias.php:8
const INACTIVE
Availabilities INACTIVE/INHERIT corresponds to an unconfigured selector (no database entries) ...
setInfo($a_info)
Set Information Text.
special template class to simplify handling of ITX/PEAR
global $lng
Definition: privfeed.php:17
This class represents a text area property in a property form.
+ 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.

References $_SESSION, $ilCtrl, $lng, $tpl, getSelectorHTML(), and ilUtil\getStyleSheetLocation().

208  {
209  global $ilCtrl, $tpl, $lng;
210 
211  // don't add the panel twice
212  if ($this->added_to_page)
213  {
214  return;
215  }
216 
217  $lng->loadLanguageModule('adve');
218 
219  // prepare the configuration for the js script
220  $this->jsconfig = new stdClass();
221  $this->jsconfig->pages = $this->config->getCharPages();
222  $this->jsconfig->ajax_url = $ilCtrl->getLinkTargetByClass("ilcharselectorgui", "saveState", "", true);
223  $this->jsconfig->open = (int) $_SESSION['char_selector_open'];
224  $this->jsconfig->current_page = (int) $_SESSION['char_selector_current_page'];
225  $this->jsconfig->current_subpage = (int) $_SESSION['char_selector_current_subpage'];
226 
227  // provide texts to be dynamically rendered in the js script
228  $this->jstexts = new stdClass();
229  $this->jstexts->page = $lng->txt('page');
230  // fau: testNav - add texts for open/close char selector actions in the question menu
231  $this->jstexts->open= $lng->txt('char_selector_menu_open');
232  $this->jstexts->close= $lng->txt('char_selector_menu_close');
233  // fau.
234 
235  // add everything neded to the page
236  // addLightbox() is just used to add the panel template outside the body
237  // The panel template is added as <script> to be not included in the DOM by default
238  // It will be included by js below the main header when the selector is switched on
239  $tpl->addCss(ilUtil::getStyleSheetLocation('','char_selector_style.css','Services/UIComponent/CharSelector'));
240  $tpl->addJavascript('./Services/UIComponent/CharSelector/js/ilCharSelector.js');
241  $tpl->addLightbox($this->getSelectorHTML(),2);
242  $tpl->addOnLoadCode('il.CharSelector.init('.json_encode($this->jsconfig).','.json_encode($this->jstexts).')');
243  $this->added_to_page = true;
244  }
$_SESSION["AccountId"]
static getStyleSheetLocation($mode="output", $a_css_name="", $a_css_location="")
get full style sheet file name (path inclusive) of current user
getSelectorHTML()
Get the HTML code of the selector panel.
global $tpl
Definition: ilias.php:8
global $ilCtrl
Definition: ilias.php:18
global $lng
Definition: privfeed.php:17
+ Here is the call graph for this function:

◆ executeCommand()

ilCharSelectorGUI::executeCommand ( )

execute command

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

References $cmd, and $ilCtrl.

301  {
302  global $ilCtrl;
303  $cmd = $ilCtrl->getCmd("saveState");
304  switch($cmd)
305  {
306  case 'saveState':
307  $this->$cmd();
308  break;
309  default:
310  return;
311  }
312  }
$cmd
Definition: sahs_server.php:35
global $ilCtrl
Definition: ilias.php:18

◆ getConfig()

ilCharSelectorGUI::getConfig ( )

Get the configuraton object.

Returns
ilCharSelectorConfig

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

References $config.

111  {
112  return $this->config;
113  }

◆ getFormValues()

ilCharSelectorGUI::getFormValues ( ilPropertyFormGUI  $a_form)

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

Parameters
objectproperty form
stringcontext of the form

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

References ilPropertyFormGUI\getInput().

196  {
197  $this->config->setAvailability($a_form->getInput('char_selector_availability'));
198  $this->config->setAddedBlocks($a_form->getInput('char_selector_blocks'));
199  $this->config->setCustomItems($a_form->getInput('char_selector_custom_items'));
200  }
getInput($a_post_var, $ensureValidation=true)
Returns the value of a HTTP-POST variable, identified by the passed id.
+ Here is the call graph for this function:

◆ getSelectorHTML()

ilCharSelectorGUI::getSelectorHTML ( )

Get the HTML code of the selector panel.

Returns
string panel html code

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

References $lng, and $tpl.

Referenced by addToPage().

251  {
252  global $lng;
253  $tpl = new ilTemplate("tpl.char_selector_panel.html", true, true, "Services/UIComponent/CharSelector");
254 
255  if (count($this->jsconfig->pages) > 1)
256  {
257  $index = 0;
258  foreach ($this->jsconfig->pages as $page)
259  {
260  $tpl->setCurrentBlock('page_option');
261  $tpl->setVariable("PAGE_INDEX", $index);
262  $tpl->setVariable("PAGE_NAME", $page[0]);
263  $tpl->parseCurrentBlock();
264  $index++;
265  }
266  }
267 
268  $tpl->setVariable('TXT_PREVIOUS_PAGE', $lng->txt('previous'));
269  $tpl->setVariable('TXT_NEXT_PAGE', $lng->txt('next'));
270  $tpl->setVariable('TXT_PAGE', $lng->txt('page'));
271 
272  $tpl->touchBlock('chars');
273  return '<script type="text/html" id="ilCharSelectorTemplate">'.$tpl->get().'</script>';
274  }
global $tpl
Definition: ilias.php:8
special template class to simplify handling of ITX/PEAR
global $lng
Definition: privfeed.php:17
+ 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 282 of file class.ilCharSelectorGUI.php.

References $_GET, $_SESSION, array, and exit.

283  {
284  $_SESSION['char_selector_open'] = (int) $_GET['open'];
285  $_SESSION['char_selector_current_page'] = (int) $_GET['current_page'];
286  $_SESSION['char_selector_current_subpage'] = (int) $_GET['current_subpage'];
287 
288  // debugging output (normally ignored by the js part)
289  echo json_encode(array(
290  'open' => $_SESSION['char_selector_open'],
291  'current_page' => $_SESSION['char_selector_current_page'],
292  'current_subpage' => $_SESSION['char_selector_current_subpage'],
293  ));
294  exit;
295  }
$_SESSION["AccountId"]
$_GET["client_id"]
Create styles array
The data for the language used.

◆ setConfig()

ilCharSelectorGUI::setConfig ( ilCharSelectorConfig  $a_config)

Set the configuraton object.

Parameters
ilCharSelectorConfig

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

102  {
103  $this->config = $a_config;
104  }

◆ setFormValues()

ilCharSelectorGUI::setFormValues ( ilPropertyFormGUI  $a_form)

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

Parameters
objectproperty form
stringcontext of the form

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

References ilPropertyFormGUI\getItemByPostVar().

183  {
184  $a_form->getItemByPostVar('char_selector_availability')->setValue($this->config->getAvailability());
185  $a_form->getItemByPostVar('char_selector_blocks')->setValue($this->config->getAddedBlocks());
186  $a_form->getItemByPostVar('char_selector_custom_items')->setValue($this->config->getCustomItems());
187  }
getItemByPostVar($a_post_var)
Get Item by POST variable.
+ Here is the call graph for this function:

Field Documentation

◆ $added_to_page

ilCharSelectorGUI::$added_to_page = false
private

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

◆ $allowed_guis

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 16 of file class.ilCharSelectorGUI.php.

◆ $config

ilCharSelectorGUI::$config = null
private

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

Referenced by getConfig().

◆ $current_gui

ilCharSelectorGUI::$current_gui
staticprivate

ilCharSelectorGUI instance used for the current selector

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


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